File tree Expand file tree Collapse file tree 3 files changed +53
-4
lines changed
typescript/packages/lookslike-high-level/src Expand file tree Collapse file tree 3 files changed +53
-4
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ const { state } = signal;
55
66import { todoList , todoTask } from "./recipes/todo-list.js" ;
77import "./recipes/todo-list-as-task.js" ; // Necessary, so that suggestions are indexed.
8+ import { recipeItem , recipeList } from "./recipes/recipe-list.js" ;
9+ import { Recipe } from "./recipe.js" ;
810
911export const keywords : { [ key : string ] : string [ ] } = {
1012 groceries : [ "grocery list" ] ,
@@ -17,21 +19,31 @@ export function addGems(gems: { [key: string]: Gem }) {
1719 dataGems . send ( { ...dataGems . get ( ) , ...gems } ) ;
1820}
1921
20- addGems ( {
22+ const recipes : { [ name : string ] : Recipe } = {
2123 "todo list" : todoList ( {
2224 items : [ "Buy groceries" , "Walk the dog" , "Wash the car" ] . map ( ( item ) =>
2325 todoTask ( {
2426 title : item ,
2527 done : false ,
26- } )
28+ } ) ,
2729 ) ,
2830 } ) ,
2931 "grocery list" : todoList ( {
3032 items : [ "milk" , "eggs" , "bread" ] . map ( ( item ) =>
3133 todoTask ( {
3234 title : item ,
3335 done : false ,
34- } )
36+ } ) ,
3537 ) ,
3638 } ) ,
39+ } ;
40+
41+ recipes [ "recipe list" ] = recipeList ( {
42+ items : Object . keys ( recipes ) . map ( ( name ) =>
43+ recipeItem ( {
44+ title : name ,
45+ } ) ,
46+ ) ,
3747} ) ;
48+
49+ addGems ( recipes ) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ const { computed, isSignal } = signal;
77
88// Hard coded todo list as UI to show
99const UI = computed ( [ dataGems ] , ( dataGems ) => {
10- let UI = dataGems [ "todo list" ] ?. UI ;
10+ if ( dataGems . length === 0 ) return null ;
11+
12+ let UI = dataGems [ "recipe list" ] ?. UI ;
1113 if ( isSignal ( UI ) ) UI = UI . get ( ) ;
1214 return UI ;
1315} ) ;
Original file line number Diff line number Diff line change 1+ import { view , tags } from "@commontools/common-ui" ;
2+ import { signal , stream } from "@commontools/common-frp" ;
3+ import { recipe } from "../recipe.js" ;
4+ import { annotation } from "../components/annotation.js" ;
5+ const { binding, repeat } = view ;
6+ const { vstack, hstack, div, include } = tags ;
7+ const { state } = signal ;
8+
9+ export const recipeList = recipe ( "recipe list" , ( { items } ) => {
10+ return {
11+ UI : [
12+ vstack ( { } , [
13+ vstack ( { } , repeat ( "items" , include ( { content : binding ( "itemUI" ) } ) ) ) ,
14+ ] ) ,
15+ { items } ,
16+ ] ,
17+ items,
18+ } ;
19+ } ) ;
20+
21+ export const recipeItem = recipe ( "recipe list item" , ( { title } ) => {
22+ return {
23+ itemUI : state ( [
24+ vstack ( { } , [
25+ hstack ( { } , [ div ( { } , binding ( "title" ) ) ] ) ,
26+ annotation ( {
27+ query : title ,
28+ data : { recipeName : title } ,
29+ } ) ,
30+ ] ) ,
31+ { title } ,
32+ ] ) ,
33+ title,
34+ } ;
35+ } ) ;
You can’t perform that action at this time.
0 commit comments