jbilcke-hf HF staff commited on
Commit
d40d743
β€’
1 Parent(s): 0cf119e
Files changed (2) hide show
  1. public/index.html +13 -12
  2. src/index.mts +2 -2
public/index.html CHANGED
@@ -21,21 +21,21 @@
21
  <p>No 3rd party service or token needed: feel free to duplicate and create interesting forks of this space πŸ”§</p>
22
  </div>
23
  <textarea
24
- name="draft"
25
- x-model="draft"
26
  rows="10"
27
  placeholder="a pong clone made using the canvas.."
28
  class="input input-bordered w-full rounded text-lg text-stone-500 bg-stone-300 font-mono h-48"
29
  ></textarea>
30
  <button
31
  class="btn disabled:text-stone-400"
32
- @click="open = true, state = state === 'stopped' ? 'loading' : 'stopped'"
33
- :class="draft.length < minPromptSize ? 'btn-neutral' : state === 'stopped' ? 'btn-accent' : 'btn-warning'"
34
- :disabled="draft.length < minPromptSize"
35
  >
36
- <span x-show="draft.length < minPromptSize">Prompt too short to generate</span>
37
- <span x-show="draft.length >= minPromptSize && state !== 'stopped'">Stop now</span>
38
- <span x-show="draft.length >= minPromptSize && state === 'stopped'">Generate!</span>
39
  </button>
40
  <span class="py-3" x-show="state === 'loading'">Waiting for the stream to begin (might take a few minutes)..</span>
41
  <span class="py-3" x-show="state === 'streaming'">
@@ -49,9 +49,9 @@
49
  <iframe
50
  id="iframe"
51
  class="border-none w-full h-screen"
52
- :src="(draft.length < minPromptSize)
53
  ? '/placeholder.html'
54
- : `/app?prompt=${draft}`
55
  "></iframe>
56
  </div>
57
  </div>
@@ -90,7 +90,8 @@ function humanFileSize(bytes, si=false, dp=1) {
90
  function app() {
91
  return {
92
  open: false,
93
- draft: new URLSearchParams(window.location.search).get('prompt') || '',
 
94
  size: 0,
95
  minPromptSize: 16, // if you change this, you will need to also change in src/index.mts
96
  timeoutInSec: 3 * 60, // time before we determine something went wrong
@@ -133,4 +134,4 @@ function app() {
133
  <script src="/js/alpinejs@3.12.2.js"></script>
134
  <script src="/js/tailwindcss@3.3.2.js"></script>
135
  </body>
136
- </html>
 
21
  <p>No 3rd party service or token needed: feel free to duplicate and create interesting forks of this space πŸ”§</p>
22
  </div>
23
  <textarea
24
+ name="promptDraft"
25
+ x-model="promptDraft"
26
  rows="10"
27
  placeholder="a pong clone made using the canvas.."
28
  class="input input-bordered w-full rounded text-lg text-stone-500 bg-stone-300 font-mono h-48"
29
  ></textarea>
30
  <button
31
  class="btn disabled:text-stone-400"
32
+ @click="open = true, prompt = promptDraft, state = state === 'stopped' ? 'loading' : 'stopped'"
33
+ :class="promptDraft.length < minPromptSize ? 'btn-neutral' : state === 'stopped' ? 'btn-accent' : 'btn-warning'"
34
+ :disabled="promptDraft.length < minPromptSize"
35
  >
36
+ <span x-show="promptDraft.length < minPromptSize">Prompt too short to generate</span>
37
+ <span x-show="promptDraft.length >= minPromptSize && state !== 'stopped'">Stop now</span>
38
+ <span x-show="promptDraft.length >= minPromptSize && state === 'stopped'">Generate!</span>
39
  </button>
40
  <span class="py-3" x-show="state === 'loading'">Waiting for the stream to begin (might take a few minutes)..</span>
41
  <span class="py-3" x-show="state === 'streaming'">
 
49
  <iframe
50
  id="iframe"
51
  class="border-none w-full h-screen"
52
+ :src="!open
53
  ? '/placeholder.html'
54
+ : `/app?prompt=${encodeURIComponent(prompt)}`
55
  "></iframe>
56
  </div>
57
  </div>
 
90
  function app() {
91
  return {
92
  open: false,
93
+ promptDraft: new URLSearchParams(window.location.search).get('prompt') || '',
94
+ prompt: '',
95
  size: 0,
96
  minPromptSize: 16, // if you change this, you will need to also change in src/index.mts
97
  timeoutInSec: 3 * 60, // time before we determine something went wrong
 
134
  <script src="/js/alpinejs@3.12.2.js"></script>
135
  <script src="/js/tailwindcss@3.3.2.js"></script>
136
  </body>
137
+ </html>
src/index.mts CHANGED
@@ -132,7 +132,7 @@ ${daisy}
132
  - All the JS code will be written directly inside the page, using <script type="text/javascript">...</script>
133
  - You MUST use English not Latin! I repeat: do NOT write lorem ipsum!
134
  - No need to write code comments, and try to make the code compact (short function names etc)
135
- - Use a central layout by wrapping everything in a \`<div class="flex flex-col justify-center">\`
136
  # HTML Code
137
  ${prefix}`
138
 
@@ -167,4 +167,4 @@ ${prefix}`
167
 
168
  })
169
 
170
- app.listen(port, () => { console.log(`Open http://localhost:${port}/?prompt=a%20webpage%20recipe%20for%20making%20chocolate%20chip%20cookies`) })
 
132
  - All the JS code will be written directly inside the page, using <script type="text/javascript">...</script>
133
  - You MUST use English not Latin! I repeat: do NOT write lorem ipsum!
134
  - No need to write code comments, and try to make the code compact (short function names etc)
135
+ - Use a central layout by wrapping everything in a \`<div class="flex flex-col items-center">\`
136
  # HTML Code
137
  ${prefix}`
138
 
 
167
 
168
  })
169
 
170
+ app.listen(port, () => { console.log(`Open http://localhost:${port}/?prompt=a%20webpage%20recipe%20for%20making%20chocolate%20chip%20cookies`) })