@moises.ai/design-system 4.15.1 → 4.15.3

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,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'