Skip to content

Commit 917a0a2

Browse files
feat: updated to latest version
1 parent 72d0cb4 commit 917a0a2

File tree

81 files changed

+5213
-57
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+5213
-57
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import type { Meta, StoryObj } from '@storybook/nextjs';
2+
3+
import { Button } from '@dxp/ui/elements/button';
4+
5+
import { ActionList } from './ActionList';
6+
7+
const meta = {
8+
title: 'Components/ActionList',
9+
component: ActionList,
10+
tags: ['autodocs'],
11+
} satisfies Meta<typeof ActionList>;
12+
13+
export default meta;
14+
15+
type Story = StoryObj<typeof meta>;
16+
17+
export const Default: Story = {
18+
args: {
19+
showMoreLabel: 'Show more actions',
20+
triggerVariant: 'outline',
21+
actions: [
22+
<Button key="primary" variant="primary">
23+
Primary Action
24+
</Button>,
25+
<Button key="secondary" variant="secondary">
26+
Secondary Action
27+
</Button>,
28+
<Button key="tertiary1" variant="outline">
29+
Tertiary Action 1
30+
</Button>,
31+
<Button key="tertiary2" variant="ghost">
32+
Tertiary Action 2
33+
</Button>,
34+
],
35+
},
36+
};
37+
38+
export const SingleAction: Story = {
39+
args: {
40+
showMoreLabel: 'Show more actions',
41+
actions: [
42+
<Button key="primary" variant="primary">
43+
Single Action
44+
</Button>,
45+
],
46+
},
47+
};
48+
49+
export const TwoActions: Story = {
50+
args: {
51+
showMoreLabel: 'Show more actions',
52+
actions: [
53+
<Button key="primary" variant="primary">
54+
Primary Action
55+
</Button>,
56+
<Button key="secondary" variant="secondary">
57+
Secondary Action
58+
</Button>,
59+
],
60+
},
61+
};
62+
63+
export const WithDifferentVariant: Story = {
64+
args: {
65+
showMoreLabel: 'Show more actions',
66+
triggerVariant: 'destructive',
67+
actions: [
68+
<Button key="primary" variant="primary">
69+
Primary Action
70+
</Button>,
71+
<Button key="secondary" variant="secondary">
72+
Secondary Action
73+
</Button>,
74+
<Button key="tertiary1" variant="outline">
75+
Tertiary Action 1
76+
</Button>,
77+
<Button key="tertiary2" variant="ghost">
78+
Tertiary Action 2
79+
</Button>,
80+
],
81+
},
82+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import type { Meta, StoryObj } from '@storybook/nextjs';
2+
import React, { useEffect } from 'react';
3+
4+
import { useGlobalContext } from '@dxp/ui/providers/GlobalProvider';
5+
6+
import { AppSpinner } from './AppSpinner';
7+
8+
// Wrapper component to control the spinner visibility through props
9+
const AppSpinnerWrapper: React.FC<{ isVisible: boolean }> = ({ isVisible }) => {
10+
const { spinner } = useGlobalContext();
11+
12+
useEffect(() => {
13+
spinner.toggle(isVisible);
14+
}, [isVisible, spinner]);
15+
16+
return (
17+
<div className="h-screen w-screen space-y-4">
18+
<div className="p-4 bg-gray-100">Content behind the spinner</div>
19+
<div className="p-4 bg-gray-100">Content behind the spinner</div>
20+
<div className="p-4 bg-gray-100">Content behind the spinner</div>
21+
<div className="p-4 bg-gray-100">Content behind the spinner</div>
22+
<div className="p-4 bg-gray-100">Content behind the spinner</div>
23+
<div className="p-4 bg-gray-100">Content behind the spinner</div>
24+
<AppSpinner />
25+
</div>
26+
);
27+
};
28+
29+
const meta = {
30+
title: 'Components/AppSpinner',
31+
component: AppSpinnerWrapper,
32+
tags: ['autodocs'],
33+
parameters: {
34+
layout: 'fullscreen',
35+
},
36+
} satisfies Meta<typeof AppSpinnerWrapper>;
37+
38+
export default meta;
39+
40+
type Story = StoryObj<typeof meta>;
41+
42+
export const Default: Story = {
43+
args: {
44+
isVisible: true,
45+
},
46+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import type { Meta, StoryObj } from '@storybook/nextjs';
2+
3+
import { Author } from './Author';
4+
5+
const meta = {
6+
title: 'Components/Author',
7+
component: Author,
8+
tags: ['autodocs'],
9+
} satisfies Meta<typeof Author>;
10+
11+
export default meta;
12+
13+
type Story = StoryObj<typeof meta>;
14+
15+
export const Default: Story = {
16+
args: {
17+
name: 'John Doe',
18+
avatar: 'https://github.com/shadcn.png',
19+
position: 'Software Engineer',
20+
},
21+
};
22+
23+
export const WithoutAvatar: Story = {
24+
args: {
25+
name: 'Jane Smith',
26+
position: 'Product Manager',
27+
},
28+
};
29+
30+
export const WithoutPosition: Story = {
31+
args: {
32+
name: 'Alex Johnson',
33+
avatar: 'https://github.com/shadcn.png',
34+
},
35+
};
36+
37+
export const NameOnly: Story = {
38+
args: {
39+
name: 'Sam Wilson',
40+
},
41+
};
42+
43+
export const LongName: Story = {
44+
args: {
45+
name: 'Alexandra Johnson-Williams',
46+
avatar: 'https://github.com/shadcn.png',
47+
position: 'Senior Software Engineer',
48+
},
49+
};
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import type { Meta, StoryObj } from '@storybook/nextjs';
2+
3+
import { Autocomplete } from './Autocomplete';
4+
5+
// Define a sample suggestion type
6+
type SampleSuggestion = {
7+
id: string;
8+
name: string;
9+
description?: string;
10+
};
11+
12+
// Sample data
13+
const sampleSuggestions: SampleSuggestion[] = [
14+
{ id: '1', name: 'Apple', description: 'A fruit' },
15+
{ id: '2', name: 'Banana', description: 'A yellow fruit' },
16+
{ id: '3', name: 'Cherry', description: 'A red fruit' },
17+
{ id: '4', name: 'Date', description: 'A sweet fruit' },
18+
{ id: '5', name: 'Elderberry', description: 'A purple berry' },
19+
{ id: '6', name: 'Fig', description: 'A sweet fruit' },
20+
{ id: '7', name: 'Grape', description: 'A small fruit' },
21+
{ id: '8', name: 'Honeydew', description: 'A melon' },
22+
];
23+
24+
const meta = {
25+
title: 'Components/Autocomplete',
26+
component: Autocomplete<SampleSuggestion>,
27+
tags: ['autodocs'],
28+
parameters: {
29+
layout: 'centered',
30+
},
31+
} satisfies Meta<typeof Autocomplete<SampleSuggestion>>;
32+
33+
export default meta;
34+
35+
type Story = StoryObj<typeof meta>;
36+
37+
// Default story
38+
export const Default: Story = {
39+
args: {
40+
label: 'Fruit',
41+
placeholder: 'Search for a fruit...',
42+
emptyMessage: 'No fruits found',
43+
suggestions: sampleSuggestions,
44+
getSuggestionValue: (suggestion: SampleSuggestion) => suggestion.name,
45+
onRenderSuggestion: (suggestion: SampleSuggestion) => (
46+
<div>
47+
<div className="font-medium">{suggestion.name}</div>
48+
{suggestion.description && (
49+
<div className="text-sm text-muted-foreground">{suggestion.description}</div>
50+
)}
51+
</div>
52+
),
53+
},
54+
};
55+
56+
// Loading state
57+
export const Loading: Story = {
58+
args: {
59+
...Default.args,
60+
isLoading: true,
61+
suggestions: [],
62+
},
63+
};
64+
65+
// Empty state
66+
export const Empty: Story = {
67+
args: {
68+
...Default.args,
69+
suggestions: [],
70+
},
71+
};
72+
73+
// Disabled state
74+
export const Disabled: Story = {
75+
args: {
76+
...Default.args,
77+
disabled: true,
78+
},
79+
};
80+
81+
// With hidden label
82+
export const HiddenLabel: Story = {
83+
args: {
84+
...Default.args,
85+
labelHidden: true,
86+
},
87+
};
88+
89+
// With pre-selected value
90+
export const WithValue: Story = {
91+
args: {
92+
...Default.args,
93+
value: sampleSuggestions[0],
94+
},
95+
};
96+
97+
// With custom minimum length
98+
export const CustomMinLength: Story = {
99+
args: {
100+
...Default.args,
101+
minLength: 1,
102+
},
103+
};

packages/ui/src/components/Autocomplete/Autocomplete.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import { Command as CommandPrimitive } from 'cmdk';
4-
import { type KeyboardEvent, useCallback, useRef, useState } from 'react';
4+
import React, { type KeyboardEvent, useCallback, useRef, useState } from 'react';
55

66
import { cn } from '@dxp/ui/lib/utils';
77

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Models as FrontendModels } from '@dxp/utils.frontend';
2+
import type { Meta, StoryObj } from '@storybook/nextjs';
3+
import React from 'react';
4+
5+
import { Breadcrumbs } from './Breadcrumbs';
6+
import { BreadcrumbItem } from './Breadcrumbs.types';
7+
8+
// Mock LinkComponent for stories
9+
const MockLinkComponent: FrontendModels.Link.LinkComponent = ({ href, className, children }) => (
10+
<a href={href} className={className}>
11+
{children}
12+
</a>
13+
);
14+
15+
const meta = {
16+
title: 'Components/Breadcrumbs',
17+
component: Breadcrumbs,
18+
tags: ['autodocs'],
19+
} satisfies Meta<typeof Breadcrumbs>;
20+
21+
export default meta;
22+
23+
type Story = StoryObj<typeof meta>;
24+
25+
// Sample breadcrumb items
26+
const sampleBreadcrumbs: BreadcrumbItem[] = [
27+
{ label: 'Home', slug: '/' },
28+
{ label: 'Products', slug: '/products' },
29+
{ label: 'Categories', slug: '/products/categories' },
30+
{ label: 'Current Page' },
31+
];
32+
33+
export const Default: Story = {
34+
args: {
35+
breadcrumbs: sampleBreadcrumbs,
36+
LinkComponent: MockLinkComponent,
37+
},
38+
};
39+
40+
export const SingleItem: Story = {
41+
args: {
42+
breadcrumbs: [{ label: 'Current Page' }],
43+
LinkComponent: MockLinkComponent,
44+
},
45+
};
46+
47+
export const TwoItems: Story = {
48+
args: {
49+
breadcrumbs: [{ label: 'Home', slug: '/' }, { label: 'Current Page' }],
50+
LinkComponent: MockLinkComponent,
51+
},
52+
};
53+
54+
export const WithoutSlugs: Story = {
55+
args: {
56+
breadcrumbs: [{ label: 'Home' }, { label: 'Products' }, { label: 'Current Page' }],
57+
LinkComponent: MockLinkComponent,
58+
},
59+
};

0 commit comments

Comments
 (0)