@zessjs/cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +50 -0
- package/index.ts +210 -0
- package/package.json +37 -0
- package/template/common/README.md +61 -0
- package/template/common/package.json +33 -0
- package/template/common/public/zess.svg +1 -0
- package/template/common/src/assets/style.css +30 -0
- package/template/common/src/assets/vite.svg +1 -0
- package/template/javascript/eslint.config.js +10 -0
- package/template/javascript/index.html +13 -0
- package/template/javascript/jsconfig.json +11 -0
- package/template/javascript/src/App.jsx +101 -0
- package/template/javascript/src/pages/ConditionalPage.jsx +85 -0
- package/template/javascript/src/pages/CounterPage.jsx +50 -0
- package/template/javascript/src/pages/HomePage.jsx +43 -0
- package/template/javascript/src/pages/ListPage.jsx +83 -0
- package/template/javascript/tests/HelloWorld.test.jsx +15 -0
- package/template/javascript/vite.config.js +11 -0
- package/template/typescript/eslint.config.ts +2 -0
- package/template/typescript/index.html +13 -0
- package/template/typescript/src/App.tsx +101 -0
- package/template/typescript/src/pages/ConditionalPage.tsx +92 -0
- package/template/typescript/src/pages/CounterPage.tsx +50 -0
- package/template/typescript/src/pages/HomePage.tsx +44 -0
- package/template/typescript/src/pages/ListPage.tsx +83 -0
- package/template/typescript/tests/HelloWorld.test.tsx +15 -0
- package/template/typescript/tsconfig.json +22 -0
- package/template/typescript/vite.config.ts +12 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { For, Show, useSignal, type Component } from '@zessjs/core'
|
|
2
|
+
import { Link } from '@zessjs/router'
|
|
3
|
+
|
|
4
|
+
const ListPage: Component = () => {
|
|
5
|
+
const [items, setItems] = useSignal([
|
|
6
|
+
'Zess Compiler',
|
|
7
|
+
'Zess Core',
|
|
8
|
+
'Zess Router',
|
|
9
|
+
])
|
|
10
|
+
const [newItem, setNewItem] = useSignal('')
|
|
11
|
+
const addItem = () => {
|
|
12
|
+
const item = newItem().trim()
|
|
13
|
+
if (item) {
|
|
14
|
+
setItems((prevItems) => [...prevItems, item])
|
|
15
|
+
setNewItem('')
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const handleKeyPress = (e: KeyboardEvent) => {
|
|
19
|
+
if (e.key === 'Enter') addItem()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div class="w-full text-center pb-8">
|
|
24
|
+
<header class="mb-8">
|
|
25
|
+
<h1 class="text-2xl font-bold mb-2">List Example</h1>
|
|
26
|
+
<p class="text-gray-600">
|
|
27
|
+
This shows how to render lists with {'<For>'} component
|
|
28
|
+
</p>
|
|
29
|
+
</header>
|
|
30
|
+
<div class="mb-8">
|
|
31
|
+
<div class="flex flex-col sm:flex-row gap-2 justify-center">
|
|
32
|
+
<input
|
|
33
|
+
type="text"
|
|
34
|
+
value={newItem()}
|
|
35
|
+
onInput={(e) => setNewItem(e.target.value)}
|
|
36
|
+
onKeyPress={handleKeyPress}
|
|
37
|
+
placeholder="Enter new item..."
|
|
38
|
+
class="px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-indigo-500"
|
|
39
|
+
/>
|
|
40
|
+
<button
|
|
41
|
+
onClick={addItem}
|
|
42
|
+
class="px-4 py-2 bg-gray-200 hover:bg-gray-300 rounded transition-all"
|
|
43
|
+
>
|
|
44
|
+
Add Item
|
|
45
|
+
</button>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
<div class="mb-8">
|
|
49
|
+
{/* Conditionally render the list or an empty state message */}
|
|
50
|
+
<Show
|
|
51
|
+
when={items().length > 0}
|
|
52
|
+
fallback={<p class="text-gray-500 py-4">No items in the list yet.</p>}
|
|
53
|
+
>
|
|
54
|
+
<ul class="space-y-2 max-w-md mx-auto">
|
|
55
|
+
{/* Zess For component for efficiently rendering lists */}
|
|
56
|
+
<For each={items()}>
|
|
57
|
+
{(item, index) => (
|
|
58
|
+
<li class="flex items-center p-2 border-b border-gray-200 bg-white">
|
|
59
|
+
<span class="mr-2 text-gray-500 font-medium">
|
|
60
|
+
{index() + 1}.
|
|
61
|
+
</span>
|
|
62
|
+
<span class="text-left flex-1">{item}</span>
|
|
63
|
+
</li>
|
|
64
|
+
)}
|
|
65
|
+
</For>
|
|
66
|
+
</ul>
|
|
67
|
+
</Show>
|
|
68
|
+
</div>
|
|
69
|
+
<div>
|
|
70
|
+
{/* Link back to home page */}
|
|
71
|
+
<Link
|
|
72
|
+
to="/"
|
|
73
|
+
relative={false}
|
|
74
|
+
class="inline-block px-4 py-2 bg-gray-200 hover:bg-gray-300 rounded transition-all"
|
|
75
|
+
>
|
|
76
|
+
Back to Home
|
|
77
|
+
</Link>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default ListPage
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { render } from '@zessjs/core'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
|
|
4
|
+
function HelloWorld() {
|
|
5
|
+
return <div>Hello World</div>
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
describe('HelloWorld', () => {
|
|
9
|
+
it('should render a <HelloWorld> component', () => {
|
|
10
|
+
const container = document.createElement('div')
|
|
11
|
+
const dispose = render(() => <HelloWorld />, container)
|
|
12
|
+
expect(container.textContent).toBe('Hello World')
|
|
13
|
+
dispose()
|
|
14
|
+
})
|
|
15
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"jsx": "preserve",
|
|
5
|
+
"jsxImportSource": "@zessjs/core",
|
|
6
|
+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"module": "preserve",
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"types": ["vite/client", "vitest/jsdom"],
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noUnusedLocals": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"isolatedModules": true,
|
|
18
|
+
"verbatimModuleSyntax": true,
|
|
19
|
+
"skipLibCheck": true
|
|
20
|
+
},
|
|
21
|
+
"include": ["src", "tests"]
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="vitest/config" />
|
|
2
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
3
|
+
import zess from '@zessjs/vite-plugin'
|
|
4
|
+
import { defineConfig } from 'vite'
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
plugins: [tailwindcss(), zess()],
|
|
8
|
+
test: {
|
|
9
|
+
environment: 'jsdom',
|
|
10
|
+
include: ['./tests/*.test.{ts,tsx}'],
|
|
11
|
+
},
|
|
12
|
+
})
|