@moises.ai/design-system 3.5.2 → 3.5.4
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 +4177 -4131
- package/package.json +1 -1
- package/src/components/ProjectsList/ProjectsList.jsx +130 -96
- package/src/components/ProjectsList/ProjectsList.stories.jsx +7 -5
- package/src/components/ProjectsList/assets/images/thumb-song-lyrics.jpg +0 -0
- package/src/components/ProjectsList/assets/images/thumb-song-master.jpg +0 -0
- package/src/components/ProjectsList/assets/images/thumb-song-stems.jpg +0 -0
- package/src/components/ProjectsList/assets/images/thumb-song-studio.jpg +0 -0
- package/src/components/ProjectsList/assets/images/thumb-song-voice.jpg +0 -0
- package/src/components/ProjectsList/utils-stories.js +24 -0
- package/src/components/ProjectsList/utils.jsx +48 -22
package/package.json
CHANGED
|
@@ -1,24 +1,59 @@
|
|
|
1
|
-
import { Flex, Text, Separator
|
|
1
|
+
import { Flex, Text, Separator } from '@radix-ui/themes'
|
|
2
2
|
import styles from './ProjectsList.module.css'
|
|
3
|
-
import { useState } from 'react'
|
|
3
|
+
import { useState, createContext, useContext } from 'react'
|
|
4
4
|
import { ArrowLeftIcon, NoMusicIcon, ChevronDownIcon, ChevronUpIcon } from '../../icons'
|
|
5
|
-
import { getIconFromTrackId } from './utils'
|
|
5
|
+
import { getIconFromTrackId, getProjectCover } from './utils'
|
|
6
|
+
import { Button } from '../Button/Button'
|
|
7
|
+
|
|
8
|
+
const ProjectsListContext = createContext({
|
|
9
|
+
onClickTrack: null,
|
|
10
|
+
onInsertAllTracks: null,
|
|
11
|
+
openedItem: null,
|
|
12
|
+
setOpenedItem: () => { },
|
|
13
|
+
})
|
|
6
14
|
|
|
7
15
|
export const ProjectsList = ({
|
|
8
|
-
|
|
16
|
+
children,
|
|
9
17
|
onClickTrack,
|
|
10
18
|
onInsertAllTracks,
|
|
11
19
|
}) => {
|
|
12
20
|
const [openedItem, setOpenedItem] = useState(null)
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<ProjectsListContext.Provider
|
|
24
|
+
value={{
|
|
25
|
+
onClickTrack,
|
|
26
|
+
onInsertAllTracks,
|
|
27
|
+
openedItem,
|
|
28
|
+
setOpenedItem,
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
<Flex direction="column" width="100%">
|
|
32
|
+
{children}
|
|
33
|
+
</Flex>
|
|
34
|
+
</ProjectsListContext.Provider>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const ProjectsListItem = ({
|
|
39
|
+
id,
|
|
40
|
+
title,
|
|
41
|
+
artist,
|
|
42
|
+
cover,
|
|
43
|
+
type,
|
|
44
|
+
tracks = [],
|
|
45
|
+
...props
|
|
46
|
+
}) => {
|
|
47
|
+
const { onClickTrack, onInsertAllTracks, openedItem, setOpenedItem } = useContext(ProjectsListContext)
|
|
13
48
|
const [showAllTracks, setShowAllTracks] = useState(false)
|
|
14
49
|
|
|
15
|
-
const handleClickProject = (
|
|
50
|
+
const handleClickProject = () => {
|
|
16
51
|
setShowAllTracks(false)
|
|
17
52
|
|
|
18
|
-
if (openedItem ===
|
|
53
|
+
if (openedItem === id) {
|
|
19
54
|
setOpenedItem(null)
|
|
20
55
|
} else {
|
|
21
|
-
setOpenedItem(
|
|
56
|
+
setOpenedItem(id)
|
|
22
57
|
}
|
|
23
58
|
}
|
|
24
59
|
|
|
@@ -28,105 +63,104 @@ export const ProjectsList = ({
|
|
|
28
63
|
setShowAllTracks(!showAllTracks)
|
|
29
64
|
}
|
|
30
65
|
|
|
66
|
+
const project = { id, title, artist, cover, type, tracks }
|
|
67
|
+
|
|
31
68
|
return (
|
|
32
|
-
<Flex
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
>
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/>
|
|
50
|
-
</Flex>
|
|
69
|
+
<Flex
|
|
70
|
+
direction="column"
|
|
71
|
+
gap="2"
|
|
72
|
+
p="1"
|
|
73
|
+
className={`${styles.item} ${openedItem === id ? styles.opened : ''}`}
|
|
74
|
+
onClick={handleClickProject}
|
|
75
|
+
{...props}
|
|
76
|
+
>
|
|
77
|
+
<Flex direction="row" gap="3">
|
|
78
|
+
<Flex className={styles.projectCover}>
|
|
79
|
+
<img
|
|
80
|
+
src={getProjectCover(project)}
|
|
81
|
+
alt={title}
|
|
82
|
+
draggable={false}
|
|
83
|
+
className={styles.projectCoverImage}
|
|
84
|
+
/>
|
|
85
|
+
</Flex>
|
|
51
86
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
87
|
+
<Flex direction="column" gap="1" align="start" justify="center">
|
|
88
|
+
<Text size="2" className={styles.projectTitle}>
|
|
89
|
+
{title}
|
|
90
|
+
</Text>
|
|
56
91
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
92
|
+
{artist && (
|
|
93
|
+
<Text size="1" className={styles.projectArtist}>
|
|
94
|
+
{artist}
|
|
95
|
+
</Text>
|
|
96
|
+
)}
|
|
97
|
+
</Flex>
|
|
98
|
+
</Flex>
|
|
99
|
+
|
|
100
|
+
{openedItem === id && (
|
|
101
|
+
<Flex direction="column">
|
|
102
|
+
{tracks.length === 0 && (
|
|
103
|
+
<Flex direction="row" gap="3" p="5" pt="2" align="center" justify="center">
|
|
104
|
+
<NoMusicIcon width={16} height={16} style={{ color: 'var(--neutral-alpha-10)' }} />
|
|
105
|
+
<Text size="2" style={{ color: 'var(--neutral-alpha-10)' }}>This file has no tracks</Text>
|
|
62
106
|
</Flex>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{openedItem === project.id && (
|
|
66
|
-
<Flex direction="column">
|
|
67
|
-
{project.tracks.length === 0 && (
|
|
68
|
-
<Flex direction="row" gap="3" p="5" pt="2" align="center" justify="center">
|
|
69
|
-
<NoMusicIcon width={16} height={16} style={{ color: 'var(--neutral-alpha-10)' }} />
|
|
70
|
-
<Text size="2" style={{ color: 'var(--neutral-alpha-10)' }}>This file has no tracks</Text>
|
|
71
|
-
</Flex>
|
|
72
|
-
)}
|
|
73
|
-
|
|
74
|
-
{project.tracks.length > 0 && (
|
|
75
|
-
<Flex direction="column" gap="1">
|
|
76
|
-
{project.tracks.slice(0, showAllTracks ? project.tracks.length : 6).map((track) => (
|
|
77
|
-
<Flex
|
|
78
|
-
key={track.id}
|
|
79
|
-
direction="row"
|
|
80
|
-
gap="3"
|
|
81
|
-
className={styles.itemTrack}
|
|
82
|
-
onClick={(e) => {
|
|
83
|
-
e.stopPropagation()
|
|
84
|
-
onClickTrack?.(track)
|
|
85
|
-
}}
|
|
86
|
-
>
|
|
87
|
-
<div className={styles.icon}>
|
|
88
|
-
<Flex className={styles.iconTrack}>
|
|
89
|
-
{getIconFromTrackId(track.id)}
|
|
90
|
-
</Flex>
|
|
91
|
-
<ArrowLeftIcon width={16} height={16} className={styles.iconArrowLeft} />
|
|
92
|
-
</div>
|
|
93
|
-
|
|
94
|
-
<Flex direction="column" gap="1" align="start" justify="center">
|
|
95
|
-
<Text size="2" className={styles.trackTitle}>
|
|
96
|
-
{track.title}
|
|
97
|
-
</Text>
|
|
98
|
-
</Flex>
|
|
99
|
-
</Flex>
|
|
100
|
-
))}
|
|
101
|
-
|
|
102
|
-
<Flex direction="row" gap="3" p="2" align="center" justify="center">
|
|
103
|
-
<Button variant="ghost" color="gray" style={{ flex: '1' }}
|
|
104
|
-
onClick={(e) => {
|
|
105
|
-
e.stopPropagation()
|
|
106
|
-
onInsertAllTracks?.(project.tracks)
|
|
107
|
-
}}
|
|
108
|
-
>
|
|
109
|
-
<ArrowLeftIcon width={16} height={16} /> Insert all
|
|
110
|
-
</Button>
|
|
107
|
+
)}
|
|
111
108
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
{tracks.length > 0 && (
|
|
110
|
+
<Flex direction="column" gap="1">
|
|
111
|
+
{tracks.slice(0, showAllTracks ? tracks.length : 6).map((track) => (
|
|
112
|
+
<Flex
|
|
113
|
+
key={track.id}
|
|
114
|
+
direction="row"
|
|
115
|
+
gap="3"
|
|
116
|
+
className={styles.itemTrack}
|
|
117
|
+
onClick={(e) => {
|
|
118
|
+
e.stopPropagation()
|
|
119
|
+
onClickTrack?.(track)
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<div className={styles.icon}>
|
|
123
|
+
<Flex className={styles.iconTrack}>
|
|
124
|
+
{getIconFromTrackId(track.id)}
|
|
125
|
+
</Flex>
|
|
126
|
+
<ArrowLeftIcon width={16} height={16} className={styles.iconArrowLeft} />
|
|
127
|
+
</div>
|
|
115
128
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
</>
|
|
121
|
-
)}
|
|
129
|
+
<Flex direction="column" gap="1" align="start" justify="center">
|
|
130
|
+
<Text size="2" className={styles.trackTitle}>
|
|
131
|
+
{track.title}
|
|
132
|
+
</Text>
|
|
122
133
|
</Flex>
|
|
123
134
|
</Flex>
|
|
124
|
-
)}
|
|
135
|
+
))}
|
|
136
|
+
|
|
137
|
+
<Flex direction="row" gap="3" p="2" align="center" justify="center">
|
|
138
|
+
<Button variant="ghost" color="neutral" style={{ flex: '1' }}
|
|
139
|
+
onClick={(e) => {
|
|
140
|
+
e.stopPropagation()
|
|
141
|
+
onInsertAllTracks?.(tracks)
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
<ArrowLeftIcon width={16} height={16} /> Insert all
|
|
145
|
+
</Button>
|
|
146
|
+
|
|
147
|
+
{tracks.length > 6 && (
|
|
148
|
+
<>
|
|
149
|
+
<Separator orientation="vertical" />
|
|
150
|
+
|
|
151
|
+
<Button variant="ghost" color="gray" style={{ flex: '1' }} onClick={handleClickShowAllTracks}>
|
|
152
|
+
{showAllTracks ? 'Show less' : 'Show more'}
|
|
153
|
+
{showAllTracks ? <ChevronUpIcon width={16} height={16} /> : <ChevronDownIcon width={16} height={16} />}
|
|
154
|
+
</Button>
|
|
155
|
+
</>
|
|
156
|
+
)}
|
|
157
|
+
</Flex>
|
|
125
158
|
</Flex>
|
|
126
159
|
)}
|
|
127
160
|
</Flex>
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
</Flex >
|
|
161
|
+
)}
|
|
162
|
+
</Flex>
|
|
131
163
|
)
|
|
132
164
|
}
|
|
165
|
+
|
|
166
|
+
ProjectsList.Item = ProjectsListItem
|
|
@@ -15,11 +15,13 @@ export const Default = {
|
|
|
15
15
|
render: (args) => {
|
|
16
16
|
return (
|
|
17
17
|
<ProjectsList
|
|
18
|
-
{
|
|
19
|
-
|
|
18
|
+
onClickTrack={args.onClickTrack}
|
|
19
|
+
onInsertAllTracks={args.onInsertAllTracks}
|
|
20
|
+
>
|
|
21
|
+
{projects.map((project) => (
|
|
22
|
+
<ProjectsList.Item key={project.id} {...project} />
|
|
23
|
+
))}
|
|
24
|
+
</ProjectsList>
|
|
20
25
|
)
|
|
21
26
|
},
|
|
22
|
-
args: {
|
|
23
|
-
projects: projects,
|
|
24
|
-
},
|
|
25
27
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -5,6 +5,7 @@ export const projects = [
|
|
|
5
5
|
"artist": "NPR Music: Tiny Desk Concert",
|
|
6
6
|
"cover": null,
|
|
7
7
|
"duration": 30.72,
|
|
8
|
+
"type": "studio",
|
|
8
9
|
"tracks": [
|
|
9
10
|
{
|
|
10
11
|
"id": "q8pzli0h38ptcxq09h2al",
|
|
@@ -29,6 +30,7 @@ export const projects = [
|
|
|
29
30
|
"artist": null,
|
|
30
31
|
"cover": null,
|
|
31
32
|
"duration": 19.924,
|
|
33
|
+
"type": "stems",
|
|
32
34
|
"tracks": [
|
|
33
35
|
{
|
|
34
36
|
"id": "original",
|
|
@@ -143,6 +145,7 @@ export const projects = [
|
|
|
143
145
|
"artist": null,
|
|
144
146
|
"cover": null,
|
|
145
147
|
"duration": 1062.0343,
|
|
148
|
+
"type": "master",
|
|
146
149
|
"tracks": []
|
|
147
150
|
},
|
|
148
151
|
{
|
|
@@ -151,6 +154,7 @@ export const projects = [
|
|
|
151
154
|
"artist": null,
|
|
152
155
|
"cover": null,
|
|
153
156
|
"duration": 227.0215,
|
|
157
|
+
"type": "voice",
|
|
154
158
|
"tracks": [
|
|
155
159
|
{
|
|
156
160
|
"id": "bass",
|
|
@@ -170,6 +174,7 @@ export const projects = [
|
|
|
170
174
|
"artist": "Led Zeppelin",
|
|
171
175
|
"cover": "https://d1-stage.moises.ai/v3/download/moises-stage--tasks2/operations/FILEMETADATA_A/76477978-88b0-4dd1-b729-ad760b9f1b9c/cover.jpeg",
|
|
172
176
|
"duration": 296.8065,
|
|
177
|
+
"type": "lyrics",
|
|
173
178
|
"tracks": [
|
|
174
179
|
{
|
|
175
180
|
"id": "bass",
|
|
@@ -182,5 +187,24 @@ export const projects = [
|
|
|
182
187
|
"audioUrl": "https://d2-stage.moises.ai/v3/download/moises-stage--tasks2/operations/SEPARATE_CUSTOM/e4325003-662f-4aeb-b75a-14797654828a/other.m4a"
|
|
183
188
|
}
|
|
184
189
|
]
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"id": "3612a6132234-b86c-408e-b23296-b9f0f22dbeb108",
|
|
193
|
+
"title": "Project without cover and type",
|
|
194
|
+
"artist": null,
|
|
195
|
+
"cover": null,
|
|
196
|
+
"duration": 227.0215,
|
|
197
|
+
"tracks": [
|
|
198
|
+
{
|
|
199
|
+
"id": "bass",
|
|
200
|
+
"title": "bass",
|
|
201
|
+
"audioUrl": "https://d2-stage.moises.ai/v3/download/moises-stage--tasks2/operations/SEPARATE_CUSTOM/09239f2d-f93f-4924-86a0-2277e5ba35ea/bass.m4a"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"id": "other",
|
|
205
|
+
"title": "other",
|
|
206
|
+
"audioUrl": "https://d3-stage.moises.ai/v3/download/moises-stage--tasks2/operations/SEPARATE_CUSTOM/09239f2d-f93f-4924-86a0-2277e5ba35ea/other.m4a"
|
|
207
|
+
}
|
|
208
|
+
]
|
|
185
209
|
}
|
|
186
210
|
]
|
|
@@ -19,52 +19,78 @@ import {
|
|
|
19
19
|
MusicIcon,
|
|
20
20
|
SparkBarsIcon,
|
|
21
21
|
} from '../../icons'
|
|
22
|
+
import thumbCoverLyrics from './assets/images/thumb-song-lyrics.jpg'
|
|
23
|
+
import thumbCoverMaster from './assets/images/thumb-song-master.jpg'
|
|
24
|
+
import thumbCoverStems from './assets/images/thumb-song-stems.jpg'
|
|
25
|
+
import thumbCoverStudio from './assets/images/thumb-song-studio.jpg'
|
|
26
|
+
import thumbCoverVoice from './assets/images/thumb-song-voice.jpg'
|
|
22
27
|
|
|
23
28
|
export const getIconFromTrackId = (trackId) => {
|
|
24
29
|
switch (trackId) {
|
|
25
30
|
case 'original':
|
|
26
|
-
return <SpliterIcon />
|
|
31
|
+
return <SpliterIcon width={16} height={16} />
|
|
27
32
|
case 'vocals':
|
|
28
|
-
return <VocalIcon />
|
|
33
|
+
return <VocalIcon width={16} height={16} />
|
|
29
34
|
case 'backing_vocals':
|
|
30
|
-
return <VocalsBackgroundIcon />
|
|
35
|
+
return <VocalsBackgroundIcon width={16} height={16} />
|
|
31
36
|
case 'drums':
|
|
32
|
-
return <DrumsIcon />
|
|
37
|
+
return <DrumsIcon width={16} height={16} />
|
|
33
38
|
case 'bass':
|
|
34
|
-
return <BassIcon />
|
|
39
|
+
return <BassIcon width={16} height={16} />
|
|
35
40
|
case 'guitars':
|
|
36
|
-
return <ElectricGuitarIcon />
|
|
41
|
+
return <ElectricGuitarIcon width={16} height={16} />
|
|
37
42
|
case 'other_kit':
|
|
38
|
-
return <IsolateDrumsIcon />
|
|
43
|
+
return <IsolateDrumsIcon width={16} height={16} />
|
|
39
44
|
case "piano":
|
|
40
|
-
return <PianoIcon />
|
|
45
|
+
return <PianoIcon width={16} height={16} />
|
|
41
46
|
case "wind":
|
|
42
|
-
return <WindIcon />
|
|
47
|
+
return <WindIcon width={16} height={16} />
|
|
43
48
|
case "strings":
|
|
44
|
-
return <StringsIcon />
|
|
49
|
+
return <StringsIcon width={16} height={16} />
|
|
45
50
|
case "keys":
|
|
46
|
-
return <KeysIcon />
|
|
51
|
+
return <KeysIcon width={16} height={16} />
|
|
47
52
|
case "kick":
|
|
48
|
-
return <KickdrumIcon />
|
|
53
|
+
return <KickdrumIcon width={16} height={16} />
|
|
49
54
|
case "snare":
|
|
50
|
-
return <SnareIcon />
|
|
55
|
+
return <SnareIcon width={16} height={16} />
|
|
51
56
|
case "toms":
|
|
52
|
-
return <TomsIcon />
|
|
57
|
+
return <TomsIcon width={16} height={16} />
|
|
53
58
|
case "hat":
|
|
54
|
-
return <HiHatIcon />
|
|
59
|
+
return <HiHatIcon width={16} height={16} />
|
|
55
60
|
case "cymbals":
|
|
56
|
-
return <CymbalsIcon />
|
|
61
|
+
return <CymbalsIcon width={16} height={16} />
|
|
57
62
|
case "rhythm":
|
|
58
|
-
return <ElectricGuitarIcon />
|
|
63
|
+
return <ElectricGuitarIcon width={16} height={16} />
|
|
59
64
|
case "lead":
|
|
60
|
-
return <ElectricGuitarIcon />
|
|
65
|
+
return <ElectricGuitarIcon width={16} height={16} />
|
|
61
66
|
case "electric":
|
|
62
|
-
return <AcousticGuitarIcon />
|
|
67
|
+
return <AcousticGuitarIcon width={16} height={16} />
|
|
63
68
|
case "acoustic":
|
|
64
|
-
return <AcousticGuitarIcon />
|
|
69
|
+
return <AcousticGuitarIcon width={16} height={16} />
|
|
65
70
|
case 'other':
|
|
66
|
-
return <MusicIcon />
|
|
71
|
+
return <MusicIcon width={16} height={16} />
|
|
67
72
|
default:
|
|
68
|
-
return <SparkBarsIcon />
|
|
73
|
+
return <SparkBarsIcon width={16} height={16} />
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const getProjectCover = (project) => {
|
|
78
|
+
if (project?.cover) {
|
|
79
|
+
return project.cover
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
switch (project?.type) {
|
|
83
|
+
case 'studio':
|
|
84
|
+
return thumbCoverStudio
|
|
85
|
+
case 'stems':
|
|
86
|
+
return thumbCoverStems
|
|
87
|
+
case 'voice':
|
|
88
|
+
return thumbCoverVoice
|
|
89
|
+
case 'master':
|
|
90
|
+
return thumbCoverMaster
|
|
91
|
+
case 'lyrics':
|
|
92
|
+
return thumbCoverLyrics
|
|
93
|
+
default:
|
|
94
|
+
return thumbCoverLyrics
|
|
69
95
|
}
|
|
70
96
|
}
|