Skip to content

Commit d9c1270

Browse files
author
Nikolai Lopin
committed
docs: move accordion stories to the accordion folder
1 parent f3cd48e commit d9c1270

File tree

5 files changed

+85
-62
lines changed

5 files changed

+85
-62
lines changed

src/components/Accordion/Accordion.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { ReactElement } from 'react';
1+
import React, { PropsWithChildren } from 'react';
22
import styled from 'styled-components';
33

44
import { SemanticColors } from '../../essentials';
@@ -24,7 +24,7 @@ const RenderedSection = styled(Box)`
2424
}
2525
`;
2626

27-
const Accordion = ({
27+
const Accordion: React.FC<PropsWithChildren<AccordionProps>> = ({
2828
heading,
2929
description,
3030
info,
@@ -34,7 +34,7 @@ const Accordion = ({
3434
children,
3535
onExpand = () => undefined,
3636
onCollapse = () => undefined
37-
}: AccordionProps): ReactElement => (
37+
}) => (
3838
<RenderedSection role="group">
3939
<HorizontalDividerTop />
4040
{variant === 'compact' ? (
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from 'react';
2+
import { StoryObj, Meta } from '@storybook/react';
3+
import { Accordion } from '../Accordion';
4+
5+
const meta: Meta<typeof Accordion> = {
6+
title: 'Components/Accordion',
7+
component: Accordion,
8+
args: {
9+
heading: 'Driver Comments',
10+
children: 'This is a very long text we need to hide',
11+
description: 'Comments about the driver left by passengers'
12+
},
13+
argTypes: {
14+
children: {
15+
description: 'Accordion content'
16+
},
17+
variant: {
18+
options: ['default', 'compact'],
19+
control: { type: 'radio' }
20+
}
21+
}
22+
};
23+
24+
export default meta;
25+
26+
type Story = StoryObj<typeof Accordion>;
27+
28+
export const Default: Story = {
29+
args: {
30+
info: '99+ comments',
31+
buttonLabel: 'Expand/Collapse'
32+
}
33+
};
34+
35+
export const Compact: Story = {
36+
args: {
37+
variant: 'compact'
38+
}
39+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Meta, ArgsTable, Primary, Stories } from '@storybook/blocks';
2+
import * as AccordionStories from './Accordion.stories';
3+
import { Accordion } from '../Accordion';
4+
5+
<Meta of={AccordionStories} />
6+
7+
# Accordion
8+
9+
Accordion component is used to display large amount of content in a compress and progressive way.
10+
11+
<Primary />
12+
13+
## Properties
14+
15+
<ArgsTable story="Default" />
16+
17+
<Stories includePrimary={false} />

src/components/Accordion/types.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
1-
import { ReactNode } from 'react';
2-
31
export interface AccordionProps {
2+
/**
3+
* Heading of the Accordion section
4+
*/
45
heading?: string;
6+
/**
7+
* Description of the section
8+
*/
59
description?: string;
10+
/**
11+
* Extra text below description
12+
*/
613
info?: string;
14+
/**
15+
* Text on the button
16+
*/
717
buttonLabel?: string;
18+
/**
19+
* UI style
20+
* @default default
21+
*/
822
variant?: 'compact' | 'default';
23+
/**
24+
* Render accordion initially opened
25+
* @default false
26+
*/
927
defaultExpanded?: boolean;
10-
children: ReactNode;
28+
/**
29+
* Callback, runs after the accordion is opened
30+
*/
1131
onExpand?: () => void;
32+
/**
33+
* Callback, runs after the accordion is closed
34+
*/
1235
onCollapse?: () => void;
1336
}

src/stories/components/Accordion.stories.tsx

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)