jbilcke-hf HF staff commited on
Commit
96fd583
1 Parent(s): b89eaf4

small ui fix

Browse files
src/app/main.tsx CHANGED
@@ -1,6 +1,6 @@
1
  "use client"
2
 
3
- import React, { useTransition } from 'react'
4
  import { ClapProject } from '@aitube/clap'
5
  import Image from "next/image"
6
  import { DeviceFrameset } from 'react-device-frameset'
@@ -23,6 +23,8 @@ import HFLogo from "./hf-logo.svg"
23
  export function Main() {
24
  const [_isPending, startTransition] = useTransition()
25
  const storyPromptDraft = useStore(s => s.storyPromptDraft)
 
 
26
  const storyPrompt = useStore(s => s.storyPrompt)
27
  const status = useStore(s => s.status)
28
  const storyGenerationStatus = useStore(s => s.storyGenerationStatus)
@@ -54,19 +56,19 @@ export function Main() {
54
  const isBusy = status === "generating" || hasPendingTasks
55
 
56
  const handleSubmit = async () => {
57
- const prompt = storyPromptDraft
58
-
59
- setStatus("generating")
60
- setStoryGenerationStatus("generating")
61
- setStoryPrompt(prompt)
62
 
63
  startTransition(async () => {
64
  console.log(`handleSubmit(): generating a clap using prompt = "${prompt}" `)
65
 
66
  let clap: ClapProject | undefined = undefined
67
  try {
68
- setProgress(0)
69
- clap = await createClap({ prompt })
 
 
 
 
 
70
 
71
  if (!clap) { throw new Error(`failed to create the clap`) }
72
 
@@ -87,9 +89,10 @@ export function Main() {
87
 
88
  // TODO Julian
89
  console.log("handleSubmit(): TODO Julian: generate images in parallel of the dialogue using Promise.all()")
90
-
 
91
  try {
92
- setProgress(5)
93
  setImageGenerationStatus("generating")
94
  clap = await editClapStoryboards({ clap })
95
 
@@ -110,7 +113,7 @@ export function Main() {
110
 
111
 
112
  try {
113
- setProgress(8)
114
  setVoiceGenerationStatus("generating")
115
  clap = await editClapDialogues({ clap })
116
 
@@ -131,7 +134,7 @@ export function Main() {
131
 
132
  let assetUrl = ""
133
  try {
134
- setProgress(50)
135
  setVideoGenerationStatus("generating")
136
  assetUrl = await exportClapToVideo({ clap })
137
 
@@ -280,6 +283,7 @@ export function Main() {
280
  // disabled={modelState != 'ready'}
281
  onChange={(e) => {
282
  setStoryPromptDraft(e.target.value)
 
283
  }}
284
  placeholder="Yesterday I was at my favorite pizza place and.."
285
  inputClassName="
@@ -334,18 +338,7 @@ export function Main() {
334
  text-stone-900/90 dark:text-stone-100/90
335
  text-sm md:text-base lg:text-lg
336
  w-full text-right">
337
- {isBusy
338
- ? (
339
- storyGenerationStatus === "generating" ? "Enhancing the story.."
340
- : imageGenerationStatus === "generating" ? "Generating storyboards.."
341
- : voiceGenerationStatus === "generating" ? "Generating voices.."
342
- : videoGenerationStatus === "generating" ? "Assembling final video.."
343
- : "Please wait.."
344
- )
345
- : status === "error"
346
- ? <span>{error || ""}</span>
347
- : <span>&nbsp;</span> // to prevent layout changes
348
- }
349
  </div>
350
  </div>
351
  </CardContent>
@@ -381,7 +374,21 @@ export function Main() {
381
  {isBusy ? <div className="
382
  flex flex-col
383
  items-center justify-center
384
- text-2xl text-center font-bold">{progress}%</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  : generatedVideo ? <video
386
  src={generatedVideo}
387
  controls
@@ -403,6 +410,7 @@ export function Main() {
403
  </div>
404
 
405
  <div className="
 
406
  flex flex-row items-center justify-end
407
  w-full p-6
408
  font-sans">
 
1
  "use client"
2
 
3
+ import React, { useRef, useTransition } from 'react'
4
  import { ClapProject } from '@aitube/clap'
5
  import Image from "next/image"
6
  import { DeviceFrameset } from 'react-device-frameset'
 
23
  export function Main() {
24
  const [_isPending, startTransition] = useTransition()
25
  const storyPromptDraft = useStore(s => s.storyPromptDraft)
26
+ const promptDraft = useRef("")
27
+ promptDraft.current = storyPromptDraft
28
  const storyPrompt = useStore(s => s.storyPrompt)
29
  const status = useStore(s => s.status)
30
  const storyGenerationStatus = useStore(s => s.storyGenerationStatus)
 
56
  const isBusy = status === "generating" || hasPendingTasks
57
 
58
  const handleSubmit = async () => {
 
 
 
 
 
59
 
60
  startTransition(async () => {
61
  console.log(`handleSubmit(): generating a clap using prompt = "${prompt}" `)
62
 
63
  let clap: ClapProject | undefined = undefined
64
  try {
65
+ setProgress(5)
66
+
67
+ setStatus("generating")
68
+ setStoryGenerationStatus("generating")
69
+ setStoryPrompt(promptDraft.current)
70
+
71
+ clap = await createClap({ prompt: promptDraft.current })
72
 
73
  if (!clap) { throw new Error(`failed to create the clap`) }
74
 
 
89
 
90
  // TODO Julian
91
  console.log("handleSubmit(): TODO Julian: generate images in parallel of the dialogue using Promise.all()")
92
+ // this is not trivial to do btw, since we will have to merge the clap together
93
+ // (this could be a helper function inside @aitube/clap)
94
  try {
95
+ setProgress(25)
96
  setImageGenerationStatus("generating")
97
  clap = await editClapStoryboards({ clap })
98
 
 
113
 
114
 
115
  try {
116
+ setProgress(50)
117
  setVoiceGenerationStatus("generating")
118
  clap = await editClapDialogues({ clap })
119
 
 
134
 
135
  let assetUrl = ""
136
  try {
137
+ setProgress(75)
138
  setVideoGenerationStatus("generating")
139
  assetUrl = await exportClapToVideo({ clap })
140
 
 
283
  // disabled={modelState != 'ready'}
284
  onChange={(e) => {
285
  setStoryPromptDraft(e.target.value)
286
+ promptDraft.current = e.target.value
287
  }}
288
  placeholder="Yesterday I was at my favorite pizza place and.."
289
  inputClassName="
 
338
  text-stone-900/90 dark:text-stone-100/90
339
  text-sm md:text-base lg:text-lg
340
  w-full text-right">
341
+
 
 
 
 
 
 
 
 
 
 
 
342
  </div>
343
  </div>
344
  </CardContent>
 
374
  {isBusy ? <div className="
375
  flex flex-col
376
  items-center justify-center
377
+ text-center space-y-1.5">
378
+ <p className="text-2xl font-bold">{progress}%</p>
379
+ <p className="text-base text-white/70">{isBusy
380
+ ? (
381
+ storyGenerationStatus === "generating" ? "Enhancing the story.."
382
+ : imageGenerationStatus === "generating" ? "Generating storyboards.."
383
+ : voiceGenerationStatus === "generating" ? "Generating voices.."
384
+ : videoGenerationStatus === "generating" ? "Assembling final video.."
385
+ : "Please wait.."
386
+ )
387
+ : status === "error"
388
+ ? <span>{error || ""}</span>
389
+ : <span>&nbsp;</span> // to prevent layout changes
390
+ }</p>
391
+ </div>
392
  : generatedVideo ? <video
393
  src={generatedVideo}
394
  controls
 
410
  </div>
411
 
412
  <div className="
413
+ absolute bottom-0 right-0
414
  flex flex-row items-center justify-end
415
  w-full p-6
416
  font-sans">
src/components/form/textarea-field.tsx CHANGED
@@ -31,10 +31,10 @@ export function TextareaField({
31
  rounded-lg md:rounded-xl lg:rounded-2xl
32
  border-2
33
 
34
- bg-stone-800/90 text-amber-400/100
35
- dark:bg-stone-800/90 dark:text-amber-400/100
36
 
37
- border-stone-800/80 dark:border-stone-800/80
38
  outline-stone-800/80 dark:outline-stone-800/80
39
  ring-stone-800/80 dark:ring-stone-800/80
40
  ring-offset-stone-800/0 dark:ring-offset-stone-800/0
 
31
  rounded-lg md:rounded-xl lg:rounded-2xl
32
  border-2
33
 
34
+ bg-stone-800/60 text-amber-400/100
35
+ dark:bg-stone-800/60 dark:text-amber-400/100
36
 
37
+ border-stone-900/80 dark:border-stone-900/80
38
  outline-stone-800/80 dark:outline-stone-800/80
39
  ring-stone-800/80 dark:ring-stone-800/80
40
  ring-offset-stone-800/0 dark:ring-offset-stone-800/0