@moises.ai/design-system 3.6.4 → 3.6.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moises.ai/design-system",
3
- "version": "3.6.4",
3
+ "version": "3.6.5",
4
4
  "description": "Design System package based on @radix-ui/themes with custom defaults",
5
5
  "private": false,
6
6
  "type": "module",
@@ -1,12 +1,15 @@
1
1
  import { Flex, Text } from '@radix-ui/themes'
2
2
  import styles from './AdditionalItems.module.css'
3
3
  import classNames from 'classnames'
4
+ import { useMobileDrawerContext } from '../../contexts/MobileDrawerContext'
4
5
 
5
6
  export const AdditionalItems = ({
6
7
  additionalItems,
7
8
  collapsed = false,
8
9
  selectedAdditionalItemId,
9
10
  }) => {
11
+ const { close, isMobile } = useMobileDrawerContext()
12
+
10
13
  if (!additionalItems) return null
11
14
  return (
12
15
  <Flex direction="column">
@@ -15,6 +18,10 @@ export const AdditionalItems = ({
15
18
  selectedAdditionalItemId !== undefined
16
19
  ? selectedAdditionalItemId === item.id
17
20
  : item.selected
21
+ const handleClick = () => {
22
+ item.onClick?.()
23
+ if (isMobile) close()
24
+ }
18
25
  return (
19
26
  <Flex
20
27
  key={item.id || index}
@@ -25,11 +32,11 @@ export const AdditionalItems = ({
25
32
  [styles.upgradeItemCollapsed]: collapsed,
26
33
  [styles.upgradeItemSelected]: isSelected,
27
34
  })}
28
- onClick={item.onClick}
35
+ onClick={handleClick}
29
36
  onKeyDown={(e) => {
30
37
  if ((e.key === 'Enter' || e.key === ' ') && item.onClick) {
31
38
  e.preventDefault()
32
- item.onClick()
39
+ handleClick()
33
40
  }
34
41
  }}
35
42
  >
@@ -1,6 +1,7 @@
1
1
  import { Flex, Text, Badge } from '@radix-ui/themes'
2
2
  import styles from './ProductsList.module.css'
3
3
  import classNames from 'classnames'
4
+ import { useMobileDrawerContext } from '../../contexts/MobileDrawerContext'
4
5
 
5
6
  export const ProductsList = ({
6
7
  products = [],
@@ -8,6 +9,13 @@ export const ProductsList = ({
8
9
  onProductClick,
9
10
  collapsed,
10
11
  }) => {
12
+ const { close, isMobile } = useMobileDrawerContext()
13
+
14
+ const handleProductClick = (product) => {
15
+ onProductClick?.(product.id, product)
16
+ if (isMobile) close()
17
+ }
18
+
11
19
  return (
12
20
  <Flex direction="column">
13
21
  {products.map((product) => {
@@ -24,11 +32,11 @@ export const ProductsList = ({
24
32
  [styles.navItemSelected]: isSelected,
25
33
  [styles.collapsed]: collapsed,
26
34
  })}
27
- onClick={() => onProductClick?.(product.id, product)}
35
+ onClick={() => handleProductClick(product)}
28
36
  onKeyDown={(e) => {
29
37
  if (e.key === 'Enter' || e.key === ' ') {
30
38
  e.preventDefault()
31
- onProductClick?.(product.id, product)
39
+ handleProductClick(product)
32
40
  }
33
41
  }}
34
42
  >
@@ -5,24 +5,32 @@ import { useIsMobileViewport } from '../../utils/useIsMobileViewport'
5
5
  import { DropdownMenu } from '../DropdownMenu/DropdownMenu'
6
6
  import { MenuTrigger } from './MenuTrigger'
7
7
  import styles from './ProfileMenu.module.css'
8
+ import { useMobileDrawerContext } from '../../contexts/MobileDrawerContext'
8
9
 
9
10
  export const ProfileMenu = ({
10
11
  className,
11
12
  user,
12
13
  menuOptions = [],
13
14
  collapsed,
15
+ onSelectionChange,
14
16
  ...props
15
17
  }) => {
16
- const isMobile = useIsMobileViewport()
18
+ const isMobileViewport = useIsMobileViewport()
19
+ const { close, isMobile } = useMobileDrawerContext()
17
20
 
21
+ const handleSelectionChange = (option) => {
22
+ onSelectionChange?.(option)
23
+ if (isMobile) close()
24
+ }
18
25
 
19
26
  return (
20
27
  <DropdownMenu
21
28
  className={classNames(styles.profileMenu, className)}
22
29
  trigger={<MenuTrigger user={user} collapsed={collapsed} />}
23
30
  options={menuOptions}
24
- side={isMobile ? 'left' : 'right'}
31
+ side={isMobileViewport ? 'top' : 'right'}
25
32
  {...props}
33
+ onSelectionChange={handleSelectionChange}
26
34
  />
27
35
  )
28
36
  }
@@ -12,6 +12,7 @@ import { DropdownMenu } from '../DropdownMenu/DropdownMenu'
12
12
  import { Tooltip } from '../Tooltip/Tooltip'
13
13
  import { useState, useEffect, useRef, useMemo, Fragment } from 'react'
14
14
  import { MoreButton } from '../MoreButton/MoreButton'
15
+ import { useMobileDrawerContext } from '../../contexts/MobileDrawerContext'
15
16
 
16
17
  const SetlistIconFallback = () => <SetlistIcon width={16} height={16} />
17
18
 
@@ -68,6 +69,7 @@ export const SetlistItem = ({
68
69
  moises = false,
69
70
  collapsed = false,
70
71
  isMobile = false,
72
+ onAvatarClick,
71
73
  }) => {
72
74
  const [isHovering, setIsHovering] = useState(false)
73
75
 
@@ -117,7 +119,32 @@ export const SetlistItem = ({
117
119
  })}
118
120
  >
119
121
  {avatar && (
120
- <div className={styles.avatarSetlist}>
122
+ <div
123
+ className={classNames(styles.avatarSetlist, {
124
+ [styles.avatarClickable]: onAvatarClick,
125
+ })}
126
+ onClick={
127
+ onAvatarClick
128
+ ? (e) => {
129
+ e.stopPropagation()
130
+ onAvatarClick(e)
131
+ }
132
+ : undefined
133
+ }
134
+ role={onAvatarClick ? 'button' : undefined}
135
+ tabIndex={onAvatarClick ? 0 : undefined}
136
+ onKeyDown={
137
+ onAvatarClick
138
+ ? (e) => {
139
+ if (e.key === 'Enter' || e.key === ' ') {
140
+ e.preventDefault()
141
+ e.stopPropagation()
142
+ onAvatarClick(e)
143
+ }
144
+ }
145
+ : undefined
146
+ }
147
+ >
121
148
  {typeof avatar === 'string' ? (
122
149
  <Avatar
123
150
  src={avatar}
@@ -188,7 +215,18 @@ export const SetlistList = ({
188
215
  collapsed = false,
189
216
  isMobile = false,
190
217
  }) => {
218
+ const { close, isMobile: isMobileDrawer } = useMobileDrawerContext()
191
219
  const [openSetlistMenuId, setOpenSetlistMenuId] = useState(null)
220
+
221
+ const handleSetlistClick = (setlistId) => {
222
+ onSetlistClick?.(setlistId)
223
+ if (isMobileDrawer) close()
224
+ }
225
+
226
+ const handleNewSetlistClick = () => {
227
+ onNewSetlistClick?.()
228
+ if (isMobileDrawer) close()
229
+ }
192
230
  const [isHoveredWhenCollapsed, setIsHoveredWhenCollapsed] = useState(false)
193
231
  const [isShrinking, setIsShrinking] = useState(false)
194
232
  const hoverTimeoutRef = useRef(null)
@@ -204,6 +242,8 @@ export const SetlistList = ({
204
242
  ? setlists.slice(0, maxCollapsedItems)
205
243
  : setlists
206
244
 
245
+ const leaveCollapseDelay = 2750
246
+
207
247
  const handleMouseEnter = () => {
208
248
  if (!collapsed) return
209
249
  if (hoverTimeoutRef.current) {
@@ -215,10 +255,11 @@ export const SetlistList = ({
215
255
  shrinkTimeoutRef.current = null
216
256
  }
217
257
  setIsShrinking(false)
218
- setIsHoveredWhenCollapsed(true)
219
258
  }
259
+
220
260
  const handleMouseLeave = () => {
221
261
  if (!collapsed) return
262
+ if (!isHoveredWhenCollapsed) return
222
263
  if (hoverTimeoutRef.current) {
223
264
  clearTimeout(hoverTimeoutRef.current)
224
265
  }
@@ -230,7 +271,18 @@ export const SetlistList = ({
230
271
  setIsHoveredWhenCollapsed(false)
231
272
  setIsShrinking(false)
232
273
  }, shrinkDuration)
233
- }, 180)
274
+ }, leaveCollapseDelay)
275
+ }
276
+
277
+ const handleSetlistIconClick = (e) => {
278
+ if (!collapsed) return
279
+ e.stopPropagation()
280
+ if (hoverTimeoutRef.current) {
281
+ clearTimeout(hoverTimeoutRef.current)
282
+ hoverTimeoutRef.current = null
283
+ }
284
+ setIsShrinking(false)
285
+ setIsHoveredWhenCollapsed(true)
234
286
  }
235
287
 
236
288
  const handleFocus = () => {
@@ -336,7 +388,8 @@ export const SetlistList = ({
336
388
  (showCollapsedStack ? (
337
389
  <SetlistItem
338
390
  isSelected={false}
339
- onClick={onNewSetlistClick}
391
+ onClick={handleNewSetlistClick}
392
+ onAvatarClick={handleSetlistIconClick}
340
393
  avatar={renderNewSetlistAvatar()}
341
394
  className={classNames(
342
395
  styles.collapsedStackItem,
@@ -352,7 +405,7 @@ export const SetlistList = ({
352
405
  ) : (
353
406
  <SetlistItem
354
407
  isSelected={false}
355
- onClick={onNewSetlistClick}
408
+ onClick={handleNewSetlistClick}
356
409
  avatar={renderNewSetlistAvatar()}
357
410
  text="New Setlist"
358
411
  className={classNames(styles.newSetlistItemButton, {
@@ -366,7 +419,7 @@ export const SetlistList = ({
366
419
  const setlistItem = (
367
420
  <SetlistItem
368
421
  isSelected={isSelected}
369
- onClick={() => onSetlistClick?.(setlist.id)}
422
+ onClick={() => handleSetlistClick(setlist.id)}
370
423
  dropdownMenuOpen={openSetlistMenuId === setlist.id}
371
424
  onDropdownMenuOpenChange={(nextOpen) => {
372
425
  setOpenSetlistMenuId(nextOpen ? setlist.id : null)
@@ -21,7 +21,8 @@
21
21
 
22
22
  &:hover,
23
23
  &.menuOpen {
24
- background: var(--neutral-alpha-2);
24
+ background: #212225 !important;
25
+
25
26
  .avatarSetlist {
26
27
  background: var(--neutral-alpha-3);
27
28
  }
@@ -90,6 +91,10 @@
90
91
  z-index: 1;
91
92
  }
92
93
 
94
+ .avatarClickable {
95
+ cursor: pointer;
96
+ }
97
+
93
98
  .iconGrid {
94
99
  display: grid;
95
100
  grid-template-columns: 1fr 1fr;
@@ -147,12 +152,13 @@
147
152
  opacity: 0;
148
153
  }
149
154
 
155
+
150
156
  .navItemSelected {
151
157
  border-radius: var(--Radius-3-max, 6px);
152
158
  background: var(--neutral-alpha-3);
153
159
 
154
160
  &.collapsed {
155
- background: transparent;
161
+ /* background: transparent; */
156
162
 
157
163
  .avatarSetlist {
158
164
  background: var(--neutral-2);
@@ -228,6 +234,9 @@
228
234
  .collapsedStackItem {
229
235
  position: relative;
230
236
  /* justify-content: flex-start; */
237
+ /* :hover {
238
+ background: #212225 !important;
239
+ } */
231
240
  }
232
241
 
233
242
  .collapsedMask {
@@ -11,6 +11,7 @@ import {
11
11
  CloseIcon,
12
12
  } from '../../icons'
13
13
  import { useMobileDrawer } from '../../utils/useMobileDrawer'
14
+ import { MobileDrawerProvider } from '../../contexts/MobileDrawerContext'
14
15
 
15
16
  export const Sidebar = ({
16
17
  className,
@@ -50,12 +51,13 @@ export const Sidebar = ({
50
51
  }
51
52
 
52
53
  return (
53
- <div
54
- className={classNames(styles.root, {
55
- [styles.rootCollapsed]: effectiveCollapsed,
56
- })}
57
- {...props}
58
- >
54
+ <MobileDrawerProvider value={{ close, isMobile }}>
55
+ <div
56
+ className={classNames(styles.root, {
57
+ [styles.rootCollapsed]: effectiveCollapsed,
58
+ })}
59
+ {...props}
60
+ >
59
61
  <div className={styles.mobileTopBarWrapper}>
60
62
  <Flex
61
63
  align="center"
@@ -170,6 +172,7 @@ export const Sidebar = ({
170
172
  </Flex>
171
173
  </Flex>
172
174
  </div>
175
+ </MobileDrawerProvider>
173
176
  )
174
177
  }
175
178
 
@@ -0,0 +1,10 @@
1
+ import { createContext, useContext } from 'react'
2
+
3
+ const MobileDrawerContext = createContext({
4
+ close: () => {},
5
+ isMobile: false,
6
+ })
7
+
8
+ export const useMobileDrawerContext = () => useContext(MobileDrawerContext)
9
+
10
+ export const MobileDrawerProvider = MobileDrawerContext.Provider