@moises.ai/design-system 3.11.19 → 3.11.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3351 -3338
- package/package.json +1 -1
- package/src/components/Sidebar/Sidebar.jsx +81 -57
- package/src/components/Sidebar/Sidebar.module.css +100 -0
package/package.json
CHANGED
|
@@ -14,6 +14,26 @@ import {
|
|
|
14
14
|
import { useMobileDrawer } from '../../utils/useMobileDrawer'
|
|
15
15
|
import { MobileDrawerProvider } from '../../contexts/MobileDrawerContext'
|
|
16
16
|
|
|
17
|
+
const DEFAULT_MOBILE_BREAKPOINT = 768
|
|
18
|
+
|
|
19
|
+
const getMobileMediaQuery = (mobileBreakpoint) => {
|
|
20
|
+
if (mobileBreakpoint == null) {
|
|
21
|
+
return `(max-width: ${DEFAULT_MOBILE_BREAKPOINT}px)`
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (typeof mobileBreakpoint === 'number') {
|
|
25
|
+
return `(max-width: ${mobileBreakpoint}px)`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (typeof mobileBreakpoint === 'string') {
|
|
29
|
+
const trimmed = mobileBreakpoint.trim()
|
|
30
|
+
if (!trimmed) return `(max-width: ${DEFAULT_MOBILE_BREAKPOINT}px)`
|
|
31
|
+
return trimmed.startsWith('(') ? trimmed : `(max-width: ${trimmed})`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return `(max-width: ${DEFAULT_MOBILE_BREAKPOINT}px)`
|
|
35
|
+
}
|
|
36
|
+
|
|
17
37
|
export const Sidebar = ({
|
|
18
38
|
className,
|
|
19
39
|
children,
|
|
@@ -23,9 +43,12 @@ export const Sidebar = ({
|
|
|
23
43
|
onCollapsedChange,
|
|
24
44
|
onLogoClick,
|
|
25
45
|
tooltip = 'Expand menu',
|
|
46
|
+
mobileBreakpoint = DEFAULT_MOBILE_BREAKPOINT,
|
|
26
47
|
...props
|
|
27
48
|
}) => {
|
|
28
|
-
const
|
|
49
|
+
const mobileMediaQuery = getMobileMediaQuery(mobileBreakpoint)
|
|
50
|
+
const { isMobile, isOpen: mobileOpen, open, close } =
|
|
51
|
+
useMobileDrawer(mobileMediaQuery)
|
|
29
52
|
const [isHovered, setIsHovered] = useState(false)
|
|
30
53
|
const [internalTemporarilyExpandedByDrag, setInternalTemporarilyExpandedByDrag] =
|
|
31
54
|
useState(false)
|
|
@@ -159,6 +182,7 @@ export const Sidebar = ({
|
|
|
159
182
|
<div
|
|
160
183
|
className={classNames(styles.root, {
|
|
161
184
|
[styles.rootCollapsed]: effectiveCollapsed,
|
|
185
|
+
[styles.rootMobile]: isMobile,
|
|
162
186
|
})}
|
|
163
187
|
{...props}
|
|
164
188
|
>
|
|
@@ -184,8 +208,8 @@ export const Sidebar = ({
|
|
|
184
208
|
cursor: effectiveCollapsed || onLogoClick ? 'pointer' : 'default',
|
|
185
209
|
}}
|
|
186
210
|
>
|
|
187
|
-
|
|
188
|
-
|
|
211
|
+
<MoisesLogoIcon width={32} height={17} />
|
|
212
|
+
<MoisesIcon height={12.269} />
|
|
189
213
|
</Flex>
|
|
190
214
|
</button>
|
|
191
215
|
|
|
@@ -240,35 +264,35 @@ export const Sidebar = ({
|
|
|
240
264
|
[styles.headerCollapsed]: effectiveCollapsed,
|
|
241
265
|
})}
|
|
242
266
|
>
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
>
|
|
249
|
-
<Flex
|
|
250
|
-
align="center"
|
|
251
|
-
gap="2"
|
|
252
|
-
style={{
|
|
253
|
-
cursor: effectiveCollapsed || onLogoClick ? 'pointer' : 'default',
|
|
254
|
-
}}
|
|
267
|
+
<button
|
|
268
|
+
type="button"
|
|
269
|
+
className={styles.logoButton}
|
|
270
|
+
onClick={handleLogoClick}
|
|
271
|
+
aria-label={desktopLogoAriaLabel}
|
|
255
272
|
>
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
273
|
+
<Flex
|
|
274
|
+
align="center"
|
|
275
|
+
gap="2"
|
|
276
|
+
style={{
|
|
277
|
+
cursor: effectiveCollapsed || onLogoClick ? 'pointer' : 'default',
|
|
278
|
+
}}
|
|
279
|
+
>
|
|
280
|
+
{logoContent}
|
|
281
|
+
</Flex>
|
|
282
|
+
</button>
|
|
283
|
+
<button
|
|
284
|
+
type="button"
|
|
285
|
+
onClick={handleToggleCollapse}
|
|
286
|
+
className={classNames(styles.toggleButton, {
|
|
287
|
+
[styles.toggleButtonHidden]: effectiveCollapsed,
|
|
288
|
+
})}
|
|
289
|
+
aria-label="Collapse menu"
|
|
290
|
+
>
|
|
291
|
+
<SidebarLeftIcon width={16} height={16} />
|
|
292
|
+
</button>
|
|
293
|
+
</Flex>
|
|
294
|
+
</div>
|
|
295
|
+
</Tooltip>
|
|
272
296
|
</div>
|
|
273
297
|
) : (
|
|
274
298
|
<div className={styles.headerWrapper}>
|
|
@@ -279,33 +303,33 @@ export const Sidebar = ({
|
|
|
279
303
|
[styles.headerCollapsed]: effectiveCollapsed,
|
|
280
304
|
})}
|
|
281
305
|
>
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
>
|
|
288
|
-
<Flex
|
|
289
|
-
align="center"
|
|
290
|
-
gap="2"
|
|
291
|
-
style={{
|
|
292
|
-
cursor: effectiveCollapsed || onLogoClick ? 'pointer' : 'default',
|
|
293
|
-
}}
|
|
306
|
+
<button
|
|
307
|
+
type="button"
|
|
308
|
+
className={styles.logoButton}
|
|
309
|
+
onClick={handleLogoClick}
|
|
310
|
+
aria-label={desktopLogoAriaLabel}
|
|
294
311
|
>
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
312
|
+
<Flex
|
|
313
|
+
align="center"
|
|
314
|
+
gap="2"
|
|
315
|
+
style={{
|
|
316
|
+
cursor: effectiveCollapsed || onLogoClick ? 'pointer' : 'default',
|
|
317
|
+
}}
|
|
318
|
+
>
|
|
319
|
+
{logoContent}
|
|
320
|
+
</Flex>
|
|
321
|
+
</button>
|
|
322
|
+
<button
|
|
323
|
+
type="button"
|
|
324
|
+
onClick={handleToggleCollapse}
|
|
325
|
+
className={classNames(styles.toggleButton, {
|
|
326
|
+
[styles.toggleButtonHidden]: effectiveCollapsed,
|
|
327
|
+
})}
|
|
328
|
+
aria-label="Collapse menu"
|
|
329
|
+
>
|
|
330
|
+
<SidebarLeftIcon width={16} height={16} />
|
|
331
|
+
</button>
|
|
332
|
+
</Flex>
|
|
309
333
|
</div>
|
|
310
334
|
)}
|
|
311
335
|
<Flex direction="column" className={styles.content}>
|
|
@@ -148,6 +148,106 @@
|
|
|
148
148
|
color: var(--neutral-alpha-12);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
.rootMobile {
|
|
152
|
+
position: absolute;
|
|
153
|
+
width: 0;
|
|
154
|
+
height: 0;
|
|
155
|
+
overflow: visible;
|
|
156
|
+
background: transparent;
|
|
157
|
+
border: none;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.rootMobile.rootCollapsed {
|
|
161
|
+
width: 0;
|
|
162
|
+
height: 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.rootMobile .desktopSidebar {
|
|
166
|
+
display: none;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.rootMobile .mobileTopBarWrapper {
|
|
170
|
+
display: block;
|
|
171
|
+
position: fixed;
|
|
172
|
+
top: 0;
|
|
173
|
+
left: 0;
|
|
174
|
+
right: 0;
|
|
175
|
+
height: 64px;
|
|
176
|
+
z-index: 1002;
|
|
177
|
+
background-color: var(--neutral-1);
|
|
178
|
+
border-bottom: 1px solid var(--neutral-3);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.rootMobile .mobileTopBar {
|
|
182
|
+
display: flex;
|
|
183
|
+
width: 100%;
|
|
184
|
+
border-bottom: none;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.rootMobile .mobileOverlay {
|
|
188
|
+
display: block;
|
|
189
|
+
position: fixed;
|
|
190
|
+
inset: 0;
|
|
191
|
+
z-index: 1000;
|
|
192
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
193
|
+
opacity: 0;
|
|
194
|
+
pointer-events: none;
|
|
195
|
+
transition: opacity 160ms ease-out;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.rootMobile .mobileOverlayOpen {
|
|
199
|
+
opacity: 1;
|
|
200
|
+
pointer-events: auto;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.rootMobile .mobileDrawer {
|
|
204
|
+
display: flex;
|
|
205
|
+
flex-direction: column;
|
|
206
|
+
position: fixed;
|
|
207
|
+
top: 64px;
|
|
208
|
+
left: 0;
|
|
209
|
+
right: 0;
|
|
210
|
+
bottom: 0;
|
|
211
|
+
z-index: 1001;
|
|
212
|
+
width: 100%;
|
|
213
|
+
height: calc(100vh - 64px);
|
|
214
|
+
height: calc(100dvh - 64px);
|
|
215
|
+
padding: 16px;
|
|
216
|
+
background-color: var(--neutral-1);
|
|
217
|
+
opacity: 0;
|
|
218
|
+
visibility: hidden;
|
|
219
|
+
pointer-events: none;
|
|
220
|
+
transition: opacity 200ms ease-out, visibility 0s linear 200ms;
|
|
221
|
+
box-sizing: border-box;
|
|
222
|
+
overflow-y: auto;
|
|
223
|
+
overflow-x: hidden;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.rootMobile .mobileDrawerOpen {
|
|
227
|
+
opacity: 1;
|
|
228
|
+
visibility: visible;
|
|
229
|
+
pointer-events: auto;
|
|
230
|
+
transition: opacity 200ms ease-out, visibility 0s linear 0s;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.rootMobile .mobileDrawerContent {
|
|
234
|
+
display: flex;
|
|
235
|
+
flex-direction: column;
|
|
236
|
+
flex: 1;
|
|
237
|
+
transform: translateY(-12px);
|
|
238
|
+
opacity: 0;
|
|
239
|
+
transition: transform 240ms ease-out, opacity 240ms ease-out;
|
|
240
|
+
will-change: transform, opacity;
|
|
241
|
+
width: 100%;
|
|
242
|
+
min-height: 0;
|
|
243
|
+
height: 100%;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.rootMobile .mobileDrawerContentOpen {
|
|
247
|
+
transform: translateY(0);
|
|
248
|
+
opacity: 1;
|
|
249
|
+
}
|
|
250
|
+
|
|
151
251
|
@media (max-width: 768px) {
|
|
152
252
|
.root {
|
|
153
253
|
position: absolute;
|