@moises.ai/design-system 4.20.5 → 4.20.6
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 +1695 -1690
- package/package.json +1 -1
- package/src/colors/Colors.stories.jsx +104 -83
- package/src/components/ProjectsList/ProjectItem/ProjectItem.jsx +56 -42
- package/src/components/ProjectsList/ProjectItem/ProjectItem.module.css +44 -0
- package/src/icons/Icons.stories.jsx +389 -36
package/package.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { useMemo } from 'react'
|
|
1
|
+
import { useState, useMemo, useRef, useEffect, useCallback } from 'react'
|
|
2
2
|
import { Box, Flex, Heading, Text, Grid, Card } from '@radix-ui/themes'
|
|
3
|
+
import { CheckCircledIcon, CopyIcon, CheckIcon } from '@radix-ui/react-icons'
|
|
4
|
+
import { Callout } from '../components/Callout/Callout'
|
|
3
5
|
import cssSource from './custom-styles.css?raw'
|
|
4
6
|
|
|
5
7
|
function isColorValue(value) {
|
|
@@ -7,84 +9,26 @@ function isColorValue(value) {
|
|
|
7
9
|
return v.startsWith('#') || /^rgba?\(/i.test(v)
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function rgbaToHex(r, g, b, a = 1) {
|
|
15
|
-
const toHex = (n) => clampByte(n).toString(16).padStart(2, '0').toUpperCase()
|
|
16
|
-
let hex = `#${toHex(r)}${toHex(g)}${toHex(b)}`
|
|
17
|
-
if (a < 1) {
|
|
18
|
-
hex += toHex(a * 255)
|
|
12
|
+
function getNeutralSection(name) {
|
|
13
|
+
if (name.startsWith('--neutral-alpha-0')) {
|
|
14
|
+
return 'Neutral Extras'
|
|
19
15
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function parseColorFormats(cssValue) {
|
|
24
|
-
const v = cssValue.trim()
|
|
25
|
-
if (v.startsWith('#')) {
|
|
26
|
-
let h = v.slice(1)
|
|
27
|
-
if (h.length === 3) {
|
|
28
|
-
h = h
|
|
29
|
-
.split('')
|
|
30
|
-
.map((c) => c + c)
|
|
31
|
-
.join('')
|
|
32
|
-
}
|
|
33
|
-
if (h.length === 6) {
|
|
34
|
-
const r = parseInt(h.slice(0, 2), 16)
|
|
35
|
-
const g = parseInt(h.slice(2, 4), 16)
|
|
36
|
-
const b = parseInt(h.slice(4, 6), 16)
|
|
37
|
-
return {
|
|
38
|
-
rgba: `rgba(${r}, ${g}, ${b}, 1)`,
|
|
39
|
-
hex: `#${h.toUpperCase()}`,
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (h.length === 8) {
|
|
43
|
-
const r = parseInt(h.slice(0, 2), 16)
|
|
44
|
-
const g = parseInt(h.slice(2, 4), 16)
|
|
45
|
-
const b = parseInt(h.slice(4, 6), 16)
|
|
46
|
-
const alpha = parseInt(h.slice(6, 8), 16) / 255
|
|
47
|
-
const aRounded = Math.round(alpha * 1000) / 1000
|
|
48
|
-
return {
|
|
49
|
-
rgba: `rgba(${r}, ${g}, ${b}, ${aRounded})`,
|
|
50
|
-
hex: `#${h.toUpperCase()}`,
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return { rgba: v, hex: v }
|
|
16
|
+
if (name.startsWith('--neutral-alpha-')) {
|
|
17
|
+
return 'Neutral Alpha'
|
|
54
18
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)(?:\s*,\s*([\d.]+))?\s*\)$/i,
|
|
58
|
-
)
|
|
59
|
-
if (m) {
|
|
60
|
-
const r = Number(m[1])
|
|
61
|
-
const g = Number(m[2])
|
|
62
|
-
const b = Number(m[3])
|
|
63
|
-
const a = m[4] !== undefined ? Number(m[4]) : 1
|
|
64
|
-
const aRounded = Math.round(a * 1000) / 1000
|
|
65
|
-
return {
|
|
66
|
-
rgba: `rgba(${r}, ${g}, ${b}, ${aRounded})`,
|
|
67
|
-
hex: rgbaToHex(r, g, b, a),
|
|
68
|
-
}
|
|
19
|
+
if (name.startsWith('--neutral-')) {
|
|
20
|
+
return 'Neutral (Solid)'
|
|
69
21
|
}
|
|
70
|
-
|
|
71
|
-
return { rgba: v, hex: '—' }
|
|
22
|
+
return null
|
|
72
23
|
}
|
|
73
24
|
|
|
74
|
-
function
|
|
25
|
+
function parseNeutralColorTokens(css) {
|
|
75
26
|
const lines = css.split('\n')
|
|
76
27
|
/** @type {{ section: string; name: string; value: string }[]} */
|
|
77
28
|
const tokens = []
|
|
78
|
-
let section = 'Cores'
|
|
79
29
|
|
|
80
30
|
for (const line of lines) {
|
|
81
31
|
const trimmed = line.trim()
|
|
82
|
-
const sectionMatch = trimmed.match(/^\/\*\s*([^*]+?)\s*\*\/$/)
|
|
83
|
-
if (sectionMatch && !trimmed.includes('--')) {
|
|
84
|
-
section = sectionMatch[1].trim()
|
|
85
|
-
continue
|
|
86
|
-
}
|
|
87
|
-
|
|
88
32
|
const varMatch = trimmed.match(/^--([\w-]+)\s*:\s*([^;]+);/)
|
|
89
33
|
if (!varMatch) continue
|
|
90
34
|
|
|
@@ -92,6 +36,10 @@ function parseColorTokens(css) {
|
|
|
92
36
|
const value = varMatch[2].trim()
|
|
93
37
|
if (value.startsWith('var(')) continue
|
|
94
38
|
if (!isColorValue(value)) continue
|
|
39
|
+
if (!name.startsWith('--neutral-')) continue
|
|
40
|
+
|
|
41
|
+
const section = getNeutralSection(name)
|
|
42
|
+
if (!section) continue
|
|
95
43
|
|
|
96
44
|
tokens.push({ section, name, value })
|
|
97
45
|
}
|
|
@@ -117,18 +65,64 @@ export default {
|
|
|
117
65
|
}
|
|
118
66
|
|
|
119
67
|
export const Colors = () => {
|
|
68
|
+
const [copiedVar, setCopiedVar] = useState(null)
|
|
69
|
+
const timeoutRef = useRef(null)
|
|
70
|
+
|
|
120
71
|
const sections = useMemo(() => {
|
|
121
|
-
const tokens =
|
|
72
|
+
const tokens = parseNeutralColorTokens(cssSource)
|
|
122
73
|
return groupBySection(tokens)
|
|
123
74
|
}, [])
|
|
124
75
|
|
|
76
|
+
const handleCopy = useCallback((name) => {
|
|
77
|
+
const textToCopy = `var(${name})`
|
|
78
|
+
navigator.clipboard.writeText(textToCopy)
|
|
79
|
+
setCopiedVar(textToCopy)
|
|
80
|
+
|
|
81
|
+
if (timeoutRef.current) {
|
|
82
|
+
clearTimeout(timeoutRef.current)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
timeoutRef.current = setTimeout(() => {
|
|
86
|
+
setCopiedVar(null)
|
|
87
|
+
}, 3000)
|
|
88
|
+
}, [])
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
return () => {
|
|
92
|
+
if (timeoutRef.current) {
|
|
93
|
+
clearTimeout(timeoutRef.current)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}, [])
|
|
97
|
+
|
|
125
98
|
return (
|
|
126
|
-
<Box p="6" style={{ maxWidth: 1200, margin: '0 auto' }}>
|
|
99
|
+
<Box p="6" style={{ maxWidth: 1200, margin: '0 auto', position: 'relative' }}>
|
|
100
|
+
{copiedVar && (
|
|
101
|
+
<Box
|
|
102
|
+
style={{
|
|
103
|
+
position: 'fixed',
|
|
104
|
+
top: 24,
|
|
105
|
+
right: 24,
|
|
106
|
+
zIndex: 9999,
|
|
107
|
+
maxWidth: 420,
|
|
108
|
+
boxShadow: '0 8px 24px rgba(0, 0, 0, 0.4)',
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
111
|
+
<Callout
|
|
112
|
+
color="success"
|
|
113
|
+
size="2"
|
|
114
|
+
Icon={CheckCircledIcon}
|
|
115
|
+
title="Copied to clipboard"
|
|
116
|
+
text={copiedVar}
|
|
117
|
+
/>
|
|
118
|
+
</Box>
|
|
119
|
+
)}
|
|
120
|
+
|
|
127
121
|
<Flex direction="column" gap="6">
|
|
128
122
|
<Flex direction="column" gap="2">
|
|
129
|
-
<Heading size="8">
|
|
123
|
+
<Heading size="8">Neutral Colors</Heading>
|
|
130
124
|
<Text size="3" color="gray">
|
|
131
|
-
|
|
125
|
+
Design system neutral color CSS variables. Click any card to copy its CSS variable.
|
|
132
126
|
</Text>
|
|
133
127
|
</Flex>
|
|
134
128
|
|
|
@@ -137,9 +131,29 @@ export const Colors = () => {
|
|
|
137
131
|
<Heading size="5">{section}</Heading>
|
|
138
132
|
<Grid columns="1" gap="2">
|
|
139
133
|
{tokens.map(({ name, value }) => {
|
|
140
|
-
const
|
|
134
|
+
const varText = `var(${name})`
|
|
135
|
+
const isCopied = copiedVar === varText
|
|
136
|
+
|
|
141
137
|
return (
|
|
142
|
-
<Card
|
|
138
|
+
<Card
|
|
139
|
+
key={name}
|
|
140
|
+
size="1"
|
|
141
|
+
onClick={() => handleCopy(name)}
|
|
142
|
+
onKeyDown={(e) => {
|
|
143
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
144
|
+
e.preventDefault()
|
|
145
|
+
handleCopy(name)
|
|
146
|
+
}
|
|
147
|
+
}}
|
|
148
|
+
tabIndex={0}
|
|
149
|
+
role="button"
|
|
150
|
+
aria-label={`Copy ${varText}`}
|
|
151
|
+
style={{
|
|
152
|
+
cursor: 'pointer',
|
|
153
|
+
transition: 'border-color 0.15s ease, background-color 0.15s ease',
|
|
154
|
+
outline: 'none',
|
|
155
|
+
}}
|
|
156
|
+
>
|
|
143
157
|
<Grid
|
|
144
158
|
columns={{ initial: '1', sm: 'auto 1fr' }}
|
|
145
159
|
gap="3"
|
|
@@ -159,9 +173,10 @@ export const Colors = () => {
|
|
|
159
173
|
aria-hidden
|
|
160
174
|
/>
|
|
161
175
|
<Grid
|
|
162
|
-
columns={{ initial: '1', xs: '1fr 1fr' }}
|
|
176
|
+
columns={{ initial: '1', xs: '1fr 1fr auto' }}
|
|
163
177
|
gap="2"
|
|
164
178
|
width="100%"
|
|
179
|
+
align="center"
|
|
165
180
|
>
|
|
166
181
|
<Flex direction="column" gap="1" minWidth="0">
|
|
167
182
|
<Text
|
|
@@ -174,22 +189,28 @@ export const Colors = () => {
|
|
|
174
189
|
>
|
|
175
190
|
{name}
|
|
176
191
|
</Text>
|
|
177
|
-
<Text
|
|
178
|
-
size="1"
|
|
179
|
-
color="gray"
|
|
180
|
-
style={{ fontFamily: 'ui-monospace, monospace' }}
|
|
181
|
-
>
|
|
182
|
-
{rgba}
|
|
183
|
-
</Text>
|
|
184
192
|
</Flex>
|
|
185
193
|
<Flex align="center">
|
|
186
194
|
<Text
|
|
187
195
|
size="2"
|
|
196
|
+
color="gray"
|
|
188
197
|
style={{ fontFamily: 'ui-monospace, monospace' }}
|
|
189
198
|
>
|
|
190
|
-
{
|
|
199
|
+
{value}
|
|
191
200
|
</Text>
|
|
192
201
|
</Flex>
|
|
202
|
+
<Flex align="center" justify="end" pr="2">
|
|
203
|
+
{isCopied ? (
|
|
204
|
+
<Flex align="center" gap="1">
|
|
205
|
+
<CheckIcon color="var(--mint-9)" width={16} height={16} />
|
|
206
|
+
<Text size="1" color="green" style={{ fontFamily: 'ui-monospace, monospace' }}>
|
|
207
|
+
Copied
|
|
208
|
+
</Text>
|
|
209
|
+
</Flex>
|
|
210
|
+
) : (
|
|
211
|
+
<CopyIcon color="var(--neutral-9)" width={16} height={16} />
|
|
212
|
+
)}
|
|
213
|
+
</Flex>
|
|
193
214
|
</Grid>
|
|
194
215
|
</Grid>
|
|
195
216
|
</Card>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Flex, Text, Separator, Spinner, Button } from '@radix-ui/themes'
|
|
2
|
+
import { Collapsible } from 'radix-ui'
|
|
2
3
|
import { useState, useContext, useCallback, useMemo } from 'react'
|
|
3
4
|
import { ArrowLeftIcon, NoMusicIcon, ChevronDownIcon, ChevronUpIcon, InfoIcon } from '../../../icons'
|
|
4
5
|
import { ProjectsListContext } from '../context'
|
|
@@ -27,19 +28,18 @@ const ProjectItem = ({
|
|
|
27
28
|
} = useContext(ProjectsListContext)
|
|
28
29
|
const [showAllTracks, setShowAllTracks] = useState(false)
|
|
29
30
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
}, [allTracks, showAllTracks])
|
|
31
|
+
const visibleTracks = useMemo(() => allTracks.slice(0, 6), [allTracks])
|
|
32
|
+
const extraTracks = useMemo(() => allTracks.slice(6), [allTracks])
|
|
33
33
|
|
|
34
34
|
const handleClickProject = useCallback(() => {
|
|
35
35
|
if (failed) return
|
|
36
|
-
setShowAllTracks(false)
|
|
37
36
|
const project = projects.find((p) => p.id === id)
|
|
38
37
|
|
|
39
38
|
if (openedItem === id) {
|
|
40
39
|
setOpenedItem(null)
|
|
41
40
|
onProjectClick?.(project, false)
|
|
42
41
|
} else {
|
|
42
|
+
setShowAllTracks(false)
|
|
43
43
|
setOpenedItem(id)
|
|
44
44
|
onProjectClick?.(project, true)
|
|
45
45
|
}
|
|
@@ -65,7 +65,6 @@ const ProjectItem = ({
|
|
|
65
65
|
return (
|
|
66
66
|
<Flex
|
|
67
67
|
direction="column"
|
|
68
|
-
gap="2"
|
|
69
68
|
p="1"
|
|
70
69
|
className={`${styles.item} ${openedItem === id ? styles.opened : ''} ${failed ? styles.failed : ''}`}
|
|
71
70
|
onClick={handleClickProject}
|
|
@@ -104,48 +103,63 @@ const ProjectItem = ({
|
|
|
104
103
|
</Flex>
|
|
105
104
|
</Flex>
|
|
106
105
|
|
|
107
|
-
{openedItem === id
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
{loading && (
|
|
117
|
-
<Flex direction="row" gap="3" p="5" align="center" justify="center">
|
|
118
|
-
<Spinner width={16} height={16} style={{ color: 'var(--neutral-alpha-10)' }} />
|
|
119
|
-
<Text size="2" style={{ color: 'var(--neutral-alpha-10)' }}>{labels.loading || 'Loading tracks...'}</Text>
|
|
120
|
-
</Flex>
|
|
121
|
-
)}
|
|
122
|
-
|
|
123
|
-
{allTracks.length > 0 && (
|
|
124
|
-
<Flex direction="column" gap="1">
|
|
125
|
-
{typeof children === 'function' ? children({ projectId: id, tracks }) : children}
|
|
106
|
+
<Collapsible.Root open={openedItem === id} className={styles.tracksCollapsible}>
|
|
107
|
+
<Collapsible.Content className={styles.tracksContent}>
|
|
108
|
+
<Flex direction="column" pt="2" style={{ border: '1px solid green' }}>
|
|
109
|
+
{type !== 'voice' && allTracks.length === 0 && !loading && (
|
|
110
|
+
<Flex direction="row" gap="3" p="5" pt="2" align="center" justify="center">
|
|
111
|
+
<NoMusicIcon width={16} height={16} style={{ color: 'var(--neutral-alpha-10)' }} />
|
|
112
|
+
<Text size="2" style={{ color: 'var(--neutral-alpha-10)' }}>{labels.noTracks || 'This file has no tracks'}</Text>
|
|
113
|
+
</Flex>
|
|
114
|
+
)}
|
|
126
115
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
>
|
|
131
|
-
|
|
132
|
-
|
|
116
|
+
{loading && (
|
|
117
|
+
<Flex direction="row" gap="3" p="5" align="center" justify="center">
|
|
118
|
+
<Spinner width={16} height={16} style={{ color: 'var(--neutral-alpha-10)' }} />
|
|
119
|
+
<Text size="2" style={{ color: 'var(--neutral-alpha-10)' }}>{labels.loading || 'Loading tracks...'}</Text>
|
|
120
|
+
</Flex>
|
|
121
|
+
)}
|
|
133
122
|
|
|
134
|
-
|
|
123
|
+
{allTracks.length > 0 && (
|
|
124
|
+
<Flex direction="column" gap="1">
|
|
125
|
+
{typeof children === 'function' ? (
|
|
135
126
|
<>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
127
|
+
{children({ projectId: id, tracks: visibleTracks })}
|
|
128
|
+
{extraTracks.length > 0 && (
|
|
129
|
+
<Collapsible.Root open={showAllTracks} className={styles.extraTracksCollapsible}>
|
|
130
|
+
<Collapsible.Content className={styles.tracksContent}>
|
|
131
|
+
<Flex direction="column" gap="1" className={styles.extraTracksInner}>
|
|
132
|
+
{children({ projectId: id, tracks: extraTracks })}
|
|
133
|
+
</Flex>
|
|
134
|
+
</Collapsible.Content>
|
|
135
|
+
</Collapsible.Root>
|
|
136
|
+
)}
|
|
142
137
|
</>
|
|
143
|
-
)}
|
|
138
|
+
) : children}
|
|
139
|
+
|
|
140
|
+
<Flex direction="row" gap="3" p="2" align="center" justify="center">
|
|
141
|
+
<Button variant="ghost" color="gray" style={{ flex: '1' }}
|
|
142
|
+
onClick={handleInsertAllTracks}
|
|
143
|
+
>
|
|
144
|
+
<ArrowLeftIcon width={16} height={16} /> {labels.insertAll || 'Insert all'}
|
|
145
|
+
</Button>
|
|
146
|
+
|
|
147
|
+
{allTracks.length > 6 && (
|
|
148
|
+
<>
|
|
149
|
+
<Separator orientation="vertical" />
|
|
150
|
+
|
|
151
|
+
<Button variant="ghost" color="gray" style={{ flex: '1' }} onClick={handleClickShowAllTracks}>
|
|
152
|
+
{showAllTracks ? labels.showLess || 'Show less' : labels.showMore || 'Show more'}
|
|
153
|
+
{showAllTracks ? <ChevronUpIcon width={16} height={16} /> : <ChevronDownIcon width={16} height={16} />}
|
|
154
|
+
</Button>
|
|
155
|
+
</>
|
|
156
|
+
)}
|
|
157
|
+
</Flex>
|
|
144
158
|
</Flex>
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
</
|
|
148
|
-
|
|
159
|
+
)}
|
|
160
|
+
</Flex>
|
|
161
|
+
</Collapsible.Content>
|
|
162
|
+
</Collapsible.Root>
|
|
149
163
|
</Flex>
|
|
150
164
|
)
|
|
151
165
|
}
|
|
@@ -51,3 +51,47 @@
|
|
|
51
51
|
background: rgba(216, 244, 246, 0.04);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
.tracksCollapsible {
|
|
56
|
+
width: 100%;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.extraTracksCollapsible {
|
|
60
|
+
width: 100%;
|
|
61
|
+
margin-top: calc(-1 * var(--space-1));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.extraTracksInner {
|
|
65
|
+
padding-top: var(--space-1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.tracksContent {
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
width: 100%;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.tracksContent[data-state='open'] {
|
|
74
|
+
animation: projectItemSlideDown 0.3s ease;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.tracksContent[data-state='closed'] {
|
|
78
|
+
animation: projectItemSlideUp 0.3s ease;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@keyframes projectItemSlideDown {
|
|
82
|
+
from {
|
|
83
|
+
height: 0;
|
|
84
|
+
}
|
|
85
|
+
to {
|
|
86
|
+
height: var(--radix-collapsible-content-height);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@keyframes projectItemSlideUp {
|
|
91
|
+
from {
|
|
92
|
+
height: var(--radix-collapsible-content-height);
|
|
93
|
+
}
|
|
94
|
+
to {
|
|
95
|
+
height: 0;
|
|
96
|
+
}
|
|
97
|
+
}
|