Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ This is a guide on how to contribute to RoValra
Don't rush me and don't expect it to get accepted instantly.\
If the PR has remained stale with no review for a few weeks then feel free to ask about it.

Every PR needs a clear description of what it does. Depending on the type of PR, please also include the following:
When opening a PR, please:

* Include a clear description of what it does
* Make sure it builds
* Make sure it works properly, without significant issues
* If Artificial Intelligence was utilised in the generation or authoring of the PR, please very clearly disclose/specify what AI did, what it was used for, and whether you tested its code
* If Artificial Intelligence was utilised in the generation or authoring of the PR, please manually review and test all code generated by the AI before opening the PR

Depending on the type of PR, please also include the following:

### New features

Expand All @@ -36,6 +44,44 @@ Describe the fix in detail. Please include:

PRs without screenshots for new features, or without a proper description for bug fixes, may take longer to review or be closed.

## Making UI with TSX

If you need to make UI, you can use JSX/TSX in the extension via PReact (not to be confused with React). Keep in mind that you do **not** need the `.jsx`/`.tsx` file extension.

The PReact API is very similar to the React API. The documentation can be found here: <https://preactjs.com/>.

### Creating an element

You can create an element in two ways.

The first way automatically gives it a parent:

```js
import { renderElement } from './core/ui/react.ts';
const renderedElement = renderElement(element, parent);
```

The second way lets you create an HTMLElement without adding it to the webpage:

```js
import { renderElement } from './core/ui/react.ts';
const renderedElement = renderElement(element);
```

Of course, standard `render()` is still available, and is used by `renderElement()`.

You can define HTML elements like this:

```js
<div
className="rovalra-overlay-content"
role="dialog"
/>
```

> [!NOTE]
> Use `className` instead of `class`, and dont forget to call `renderElement(el)` before adding it to the webpage, or just call `renderElement(el, parent)` or `render(el, parent)`!

## Adding Translations

RoValra uses [i18next](https://www.i18next.com/) for translations. All translations are community made.
Expand Down
10 changes: 10 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ try {
);
process.exit(1);
}

//E why the hell did i make this comment?
const bannerText = `/*!
* ${pkg.name} v${pkg.version}
Expand All @@ -76,6 +77,13 @@ const commonConfig = {
js: bannerText,
css: bannerText,
},

loader: {
'.js': 'jsx'
},

jsx: 'automatic',
jsxImportSource: 'preact',
};

function compileScssFile(inputFile, outputFile) {
Expand All @@ -99,6 +107,7 @@ esbuild
entryPoints: [backgroundEntryPath],
outfile: 'dist/background.js',
bundle: true,
inject: ['./src/shared/preact-inject.js'],
})
.catch(() => process.exit(1));

Expand Down Expand Up @@ -189,6 +198,7 @@ esbuild
banner: {
js: bannerText + '\n' + dracoSource,
},
inject: ['./src/shared/preact-inject.js'],
})
.catch(() => process.exit(1));
if (fs.existsSync(cssDir)) {
Expand Down
Loading