@@ -10,6 +10,8 @@ import {
1010 cell ,
1111} from "@commontools/common-builder" ;
1212
13+ import { launch } from "../data.js" ;
14+
1315const formatData = lift ( ( { obj } ) => {
1416 console . log ( "stringify" , obj ) ;
1517 return JSON . stringify ( obj , null , 2 ) ;
@@ -95,14 +97,18 @@ const viewSystemPrompt = `generate a complete HTML document within a json block
9597 key: 'exampleKey',
9698 }, '*');` ;
9799
100+ const cloneRecipe = handler < void , { data : any , title : string , prompt : string } > ( ( _ , state ) => {
101+ launch ( iframeExample , { data : state . data , title : 'clone of ' + state . title , prompt : state . prompt } ) ;
102+ } ) ;
103+
98104export const iframeExample = recipe < { title : string ; prompt : string ; data : any } > (
99105 "iFrame Example" ,
100106 ( { title, prompt, data } ) => {
101107 tap ( { data } ) ;
102108 prompt . setDefault (
103109 "counter example using write and subscribe with key `counter`"
104110 ) ;
105- data . setDefault ( { message : "hello" , counter : 0 } ) ;
111+ data . setDefault ( { message : "hello" } ) ;
106112
107113 const query = cell < string > ( ) ;
108114 const response = generateData < { html : string } > ( {
@@ -131,6 +137,9 @@ export const iframeExample = recipe<{ title: string; prompt: string; data: any }
131137 < common-button onclick =${ randomize ( { data } ) }
132138 > Randomize Values</ common-button
133139 >
140+ < common-button onclick =${ cloneRecipe ( { data, title, prompt } ) }
141+ > Clone</ common-button
142+ >
134143 < common-button onclick =${ generate ( { prompt, query } ) }
135144 > Generate</ common-button
136145 >
0 commit comments