Skip to content

Commit ca751e2

Browse files
Add Storybook stories for all components and hooks (#397)
* Initial plan * Add Storybook stories for all components and hook MDX docs Agent-Logs-Url: https://github.com/linn/react-components-library/sessions/9a479ef6-d099-463a-8484-230d8cde1bac Co-authored-by: lewisrenfrew <16683709+lewisrenfrew@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lewisrenfrew <16683709+lewisrenfrew@users.noreply.github.com>
1 parent def0b63 commit ca751e2

24 files changed

Lines changed: 1408 additions & 2 deletions

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { fn } from 'storybook/test';
2+
import BackButton from './BackButton';
3+
4+
export default {
5+
title: 'Components/BackButton',
6+
component: BackButton,
7+
tags: ['autodocs'],
8+
args: {
9+
backClick: fn()
10+
}
11+
};
12+
13+
export const Default = {};
14+
15+
export const CustomText = {
16+
name: 'Custom text',
17+
args: {
18+
text: 'Go Back'
19+
}
20+
};
21+
22+
export const LongCustomText = {
23+
name: 'Long custom text',
24+
args: {
25+
text: 'Return to previous page'
26+
}
27+
};
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { fn } from 'storybook/test';
2+
import Breadcrumbs from './Breadcrumbs';
3+
4+
export default {
5+
title: 'Components/Breadcrumbs',
6+
component: Breadcrumbs,
7+
tags: ['autodocs'],
8+
args: {
9+
navigate: fn(),
10+
homeUrl: 'https://app.linn.co.uk',
11+
rootPathLength: 2,
12+
location: { pathname: '/purchasing/orders/12345' }
13+
}
14+
};
15+
16+
export const Default = {};
17+
18+
export const ShallowPath = {
19+
name: 'Shallow path',
20+
args: {
21+
location: { pathname: '/products' }
22+
}
23+
};
24+
25+
export const DeepPath = {
26+
name: 'Deep path',
27+
args: {
28+
location: { pathname: '/manufacturing/works-orders/12345/operations' }
29+
}
30+
};
31+
32+
export const TrailingSlash = {
33+
name: 'Trailing slash (normalised)',
34+
args: {
35+
location: { pathname: '/sales/invoices/' }
36+
}
37+
};
38+
39+
export const CustomHomeUrl = {
40+
name: 'Custom home URL',
41+
args: {
42+
homeUrl: 'https://internal.example.com',
43+
location: { pathname: '/admin/settings' }
44+
}
45+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { fn } from 'storybook/test';
2+
import CheckboxWithLabel from './CheckboxWithLabel';
3+
4+
export default {
5+
title: 'Components/CheckboxWithLabel',
6+
component: CheckboxWithLabel,
7+
tags: ['autodocs'],
8+
args: {
9+
onChange: fn(),
10+
label: 'Accept terms and conditions',
11+
checked: false,
12+
color: 'primary'
13+
}
14+
};
15+
16+
export const Default = {};
17+
18+
export const Checked = {
19+
args: {
20+
checked: true,
21+
label: 'Subscribe to newsletter'
22+
}
23+
};
24+
25+
export const Unchecked = {
26+
args: {
27+
checked: false,
28+
label: 'Subscribe to newsletter'
29+
}
30+
};
31+
32+
export const SecondaryColour = {
33+
name: 'Secondary colour',
34+
args: {
35+
checked: true,
36+
color: 'secondary',
37+
label: 'Secondary checkbox'
38+
}
39+
};
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { fn } from 'storybook/test';
2+
import ConfirmDialog from './ConfirmDialog';
3+
4+
export default {
5+
title: 'Components/ConfirmDialog',
6+
component: ConfirmDialog,
7+
tags: ['autodocs'],
8+
args: {
9+
closeDialog: fn(),
10+
onConfirm: fn(),
11+
onCancel: fn(),
12+
visible: true,
13+
title: 'Are you sure?',
14+
primaryText: 'This action cannot be undone.',
15+
secondaryText: null,
16+
confirmButtonText: 'Confirm',
17+
cancelButtonText: 'Cancel',
18+
maxWidth: 'md'
19+
}
20+
};
21+
22+
export const Default = {};
23+
24+
export const WithSecondaryText = {
25+
name: 'With secondary text',
26+
args: {
27+
primaryText: 'You are about to delete this record.',
28+
secondaryText: 'All associated data will be permanently removed.'
29+
}
30+
};
31+
32+
export const DeleteConfirmation = {
33+
name: 'Delete confirmation',
34+
args: {
35+
title: 'Delete record?',
36+
primaryText: 'Are you sure you want to delete this item?',
37+
secondaryText: 'This action is permanent and cannot be reversed.',
38+
confirmButtonText: 'Delete',
39+
cancelButtonText: 'Keep'
40+
}
41+
};
42+
43+
export const Closed = {
44+
args: {
45+
visible: false
46+
}
47+
};
48+
49+
export const NarrowWidth = {
50+
name: 'Narrow width',
51+
args: {
52+
maxWidth: 'sm',
53+
primaryText: 'Confirm this action.'
54+
}
55+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { MemoryRouter } from 'react-router-dom';
2+
import CreateButton from './CreateButton';
3+
4+
export default {
5+
title: 'Components/CreateButton',
6+
component: CreateButton,
7+
tags: ['autodocs'],
8+
decorators: [
9+
Story => (
10+
<MemoryRouter>
11+
<Story />
12+
</MemoryRouter>
13+
)
14+
],
15+
args: {
16+
createUrl: '/items/create',
17+
disabled: false
18+
}
19+
};
20+
21+
export const Default = {};
22+
23+
export const Disabled = {
24+
args: {
25+
disabled: true
26+
}
27+
};
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { fn } from 'storybook/test';
2+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
3+
import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
4+
import DatePicker from './DatePicker';
5+
6+
export default {
7+
title: 'Components/DatePicker',
8+
component: DatePicker,
9+
tags: ['autodocs'],
10+
decorators: [
11+
Story => (
12+
<LocalizationProvider dateAdapter={AdapterMoment}>
13+
<Story />
14+
</LocalizationProvider>
15+
)
16+
],
17+
args: {
18+
onChange: fn(),
19+
label: 'Select date',
20+
value: '2025-06-15T00:00:00.000Z',
21+
disabled: false,
22+
required: false,
23+
minDate: null,
24+
maxDate: null
25+
}
26+
};
27+
28+
export const Default = {};
29+
30+
export const WithLabel = {
31+
name: 'With label',
32+
args: {
33+
label: 'Date of Birth',
34+
value: '1990-03-22T00:00:00.000Z'
35+
}
36+
};
37+
38+
export const Required = {
39+
args: {
40+
label: 'Required Date',
41+
required: true
42+
}
43+
};
44+
45+
export const Disabled = {
46+
args: {
47+
label: 'Read-only Date',
48+
disabled: true,
49+
value: '2024-01-01T00:00:00.000Z'
50+
}
51+
};
52+
53+
export const WithMinMaxDate = {
54+
name: 'With min/max date',
55+
args: {
56+
label: 'Restricted Date',
57+
minDate: '2025-01-01T00:00:00.000Z',
58+
maxDate: '2025-12-31T00:00:00.000Z',
59+
value: '2025-06-15T00:00:00.000Z'
60+
}
61+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { fn } from 'storybook/test';
2+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
3+
import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
4+
import DateTimePicker from './DateTimePicker';
5+
6+
export default {
7+
title: 'Components/DateTimePicker',
8+
component: DateTimePicker,
9+
tags: ['autodocs'],
10+
decorators: [
11+
Story => (
12+
<LocalizationProvider dateAdapter={AdapterMoment}>
13+
<Story />
14+
</LocalizationProvider>
15+
)
16+
],
17+
args: {
18+
onChange: fn(),
19+
label: 'Select date and time',
20+
value: '2025-06-15T14:30:00.000Z',
21+
disabled: false,
22+
required: false
23+
}
24+
};
25+
26+
export const Default = {};
27+
28+
export const WithLabel = {
29+
name: 'With label',
30+
args: {
31+
label: 'Appointment Date & Time',
32+
value: '2025-09-01T09:00:00.000Z'
33+
}
34+
};
35+
36+
export const Required = {
37+
args: {
38+
label: 'Required Date & Time',
39+
required: true
40+
}
41+
};
42+
43+
export const Disabled = {
44+
args: {
45+
label: 'Read-only Date & Time',
46+
disabled: true,
47+
value: '2024-12-25T12:00:00.000Z'
48+
}
49+
};

0 commit comments

Comments
 (0)