@moises.ai/design-system 3.6.1 → 3.6.2
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 +1556 -1574
- package/package.json +1 -1
- package/src/components/ProfileMenu/MenuTrigger.jsx +1 -1
- package/src/components/ProfileMenu/ProfileMenu.jsx +2 -40
- package/src/components/ProfileMenu/ProfileMenu.module.css +45 -0
- package/src/components/SetlistList/SetlistList.jsx +19 -0
- package/src/components/Shell/Shell.jsx +2 -1
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@ export function MenuTrigger({ className, user, collapsed, ...props }) {
|
|
|
22
22
|
onMouseLeave={handleMouseLeave}
|
|
23
23
|
className={classNames(styles.userProfile, { [styles.collapsed]: collapsed }, className)}
|
|
24
24
|
align="center"
|
|
25
|
-
justify=
|
|
25
|
+
justify={collapsed ? 'center' : 'between'}
|
|
26
26
|
{...props}
|
|
27
27
|
>
|
|
28
28
|
<div className={styles.userProfileInner}>
|
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
import classNames from 'classnames'
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react'
|
|
3
3
|
import { Button } from '../Button/Button'
|
|
4
4
|
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
8
|
|
|
9
|
-
const renderUserMenuOption = (opt) => (
|
|
10
|
-
<div key={opt.key} className={styles.creditsHeader}>
|
|
11
|
-
<div className={styles.creditsInfo}>
|
|
12
|
-
<span className={styles.creditsLabel}>Credits: </span>
|
|
13
|
-
<span className={styles.creditsValue}>{opt.current}</span>/{opt.total}
|
|
14
|
-
</div>
|
|
15
|
-
{opt.onUpgrade && (
|
|
16
|
-
<Button
|
|
17
|
-
variant="solid"
|
|
18
|
-
color="cyan"
|
|
19
|
-
size="2"
|
|
20
|
-
onClick={(e) => {
|
|
21
|
-
e.stopPropagation()
|
|
22
|
-
opt.onUpgrade()
|
|
23
|
-
}}
|
|
24
|
-
className={styles.upgradeButton}
|
|
25
|
-
>
|
|
26
|
-
Upgrade
|
|
27
|
-
</Button>
|
|
28
|
-
)}
|
|
29
|
-
</div>
|
|
30
|
-
)
|
|
31
|
-
|
|
32
9
|
export const ProfileMenu = ({
|
|
33
10
|
className,
|
|
34
11
|
user,
|
|
@@ -38,27 +15,12 @@ export const ProfileMenu = ({
|
|
|
38
15
|
}) => {
|
|
39
16
|
const isMobile = useIsMobileViewport()
|
|
40
17
|
|
|
41
|
-
const processedItems = useMemo(() => {
|
|
42
|
-
const creditsItem = menuOptions.find((item) => item.type === 'credits')
|
|
43
|
-
const otherItems = menuOptions.filter((item) => item.type !== 'credits')
|
|
44
|
-
|
|
45
|
-
return creditsItem
|
|
46
|
-
? [
|
|
47
|
-
{
|
|
48
|
-
type: 'custom',
|
|
49
|
-
key: 'credits-header',
|
|
50
|
-
customRender: () => renderUserMenuOption(creditsItem),
|
|
51
|
-
},
|
|
52
|
-
...otherItems,
|
|
53
|
-
]
|
|
54
|
-
: otherItems
|
|
55
|
-
}, [menuOptions])
|
|
56
18
|
|
|
57
19
|
return (
|
|
58
20
|
<DropdownMenu
|
|
59
21
|
className={classNames(styles.profileMenu, className)}
|
|
60
22
|
trigger={<MenuTrigger user={user} collapsed={collapsed} />}
|
|
61
|
-
options={
|
|
23
|
+
options={menuOptions}
|
|
62
24
|
side={isMobile ? 'left' : 'right'}
|
|
63
25
|
{...props}
|
|
64
26
|
/>
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
.userProfile {
|
|
2
2
|
cursor: pointer;
|
|
3
3
|
width: 100%;
|
|
4
|
+
min-width: 0;
|
|
5
|
+
transition: width 280ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.collapsed .userProfile {
|
|
9
|
+
width: auto;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
flex-shrink: 0;
|
|
4
12
|
}
|
|
5
13
|
|
|
6
14
|
.userProfile:focus-visible {
|
|
@@ -13,11 +21,13 @@
|
|
|
13
21
|
align-items: center;
|
|
14
22
|
flex: 1;
|
|
15
23
|
gap: 13px;
|
|
24
|
+
min-width: 0;
|
|
16
25
|
transition: gap 280ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
17
26
|
}
|
|
18
27
|
|
|
19
28
|
.collapsed .userProfileInner {
|
|
20
29
|
gap: 0;
|
|
30
|
+
flex: 0;
|
|
21
31
|
}
|
|
22
32
|
|
|
23
33
|
.userAvatar {
|
|
@@ -42,6 +52,9 @@
|
|
|
42
52
|
opacity: 0;
|
|
43
53
|
transform: translateX(-8px);
|
|
44
54
|
flex: 0;
|
|
55
|
+
width: 0;
|
|
56
|
+
min-width: 0;
|
|
57
|
+
overflow: hidden;
|
|
45
58
|
transition-delay: 50ms;
|
|
46
59
|
}
|
|
47
60
|
|
|
@@ -78,6 +91,10 @@
|
|
|
78
91
|
opacity: 0;
|
|
79
92
|
transform: translateX(-8px);
|
|
80
93
|
pointer-events: none;
|
|
94
|
+
width: 0;
|
|
95
|
+
min-width: 0;
|
|
96
|
+
flex: 0;
|
|
97
|
+
overflow: hidden;
|
|
81
98
|
transition-delay: 50ms;
|
|
82
99
|
}
|
|
83
100
|
|
|
@@ -86,6 +103,34 @@
|
|
|
86
103
|
width: 100%;
|
|
87
104
|
}
|
|
88
105
|
|
|
106
|
+
.creditsHeader {
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
justify-content: space-between;
|
|
110
|
+
gap: 12px;
|
|
111
|
+
padding: 8px 12px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.creditsInfo {
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
gap: 4px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.creditsLabel {
|
|
121
|
+
color: var(--neutral-alpha-11);
|
|
122
|
+
font-size: 14px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.creditsValue {
|
|
126
|
+
color: var(--neutral-alpha-12);
|
|
127
|
+
font-size: 14px;
|
|
128
|
+
font-weight: 500;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.upgradeButton {
|
|
132
|
+
flex-shrink: 0;
|
|
133
|
+
}
|
|
89
134
|
|
|
90
135
|
.dropdownTriggerWrapper {
|
|
91
136
|
display: flex;
|
|
@@ -154,6 +154,7 @@ export const SetlistList = ({
|
|
|
154
154
|
const [isFullyCollapsed, setIsFullyCollapsed] = useState(false)
|
|
155
155
|
const hoverTimeoutRef = useRef(null)
|
|
156
156
|
const collapseCenterTimeoutRef = useRef(null)
|
|
157
|
+
const hoverRegionRef = useRef(null)
|
|
157
158
|
const collapsedItemHeight = 44
|
|
158
159
|
const collapsedVisibleOffset = 8
|
|
159
160
|
const maxCollapsedItems = 4
|
|
@@ -182,6 +183,21 @@ export const SetlistList = ({
|
|
|
182
183
|
}, 180)
|
|
183
184
|
}
|
|
184
185
|
|
|
186
|
+
const handleFocus = () => {
|
|
187
|
+
if (collapsed) setIsHoveredWhenCollapsed(true)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const handleBlur = () => {
|
|
191
|
+
if (!collapsed) return
|
|
192
|
+
const el = hoverRegionRef.current
|
|
193
|
+
if (!el) return
|
|
194
|
+
setTimeout(() => {
|
|
195
|
+
if (!el.contains(document.activeElement)) {
|
|
196
|
+
setIsHoveredWhenCollapsed(false)
|
|
197
|
+
}
|
|
198
|
+
}, 0)
|
|
199
|
+
}
|
|
200
|
+
|
|
185
201
|
useEffect(() => {
|
|
186
202
|
if (showCollapsedStack) {
|
|
187
203
|
collapseCenterTimeoutRef.current = setTimeout(() => {
|
|
@@ -274,9 +290,12 @@ export const SetlistList = ({
|
|
|
274
290
|
})}
|
|
275
291
|
>
|
|
276
292
|
<div
|
|
293
|
+
ref={hoverRegionRef}
|
|
277
294
|
className={styles.hoverRegion}
|
|
278
295
|
onMouseEnter={handleMouseEnter}
|
|
279
296
|
onMouseLeave={handleMouseLeave}
|
|
297
|
+
onFocusCapture={handleFocus}
|
|
298
|
+
onBlurCapture={handleBlur}
|
|
280
299
|
>
|
|
281
300
|
<Flex
|
|
282
301
|
direction="column"
|
|
@@ -64,7 +64,8 @@ export const Shell = ({
|
|
|
64
64
|
selectedAdditionalItemId={selectedAdditionalItemId}
|
|
65
65
|
/>
|
|
66
66
|
<ProfileMenu
|
|
67
|
-
|
|
67
|
+
user={userProfileItems}
|
|
68
|
+
menuOptions={userProfileItems?.menuOptions}
|
|
68
69
|
collapsed={effectiveCollapsed}
|
|
69
70
|
/>
|
|
70
71
|
</Flex>
|