1
1
/* eslint-disable react/button-has-type */
2
2
/* eslint-disable jsx-a11y/control-has-associated-label */
3
- import { Flex , Link , Image } from '@chakra-ui/react' ;
3
+ import { Flex , Link , Text } from '@chakra-ui/react' ;
4
4
import { Avatar } from '@codiga/components' ;
5
+ import { ProviderKind } from '@codiga/components/dist/lib/ProviderLogo' ;
6
+
5
7
import { useUser } from '../UserContext' ;
6
8
import { APP_URL } from '../../lib/config' ;
7
9
import { getAvatarUrl } from '../../utils/userUtils' ;
8
- import CodigaLogo from './CodigaIcon.png' ;
9
- import TitlebarButton from './TitlebarButton' ;
10
+
11
+ import TitlebarButtonsMac from './TitlebarButtonsMac' ;
12
+ import TitlebarButtonsWin from './TitlebarButtonsWin' ;
10
13
11
14
type TitlebarProps = {
12
15
openLoginModal : ( ) => void ;
@@ -25,84 +28,55 @@ export default function Titlebar({ openLoginModal, isOnline }: TitlebarProps) {
25
28
justifyContent = "space-between"
26
29
bg = "neutral.25"
27
30
_dark = { { bg : 'base.dark' } }
28
- sx = { {
29
- '-webkit-app-region' : 'drag' ,
30
- } }
31
+ sx = { { '-webkit-app-region' : 'drag' } }
31
32
>
32
- < Image src = { CodigaLogo } h = "24px" ml = "space_16" />
33
-
34
- < Flex
35
- alignItems = "center"
36
- gridGap = "space_16"
37
- sx = { { '-webkit-app-region' : 'no-drag' } }
38
- >
39
- { isOnline && (
40
- < >
41
- < Link
42
- isExternal
43
- href = { `${ APP_URL } /assistant/snippet/create` }
44
- variant = "square"
45
- >
46
- Create Snippet
47
- </ Link >
48
-
49
- < Flex w = "32px" alignItems = "center" >
50
- { id ? (
51
- < Avatar
52
- name = { username || 'Anon' }
53
- kind = { accountType as any }
54
- src = { getAvatarUrl ( { id, username, accountType } ) }
55
- size = "sm"
56
- />
57
- ) : (
58
- // eslint-disable-next-line jsx-a11y/anchor-is-valid
59
- < Link
60
- as = "button"
61
- onClick = { openLoginModal }
62
- variant = "solid"
63
- size = "sm"
64
- p = "0"
65
- >
66
- Login
67
- </ Link >
68
- ) }
69
- </ Flex >
70
- </ >
71
- ) }
33
+ { /* LEFT SIDE */ }
34
+ { /* we either show the Mac buttons or a Codiga img here */ }
35
+ < TitlebarButtonsMac />
72
36
73
- < Flex >
74
- < TitlebarButton message = "minimizeApp" >
75
- < svg
76
- width = "12"
77
- height = "12"
78
- xmlns = "http://www.w3.org/2000/svg"
79
- viewBox = "0 0 448 512"
80
- >
81
- < path d = "M400 288h-352c-17.69 0-32-14.32-32-32.01s14.31-31.99 32-31.99h352c17.69 0 32 14.3 32 31.99S417.7 288 400 288z" />
82
- </ svg >
83
- </ TitlebarButton >
84
- < TitlebarButton message = "maximizeApp" >
85
- < svg
86
- width = "12"
87
- height = "12"
88
- xmlns = "http://www.w3.org/2000/svg"
89
- viewBox = "0 0 448 512"
90
- >
91
- < path d = "M128 32H32C14.31 32 0 46.31 0 64v96c0 17.69 14.31 32 32 32s32-14.31 32-32V96h64c17.69 0 32-14.31 32-32S145.7 32 128 32zM416 32h-96c-17.69 0-32 14.31-32 32s14.31 32 32 32h64v64c0 17.69 14.31 32 32 32s32-14.31 32-32V64C448 46.31 433.7 32 416 32zM128 416H64v-64c0-17.69-14.31-32-32-32s-32 14.31-32 32v96c0 17.69 14.31 32 32 32h96c17.69 0 32-14.31 32-32S145.7 416 128 416zM416 320c-17.69 0-32 14.31-32 32v64h-64c-17.69 0-32 14.31-32 32s14.31 32 32 32h96c17.69 0 32-14.31 32-32v-96C448 334.3 433.7 320 416 320z" />
92
- </ svg >
93
- </ TitlebarButton >
37
+ { /* RIGHT SIDE */ }
38
+ { /* we show windows buttons, connecting text or CTA/Avatar here */ }
39
+ < Flex sx = { { '-webkit-app-region' : 'no-drag' } } >
40
+ < Flex alignItems = "center" gridGap = "space_16" mr = "space_16" >
41
+ { isOnline ? (
42
+ < >
43
+ < Link
44
+ isExternal
45
+ href = { `${ APP_URL } /assistant/snippet/create` }
46
+ variant = "square"
47
+ >
48
+ Create Snippet
49
+ </ Link >
94
50
95
- < TitlebarButton message = "closeApp" >
96
- < svg
97
- width = "12"
98
- height = "12"
99
- xmlns = "http://www.w3.org/2000/svg"
100
- viewBox = "0 0 320 512"
101
- >
102
- < path d = "M310.6 361.4c12.5 12.5 12.5 32.75 0 45.25C304.4 412.9 296.2 416 288 416s-16.38-3.125-22.62-9.375L160 301.3L54.63 406.6C48.38 412.9 40.19 416 32 416S15.63 412.9 9.375 406.6c-12.5-12.5-12.5-32.75 0-45.25l105.4-105.4L9.375 150.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0L160 210.8l105.4-105.4c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25l-105.4 105.4L310.6 361.4z" />
103
- </ svg >
104
- </ TitlebarButton >
51
+ < Flex w = "32px" alignItems = "center" >
52
+ { id ? (
53
+ < Avatar
54
+ name = { username || 'Anon' }
55
+ kind = { accountType as ProviderKind }
56
+ src = { getAvatarUrl ( { id, username, accountType } ) }
57
+ size = "sm"
58
+ />
59
+ ) : (
60
+ // eslint-disable-next-line jsx-a11y/anchor-is-valid
61
+ < Link
62
+ as = "button"
63
+ onClick = { openLoginModal }
64
+ variant = "solid"
65
+ size = "sm"
66
+ p = "0"
67
+ >
68
+ Login
69
+ </ Link >
70
+ ) }
71
+ </ Flex >
72
+ </ >
73
+ ) : (
74
+ < Text size = "xs" opacity = { 0.7 } >
75
+ Connecting...
76
+ </ Text >
77
+ ) }
105
78
</ Flex >
79
+ < TitlebarButtonsWin />
106
80
</ Flex >
107
81
</ Flex >
108
82
) ;
0 commit comments