Skip to content

Commit 5fbff0a

Browse files
docs: add Storybook MDX docs for 8 undocumented hooks (#398)
* Initial plan * Initial plan * docs: add MDX documentation for 8 missing hooks Agent-Logs-Url: https://github.com/linn/react-components-library/sessions/20d84e38-5ee4-43e2-bd9b-7174d48bf428 Co-authored-by: lewisrenfrew <16683709+lewisrenfrew@users.noreply.github.com> * Add missing Storybook stories for 13 components Agent-Logs-Url: https://github.com/linn/react-components-library/sessions/50babd49-3d47-4790-8207-8b4ca1b63fee 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 ca751e2 commit 5fbff0a

21 files changed

Lines changed: 1514 additions & 0 deletions
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { MemoryRouter } from 'react-router-dom';
2+
import { fn } from 'storybook/test';
3+
import AddressUtility from './AddressUtility';
4+
5+
const sampleCountries = [
6+
{ id: 'GB', name: 'United Kingdom', countryCode: 'GB', countryName: 'United Kingdom' },
7+
{ id: 'US', name: 'United States', countryCode: 'US', countryName: 'United States' },
8+
{ id: 'DE', name: 'Germany', countryCode: 'DE', countryName: 'Germany' }
9+
];
10+
11+
const sampleAddresses = [
12+
{
13+
id: 1,
14+
name: '1 Linn Products Way',
15+
description: 'Glasgow, G76 0EQ',
16+
addressId: 1,
17+
postCode: 'G76 0EQ',
18+
countryCode: 'GB',
19+
href: '/addresses/1'
20+
}
21+
];
22+
23+
export default {
24+
title: 'Components/AddressUtility',
25+
component: AddressUtility,
26+
tags: ['autodocs'],
27+
decorators: [
28+
Story => (
29+
<MemoryRouter>
30+
<Story />
31+
</MemoryRouter>
32+
)
33+
],
34+
args: {
35+
createAddress: fn(),
36+
createAddressLoading: false,
37+
selectAddress: fn(),
38+
searchCountries: fn(),
39+
searchAddresses: fn(),
40+
countriesSearchResults: [],
41+
countriesSearchLoading: false,
42+
addressSearchResults: [],
43+
addressSearchLoading: false,
44+
clearAddressesSearch: fn(),
45+
clearCountriesSearch: fn(),
46+
defaultAddressee: false,
47+
isActive: false,
48+
setIsActive: fn()
49+
}
50+
};
51+
52+
export const Default = {};
53+
54+
export const DialogOpen = {
55+
name: 'Dialog open',
56+
args: {
57+
isActive: true
58+
}
59+
};
60+
61+
export const WithCountryResults = {
62+
name: 'Dialog open with country results',
63+
args: {
64+
isActive: true,
65+
countriesSearchResults: sampleCountries
66+
}
67+
};
68+
69+
export const WithAddressResults = {
70+
name: 'Dialog open with address results',
71+
args: {
72+
isActive: true,
73+
addressSearchResults: sampleAddresses
74+
}
75+
};
76+
77+
export const LoadingAddress = {
78+
name: 'Loading address creation',
79+
args: {
80+
isActive: true,
81+
createAddressLoading: true
82+
}
83+
};
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { MemoryRouter } from 'react-router-dom';
2+
import { fn } from 'storybook/test';
3+
import EntityList from './EntityList';
4+
5+
const sampleEntities = [
6+
{ id: 1, name: 'Widget A', href: '/products/1' },
7+
{ id: 2, name: 'Widget B', href: '/products/2' },
8+
{ id: 3, name: 'Gadget Pro', href: '/products/3' }
9+
];
10+
11+
const entitiesWithDescription = [
12+
{ id: 'WA', description: 'Widest widget', href: '/products/WA' },
13+
{ id: 'WB', description: 'Mid-range widget', href: '/products/WB' },
14+
{ id: 'GP', description: 'Professional gadget', href: '/products/GP' }
15+
];
16+
17+
export default {
18+
title: 'Components/EntityList',
19+
component: EntityList,
20+
tags: ['autodocs'],
21+
decorators: [
22+
Story => (
23+
<MemoryRouter>
24+
<Story />
25+
</MemoryRouter>
26+
)
27+
],
28+
args: {
29+
title: 'Products',
30+
entityList: sampleEntities,
31+
entityId: 'id',
32+
descriptionFieldName: null,
33+
hasExternalLinks: false
34+
}
35+
};
36+
37+
export const Default = {};
38+
39+
export const WithDescriptions = {
40+
name: 'With description field',
41+
args: {
42+
entityList: entitiesWithDescription,
43+
entityId: 'id',
44+
descriptionFieldName: 'description'
45+
}
46+
};
47+
48+
export const ExternalLinks = {
49+
name: 'External links',
50+
args: {
51+
hasExternalLinks: true
52+
}
53+
};
54+
55+
export const NoTitle = {
56+
name: 'No title',
57+
args: {
58+
title: ''
59+
}
60+
};
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 FileUploader from './FileUploader';
3+
4+
export default {
5+
title: 'Components/FileUploader',
6+
component: FileUploader,
7+
tags: ['autodocs'],
8+
args: {
9+
title: 'File Uploader',
10+
helperText: 'Upload a File',
11+
initiallyExpanded: true,
12+
loading: false,
13+
result: null,
14+
snackbarVisible: false,
15+
setSnackbarVisible: fn(),
16+
onFileSelect: fn(),
17+
doUpload: fn()
18+
}
19+
};
20+
21+
export const Default = {};
22+
23+
export const Collapsed = {
24+
args: {
25+
initiallyExpanded: false
26+
}
27+
};
28+
29+
export const Loading = {
30+
args: {
31+
loading: true
32+
}
33+
};
34+
35+
export const WithError = {
36+
name: 'Upload error',
37+
args: {
38+
result: {
39+
success: false,
40+
message: 'File upload failed',
41+
errors: [
42+
{ descriptor: 'Row 1', message: 'Invalid format' },
43+
{ descriptor: 'Row 2', message: 'Missing required field' }
44+
]
45+
}
46+
}
47+
};
48+
49+
export const CustomTitle = {
50+
name: 'Custom title and helper text',
51+
args: {
52+
title: 'Import CSV',
53+
helperText: 'Select a CSV file to import records'
54+
}
55+
};
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { MemoryRouter } from 'react-router-dom';
2+
import LinkField from './LinkField';
3+
4+
export default {
5+
title: 'Components/LinkField',
6+
component: LinkField,
7+
tags: ['autodocs'],
8+
decorators: [
9+
Story => (
10+
<MemoryRouter>
11+
<Story />
12+
</MemoryRouter>
13+
)
14+
],
15+
args: {
16+
value: 'View product details',
17+
to: 'https://example.com/products/123',
18+
external: true,
19+
openLinksInNewTabs: false,
20+
disabled: false,
21+
label: '',
22+
shouldRender: true
23+
}
24+
};
25+
26+
export const Default = {};
27+
28+
export const WithLabel = {
29+
name: 'With label',
30+
args: {
31+
label: 'Product Link',
32+
value: 'Widget A'
33+
}
34+
};
35+
36+
export const OpenInNewTab = {
37+
name: 'Open in new tab',
38+
args: {
39+
openLinksInNewTabs: true,
40+
value: 'External resource'
41+
}
42+
};
43+
44+
export const Disabled = {
45+
args: {
46+
disabled: true,
47+
value: 'Disabled link text'
48+
}
49+
};
50+
51+
export const NotRendered = {
52+
name: 'Not rendered',
53+
args: {
54+
shouldRender: false,
55+
value: 'This should not appear'
56+
}
57+
};
58+
59+
export const InternalLink = {
60+
name: 'Internal link (router)',
61+
args: {
62+
external: false,
63+
to: '/products/123',
64+
value: 'View product'
65+
}
66+
};
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import { SnackbarProvider } from 'notistack';
2+
import { fn } from 'storybook/test';
3+
import Navigation from './Navigation';
4+
5+
const sampleSections = [
6+
{
7+
id: 'purchasing',
8+
title: 'Purchasing',
9+
columns: [
10+
{
11+
categories: [
12+
{
13+
title: 'Purchase Orders',
14+
items: [
15+
{ title: 'Create PO', href: '#', showInMenu: true },
16+
{ title: 'View POs', href: '#', showInMenu: true }
17+
]
18+
},
19+
{
20+
title: 'Suppliers',
21+
items: [
22+
{ title: 'Supplier List', href: '#', showInMenu: true },
23+
{ title: 'Add Supplier', href: '#', showInMenu: true }
24+
]
25+
}
26+
]
27+
}
28+
]
29+
},
30+
{
31+
id: 'sales',
32+
title: 'Sales',
33+
columns: [
34+
{
35+
categories: [
36+
{
37+
title: 'Orders',
38+
items: [
39+
{ title: 'Sales Orders', href: '#', showInMenu: true },
40+
{ title: 'Invoices', href: '#', showInMenu: true }
41+
]
42+
}
43+
]
44+
}
45+
]
46+
}
47+
];
48+
49+
const sampleMyStuff = {
50+
groups: [
51+
{
52+
items: [{ title: 'My Profile', href: '#/profile' }]
53+
},
54+
{
55+
items: [{ title: 'My Settings', href: '#/settings' }]
56+
}
57+
]
58+
};
59+
60+
export default {
61+
title: 'Components/Navigation',
62+
component: Navigation,
63+
tags: ['autodocs'],
64+
decorators: [
65+
Story => (
66+
<SnackbarProvider maxSnack={3}>
67+
<div style={{ height: '200px' }}>
68+
<Story />
69+
</div>
70+
</SnackbarProvider>
71+
)
72+
],
73+
args: {
74+
sections: sampleSections,
75+
loading: false,
76+
username: 'jsmith',
77+
myStuff: sampleMyStuff,
78+
notifications: [],
79+
handleSignOut: fn()
80+
}
81+
};
82+
83+
export const Default = {};
84+
85+
export const Loading = {
86+
args: {
87+
loading: true
88+
}
89+
};
90+
91+
export const WithNotifications = {
92+
name: 'With notifications',
93+
args: {
94+
notifications: [
95+
{ title: 'Order Approved', content: 'PO-12345 has been approved' },
96+
{ title: 'Low Stock Alert', content: 'Widget A is running low' }
97+
]
98+
}
99+
};
100+
101+
export const NoSections = {
102+
name: 'No sections (empty bar)',
103+
args: {
104+
sections: null
105+
}
106+
};

src/components/NotFound.stories.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import NotFound from './NotFound';
2+
3+
export default {
4+
title: 'Components/NotFound',
5+
component: NotFound,
6+
tags: ['autodocs']
7+
};
8+
9+
export const Default = {};

0 commit comments

Comments
 (0)