aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/examples/with-vite/packages/ui
diff options
context:
space:
mode:
author简律纯 <hsiangnianian@outlook.com>2023-04-28 01:47:57 +0800
committer简律纯 <hsiangnianian@outlook.com>2023-04-28 01:47:57 +0800
commit8b2c4a38a461ff5ecc95972291bc711e2c5dec9a (patch)
tree29f552e3df949073e21bf5c76d7abc3044830ec6 /examples/with-vite/packages/ui
parentfc8c5fdce62fb229202659408798a7b6c98f6e8b (diff)
downloadHydroRoll-8b2c4a38a461ff5ecc95972291bc711e2c5dec9a.tar.gz
HydroRoll-8b2c4a38a461ff5ecc95972291bc711e2c5dec9a.zip
Diffstat (limited to 'examples/with-vite/packages/ui')
-rw-r--r--examples/with-vite/packages/ui/.eslintrc.cjs4
-rw-r--r--examples/with-vite/packages/ui/components/counter.ts3
-rw-r--r--examples/with-vite/packages/ui/components/header.ts7
-rw-r--r--examples/with-vite/packages/ui/index.ts6
-rw-r--r--examples/with-vite/packages/ui/package.json16
-rw-r--r--examples/with-vite/packages/ui/tsconfig.json5
-rw-r--r--examples/with-vite/packages/ui/utils/counter.ts9
7 files changed, 50 insertions, 0 deletions
diff --git a/examples/with-vite/packages/ui/.eslintrc.cjs b/examples/with-vite/packages/ui/.eslintrc.cjs
new file mode 100644
index 0000000..c8df607
--- /dev/null
+++ b/examples/with-vite/packages/ui/.eslintrc.cjs
@@ -0,0 +1,4 @@
+module.exports = {
+ root: true,
+ extends: ["custom"],
+};
diff --git a/examples/with-vite/packages/ui/components/counter.ts b/examples/with-vite/packages/ui/components/counter.ts
new file mode 100644
index 0000000..d58f883
--- /dev/null
+++ b/examples/with-vite/packages/ui/components/counter.ts
@@ -0,0 +1,3 @@
+export function Counter() {
+ return `<button id="counter" type="button"></button>`;
+}
diff --git a/examples/with-vite/packages/ui/components/header.ts b/examples/with-vite/packages/ui/components/header.ts
new file mode 100644
index 0000000..14e0ab9
--- /dev/null
+++ b/examples/with-vite/packages/ui/components/header.ts
@@ -0,0 +1,7 @@
+export function Header({ title }: { title: string }) {
+ return `
+ <header id="header">
+ <h1>${title}</h1>
+ </header>
+ `;
+}
diff --git a/examples/with-vite/packages/ui/index.ts b/examples/with-vite/packages/ui/index.ts
new file mode 100644
index 0000000..438ff06
--- /dev/null
+++ b/examples/with-vite/packages/ui/index.ts
@@ -0,0 +1,6 @@
+// utils
+export { setupCounter } from "./utils/counter";
+
+// components
+export { Header } from "./components/header";
+export { Counter } from "./components/counter";
diff --git a/examples/with-vite/packages/ui/package.json b/examples/with-vite/packages/ui/package.json
new file mode 100644
index 0000000..3db9e0d
--- /dev/null
+++ b/examples/with-vite/packages/ui/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "ui",
+ "version": "0.0.0",
+ "main": "./index.ts",
+ "types": "./index.ts",
+ "license": "MIT",
+ "scripts": {
+ "lint": "eslint \"**/*.ts\""
+ },
+ "devDependencies": {
+ "eslint": "^7.32.0",
+ "eslint-config-custom": "workspace:*",
+ "tsconfig": "workspace:*",
+ "typescript": "^4.9.4"
+ }
+}
diff --git a/examples/with-vite/packages/ui/tsconfig.json b/examples/with-vite/packages/ui/tsconfig.json
new file mode 100644
index 0000000..61a00fa
--- /dev/null
+++ b/examples/with-vite/packages/ui/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "extends": "tsconfig/base.json",
+ "include": ["."],
+ "exclude": ["node_modules"]
+}
diff --git a/examples/with-vite/packages/ui/utils/counter.ts b/examples/with-vite/packages/ui/utils/counter.ts
new file mode 100644
index 0000000..0de7dcf
--- /dev/null
+++ b/examples/with-vite/packages/ui/utils/counter.ts
@@ -0,0 +1,9 @@
+export function setupCounter(element: HTMLButtonElement) {
+ let counter = 0;
+ const setCounter = (count: number) => {
+ counter = count;
+ element.innerText = `count is ${counter}`;
+ };
+ element.addEventListener("click", () => setCounter(++counter));
+ setCounter(0);
+}