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 TodoList = ({ store, editTodo, removeTodo, toggleAll }) => { | |
const [state, setState] = createState(), | |
filterList = todos => { | |
if (store.showMode === 'active') | |
return todos.filter(todo => !todo.completed); | |
else if (store.showMode === 'completed') | |
return todos.filter(todo => todo.completed); | |
else return todos | |
}, | |
isEditing = todoId => state.editingTodoId === todoId, |
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
function createTodosStore() { | |
const [state, setState] = createLocalState({ | |
counter: 1, todos: [], showMode: 'all' | |
}); | |
createEffect(() => { | |
const completedCount = state.todos.filter( | |
todo => todo.completed | |
).length; | |
setState({ | |
completedCount, |
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 { createState, createEffect } from 'solid-js'; | |
const LOCAL_STORAGE_KEY = 'todos-solid'; | |
function createLocalState(value) { | |
// load stored todos on init | |
const stored = localStorage.getItem(LOCAL_STORAGE_KEY), | |
[state, setState] = createState( | |
stored ? JSON.parse(stored) : value | |
); | |
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 { root, useState } from 'solid-js'; | |
import { r, selectWhen } from 'solid-js/dom'; | |
let idCounter = 1; | |
const adjectives = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"], | |
colours = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"], | |
nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"]; | |
function _random (max) { return Math.round(Math.random() * 1000) % max; }; |
NewerOlder