This commit is contained in:
Morten Olsen
2025-09-21 08:43:15 +02:00
commit 0ab9a27493
18 changed files with 5379 additions and 0 deletions

68
demo/main.tsx Normal file
View File

@@ -0,0 +1,68 @@
import { value, component, div, h1, p, button, scope } from '../lib/exports';
const counter = value(0);
const child = component<{ count: number }>(({ context, props }) => {
const count = context(counter);
return div`
And the count according to the child: ${count.value} which got ${props.count}
${button.$({
click: () => {
count.value -= 1;
},
})`
Decrement
`}
`;
});
const root = component(({ context }) => {
const count = context(counter);
return div`
${h1.$({ style: { color: 'red' } })`
Hello
`}
The current count is: ${count.value}
${div`
${h1`Hello`}
... Something
${p`
Testing
`}
`}
${button.$({
click: () => {
count.value += 1;
},
})`
Increment
`}
${div`
${h1`With prop`}
${child({ count: count.value })}
`}
${div`
${h1`Without prop`}
${child}
`}
${scope(counter)`
${h1`Without scope`}
${child}
`}
So long and thanks for all the fish
`;
});
document.body.appendChild(root.toHtmlElement());

1
demo/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />