File size: 1,948 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { Meta, StoryObj } from '@storybook/react';
import { Breadcrumbs } from './';

const meta: Meta< typeof Breadcrumbs > = {
	title: 'Breadcrumbs',
	component: Breadcrumbs,
	tags: [ 'autodocs' ],
	parameters: {
		actions: { argTypesRegex: '^on.*' },
		// Prevent flickering + automatic menu closing in compact mode.
		layout: 'fullscreen',
	},
	decorators: [
		( Story ) => (
			<div style={ { paddingInlineStart: '1rem', paddingBlockStart: '1rem' } }>
				<Story />
			</div>
		),
	],
};

export default meta;
type Story = StoryObj< typeof Breadcrumbs >;

export const Default: Story = {
	args: {
		items: [
			{ label: 'Home', href: 'javascript:void(0)' },
			{ label: 'Products', href: 'javascript:void(0)' },
			{ label: 'Electronics', href: 'javascript:void(0)' },
			{ label: 'Computers', href: 'javascript:void(0)' },
		],
	},
};

export const WithCurrentItemVisible: Story = {
	args: {
		...Default.args,
		showCurrentItem: true,
	},
};

export const WithLongPath: Story = {
	args: {
		...Default.args,
		items: [
			{ label: 'Home', href: 'javascript:void(0)' },
			{ label: 'Products', href: 'javascript:void(0)' },
			{ label: 'Electronics', href: 'javascript:void(0)' },
			{ label: 'Computers', href: 'javascript:void(0)' },
			{ label: 'Laptops', href: 'javascript:void(0)' },
			{ label: 'Gaming', href: 'javascript:void(0)' },
			{ label: '17 inch', href: 'javascript:void(0)' },
			{
				label: 'Alienware X17',
				href: 'javascript:void(0)',
			},
		],
	},
};

export const WithCustomItem: Story = {
	args: {
		...Default.args,
		renderItemLink: ( { label, href, ...props } ) => {
			const onClick = ( event: React.MouseEvent< HTMLAnchorElement > ) => {
				props.onClick?.( event );
				event.preventDefault();
				// eslint-disable-next-line no-console
				console.log( `Router navigation to ${ label }` );
			};

			return (
				<a href={ href } { ...props } onClick={ onClick }>
					{ label }
				</a>
			);
		},
	},
};