@dust-tt/sparkle 0.4.2 → 0.4.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.
@@ -43,6 +43,10 @@ const meta = {
43
43
  control: "text",
44
44
  description: "Additional CSS classes to apply",
45
45
  },
46
+ selected: {
47
+ control: "boolean",
48
+ description: "Visually highlight the card as selected",
49
+ },
46
50
  children: {
47
51
  control: "text",
48
52
  description: "Content to display inside the card",
@@ -58,6 +62,7 @@ export const Playground: Story = {
58
62
  variant: "primary",
59
63
  size: "md",
60
64
  disabled: false,
65
+ selected: false,
61
66
  children: "Card Content",
62
67
  },
63
68
  render: (args) => <Card {...args} />,
@@ -96,6 +101,15 @@ export const DisabledCard: Story = {
96
101
  },
97
102
  };
98
103
 
104
+ export const SelectedCard: Story = {
105
+ args: {
106
+ variant: "secondary",
107
+ size: "md",
108
+ selected: true,
109
+ children: "Selected Card",
110
+ },
111
+ };
112
+
99
113
  export const AllVariants: Story = {
100
114
  render: () => {
101
115
  const variants = CARD_VARIANTS;
@@ -221,3 +235,65 @@ export const WithActions: Story = {
221
235
  </CardGrid>
222
236
  ),
223
237
  };
238
+
239
+ export const SelectableGrid: Story = {
240
+ render: () => {
241
+ const [selected, setSelected] = React.useState(0);
242
+
243
+ return (
244
+ <CardGrid>
245
+ {cardData.slice(0, 4).map((card, index) => (
246
+ <Card
247
+ key={card.title}
248
+ variant="primary"
249
+ size="md"
250
+ selected={selected === index}
251
+ onClick={() => setSelected(index)}
252
+ action={<CardActionButton size="mini" icon={XMarkIcon} />}
253
+ >
254
+ <div className="s-flex s-w-full s-flex-col s-gap-1 s-text-sm">
255
+ <div className="s-flex s-w-full s-gap-1 s-font-semibold s-text-foreground">
256
+ <Icon visual={card.icon} size="sm" />
257
+ <div className="s-w-full">{card.title}</div>
258
+ </div>
259
+ <div className="s-w-full s-truncate s-text-sm s-text-muted-foreground">
260
+ {card.description}
261
+ </div>
262
+ </div>
263
+ </Card>
264
+ ))}
265
+ </CardGrid>
266
+ );
267
+ },
268
+ };
269
+
270
+ export const DualSelectable: Story = {
271
+ render: () => {
272
+ const [selectedIndex, setSelectedIndex] = React.useState(0);
273
+ const duoCards = cardData.slice(0, 2);
274
+
275
+ return (
276
+ <div className="s-flex s-gap-4">
277
+ {duoCards.map((card, index) => (
278
+ <Card
279
+ key={card.title}
280
+ variant="secondary"
281
+ size="md"
282
+ selected={selectedIndex === index}
283
+ onClick={() => setSelectedIndex(index)}
284
+ >
285
+ <div className="s-flex s-w-full s-flex-col s-gap-1 s-text-sm">
286
+ <div className="s-flex s-w-full s-gap-1 s-font-semibold s-text-foreground">
287
+ <Icon visual={card.icon} size="sm" />
288
+ <div className="s-w-full">{card.title}</div>
289
+ </div>
290
+ <div className="s-w-full s-truncate s-text-sm s-text-muted-foreground">
291
+ {card.description}
292
+ </div>
293
+ </div>
294
+ </Card>
295
+ ))}
296
+ </div>
297
+ );
298
+ },
299
+ };