This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE employees ( | |
first_name varchar(25), | |
last_name varchar(25), | |
department varchar(15), | |
email varchar(50) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO employees (first_name, last_name, department, email) | |
VALUES ('Lorenz', 'Vanthillo', 'IT', '[email protected]'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { hc, text } from '@crui/core' | |
const Title = hc('h1', [ | |
text('TODO App') | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StreamBox } from '@crui/reactive/rx/box'; | |
export type Todo = { | |
text: string, | |
} | |
export type TodoList = Todo[] | |
export class TodoStore { | |
public readonly input: StreamBox<string> | |
public readonly todos: TodoList | |
constructor() { | |
this.input = new StreamBox('') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const submit = (store: TodoStore) => | |
h('button', { | |
props: { className: 'add-todo-submit' }, | |
events: { | |
click: (e) => { | |
e.preventDefault() | |
store.addTodo(store.input.get()) | |
store.input.set('') | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StreamBox } from '@crui/reactive/rx/box'; | |
import { StreamList } from '@crui/reactive/rx/list'; | |
export type Todo = { | |
text: string, | |
} | |
export type TodoList = StreamList<Todo> | |
export class TodoStore { | |
public readonly input: StreamBox<string> | |
public readonly todos: TodoList | |
constructor() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { h$map } from '@crui/reactive/elems/$children' | |
const TodoList = (store: TodoStore) => h$map( | |
h('ul'), | |
store.todos, | |
TodoComponent | |
) | |
const TodoComponent = ({ text }) => ht('li', text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TodoComponent = (todo: Todo) => ( | |
hcc('li', 'todo-wrapper', [ | |
hcc('label', 'todo', [ | |
h$('input', { | |
props: { | |
type: 'checkbox', | |
}, | |
$bind: { | |
checked: todo.done | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const submit = h('button', { | |
props: { className: 'add-todo-submit' }, | |
events: { | |
click: (e) => { | |
e.preventDefault() | |
// what to do? | |
} | |
}, | |
children: [ | |
text('Add') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type AddTodo = (todo: string) => void | |
const submit = (todo: StreamBox<string>, addTodo: AddTodo) => | |
h('button', { | |
props: { className: 'add-todo-submit' }, | |
events: { | |
click: (e) => { | |
e.preventDefault() | |
addTodo(todo.get()) | |
todo.set('') | |
} |
OlderNewer