@@ -13,6 +13,8 @@ import {
13
13
} from '@/components/ui/select' ;
14
14
import { getTheme , type IEditorTheme , languages , themeOptions } from '@/lib/editor/extensions' ;
15
15
import { useCollab } from '@/lib/hooks/use-collab' ;
16
+ import { Button } from '@/components/ui/button' ;
17
+ import { ChevronLeftIcon } from '@radix-ui/react-icons' ;
16
18
17
19
const EXTENSION_HEIGHT = 250 ;
18
20
const MIN_EDITOR_HEIGHT = 350 ;
@@ -24,43 +26,65 @@ type EditorProps = {
24
26
export const Editor = ( { room } : EditorProps ) => {
25
27
const { height } = useWindowSize ( ) ;
26
28
const [ theme , setTheme ] = useState < IEditorTheme > ( 'vscodeDark' ) ;
27
- const { editorRef, extensions, language, setLanguage, code, setCode } = useCollab ( room ) ;
29
+ const { editorRef, extensions, language, setLanguage, code, setCode, members } = useCollab ( room ) ;
28
30
const themePreset = useMemo ( ( ) => {
29
31
return getTheme ( theme ) ;
30
32
} , [ theme ] ) ;
31
33
32
34
return (
33
35
< div className = 'flex flex-col gap-4 p-4' >
34
- < div className = 'flex gap-4' >
35
- < div className = 'flex flex-col gap-2' >
36
- < Label > Language</ Label >
37
- < Select value = { language } onValueChange = { ( val ) => setLanguage ( val as LanguageName ) } >
38
- < SelectTrigger className = 'max-w-[150px]' >
39
- < SelectValue />
40
- </ SelectTrigger >
41
- < SelectContent >
42
- { languages . map ( ( lang , idx ) => (
43
- < SelectItem value = { lang } key = { idx } >
44
- { lang }
45
- </ SelectItem >
46
- ) ) }
47
- </ SelectContent >
48
- </ Select >
36
+ < div className = 'flex w-full justify-between gap-4' >
37
+ < div className = 'flex gap-4' >
38
+ < div className = 'flex flex-col gap-2' >
39
+ < Label > Language</ Label >
40
+ < Select value = { language } onValueChange = { ( val ) => setLanguage ( val as LanguageName ) } >
41
+ < SelectTrigger className = 'max-w-[150px]' >
42
+ < SelectValue />
43
+ </ SelectTrigger >
44
+ < SelectContent >
45
+ { languages . map ( ( lang , idx ) => (
46
+ < SelectItem value = { lang } key = { idx } >
47
+ { lang }
48
+ </ SelectItem >
49
+ ) ) }
50
+ </ SelectContent >
51
+ </ Select >
52
+ </ div >
53
+ < div className = 'flex flex-col gap-2' >
54
+ < Label > Theme</ Label >
55
+ < Select value = { theme } onValueChange = { ( val ) => setTheme ( val as IEditorTheme ) } >
56
+ < SelectTrigger className = 'max-w-[150px]' >
57
+ < SelectValue />
58
+ </ SelectTrigger >
59
+ < SelectContent >
60
+ { themeOptions . map ( ( theme , idx ) => (
61
+ < SelectItem value = { theme } key = { idx } >
62
+ { theme }
63
+ </ SelectItem >
64
+ ) ) }
65
+ </ SelectContent >
66
+ </ Select >
67
+ </ div >
49
68
</ div >
50
- < div className = 'flex flex-col gap-2' >
51
- < Label > Theme</ Label >
52
- < Select value = { theme } onValueChange = { ( val ) => setTheme ( val as IEditorTheme ) } >
53
- < SelectTrigger className = 'max-w-[150px]' >
54
- < SelectValue />
55
- </ SelectTrigger >
56
- < SelectContent >
57
- { themeOptions . map ( ( theme , idx ) => (
58
- < SelectItem value = { theme } key = { idx } >
59
- { theme }
60
- </ SelectItem >
61
- ) ) }
62
- </ SelectContent >
63
- </ Select >
69
+ < div className = 'flex items-center gap-2' >
70
+ < div className = 'flex gap-1 font-mono text-xs' >
71
+ { /* TODO: Get user avatar and display */ }
72
+ { members . map ( ( member , index ) => (
73
+ < div
74
+ className = 'grid size-8 place-items-center text-clip rounded-full border p-1 text-xs'
75
+ style = { {
76
+ borderColor : member . color ,
77
+ } }
78
+ key = { index }
79
+ >
80
+ < span > { member . name } </ span >
81
+ </ div >
82
+ ) ) }
83
+ </ div >
84
+ < Button variant = 'destructive' size = 'sm' className = 'group flex items-center !px-2 !py-1' >
85
+ < ChevronLeftIcon className = 'transition-transform duration-200 ease-in-out group-hover:-translate-x-px' />
86
+ < span > Disconnect</ span >
87
+ </ Button >
64
88
</ div >
65
89
</ div >
66
90
< div className = 'border-border w-full !overflow-clip rounded-lg border shadow-sm' >
0 commit comments