@moises.ai/design-system 4.20.10 → 4.21.0

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.
Files changed (20) hide show
  1. package/dist/index.js +4867 -4378
  2. package/package.json +1 -1
  3. package/src/components/ProjectsList/ProjectItem/ListItems.jsx +106 -0
  4. package/src/components/ProjectsList/ProjectItem/ListItems.module.css +43 -0
  5. package/src/components/ProjectsList/ProjectItem/ProjectItem.jsx +13 -84
  6. package/src/components/ProjectsList/ProjectItem/ProjectItem.module.css +0 -44
  7. package/src/components/ProjectsList/ProjectItemStemSeparation/ListStems.jsx +108 -0
  8. package/src/components/ProjectsList/ProjectItemStemSeparation/ListStems.module.css +43 -0
  9. package/src/components/ProjectsList/ProjectItemStemSeparation/ProjectItemStemSeparation.jsx +153 -0
  10. package/src/components/ProjectsList/ProjectItemStemSeparation/ProjectItemStemSeparation.module.css +68 -0
  11. package/src/components/ProjectsList/ProjectItemStemSeparation/StemSeparationForm.jsx +82 -0
  12. package/src/components/ProjectsList/ProjectItemStemSeparation/StemSeparationForm.module.css +40 -0
  13. package/src/components/ProjectsList/ProjectItemStemSeparation/use-form.js +46 -0
  14. package/src/components/ProjectsList/ProjectItemStemSeparation/utils.js +170 -0
  15. package/src/components/ProjectsList/ProjectTrack/ProjectTrack.jsx +12 -4
  16. package/src/components/ProjectsList/ProjectTrack/ProjectTrack.module.css +6 -2
  17. package/src/components/ProjectsList/ProjectsList.jsx +14 -3
  18. package/src/components/ProjectsList/ProjectsList.stories.jsx +47 -0
  19. package/src/components/ProjectsList/context.js +2 -0
  20. package/src/components/ProjectsList/utils-stories.js +425 -215
