File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 44 import Label from " ./components/Label.svelte" ;
55 import Message from " ./components/Message.svelte" ;
66
7+ import { Loader } from " @lucide/svelte" ;
78 import { type Problem } from " ./utils/types" ;
89
910 let under_diff = $state <string >(" 0" );
1718
1819 let result = $state <Problem | null >(null );
1920 let errorMessage = $state <string | null >(null );
21+ let loading = $state <boolean >(false );
2022
2123 const sendQuery = async (): Promise <void > => {
2224 if (errors .rangeError || errors .isMinusUnderDiff || errors .isMinusOverDiff ) {
2325 return ;
2426 }
2527
2628 errorMessage = null ;
29+ loading = true ;
2730
2831 try {
2932 const API_URL = import .meta .env .VITE_API_URL ;
4144 errorMessage = (err as Error ).message ;
4245 result = null ;
4346 }
47+
48+ setTimeout (() => {
49+ loading = false ;
50+ }, 2200 );
4451 }
4552 </script >
4653
6370 <div class =" flex items-center gap-2" >
6471 <Input type ="number" placeholder ="最低Diffを入力してください。" isErrors ={errors } bind:value ={under_diff } />
6572 <Input type ="number" placeholder ="最高Diffを入力してください。" isErrors ={errors } bind:value ={over_diff } />
66- <Button onclick ={sendQuery } class =" shrink-0" >Pick</Button >
73+ <Button onclick ={sendQuery } class ="shrink-0" disabled ={loading }>
74+ {#if loading }
75+ <div class =" animate-spin [animation-duration: 2.2s] mr-2" >
76+ <Loader size =" 1rem" />
77+ </div >
78+ {/if }
79+ Pick
80+ </Button >
6781 </div >
6882
69- {#if result !== null }
83+ {#if ! loading && result !== null }
7084 <div class =" mt-4" >
7185 <Message variant =" success" >
7286 <div class =" flex flex-col" >
You can’t perform that action at this time.
0 commit comments