1+ import { type VariantProps } from 'class-variance-authority' ;
12import { Track } from 'livekit-client' ;
2- import { type ReceivedChatMessage } from '@livekit/components-react' ;
3- import { PlusIcon } from '@phosphor-icons/react/dist/ssr' ;
3+ import { MicrophoneIcon } from '@phosphor-icons/react/dist/ssr' ;
44import { AgentControlBar } from '@/components/livekit/agent-control-bar/agent-control-bar' ;
55import { TrackDeviceSelect } from '@/components/livekit/agent-control-bar/track-device-select' ;
66import { TrackSelector } from '@/components/livekit/agent-control-bar/track-selector' ;
77import { TrackToggle } from '@/components/livekit/agent-control-bar/track-toggle' ;
8- import { Alert , AlertDescription , AlertTitle } from '@/components/livekit/alert' ;
8+ import { Alert , AlertDescription , AlertTitle , alertVariants } from '@/components/livekit/alert' ;
99import { AlertToast } from '@/components/livekit/alert-toast' ;
10- import { Button } from '@/components/livekit/button' ;
10+ import { Button , buttonVariants } from '@/components/livekit/button' ;
1111import { ChatEntry } from '@/components/livekit/chat-entry' ;
1212import {
1313 Select ,
@@ -17,20 +17,33 @@ import {
1717 SelectValue ,
1818} from '@/components/livekit/select' ;
1919import { ShimmerText } from '@/components/livekit/shimmer-text' ;
20- import { Toggle } from '@/components/livekit/toggle' ;
21- import { Container } from './_container ' ;
20+ import { Toggle , toggleVariants } from '@/components/livekit/toggle' ;
21+ import { cn } from '@/lib/utils ' ;
2222
23- const buttonVariants = [
24- 'default' ,
25- 'primary' ,
26- 'secondary' ,
27- 'outline' ,
28- 'ghost' ,
29- 'link' ,
30- 'destructive' ,
31- ] as const ;
32- const toggleVariants = [ 'default' , 'primary' , 'secondary' , 'outline' ] as const ;
33- const alertVariants = [ 'default' , 'destructive' ] as const ;
23+ type toggleVariantsType = VariantProps < typeof toggleVariants > [ 'variant' ] ;
24+ type toggleVariantsSizeType = VariantProps < typeof toggleVariants > [ 'size' ] ;
25+ type buttonVariantsType = VariantProps < typeof buttonVariants > [ 'variant' ] ;
26+ type buttonVariantsSizeType = VariantProps < typeof buttonVariants > [ 'size' ] ;
27+ type alertVariantsType = VariantProps < typeof alertVariants > [ 'variant' ] ;
28+
29+ interface ContainerProps {
30+ componentName ?: string ;
31+ children : React . ReactNode ;
32+ className ?: string ;
33+ }
34+
35+ function Container ( { componentName, children, className } : ContainerProps ) {
36+ return (
37+ < div className = { cn ( 'space-y-4' , className ) } >
38+ < h3 className = "text-foreground text-2xl font-bold" >
39+ < span className = "tracking-tight" > { componentName } </ span >
40+ </ h3 >
41+ < div className = "bg-background border-input space-y-4 rounded-3xl border p-8 drop-shadow-lg/5" >
42+ { children }
43+ </ div >
44+ </ div >
45+ ) ;
46+ }
3447
3548function StoryTitle ( { children } : { children : React . ReactNode } ) {
3649 return < h4 className = "text-muted-foreground mb-2 font-mono text-xs uppercase" > { children } </ h4 > ;
@@ -54,29 +67,23 @@ export default function Base() {
5467 </ tr >
5568 </ thead >
5669 < tbody className = "[&_td]:p-2 [&_td:not(:first-child)]:text-center" >
57- { buttonVariants . map ( ( variant ) => (
58- < tr key = { variant } >
59- < td className = "text-right font-mono text-xs font-normal uppercase" > { variant } </ td >
60- < td >
61- < Button variant = { variant } size = "sm" >
62- Button
63- </ Button >
64- </ td >
65- < td >
66- < Button variant = { variant } > Button</ Button >
67- </ td >
68- < td >
69- < Button variant = { variant } size = "lg" >
70- Button
71- </ Button >
72- </ td >
73- < td >
74- < Button variant = { variant } size = "icon" >
75- < PlusIcon size = { 16 } weight = "bold" />
76- </ Button >
77- </ td >
78- </ tr >
79- ) ) }
70+ { [ 'default' , 'primary' , 'secondary' , 'outline' , 'ghost' , 'link' , 'destructive' ] . map (
71+ ( variant ) => (
72+ < tr key = { variant } >
73+ < td className = "text-right font-mono text-xs font-normal uppercase" > { variant } </ td >
74+ { [ 'sm' , 'default' , 'lg' , 'icon' ] . map ( ( size ) => (
75+ < td key = { size } >
76+ < Button
77+ variant = { variant as buttonVariantsType }
78+ size = { size as buttonVariantsSizeType }
79+ >
80+ { size === 'icon' ? < MicrophoneIcon size = { 16 } weight = "bold" /> : 'Button' }
81+ </ Button >
82+ </ td >
83+ ) ) }
84+ </ tr >
85+ )
86+ ) }
8087 </ tbody >
8188 </ table >
8289 </ Container >
@@ -94,61 +101,31 @@ export default function Base() {
94101 </ tr >
95102 </ thead >
96103 < tbody className = "[&_td]:p-2 [&_td:not(:first-child)]:text-center" >
97- { toggleVariants . map ( ( variant ) => (
104+ { [ 'default' , 'primary' , 'secondary' , 'outline' ] . map ( ( variant ) => (
98105 < tr key = { variant } >
99106 < td className = "text-right font-mono text-xs font-normal uppercase" > { variant } </ td >
100- < td >
101- < Toggle variant = { variant } size = "sm" >
102- Toggle
103- </ Toggle >
104- </ td >
105- < td >
106- < Toggle variant = { variant } > Toggle</ Toggle >
107- </ td >
108- < td >
109- < Toggle variant = { variant } size = "lg" >
110- Toggle
111- </ Toggle >
112- </ td >
113- < td >
114- < Toggle variant = { variant } size = "icon" >
115- < PlusIcon size = { 16 } weight = "bold" />
116- </ Toggle >
117- </ td >
107+ { [ 'sm' , 'default' , 'lg' , 'icon' ] . map ( ( size ) => (
108+ < td key = { size } >
109+ < Toggle
110+ size = { size as toggleVariantsSizeType }
111+ variant = { variant as toggleVariantsType }
112+ >
113+ { size === 'icon' ? < MicrophoneIcon size = { 16 } weight = "bold" /> : 'Toggle' }
114+ </ Toggle >
115+ </ td >
116+ ) ) }
118117 </ tr >
119118 ) ) }
120119 </ tbody >
121120 </ table >
122- { /* {toggleVariants.map((variant) => (
123- <div key={variant}>
124- <StoryTitle>{variant}</StoryTitle>
125- <div className="flex justify-center gap-8">
126- <div>
127- <Toggle key={variant} variant={variant} size="sm">
128- Size sm
129- </Toggle>
130- </div>
131- <div>
132- <Toggle key={variant} variant={variant}>
133- Size default
134- </Toggle>
135- </div>
136- <div>
137- <Toggle key={variant} variant={variant} size="lg">
138- Size lg
139- </Toggle>
140- </div>
141- </div>
142- </div>
143- ))} */ }
144121 </ Container >
145122
146123 { /* Alert */ }
147124 < Container componentName = "Alert" >
148- { alertVariants . map ( ( variant ) => (
125+ { [ 'default' , 'destructive' ] . map ( ( variant ) => (
149126 < div key = { variant } >
150127 < StoryTitle > { variant } </ StoryTitle >
151- < Alert key = { variant } variant = { variant } >
128+ < Alert key = { variant } variant = { variant as alertVariantsType } >
152129 < AlertTitle > Alert { variant } title</ AlertTitle >
153130 < AlertDescription > This is a { variant } alert description.</ AlertDescription >
154131 </ Alert >
@@ -252,40 +229,18 @@ export default function Base() {
252229 < Container componentName = "ChatEntry" >
253230 < div className = "mx-auto max-w-prose space-y-4" >
254231 < ChatEntry
255- entry = {
256- {
257- id : '1' ,
258- timestamp : Date . now ( ) ,
259- message : 'Hello, how are you?' ,
260- from : {
261- identity : 'user' ,
262- isLocal : true ,
263- name : 'User' ,
264- audioTrackPublications : new Map ( ) ,
265- videoTrackPublications : new Map ( ) ,
266- trackPublications : new Map ( ) ,
267- audioLevel : 0 ,
268- } ,
269- } as ReceivedChatMessage
270- }
232+ locale = "en-US"
233+ timestamp = { Date . now ( ) + 1000 }
234+ message = "Hello, how are you?"
235+ messageOrigin = "local"
236+ name = "User"
271237 />
272238 < ChatEntry
273- entry = {
274- {
275- id : '1' ,
276- timestamp : Date . now ( ) ,
277- message : 'I am good, how about you?' ,
278- from : {
279- identity : 'agent' ,
280- isLocal : false ,
281- name : 'Agent' ,
282- audioTrackPublications : new Map ( ) ,
283- videoTrackPublications : new Map ( ) ,
284- trackPublications : new Map ( ) ,
285- audioLevel : 0 ,
286- } ,
287- } as ReceivedChatMessage
288- }
239+ locale = "en-US"
240+ timestamp = { Date . now ( ) + 5000 }
241+ message = "I am good, how about you?"
242+ messageOrigin = "remote"
243+ name = "Agent"
289244 />
290245 </ div >
291246 </ Container >
0 commit comments