Skip to content

Instantly share code, notes, and snippets.

nanotroy

Block or report user

Report or block nanotroy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View CreateTable.sql
CREATE TABLE employees (
first_name varchar(25),
last_name varchar(25),
department varchar(15),
email varchar(50)
);
View InsertData.sql
INSERT INTO employees (first_name, last_name, department, email)
VALUES ('Lorenz', 'Vanthillo', 'IT', 'lvthillo@mail.com');
View title.js
import { hc, text } from '@crui/core'
const Title = hc('h1', [
text('TODO App')
])
View structure.js
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('')
View streamremove.js
const submit = (store: TodoStore) =>
h('button', {
props: { className: 'add-todo-submit' },
events: {
click: (e) => {
e.preventDefault()
store.addTodo(store.input.get())
store.input.set('')
}
},
View store.js
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() {
View todo.js
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)
View todocomp.js
const TodoComponent = (todo: Todo) => (
hcc('li', 'todo-wrapper', [
hcc('label', 'todo', [
h$('input', {
props: {
type: 'checkbox',
},
$bind: {
checked: todo.done
}
View submit.js
const submit = h('button', {
props: { className: 'add-todo-submit' },
events: {
click: (e) => {
e.preventDefault()
// what to do?
}
},
children: [
text('Add')
View submit2.js
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('')
}
You can’t perform that action at this time.