-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathindex.tsx
More file actions
224 lines (209 loc) Β· 7.28 KB
/
index.tsx
File metadata and controls
224 lines (209 loc) Β· 7.28 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
import React, { useEffect, useState, useCallback, MouseEvent } from 'react'
import cn from 'classnames'
import HamburgerIcon from '../HamburgerIcon'
import Link from '../../atoms/Link'
import SiteLogo from '../SiteLogo'
import { logEvent } from '@dvcorg/gatsby-theme-iterative/src/utils/front/plausible'
import { getFirstPage } from '../../../utils/shared/sidebar'
import { ReactComponent as TwitterIcon } from '@media/icons/twitter.svg'
import { ReactComponent as GithubIcon } from '@media/icons/github.svg'
import { ReactComponent as MailIcon } from '@media/icons/mail.svg'
import { ReactComponent as DiscordIcon } from '@media/icons/discord.svg'
import * as styles from './styles.module.css'
const docsPage = getFirstPage()
export type HamburgerHelpers = {
opened: boolean
setOpened: (newState: boolean) => void
handleToggle: () => void
handleClose: () => void
handleItemClick: (name?: string) => (e: MouseEvent) => void
}
export const useHamburgerMenu: () => HamburgerHelpers = () => {
const [opened, setOpened] = useState(false)
const handleToggle = useCallback(() => setOpened(!opened), [opened])
const handleClose = useCallback(() => setOpened(false), [opened])
const handleItemClick = useCallback<HamburgerHelpers['handleItemClick']>(
item => (): void => {
handleClose()
if (item) {
logEvent('Hamburger Menu', { Item: item })
}
},
[]
)
useEffect(() => {
const method = opened ? 'add' : 'remove'
document.body.classList[method](styles.hiddenScrollbar)
}, [opened])
return {
opened,
setOpened,
handleToggle,
handleClose,
handleItemClick
}
}
export const HamburgerMenu: React.FC<
Pick<HamburgerHelpers, 'opened' | 'handleItemClick' | 'handleToggle'> & {
collapsed: boolean
}
> = ({ opened, handleItemClick }) => {
return (
<div className={cn(styles.wrapper, opened && styles.opened)}>
<div className={styles.logoRow}>
<span className={styles.logo}>
<SiteLogo />
</span>
<Link
className={styles.company}
href="https://iterative.ai/"
target="_blank"
>
by <span className={styles.companyName}>iterative.ai</span>
</Link>
</div>
<ul className={styles.sections}>
<li className={styles.section}>
<Link
href="/#use-cases"
className={styles.sectionHeading}
onClick={handleItemClick('use-cases')}
>
Use Cases
</Link>
</li>
<li className={styles.section}>
<Link
href={docsPage}
className={styles.sectionHeading}
onClick={handleItemClick('doc')}
>
Doc
</Link>
</li>
<li className={styles.section}>
<div className={styles.sectionHeading}>Support</div>
<ul className={styles.subSections}>
<li className={styles.subSection}>
<Link
className={styles.subSectionLink}
href="mailto:support@dvc.org"
target="_blank"
onClick={handleItemClick('mail')}
>
<MailIcon className={styles.subSectionLinkImage} />
<span className={styles.subSectionLinkTitle}>E-Mail</span>
</Link>
</li>
<li className={styles.subSection}>
<Link
className={styles.subSectionLink}
href="https://github.com/iterative/cml"
onClick={handleItemClick('github')}
target="_blank"
>
<GithubIcon className={styles.subSectionLinkImage} />
<span className={styles.subSectionLinkTitle}>GitHub</span>
</Link>
</li>
<li className={styles.subSection}>
<Link
className={styles.subSectionLink}
href="https://cml.dev/chat"
onClick={handleItemClick('chat')}
target="_blank"
>
<DiscordIcon className={styles.subSectionLinkImage} />
<span className={styles.subSectionLinkTitle}>Discord</span>
</Link>
</li>
<li className={styles.subSection}>
<Link
className={styles.subSectionLink}
href="https://twitter.com/DVCorg"
onClick={handleItemClick('twitter')}
target="_blank"
>
<TwitterIcon className={styles.subSectionLinkImage} />
<span className={styles.subSectionLinkTitle}>Twitter</span>
</Link>
</li>
</ul>
</li>
<li className={styles.section}>
<p className={styles.sectionHeading}>All Tools</p>
<ul className={styles.subSections}>
<li className={styles.subSection}>
<Link
href="https://studio.iterative.ai/"
className={styles.subSectionLink}
>
<div
className={cn(styles.subSectionLinkImage, styles.bgImgStudio)}
/>
<span className={styles.subSectionLinkTitle}>Studio</span>
</Link>
</li>
<li className={styles.subSection}>
<Link href="https://dvc.org" className={styles.subSectionLink}>
<div
className={cn(styles.subSectionLinkImage, styles.bgImgDvc)}
/>
<span className={styles.subSectionLinkTitle}>DVC</span>
</Link>
</li>
<li className={styles.subSection}>
<Link href="/" className={styles.subSectionLink}>
<div
className={cn(styles.subSectionLinkImage, styles.bgImgCml)}
/>
<span className={styles.subSectionLinkTitle}>CML</span>
</Link>
</li>
<li className={styles.subSection}>
<Link href="https://mlem.ai/" className={styles.subSectionLink}>
<div
className={cn(styles.subSectionLinkImage, styles.bgImgMlem)}
/>
<span className={styles.subSectionLinkTitle}>MLEM</span>
</Link>
</li>
<li className={styles.subSection}>
<Link
href="https://marketplace.visualstudio.com/items?itemName=Iterative.dvc"
className={styles.subSectionLink}
>
<div
className={cn(styles.subSectionLinkImage, styles.bgImgDvc)}
/>
<span className={styles.subSectionLinkTitle}>
VS Code Extension
</span>
</Link>
</li>
</ul>
</li>
</ul>
<Link
href="/doc/start"
className={styles.linkButton}
onClick={handleItemClick('get-started')}
>
Get started
</Link>
</div>
)
}
export const HamburgerButton: React.FC<{
opened: boolean
collapsed: boolean
handleClick: (e: MouseEvent) => void
}> = ({ opened, handleClick }) => (
<button
className={cn(styles.toggleButton, opened && styles.opened)}
onClick={handleClick}
aria-label="Toggle Mobile Menu"
>
<HamburgerIcon opened={opened} />
</button>
)