-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathindex.tsx
More file actions
265 lines (252 loc) Β· 7.9 KB
/
index.tsx
File metadata and controls
265 lines (252 loc) Β· 7.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
import React from 'react'
import { Flex, Box, Container, Button } from '@theme-ui/components'
import SmartLink from '../../../../components/atoms/SmartLink'
import SiteLogo from '../../../../components/molecules/SiteLogo'
import Alert from './Alert'
import { ReactComponent as DiscordIcon } from '@media/icons/discord.svg'
import { ReactComponent as GithubIcon } from '@media/icons/github.svg'
import { ReactComponent as UpIcon } from '@media/icons/up.svg'
import { ReactComponent as DownIcon } from '@media/icons/down.svg'
import { ReactComponent as CmlIcon } from '@media/icons/cml.svg'
import { ReactComponent as DvcIcon } from '@media/icons/dvc.svg'
import { ReactComponent as StudioIcon } from '@media/icons/studio.svg'
import { ReactComponent as MlemIcon } from '@media/icons/mlem.svg'
import { ReactComponent as ExternalLinkIcon } from '@media/icons/external-link.svg'
import { ReactComponent as VsCodeIcon } from '@media/icons/vscode.svg'
import {
HamburgerMenu,
HamburgerButton,
useHamburgerMenu
} from '../../../../components/molecules/HamburgerMenu'
import * as styles from './styles.module.css'
import usePopup from '../../../../utils/hooks/usePopup'
import onSelectKey from '../../../../utils/onSelectKey'
interface IHeaderProps {
isMain?: boolean
}
interface IOtherToolsItem {
title: string
titleIcon?: JSX.Element
icon: JSX.Element
description: string
href: string
}
interface IOtherToolsPopupProps {
list: Array<IOtherToolsItem>
isOpen: boolean
}
const socialLinkDefinitions = [
{
url: 'https://github.com/iterative/cml',
icon: <GithubIcon width="16" height="16" />,
title: 'CML GitHub repo'
},
{
url: 'https://cml.dev/chat',
icon: <DiscordIcon className="small-svg" />,
title: 'DVC Discord chat'
}
]
const primaryNavItems = [
{
label: 'Use Cases',
href: '/#use-cases'
},
{
label: 'Docs',
href: '/doc'
},
{
label: 'Blog',
href: 'https://iterative.ai/blog'
}
]
const otherToolsItems: Array<IOtherToolsItem> = [
{
title: 'Studio',
icon: <StudioIcon width="24" height="24" />,
description: 'Track experiments and share insights from ML projects',
href: 'https://studio.iterative.ai/'
},
{
title: 'DVC',
icon: <DvcIcon width="24" height="24" />,
description: 'Open-source version control system for ML projects',
href: 'https://dvc.org/'
},
{
title: 'VS Code Extension',
titleIcon: <VsCodeIcon className="title-icon" width="14" height="14" />,
icon: <div></div>,
description: 'Local ML model development and experiment tracking',
href: 'https://marketplace.visualstudio.com/items?itemName=Iterative.dvc'
},
{
title: 'CML',
icon: <CmlIcon width="24" height="24" />,
description: 'Open-source CI/CD for ML projects',
href: '/'
},
{
title: 'MLEM',
icon: <MlemIcon width="24" height="24" />,
description:
'Open-source model registry and deployment tool for ML projects',
href: 'https://mlem.ai'
}
]
const OtherToolsPopup: React.FC<IOtherToolsPopupProps> = ({ list, isOpen }) => {
return (
<Flex
variant="layout.Header.Nav.OtherToolsPopup"
sx={isOpen ? { variant: 'layout.Header.Nav.OtherToolsPopup.Open' } : {}}
>
{list.map(
({ title, icon, description, href, titleIcon: TitleIcon }, i) => (
<SmartLink
href={href}
key={i}
variant="layout.Header.Nav.OtherToolsPopup.Link"
>
<Box variant="layout.Header.Nav.OtherToolsPopup.Link.Icon">
{icon}
</Box>
<Box as="h2" variant="layout.Header.Nav.OtherToolsPopup.Link.Title">
{title}
{TitleIcon && TitleIcon}
{href.match(/^https?:\/\//) && (
<ExternalLinkIcon width="16" height="16" />
)}
</Box>
<Box
as="p"
variant="layout.Header.Nav.OtherToolsPopup.Link.Description"
>
{description}
</Box>
</SmartLink>
)
)}
</Flex>
)
}
const Header: React.FC<IHeaderProps> = ({ isMain }) => {
const { opened, handleToggle, handleItemClick } = useHamburgerMenu()
const collapsed = opened
const otherToolsPopup = usePopup()
return (
<>
<Box
as="header"
variant="layout.Header"
className={isMain ? '' : styles.headerForDoc}
sx={
isMain
? { backgroundColor: 'transparent' }
: { position: 'fixed', width: '100%' }
}
>
{isMain && <Alert />}
<Container variant="layout.Header.Inner">
<Box as="nav" variant="layout.Header.Nav">
<SiteLogo variant="layout.Header.Nav.Logo" />
<SmartLink
href="https://iterative.ai/"
variant="layout.Header.Nav.CompanyLabel"
>
{' '}
by iterative.ai
</SmartLink>
<Flex variant="layout.Header.Nav.SocialIcons">
{socialLinkDefinitions.map(({ url, icon, title }, i) => (
<SmartLink
key={i}
href={url}
variant="layout.Header.Nav.Link"
title={title}
sx={{
display: 'inline-block',
textAlign: 'center',
py: 2,
px: 1
}}
>
{icon}
</SmartLink>
))}
</Flex>
<Flex variant="layout.Header.Nav.LinksWrapper">
{primaryNavItems.map(({ label, href }, i) => (
<SmartLink href={href} variant="layout.Header.Nav.Link" key={i}>
{label}
</SmartLink>
))}
<Box
variant="layout.Header.Nav.OtherTools"
ref={otherToolsPopup.containerEl}
sx={{ position: 'relative' }}
onMouseEnter={otherToolsPopup.open}
onMouseLeave={otherToolsPopup.close}
>
<Button
onPointerUp={otherToolsPopup.toggle}
onKeyUp={onSelectKey(otherToolsPopup.toggle)}
variant="layout.Header.Nav.NavButton"
sx={
otherToolsPopup.isOpen
? { variant: 'layout.Header.Nav.NavButton.Active' }
: {}
}
>
Other Tools
<Box
variant="layout.Header.Nav.NavButton.Icon"
sx={
otherToolsPopup.isOpen
? { display: 'none' }
: { display: 'flex' }
}
as="span"
>
<DownIcon width="14" height="14" />
</Box>
<Box
variant="layout.Header.Nav.NavButton.Icon"
sx={
otherToolsPopup.isOpen
? { display: 'flex' }
: { display: 'none' }
}
as="span"
>
<UpIcon width="14" height="14" />
</Box>
</Button>
<OtherToolsPopup
isOpen={otherToolsPopup.isOpen}
list={otherToolsItems}
/>
</Box>
</Flex>
</Box>
</Container>
{!isMain && (
<>
<HamburgerButton
opened={opened}
collapsed={collapsed}
handleClick={handleToggle}
/>
<HamburgerMenu
opened={opened}
collapsed={collapsed}
handleToggle={handleToggle}
handleItemClick={handleItemClick}
/>
</>
)}
</Box>
</>
)
}
export default Header