@@ -0,0 +1,68 @@
1
+ .projectTitle {
2
+ color: var(--neutral-12);
3
+ padding-right: var(--space-2);
4
+ display: block;
5
+ width: 100%;
6
+ min-width: 0;
7
+ overflow: hidden;
8
+ text-overflow: ellipsis;
9
+ white-space: nowrap;
10
+ }
11
+
12
+ .projectArtist {
13
+ color: var(--neutral-alpha-9);
14
+ display: block;
15
+ width: 100%;
16
+ min-width: 0;
17
+ overflow: hidden;
18
+ text-overflow: ellipsis;
19
+ white-space: nowrap;
20
+ }
21
+
22
+ .projectFailed {
23
+ color: var(--error-alpha-11);
24
+ }
25
+
26
+ .projectCover {
27
+ width: 48px;
28
+ height: 48px;
29
+ flex: 0 0 48px;
30
+ border-radius: var(--radius-3);
31
+ overflow: hidden;
32
+ }
33
+
34
+ .projectCover img {
35
+ width: 100%;
36
+ height: 100%;
37
+ object-fit: cover;
38
+ pointer-events: none;
39
+ }
40
+
41
+ .item:not(.failed) {
42
+ cursor: pointer;
43
+ border-radius: var(--radius-4);
44
+
45
+ &.opened {
46
+ background: var(--neutral-alpha-2);
47
+ box-shadow: 0 24px 24px -16px rgba(0, 0, 0, 0.40);
48
+ }
49
+
50
+ &:hover:not(.opened) {
51
+ background: rgba(216, 244, 246, 0.04);
52
+ }
53
+
54
+ .changeStems {
55
+ opacity: 0;
56
+ pointer-events: none;
57
+ }
58
+
59
+ &:hover .changeStems {
60
+ opacity: 1;
61
+ pointer-events: auto;
62
+ }
63
+
64
+ .changeStemsVisible {
65
+ opacity: 1;
66
+ pointer-events: auto;
67
+ }
68
+ }
@@ -0,0 +1,82 @@
1
+ import { Flex, Text } from '@radix-ui/themes'
2
+ import { Button } from '../../Button/Button'
3
+ import { Collapsible } from 'radix-ui'
4
+ import { useContext, useState } from 'react'
5
+ import { InstrumentSelect } from '../../InstrumentSelect/InstrumentSelect'
6
+ import { ProjectsListContext } from '../context'
7
+ import styles from './StemSeparationForm.module.css'
8
+ import { useForm } from './use-form'
9
+
10
+ const StemSeparationForm = ({
11
+ project,
12
+ id,
13
+ open,
14
+ options = [],
15
+ selected = [],
16
+ labels = {},
17
+ onSubmit,
18
+ setIsChangingStems,
19
+ }) => {
20
+ const { openedItem, onShowPaywall } = useContext(ProjectsListContext)
21
+
22
+ const {
23
+ stemsSelected,
24
+ hasChanges,
25
+ onToggleStems,
26
+ } = useForm({ onShowPaywall, selected })
27
+
28
+ const [loading, setLoading] = useState(false)
29
+ const isOpen = open ?? openedItem === id
30
+
31
+ const handleSubmit = async (e) => {
32
+ e.stopPropagation()
33
+ setLoading(true)
34
+ await onSubmit?.(project, stemsSelected)
35
+ setLoading(false)
36
+ setIsChangingStems(false)
37
+ }
38
+
39
+ return (
40
+ <Collapsible.Root open={isOpen} className={styles.contentCollapsible}>
41
+ <Collapsible.Content className={styles.content}>
42
+ <Flex pt="3">
43
+ <Button
44
+ variant="solid"
45
+ color="cyan"
46
+ size="2"
47
+ style={{ width: '100%' }}
48
+ disabled={!hasChanges}
49
+ loading={loading}
50
+ onClick={handleSubmit}
51
+ >
52
+ {labels.changeStems || 'Change Stems'}
53
+ </Button>
54
+ </Flex>
55
+
56
+ <Flex
57
+ direction="column"
58
+ gap="4"
59
+ pt="3"
60
+ pb="5"
61
+ height="100%"
62
+ onClick={(e) => e.stopPropagation()}
63
+ >
64
+ {options.map((option) => (
65
+ <Flex key={option.id} direction="column" gap="2">
66
+ <Text size="1" className={styles.groupLabel}>
67
+ {option.title}
68
+ </Text>
69
+ <InstrumentSelect
70
+ items={option.items}
71
+ selectedValue={stemsSelected}
72
+ onSelect={onToggleStems}
73
+ />
74
+ </Flex>
75
+ ))}
76
+ </Flex>
77
+ </Collapsible.Content>
78
+ </Collapsible.Root>
79
+ )
80
+ }
81
+
82
+ export default StemSeparationForm
@@ -0,0 +1,40 @@
1
+ .groupLabel {
2
+ color: var(--neutral-alpha-8);
3
+ letter-spacing: 1.5px;
4
+ text-transform: uppercase;
5
+ }
6
+
7
+ .contentCollapsible {
8
+ width: 100%;
9
+ }
10
+
11
+ .content {
12
+ overflow: hidden;
13
+ width: 100%;
14
+ }
15
+
16
+ .content[data-state='open'] {
17
+ animation: projectItemSlideDown 0.3s ease;
18
+ }
19
+
20
+ .content[data-state='closed'] {
21
+ animation: projectItemSlideUp 0.3s ease;
22
+ }
23
+
24
+ @keyframes projectItemSlideDown {
25
+ from {
26
+ height: 0;
27
+ }
28
+ to {
29
+ height: var(--radix-collapsible-content-height);
30
+ }
31
+ }
32
+
33
+ @keyframes projectItemSlideUp {
34
+ from {
35
+ height: var(--radix-collapsible-content-height);
36
+ }
37
+ to {
38
+ height: 0;
39
+ }
40
+ }
@@ -0,0 +1,46 @@
1
+ import { useState, useMemo, useEffect } from 'react'
2
+ import { stems } from './utils'
3
+
4
+ function areStemSelectionsEqual(current = [], initial = []) {
5
+ if (current.length !== initial.length) return false
6
+ const initialSet = new Set(initial)
7
+ return current.every((stem) => initialSet.has(stem))
8
+ }
9
+
10
+ export function useForm({ onShowPaywall, selected = [] }) {
11
+ const [stemsSelected, setStemsSelected] = useState(selected)
12
+
13
+ useEffect(() => {
14
+ setStemsSelected(selected)
15
+ }, [selected])
16
+
17
+ const onToggleStems = async (value) => {
18
+ if (value.locked) {
19
+ onShowPaywall(value.paywallId)
20
+ return
21
+ }
22
+
23
+ setStemsSelected((prev) => {
24
+ // If the item is already selected, remove it (toggle off)
25
+ if (prev.includes(value.value)) {
26
+ return prev.filter((stem) => stem !== value.value)
27
+ }
28
+
29
+ // If the item is not selected, add it and remove the mutualExclusiveStems
30
+ const newStems = [...prev, value.value]
31
+ const mutualExclusiveStems = stems.find((s) => s.value === value.value)?.mutualExclusiveStems
32
+ return newStems.filter((stem) => !mutualExclusiveStems?.includes(stem))
33
+ })
34
+ }
35
+
36
+ const hasChanges = useMemo(
37
+ () => !areStemSelectionsEqual(stemsSelected, selected),
38
+ [stemsSelected, selected],
39
+ )
40
+
41
+ return {
42
+ stemsSelected,
43
+ onToggleStems,
44
+ hasChanges,
45
+ }
46
+ }
@@ -0,0 +1,170 @@
1
+ export const stems = [
2
+ {
3
+ value: 'freeVocalInstruments',
4
+ name: 'Vocals & Instruments',
5
+ category: 'free',
6
+ stems: ['vocals', 'other'],
7
+ mutualExclusiveStems: ['freeVocalBassDrumsOthers'],
8
+ },
9
+ {
10
+ value: 'freeVocalBassDrumsOthers',
11
+ name: 'Vocal, Bass, Drums & Others',
12
+ category: 'free',
13
+ stems: ['vocals', 'bass', 'drums', 'other'],
14
+ mutualExclusiveStems: ['freeVocalInstruments'],
15
+ },
16
+ {
17
+ value: 'vocals',
18
+ name: 'Vocals',
19
+ category: 'premium',
20
+ paywallId: 'customSeparationVocals-stemSeparationExtension',
21
+ stems: ['vocals'],
22
+ mutualExclusiveStems: ['leadVocals', 'backingVocals'],
23
+ },
24
+ {
25
+ value: 'leadVocals',
26
+ name: 'Lead Vocals',
27
+ category: 'premium',
28
+ paywallId: 'customSeparationLeadVocals-stemSeparationExtension',
29
+ stems: ['leadVocals'],
30
+ mutualExclusiveStems: ['vocals'],
31
+ },
32
+ {
33
+ value: 'backingVocals',
34
+ name: 'Backing Vocals',
35
+ category: 'premium',
36
+ paywallId: 'customSeparationBackgroundVocals-stemSeparationExtension',
37
+ stems: ['backingVocals'],
38
+ mutualExclusiveStems: ['vocals'],
39
+ },
40
+ {
41
+ value: 'bass',
42
+ name: 'Bass',
43
+ category: 'premium',
44
+ paywallId: 'customSeparationBass-stemSeparationExtension',
45
+ stems: ['bass'],
46
+ },
47
+ {
48
+ value: 'guitars',
49
+ name: 'Guitars',
50
+ category: 'premium',
51
+ paywallId: 'customSeparationGuitars-stemSeparationExtension',
52
+ stems: ['guitars'],
53
+ mutualExclusiveStems: ['rhythmGuitars', 'soloGuitars', 'acousticGuitar', 'electricGuitar'],
54
+ },
55
+ {
56
+ value: 'rhythmGuitars',
57
+ name: 'Rhythm Guitars',
58
+ category: 'premium',
59
+ paywallId: 'customSeparationRhythmGuitar-stemSeparationExtension',
60
+ stems: ['rhythmGuitars'],
61
+ mutualExclusiveStems: ['guitars', 'acousticGuitar', 'electricGuitar'],
62
+ },
63
+ {
64
+ value: 'soloGuitars',
65
+ name: 'Solo Guitars',
66
+ category: 'premium',
67
+ paywallId: 'customSeparationLeadGuitar-stemSeparationExtension',
68
+ stems: ['soloGuitars'],
69
+ mutualExclusiveStems: ['guitars', 'acousticGuitar', 'electricGuitar'],
70
+ },
71
+ {
72
+ value: 'acousticGuitar',
73
+ name: 'Acoustic Guitar',
74
+ category: 'premium',
75
+ paywallId: 'customSeparationAcousticGuitar-stemSeparationExtension',
76
+ stems: ['acousticGuitar'],
77
+ mutualExclusiveStems: ['guitars', 'rhythmGuitars', 'soloGuitars'],
78
+ },
79
+ {
80
+ value: 'electricGuitar',
81
+ name: 'Electric Guitar',
82
+ category: 'premium',
83
+ paywallId: 'customSeparationElectricGuitar-stemSeparationExtension',
84
+ stems: ['electricGuitar'],
85
+ mutualExclusiveStems: ['guitars', 'rhythmGuitars', 'soloGuitars'],
86
+ },
87
+ {
88
+ value: 'strings',
89
+ name: 'Strings',
90
+ category: 'premium',
91
+ paywallId: 'customSeparationStrings-stemSeparationExtension',
92
+ stems: ['strings'],
93
+ },
94
+ {
95
+ value: 'piano',
96
+ name: 'Piano',
97
+ category: 'premium',
98
+ paywallId: 'customSeparationPiano-stemSeparationExtension',
99
+ stems: ['piano'],
100
+ },
101
+ {
102
+ value: 'keys',
103
+ name: 'Keys',
104
+ category: 'premium',
105
+ paywallId: 'customSeparationKeys-stemSeparationExtension',
106
+ stems: ['keys'],
107
+ },
108
+ {
109
+ value: 'wind',
110
+ name: 'Wind',
111
+ category: 'premium',
112
+ paywallId: 'customSeparationWind-stemSeparationExtension',
113
+ stems: ['wind'],
114
+ },
115
+ {
116
+ value: 'drums',
117
+ name: 'Drums',
118
+ category: 'premium',
119
+ paywallId: 'customSeparationDrums-stemSeparationExtension',
120
+ stems: ['drums'],
121
+ mutualExclusiveStems: ['kickDrums', 'snareDrums', 'toms', 'hiHat', 'cymbals'],
122
+ },
123
+ {
124
+ value: 'kickDrums',
125
+ name: 'Kick Drums',
126
+ category: 'pro',
127
+ paywallId: 'customSeparationDrumPartsKickDrum-stemSeparationExtension',
128
+ stems: ['kickDrums'],
129
+ mutualExclusiveStems: ['drums'],
130
+ },
131
+ {
132
+ value: 'snareDrums',
133
+ name: 'Snare Drums',
134
+ category: 'pro',
135
+ paywallId: 'customSeparationDrumPartsSnare-stemSeparationExtension',
136
+ stems: ['snareDrums'],
137
+ mutualExclusiveStems: ['drums'],
138
+ },
139
+ {
140
+ value: 'toms',
141
+ name: 'Toms',
142
+ category: 'pro',
143
+ paywallId: 'customSeparationDrumPartsToms-stemSeparationExtension',
144
+ stems: ['toms'],
145
+ mutualExclusiveStems: ['drums'],
146
+ },
147
+ {
148
+ value: 'hiHat',
149
+ name: 'Hi-Hat',
150
+ category: 'pro',
151
+ paywallId: 'customSeparationDrumPartsHiHat-stemSeparationExtension',
152
+ stems: ['hiHat'],
153
+ mutualExclusiveStems: ['drums'],
154
+ },
155
+ {
156
+ value: 'cymbals',
157
+ name: 'Cymbals',
158
+ category: 'pro',
159
+ paywallId: 'customSeparationDrumPartsCymbals-stemSeparationExtension',
160
+ stems: ['cymbals'],
161
+ mutualExclusiveStems: ['drums'],
162
+ },
163
+ {
164
+ value: 'other',
165
+ name: 'Other',
166
+ paywallId: 'customSeparationOther-stemSeparationExtension',
167
+ category: 'pro',
168
+ stems: ['other'],
169
+ },
170
+ ]
@@ -1,4 +1,4 @@
1
- import { Flex, Text } from '@radix-ui/themes'
1
+ import { Flex, Text, Spinner } from '@radix-ui/themes'
2
2
  import { useCallback, useContext } from 'react'
