Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit56e0692

Browse files
committed
add loading ui generating graph
1 parent0745fd1 commit56e0692

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

‎app/create/page.tsx‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default function Home() {
3131
const[hasSearched,setHasSearched]=useState<boolean>(false)
3232
const[error,setError]=useState<string|null>(null)
3333
const[selectedBook,setSelectedBook]=useState<Book|null>(null)
34+
const[isGeneratingGraph,setIsGeneratingGraph]=useState<boolean>(false)
3435

3536
useEffect(()=>{
3637
constrequestBooks=async()=>{
@@ -79,7 +80,9 @@ export default function Home() {
7980
setShowResults(false)
8081
setSearchTerm(book.title)
8182
setError(null)
83+
setGraphResult(null)
8284
setSelectedBook(book)
85+
setIsGeneratingGraph(true)
8386

8487
startTransition(async()=>{
8588
try{
@@ -89,7 +92,8 @@ export default function Home() {
8992
setError(
9093
errinstanceofError ?err.message :'Failed to generate graph',
9194
)
92-
setGraphResult(null)
95+
}finally{
96+
setIsGeneratingGraph(false)
9397
}
9498
})
9599
}
@@ -200,6 +204,21 @@ export default function Home() {
200204
</div>
201205
</div>
202206

207+
{isGeneratingGraph&&(
208+
<divclassName="mx-auto mb-8 max-w-4xl">
209+
<divclassName="flex flex-col items-center justify-center rounded-2xl border border-gray-200 bg-white p-8 text-center shadow-lg">
210+
<divclassName="h-10 w-10 animate-spin rounded-full border-4 border-gray-300 border-t-teal-600 sm:h-12 sm:w-12"/>
211+
<pclassName="mt-4 text-lg font-medium text-gray-800">
212+
Generating your story graph
213+
{selectedBook&&` for "${selectedBook.title}"`}...
214+
</p>
215+
<pclassName="mt-2 text-sm text-gray-500">
216+
This might take a few moments.
217+
</p>
218+
</div>
219+
</div>
220+
)}
221+
203222
{error&&(
204223
<divclassName="mx-auto mb-8 max-w-4xl">
205224
<divclassName="rounded-2xl border-2 border-red-200 bg-red-50 p-6 shadow-lg">

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp