BennyKok commited on
Commit
b747f96
1 Parent(s): 0bf8fdb

chore: add some transition

Browse files
Files changed (1) hide show
  1. src/components/WebsocketDemo.tsx +14 -1
src/components/WebsocketDemo.tsx CHANGED
@@ -7,6 +7,8 @@ import useWebSocket, { ReadyState } from 'react-use-websocket';
7
  import { useDebounce } from "use-debounce";
8
  import { Input } from './ui/input';
9
  import { Badge } from './ui/badge';
 
 
10
 
11
  export function WebsocketDemo() {
12
  const { data } = useSWR("ws", getWebsocketUrl, {
@@ -155,6 +157,8 @@ export function WebsocketDemo() {
155
  return connectWS(data)
156
  }, [connectWS, reconnectCounter])
157
 
 
 
158
  return (
159
  <div className='flex md:flex-col gap-2 px-2 flex-col-reverse'>
160
  <div className='flex gap-2'>
@@ -165,7 +169,16 @@ export function WebsocketDemo() {
165
  {status == "ready" && !currentLog && " running"}
166
  </Badge>}
167
  </div>
168
- <canvas ref={canvasRef} className='rounded-lg ring-1 ring-black/10' width="1024" height="1024"></canvas>
 
 
 
 
 
 
 
 
 
169
 
170
  <Input
171
  type="text"
 
7
  import { useDebounce } from "use-debounce";
8
  import { Input } from './ui/input';
9
  import { Badge } from './ui/badge';
10
+ import { Skeleton } from './ui/skeleton';
11
+ import { cn } from '@/lib/utils';
12
 
13
  export function WebsocketDemo() {
14
  const { data } = useSWR("ws", getWebsocketUrl, {
 
157
  return connectWS(data)
158
  }, [connectWS, reconnectCounter])
159
 
160
+ const pending = (status == "not-connected" || status == "connecting" || status == "reconnecting" || currentLog?.startsWith("running") || (!currentLog && status == "connected"))
161
+
162
  return (
163
  <div className='flex md:flex-col gap-2 px-2 flex-col-reverse'>
164
  <div className='flex gap-2'>
 
169
  {status == "ready" && !currentLog && " running"}
170
  </Badge>}
171
  </div>
172
+
173
+ <div className='relative w-full'>
174
+ <canvas ref={canvasRef} className='rounded-lg ring-1 ring-black/10 w-full aspect-square' width={1024} height={1024}></canvas>
175
+ {
176
+ <><Skeleton className={
177
+ cn("absolute top-0 left-0 w-full h-full aspect-square opacity-20 transition-opacity", pending ? "visible" : "invisible opacity-0")
178
+ } /></>
179
+ }
180
+ </div>
181
+
182
 
183
  <Input
184
  type="text"