@moises.ai/design-system 4.15.0 → 4.15.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.
@@ -0,0 +1,257 @@
1
+ @keyframes skeleton_animate_mask {
2
+ 0% {
3
+ mask-position: 200% 50%;
4
+ }
5
+ 100% {
6
+ mask-position: -100% 50%;
7
+ }
8
+ }
9
+
10
+ @keyframes equalizerBar1 {
11
+ 0%,
12
+ 100% {
13
+ height: 17px;
14
+ }
15
+ 50% {
16
+ height: 7px;
17
+ }
18
+ }
19
+
20
+ @keyframes equalizerBar2 {
21
+ 0%,
22
+ 100% {
23
+ height: 5px;
24
+ }
25
+ 50% {
26
+ height: 17px;
27
+ }
28
+ }
29
+
30
+ @keyframes equalizerBar3 {
31
+ 0%,
32
+ 100% {
33
+ height: 21px;
34
+ }
35
+ 50% {
36
+ height: 9px;
37
+ }
38
+ }
39
+
40
+ @keyframes equalizerBar4 {
41
+ 0%,
42
+ 100% {
43
+ height: 17px;
44
+ }
45
+ 50% {
46
+ height: 5px;
47
+ }
48
+ }
49
+
50
+ @keyframes equalizerBar5 {
51
+ 0%,
52
+ 100% {
53
+ height: 7px;
54
+ }
55
+ 50% {
56
+ height: 17px;
57
+ }
58
+ }
59
+
60
+ .previewCard {
61
+ display: flex;
62
+ align-items: center;
63
+ gap: 12px;
64
+ width: 100%;
65
+ max-width: 344px;
66
+ padding: 4px;
67
+ border-radius: 8px;
68
+ border: 1px solid var(--neutral-alpha-4);
69
+ background: transparent;
70
+ cursor: pointer;
71
+ box-sizing: border-box;
72
+ transition: background-color 0.2s ease, border-color 0.2s ease;
73
+ }
74
+
75
+ .previewCard:hover:not(.selected):not(.skeleton):not(.playing),
76
+ .previewCard:has(.leftButton:hover):not(.selected):not(.skeleton) {
77
+ background-color: var(--neutral-alpha-2);
78
+ }
79
+
80
+ .selected {
81
+ background-color: var(--neutral-alpha-2);
82
+ border: 2px solid var(--colors-accent-accent-10);
83
+ padding: 3px;
84
+ }
85
+
86
+ .skeleton {
87
+ background: linear-gradient(
88
+ 90deg,
89
+ var(--neutral-alpha-3) 0%,
90
+ rgba(221, 235, 236, 0.02) 61.19%
91
+ );
92
+ pointer-events: none;
93
+ border-color: transparent;
94
+ }
95
+
96
+ .leftButton {
97
+ display: flex;
98
+ align-items: center;
99
+ justify-content: center;
100
+ flex-shrink: 0;
101
+ width: 40px;
102
+ height: 40px;
103
+ padding: 0;
104
+ border: none;
105
+ border-radius: 6px;
106
+ background: var(--neutral-alpha-3);
107
+ color: var(--neutral-alpha-11);
108
+ cursor: pointer;
109
+ }
110
+
111
+ .leftButton:disabled {
112
+ cursor: default;
113
+ pointer-events: none;
114
+ }
115
+
116
+ .skeleton .leftButton,
117
+ .skeleton .actions {
118
+ opacity: 0;
119
+ }
120
+
121
+ .equalizer {
122
+ display: none;
123
+ align-items: center;
124
+ justify-content: center;
125
+ gap: 1.8px;
126
+ width: 19px;
127
+ height: 21px;
128
+ }
129
+
130
+ .equalizerBar {
131
+ display: block;
132
+ width: 2px;
133
+ border-radius: 4.8px;
134
+ background: var(--neutral-alpha-11);
135
+ flex-shrink: 0;
136
+ }
137
+
138
+ .equalizerBar:nth-child(1) {
139
+ height: 17px;
140
+ animation: equalizerBar1 0.8s ease-in-out infinite;
141
+ }
142
+
143
+ .equalizerBar:nth-child(2) {
144
+ height: 5px;
145
+ animation: equalizerBar2 0.8s ease-in-out infinite;
146
+ }
147
+
148
+ .equalizerBar:nth-child(3) {
149
+ height: 21px;
150
+ animation: equalizerBar3 0.8s ease-in-out infinite;
151
+ }
152
+
153
+ .equalizerBar:nth-child(4) {
154
+ height: 17px;
155
+ animation: equalizerBar4 0.8s ease-in-out infinite;
156
+ }
157
+
158
+ .equalizerBar:nth-child(5) {
159
+ height: 7px;
160
+ animation: equalizerBar5 0.8s ease-in-out infinite;
161
+ }
162
+
163
+ .pauseOnHover {
164
+ display: none;
165
+ }
166
+
167
+ .playIcon {
168
+ display: flex;
169
+ }
170
+
171
+ .leftButton.isPlaying .equalizer {
172
+ display: flex;
173
+ }
174
+
175
+ .leftButton.isPlaying .playIcon {
176
+ display: none !important;
177
+ }
178
+
179
+ .previewCard.playing:has(.leftButton:hover) .equalizer {
180
+ display: none;
181
+ }
182
+
183
+ .previewCard.playing:has(.leftButton:hover) .pauseOnHover {
184
+ display: flex;
185
+ }
186
+
187
+ .waveformContainer {
188
+ position: relative;
189
+ flex: 1 1 0;
190
+ min-width: 0;
191
+ height: 40px;
192
+ overflow: hidden;
193
+ cursor: pointer;
194
+ }
195
+
196
+ .waveformContainer :global(wave) {
197
+ display: block;
198
+ }
199
+
200
+ .skeleton .waveformContainer :global(wave) {
201
+ visibility: hidden;
202
+ }
203
+
204
+ .skeletonWaveform {
205
+ position: absolute;
206
+ inset: 0;
207
+ overflow: hidden;
208
+ border-radius: 4px;
209
+ }
210
+
211
+ .skeletonMask {
212
+ width: 100%;
213
+ height: 100%;
214
+ display: block;
215
+ background-repeat: repeat-x;
216
+ background-position: 30px center;
217
+ mask-image: radial-gradient(circle, blue 50%, rgba(255, 255, 0, 0.5) 50%);
218
+ mask-size: 400% 400%;
219
+ animation: skeleton_animate_mask 3s linear infinite;
220
+ -webkit-animation: skeleton_animate_mask 3s linear infinite;
221
+ background-image: url('/waveform.svg');
222
+ }
223
+
224
+ .actions {
225
+ display: flex;
226
+ flex-shrink: 0;
227
+ align-items: center;
228
+ justify-content: center;
229
+ width: 24px;
230
+ height: 24px;
231
+ border-radius: 4px;
232
+ opacity: 0.4;
233
+ transition: opacity 0.2s ease;
234
+ }
235
+
236
+ .actions :global(button) {
237
+ display: inline-flex;
238
+ align-items: center;
239
+ justify-content: center;
240
+ width: 24px !important;
241
+ height: 24px !important;
242
+ min-width: 24px !important;
243
+ min-height: 24px !important;
244
+ padding: 0 !important;
245
+ border-radius: 4px;
246
+ }
247
+
248
+ .actions :global(svg) {
249
+ width: 16px;
250
+ height: 16px;
251
+ }
252
+
253
+ .previewCard:hover .actions,
254
+ .previewCard:has(.leftButton:hover) .actions,
255
+ .selected .actions {
256
+ opacity: 1;
257
+ }
@@ -0,0 +1,112 @@
1
+ import React, { useMemo, useState } from 'react'
2
+ import { Flex, Text } from '@radix-ui/themes'
3
+ import { PreviewCard } from './PreviewCard'
4
+ import { MoreButton } from '../MoreButton/MoreButton'
5
+
6
+ const SAMPLE_AUDIO = {
7
+ zuri: 'https://storage.googleapis.com/moises-api-assets/voice/demo_zuri.m4a',
8
+ amy: 'https://storage.googleapis.com/moises-api-assets/voice/demo_amy.m4a',
9
+ rosa: 'https://storage.googleapis.com/moises-api-assets/voice/demo_rosa.m4a',
10
+ aisha: 'https://storage.googleapis.com/moises-api-assets/voice/demo_aisha.m4a',
11
+ }
12
+
13
+ const PREVIEW_ITEMS = [
14
+ { id: 'zuri', label: 'Zuri', audio: SAMPLE_AUDIO.zuri },
15
+ { id: 'amy', label: 'Amy', audio: SAMPLE_AUDIO.amy },
16
+ { id: 'rosa', label: 'Rosa', audio: SAMPLE_AUDIO.rosa },
17
+ { id: 'aisha', label: 'Aisha', audio: SAMPLE_AUDIO.aisha },
18
+ ]
19
+
20
+ export default {
21
+ title: 'Components/PreviewCard',
22
+ component: PreviewCard,
23
+ parameters: {
24
+ layout: 'centered',
25
+ docs: {
26
+ description: {
27
+ component: `
28
+ Preview card for tone previews with waveform, play/pause, selection, and continuous audio across multiple cards via \`wavegroup\`.
29
+ `,
30
+ },
31
+ },
32
+ },
33
+ decorators: [
34
+ (Story) => (
35
+ <Flex direction="column" gap="2" width="344px">
36
+ <Story />
37
+ </Flex>
38
+ ),
39
+ ],
40
+ }
41
+
42
+ export const Default = {
43
+ args: {
44
+ audio: SAMPLE_AUDIO.zuri,
45
+ },
46
+ }
47
+
48
+ export const Selected = {
49
+ args: {
50
+ audio: SAMPLE_AUDIO.amy,
51
+ selected: true,
52
+ },
53
+ }
54
+
55
+ export const Loading = {
56
+ args: {
57
+ audio: SAMPLE_AUDIO.rosa,
58
+ loading: true,
59
+ },
60
+ }
61
+
62
+ export const WithActions = {
63
+ args: {
64
+ audio: SAMPLE_AUDIO.zuri,
65
+ selected: true,
66
+ actions: <MoreButton aria-label="More options" />,
67
+ },
68
+ }
69
+
70
+ function PreviewCardGroupStory() {
71
+ const [selectedId, setSelectedId] = useState('zuri')
72
+ const [wavegroupState, setWavegroupState] = useState({
73
+ lastPlayed: null,
74
+ active: null,
75
+ isPlaying: false,
76
+ id: 'preview-card-group',
77
+ })
78
+
79
+ const wavegroup = useMemo(
80
+ () => ({
81
+ state: wavegroupState,
82
+ setter: setWavegroupState,
83
+ }),
84
+ [wavegroupState],
85
+ )
86
+
87
+ return (
88
+ <Flex direction="column" gap="3" width="344px">
89
+ <Text size="1" color="gray">
90
+ Click the card (outside waveform/play) to select. Play on another card
91
+ continues from the same position.
92
+ </Text>
93
+ {PREVIEW_ITEMS.map((item) => (
94
+ <PreviewCard
95
+ key={item.id}
96
+ audio={item.audio}
97
+ selected={selectedId === item.id}
98
+ wavegroup={wavegroup}
99
+ onSelect={() => setSelectedId(item.id)}
100
+ actions={<MoreButton aria-label={`More options for ${item.label}`} />}
101
+ />
102
+ ))}
103
+ </Flex>
104
+ )
105
+ }
106
+
107
+ export const Group = {
108
+ render: () => <PreviewCardGroupStory />,
109
+ parameters: {
110
+ layout: 'padded',
111
+ },
112
+ }
package/src/index.jsx CHANGED
@@ -148,6 +148,7 @@ export { TrackHeader } from './components/TrackHeader/TrackHeader'
148
148
  export { useForm } from './components/useForm/useForm'
149
149
  export { VoiceConversionForm } from './components/VoiceConversionForm/VoiceConversionForm'
150
150
  export { Waveform } from './components/VoiceConversionForm/Waveform/Waveform'
151
+ export { PreviewCard } from './components/PreviewCard/PreviewCard'
151
152
  export { SpecialDialog } from './components/SpecialDialog/SpecialDialog'
152
153
 
153
154
  export { VerticalSegmentControl } from './components/VerticalSegmentControl/VerticalSegmentControl'