@moises.ai/design-system 4.15.0 → 4.15.1
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/package.json
CHANGED
|
@@ -21,7 +21,8 @@ The \`CardDetails\` component is the enhanced card variant for the ListCards com
|
|
|
21
21
|
- **See details button** - Navigate to detailed views or trigger modals
|
|
22
22
|
- **Clickable avatar** - Add interactive elements like play/pause to the avatar area
|
|
23
23
|
- **Custom avatar content** - Display custom React nodes in the avatar area
|
|
24
|
-
- **
|
|
24
|
+
- **Auto description** - Renders \`item.description\` (or the \`description\` prop) by default
|
|
25
|
+
- **Rich formatting** - Override the description by passing \`children\` for separators, ellipsis, etc.
|
|
25
26
|
|
|
26
27
|
### Usage Examples
|
|
27
28
|
|
|
@@ -83,6 +84,7 @@ import { ListCards } from '@moises.ai/design-system'
|
|
|
83
84
|
id?: string; // Unique identifier
|
|
84
85
|
name?: string; // Display name
|
|
85
86
|
avatar?: string; // Avatar image URL
|
|
87
|
+
description?: string; // Description text (rendered when no children are provided)
|
|
86
88
|
|
|
87
89
|
// Interactive features
|
|
88
90
|
favorite?: boolean; // Whether item is favorited (shows/hides favorite icon)
|
|
@@ -95,7 +97,7 @@ import { ListCards } from '@moises.ai/design-system'
|
|
|
95
97
|
avatarContent?: React.ReactNode; // Custom content to render in avatar area
|
|
96
98
|
|
|
97
99
|
// Content
|
|
98
|
-
children?: React.ReactNode; // Custom content for the description area
|
|
100
|
+
children?: React.ReactNode; // Custom content for the description area (overrides description)
|
|
99
101
|
}
|
|
100
102
|
\`\`\`
|
|
101
103
|
`,
|
|
@@ -151,6 +153,96 @@ const CardDetailsExample = ({ title, children }) => (
|
|
|
151
153
|
</Flex>
|
|
152
154
|
)
|
|
153
155
|
|
|
156
|
+
export const WithDescriptionFromItem = {
|
|
157
|
+
render: () => (
|
|
158
|
+
<CardDetailsExample title="Description rendered automatically from item.description">
|
|
159
|
+
{sampleItems.map((item) => (
|
|
160
|
+
<ListCards.CardDetails key={item.id} item={item} />
|
|
161
|
+
))}
|
|
162
|
+
</CardDetailsExample>
|
|
163
|
+
),
|
|
164
|
+
parameters: {
|
|
165
|
+
docs: {
|
|
166
|
+
description: {
|
|
167
|
+
story:
|
|
168
|
+
'When no `children` are provided, `CardDetails` automatically renders `item.description` (or the `description` prop) with text-overflow ellipsis. Pass `children` to fully customize the description area.',
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const longDescriptionItems = [
|
|
175
|
+
{
|
|
176
|
+
id: '1',
|
|
177
|
+
name: 'Vintage Tube Amp',
|
|
178
|
+
description:
|
|
179
|
+
'Warm tube saturation, expressive dynamics, and gritty lead breakup',
|
|
180
|
+
avatar:
|
|
181
|
+
'https://storage.googleapis.com/moises-api-assets/voice/ana-avatar.jpg',
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
id: '2',
|
|
185
|
+
name: 'Modern Lead',
|
|
186
|
+
description:
|
|
187
|
+
'Warm tube saturation, expressive dynamics, and gritty lead breakup ... and a lot more text to make it really long',
|
|
188
|
+
avatar:
|
|
189
|
+
'https://storage.googleapis.com/moises-api-assets/voice/carrie-avatar.jpg',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
id: '3',
|
|
193
|
+
name: 'Crunch',
|
|
194
|
+
description: 'Short one',
|
|
195
|
+
avatar:
|
|
196
|
+
'https://storage.googleapis.com/moises-api-assets/voice/chris-avatar.jpg',
|
|
197
|
+
},
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
export const WithLongDescription = {
|
|
201
|
+
render: () => (
|
|
202
|
+
<CardDetailsExample title="Long description (truncated with ellipsis)">
|
|
203
|
+
{longDescriptionItems.map((item) => (
|
|
204
|
+
<ListCards.CardDetails
|
|
205
|
+
key={item.id}
|
|
206
|
+
item={item}
|
|
207
|
+
// onSeeDetails={() => console.log('See details clicked for', item.name)}
|
|
208
|
+
/>
|
|
209
|
+
))}
|
|
210
|
+
</CardDetailsExample>
|
|
211
|
+
),
|
|
212
|
+
parameters: {
|
|
213
|
+
docs: {
|
|
214
|
+
description: {
|
|
215
|
+
story:
|
|
216
|
+
'Long descriptions are clipped to a single line with `text-overflow: ellipsis` so the card height stays consistent (68px).',
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export const WithDescriptionProp = {
|
|
223
|
+
render: () => (
|
|
224
|
+
<CardDetailsExample title="Description rendered from the description prop">
|
|
225
|
+
{sampleItems.map((item) => (
|
|
226
|
+
<ListCards.CardDetails
|
|
227
|
+
key={item.id}
|
|
228
|
+
id={item.id}
|
|
229
|
+
name={item.name}
|
|
230
|
+
avatar={item.avatar}
|
|
231
|
+
description={item.description}
|
|
232
|
+
/>
|
|
233
|
+
))}
|
|
234
|
+
</CardDetailsExample>
|
|
235
|
+
),
|
|
236
|
+
parameters: {
|
|
237
|
+
docs: {
|
|
238
|
+
description: {
|
|
239
|
+
story:
|
|
240
|
+
'You can also pass `description` directly as a prop instead of using the `item` object.',
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
}
|
|
245
|
+
|
|
154
246
|
export const WithFavoriteButton = {
|
|
155
247
|
render: () => {
|
|
156
248
|
const [favoriteItems, setFavoriteItems] = useState(['1'])
|
|
@@ -131,6 +131,7 @@ const CardDetails = ({
|
|
|
131
131
|
className,
|
|
132
132
|
avatar,
|
|
133
133
|
name,
|
|
134
|
+
description,
|
|
134
135
|
id,
|
|
135
136
|
item,
|
|
136
137
|
favorite,
|
|
@@ -150,6 +151,7 @@ const CardDetails = ({
|
|
|
150
151
|
const itemId = item?.id || id
|
|
151
152
|
const itemName = item?.name || name
|
|
152
153
|
const itemAvatar = item?.avatar || avatar
|
|
154
|
+
const itemDescription = item?.description || description
|
|
153
155
|
|
|
154
156
|
// Extract the avatar URL from the pattern data URL
|
|
155
157
|
const avatarUrl =
|
|
@@ -176,7 +178,7 @@ const CardDetails = ({
|
|
|
176
178
|
style={{
|
|
177
179
|
'--color-surface': 'transparent',
|
|
178
180
|
width: '100%',
|
|
179
|
-
|
|
181
|
+
minHeight: '68px',
|
|
180
182
|
...style,
|
|
181
183
|
}}
|
|
182
184
|
{...props}
|
|
@@ -201,23 +203,38 @@ const CardDetails = ({
|
|
|
201
203
|
) : (
|
|
202
204
|
<Avatar src={avatarUrl} className={styles.listCardsAvatar} />
|
|
203
205
|
))}
|
|
204
|
-
<Flex
|
|
206
|
+
<Flex
|
|
207
|
+
direction="column"
|
|
208
|
+
justify="center"
|
|
209
|
+
style={{ flex: 1, minWidth: 0 }}
|
|
210
|
+
>
|
|
205
211
|
<Text as="div" size="2" className={styles.listCardsItemText}>
|
|
206
212
|
{itemName}
|
|
207
213
|
</Text>
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
214
|
+
{children ? (
|
|
215
|
+
<Flex
|
|
216
|
+
direction="row"
|
|
217
|
+
gap="1"
|
|
218
|
+
align="center"
|
|
219
|
+
style={{
|
|
220
|
+
flexWrap: 'nowrap',
|
|
221
|
+
overflow: 'hidden',
|
|
222
|
+
width: '100%',
|
|
223
|
+
whiteSpace: 'nowrap',
|
|
224
|
+
minWidth: 0,
|
|
225
|
+
}}
|
|
226
|
+
>
|
|
227
|
+
{children}
|
|
228
|
+
</Flex>
|
|
229
|
+
) : (
|
|
230
|
+
<Text
|
|
231
|
+
as="div"
|
|
232
|
+
size="1"
|
|
233
|
+
className={styles.listCardsItemDescriptionWrappable}
|
|
234
|
+
>
|
|
235
|
+
{itemDescription}
|
|
236
|
+
</Text>
|
|
237
|
+
)}
|
|
221
238
|
</Flex>
|
|
222
239
|
</Flex>
|
|
223
240
|
</RadioCards.Item>
|
|
@@ -230,10 +247,10 @@ const CardDetails = ({
|
|
|
230
247
|
onClick={
|
|
231
248
|
onAvatarClick
|
|
232
249
|
? (e) => {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
250
|
+
e.stopPropagation()
|
|
251
|
+
e.preventDefault()
|
|
252
|
+
onAvatarClick(e)
|
|
253
|
+
}
|
|
237
254
|
: undefined
|
|
238
255
|
}
|
|
239
256
|
>
|