3
3
  import { ArrowLeftIcon } from '../../../icons'
4
4
  import { ProjectsListContext } from '../context'
@@ -9,19 +9,21 @@ const ProjectTrack = ({
9
9
  ...props
10
10
  }) => {
11
11
  const { onClickTrack } = useContext(ProjectsListContext)
12
- const { id, title } = props
12
+ const { id, title, loading } = props
13
13
 
14
14
  const handleClickTrack = useCallback((e) => {
15
15
  e.stopPropagation()
16
+ if (loading) return
17
+
16
18
  onClickTrack?.(props)
17
- }, [onClickTrack, props])
19
+ }, [onClickTrack, props, loading])
18
20
 
19
21
  return (
20
22
  <Flex direction="column" gap="1">
21
23
  <Flex
22
24
  direction="row"
23
25
  gap="3"
24
- className={styles.itemTrack}
26
+ className={`${styles.itemTrack} ${loading ? styles.disabledHover : ''}`}
25
27
  onClick={handleClickTrack}
26
28
  >
27
29
  <div className={styles.icon}>
@@ -44,6 +46,12 @@ const ProjectTrack = ({
44
46
  </span>
45
47
  </Text>
46
48
  </Flex>
49
+
50
+ {loading && (
51
+ <Flex align="center" justify="center" px="2">
52
+ <Spinner />
53
+ </Flex>
54
+ )}
47
55
  </Flex>
48
56
  </Flex>
49
57
  )
@@ -1,12 +1,12 @@
1
1
  .itemTrack {
2
- cursor: pointer;
3
2
  border-radius: var(--radius-3);
3
+ cursor: pointer;
4
4
 
5
5
  .iconArrowLeft {
6
6
  display: none;
7
7
  }
8
8
 
9
- &:hover {
9
+ &:not(.disabledHover):hover {
10
10
  background: var(--neutral-alpha-2);
11
11
  box-shadow: 0 24px 24px -16px rgba(0, 0, 0, 0.40);
12
12
 
@@ -18,6 +18,10 @@
18
18
  display: none;
19
19
  }
20
20
  }
21
+
22
+ &.disabledHover {
23
+ cursor: default;
24
+ }
21
25
  }
22
26
 
23
27
  .trackTitle {
@@ -2,6 +2,7 @@ import { Flex } from '@radix-ui/themes'
2
2
  import { useState } from 'react'
3
3
  import { ProjectsListContext } from './context'
4
4
  import ProjectItem from './ProjectItem/ProjectItem'
5
+ import ProjectItemStemSeparation from './ProjectItemStemSeparation/ProjectItemStemSeparation'
5
6
  import ProjectTrack from './ProjectTrack/ProjectTrack'
6
7
  import ProjectTrackVoice from './ProjectTrackVoice/ProjectTrackVoice'
7
8
 
@@ -12,6 +13,8 @@ export const ProjectsList = ({
12
13
  onInsertAllTracks,
13
14
  onProjectClick,
14
15
  onChangeTransfer,
16
+ onSubmitStemSeparation,
17
+ onShowPaywall,
15
18
  labels = {},
16
19
  showCover = true
17
20
  }) => {
@@ -25,6 +28,8 @@ export const ProjectsList = ({
25
28
  onInsertAllTracks,
26
29
  onProjectClick,
27
30
  onChangeTransfer,
31
+ onSubmitStemSeparation,
32
+ onShowPaywall,
28
33
  openedItem,
29
34
  setOpenedItem,
30
35
  labels,
@@ -33,9 +38,15 @@ export const ProjectsList = ({
33
38
  >
34
39
  <Flex direction="column" width="100%">
35
40
  {projects.map((project) => (
36
- <ProjectItem key={project.id} {...project} labels={labels}>
37
- {children}
38
- </ProjectItem>
41
+ project.type === 'stems' ? (
42
+ <ProjectItemStemSeparation key={project.id} {...project} labels={labels}>
43
+ {children}
44
+ </ProjectItemStemSeparation>
45
+ ) : (
46
+ <ProjectItem key={project.id} {...project} labels={labels}>
47
+ {children}
48
+ </ProjectItem>
49
+ )
39
50
  ))}
40
51
  </Flex>
41
52
  </ProjectsListContext.Provider>
@@ -209,6 +209,53 @@ export const WithProjectFailed = {
209
209
  },
210
210
  }
211
211
 
212
+ export const WithTrackSeparate = {
213
+ args: {
214
+ projects: projects.filter((project) => project.type === 'stems'),
215
+ onProjectClick: (project, opened) => {
216
+ console.log('project', project)
217
+ console.log('opened', opened)
218
+ },
219
+ onClickTrack: (track) => {
220
+ console.log('track', track)
221
+ },
222
+ onInsertAllTracks: (tracks) => {
223
+ console.log('insert-all-tracks', tracks)
224
+ },
225
+ onSubmitStemSeparation: async (project, stems) => {
226
+ await new Promise((resolve) => setTimeout(resolve, 1000))
227
+ console.log('submit-stem-separation', project, stems)
228
+ },
229
+ onShowPaywall: (paywallId) => {
230
+ console.log('show-paywall', paywallId)
231
+ },
232
+ },
233
+ render: (args) => {
234
+ return (
235
+ <Flex width="300px">
236
+ <ProjectsList
237
+ projects={args.projects}
238
+ onClickTrack={args.onClickTrack}
239
+ onInsertAllTracks={args.onInsertAllTracks}
240
+ onProjectClick={args.onProjectClick}
241
+ onSubmitStemSeparation={args.onSubmitStemSeparation}
242
+ onShowPaywall={args.onShowPaywall}
243
+ >
244
+ {({ projectId, tracks }) =>
245
+ tracks.map((track) => (
246
+ <ProjectsList.Track
247
+ projectId={projectId}
248
+ key={track.id}
249
+ {...track}
250
+ />
251
+ ))
252
+ }
253
+ </ProjectsList>
254
+ </Flex>
255
+ )
256
+ },
257
+ }
258
+
212
259
  export const WithTrackVoice = {
213
260
  args: {
214
261
  projects: projectsVoiceStudio,
@@ -6,6 +6,8 @@ export const ProjectsListContext = createContext({
6
6
  onInsertAllTracks: null,
7
7
  onProjectClick: null,
8
8
  onChangeTransfer: null,
9
+ onSubmitStemSeparation: null,
10
+ onShowPaywall: null,
9
11
  openedItem: null,
10
12
  setOpenedItem: () => { },
11
13
  labels: {},