Skip to content

Commit 954a861

Browse files
authored
refactor: add interactivity to templates (#6)
also fix a few small issues
1 parent 45970a8 commit 954a861

File tree

40 files changed

+255
-144
lines changed

40 files changed

+255
-144
lines changed

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,10 @@ async function init() {
309309
}
310310

311311
// Rename, remove js files matching ts file
312-
if (filepath.endsWith(".js")) {
312+
if (
313+
filepath.endsWith(".js") &&
314+
!filepath.endsWith("svelte.config.js")
315+
) {
313316
const tsFilePath = filepath.replace(/\.js$/, ".ts");
314317
if (fs.existsSync(tsFilePath)) {
315318
fs.unlinkSync(filepath);

scripts/snapshot.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const builds = [];
1111

1212
(async () => {
1313
await exec("mkdir -p playground");
14-
// await exec('rm -rf playground/*');
14+
await exec("rm -rf playground/*");
1515

1616
for (const framework of frameworks) {
1717
for (const manifest of manifestVersions) {
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+
}

template/framework/preact-ts/src/components/PageHeader.tsx renamed to template/framework/preact-ts/src/components/PageContent.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
import { useState } from "preact/hooks";
2+
import "./PageContent.css";
13
import logo from "~/assets/logo.svg";
24

35
function PageHeader(props) {
46
const imageUrl = new URL(logo, import.meta.url).href;
57

8+
const [count, setCount] = useState(0);
9+
610
return (
711
<div>
812
<img src={imageUrl} height="45" />
913
<h1>{props.children}</h1>
10-
<a href="https://vitejs.dev/guide/features.html" target="_blank">
11-
Documentation
12-
</a>
14+
<button type="button" onClick={() => setCount((count) => count + 1)}>
15+
Count: {count}
16+
</button>
1317
</div>
1418
);
1519
}

template/framework/preact-ts/src/entries/options/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import PageHeader from "~/components/PageHeader";
1+
import PageContent from "~/components/PageContent";
22
import "./App.css";
33

44
function App() {
55
return (
66
<main>
7-
<PageHeader>Options</PageHeader>
7+
<PageContent>Options</PageContent>
88
</main>
99
);
1010
}

template/framework/preact-ts/src/entries/popup/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import PageHeader from "~/components/PageHeader";
1+
import PageContent from "~/components/PageContent";
22
import "./App.css";
33

44
function App() {
55
return (
66
<main>
7-
<PageHeader>Popup</PageHeader>
7+
<PageContent>Popup</PageContent>
88
</main>
99
);
1010
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
/// <reference types="vite/client" />
2+
3+
interface ImportMeta {
4+
CURRENT_CONTENT_SCRIPT_CSS_URL: string;
5+
}
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 { useState } from "preact/hooks";
2+
import "./PageContent.css";
3+
import logo from "~/assets/logo.svg";
4+
5+
function PageContent(props) {
6+
const imageUrl = new URL(logo, import.meta.url).href;
7+
8+
const [count, setCount] = useState(0);
9+
10+
return (
11+
<div>
12+
<img src={imageUrl} height="45" />
13+
<h1>{props.children}</h1>
14+
<button type="button" onClick={() => setCount((count) => count + 1)}>
15+
Count: {count}
16+
</button>
17+
</div>
18+
);
19+
}
20+
21+
export default PageContent;

template/framework/preact/src/components/PageHeader.jsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)