Skip to content

Commit 63c46b3

Browse files
authored
feat: solid templates (#42)
1 parent bb4e45f commit 63c46b3

File tree

34 files changed

+366
-8
lines changed

34 files changed

+366
-8
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ An easy way to start a Vite Web Extension project
1010
- Manifest V2, Manifest V3, or Both
1111
- TypeScript
1212
- Choice of framework including:
13+
- Preact
14+
- React
15+
- Solid
16+
- Svelte
1317
- Vanilla
1418
- Vue
15-
- Svelte
16-
- React
17-
- Preact
1819

1920
## Usage
2021

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,11 @@ async function init() {
150150
message: "Framework:",
151151
choices: [
152152
{ title: "Vanilla (None)", value: "vanilla" },
153-
{ title: "Vue", value: "vue" },
153+
{ title: "Preact", value: "preact" },
154154
{ title: "React", value: "react" },
155+
{ title: "Solid", value: "solid" },
155156
{ title: "Svelte", value: "svelte" },
156-
{ title: "Preact", value: "preact" },
157+
{ title: "Vue", value: "vue" },
157158
],
158159
initial: 0,
159160
},
@@ -220,7 +221,7 @@ async function init() {
220221

221222
// Cleanup.
222223

223-
if (["react", "preact"].includes(framework)) {
224+
if (["react", "preact", "solid"].includes(framework)) {
224225
preOrderDirectoryTraverse(
225226
root,
226227
() => {},

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"preact",
4949
"svelte",
5050
"vue",
51-
"typescript"
51+
"typescript",
52+
"solid"
5253
],
5354
"author": "Ruben Medina <dev@rubenmedina.com>",
5455
"repository": {

scripts/build-playground.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const exec = util.promisify(execCallback);
77

88
const __dirname = dirname(fileURLToPath(import.meta.url));
99

10-
const frameworks = ["vanilla", "vue", "svelte", "react", "preact"];
10+
const frameworks = ["preact", "react", "solid", "svelte", "vanilla", "vue"];
1111

1212
const manifestVersions = ["2", "3", "2+3"];
1313

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"devDependencies": {
3+
"vite-plugin-solid": "^2.7.0",
4+
"typescript": "^5.0.4"
5+
},
6+
"dependencies": {
7+
"solid-js": "^1.7.8"
8+
}
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
h1 {
2+
margin: 5px;
3+
}
4+
5+
button {
6+
margin-top: 10px;
7+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Solid, { createSignal } from "solid-js";
2+
import "./PageContent.css";
3+
import logo from "~/assets/logo.svg";
4+
5+
function PageContent(props: Solid.ParentProps) {
6+
const imageUrl = new URL(logo, import.meta.url).href;
7+
8+
const [count, setCount] = createSignal(0);
9+
10+
return (
11+
<div>
12+
<img src={imageUrl} height="45" alt="" />
13+
<h1>{props.children}</h1>
14+
<button type="button" onClick={() => setCount((count) => count + 1)}>
15+
Clicks: {count()}
16+
</button>
17+
</div>
18+
);
19+
}
20+
21+
export default PageContent;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.logo {
2+
z-index: 99999;
3+
position: fixed;
4+
bottom: 20px;
5+
right: 10px;
6+
width: 60px;
7+
height: 60px;
8+
display: flex;
9+
justify-content: center;
10+
align-items: center;
11+
border: 4px solid #c72a21;
12+
border-radius: 50%;
13+
background-color: #fff;
14+
}
15+
16+
img {
17+
position: absolute;
18+
top: 7px;
19+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import logo from "~/assets/logo.svg";
2+
import "./App.css";
3+
4+
function App() {
5+
const logoImageUrl = new URL(logo, import.meta.url).href;
6+
7+
return (
8+
<div class="logo">
9+
<img src={logoImageUrl} height="50" alt="" />
10+
</div>
11+
);
12+
}
13+
14+
export default App;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* @refresh reload */
2+
import { render } from "solid-js/web";
3+
import renderContent from "../renderContent";
4+
import App from "./App";
5+
6+
renderContent(import.meta.PLUGIN_WEB_EXT_CHUNK_CSS_PATHS, (appRoot) => {
7+
render(() => <App />, appRoot);
8+
});

0 commit comments

Comments
 (0)