Skip to content

Commit 362adc7

Browse files
Nikolai Lopinnlopin
Nikolai Lopin
authored andcommitted
docs: use helper for dark background (+43 squashed commits)
Squashed commits: [878b4fa] docs: polish docs [f85e0c6] docs: use consistent stories import [fb1df67] docs: use ArgTypes for table ArgsTable is deprecated [3f38897] docs: migrate Pagination docs to csf3 [225584e] docs: migrate SelectList docs to csf3 [54ca704] docs: align naming of doc pages [74e8eab] docs: migrate Select docs to csf3 [87e0c69] docs: migrate Skeleton docs to csf3 [eeec04e] docs: migrate FilePicker docs to csf3 [2a3d688] docs: migrate Offcanvas docs to csf3 [5bb2814] docs: migrate PhoneInput docs to csf3 [c89f128] docs: migrate RadioButton docs to csf3 [a97cdd9] docs: migrate TabBar docs to csf3 [1d40058] docs: migrate Password docs to csf3 [4f53305] docs: show Text default values [663a8c8] docs: migrate Text docs to csf3 [0fa46b1] docs: migrate Textarea docs to csf3 [87e40ad] docs: migrate Toggle docs to csf3 [09673a9] docs: migrate Tooltip docs to csf3 [d564c88] docs: migrate Modal docs to csf3 [b724948] docs: migrate Tag docs to csf3 [7ef196a] docs: migrate Link docs to csf3 [aa0312e] docs: migrate Label docs to csf3 [8902acc] docs: migrate Popover docs to csf3 [5f31507] docs: migrate Input docs to csf3 [a8d3fe5] docs: migrate Table docs to csf3 [de07c95] docs: remove stories folder [3727e13] docs: use new imports [1e0b2bb] docs: clean banner docs [64e8bb9] docs: moves datepicker stories to the datepicker folder [ec9c6a2] docs: moves Divider stories to the divider folder [c6d1213] docs: moves Dimming stories to the dimming folder [5889c10] docs: moves Banner stories to the banner folder [c746efb] docs: moves Checkbox stories to the checkbox folder [488700b] docs: moves Card stories to the card folder [30786b7] docs: move Button stories to the button folder [1d6a00a] docs: move Box stories to the box folder [d9c1270] docs: move accordion stories to the accordion folder [f3cd48e] docs: remove unused code [7b5c307] docs: migrate Infobanner docs [0d4dcec] docs: migrate InlineSpinner [ffcddfb] docs: migrate HelperText [5848410] docs: migrate Headline docs
1 parent 34cda7a commit 362adc7

File tree

161 files changed

+3773
-4718
lines changed

Some content is hidden

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

161 files changed

+3773
-4718
lines changed

.storybook/main.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { StorybookConfig } from '@storybook/react-webpack5';
22

33
const config: StorybookConfig = {
4-
stories: [
5-
'../docs/**/*.(stories|storybook).mdx',
6-
'../src/**/*.(stories|storybook).mdx',
7-
'../src/**/*.stories.@(ts|tsx)'
8-
],
4+
stories: ['../**/*.storybook.mdx', '../src/**/*.stories.@(ts|tsx)'],
95
addons: [
106
'@storybook/addon-links',
117
'@storybook/addon-essentials',
@@ -18,7 +14,8 @@ const config: StorybookConfig = {
1814
},
1915
docs: {
2016
autodocs: true
21-
}
17+
},
18+
staticDirs: ['../public']
2219
};
2320

2421
export default config;

.storybook/preview.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,11 @@ export const preview: Preview = {
6464
},
6565
options: {
6666
storySort: {
67-
order: ['Get Started']
67+
method: 'alphabetical',
68+
order: ['Get Started', 'Essentials', 'Components', 'Form Elements']
6869
}
6970
}
7071
}
7172
};
7273

7374
export default preview;
74-
75-
// (default) 0 - Mobile (portrait)
76-
// 30rem (480px) 1 small Mobile (landscape)
77-
// 48rem (768px) 2 medium Tablet (portrait)
78-
// 62rem (992px) 3 large Tablet (landscape)
79-
// 75rem (1200px) 4 xlarge Laptops (and Desktops)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Meta, ArgTypes, Primary, Stories } from '@storybook/blocks';
2+
import * as AccordionStories from './Accordion.stories';
3+
4+
<Meta of={AccordionStories} />
5+
6+
# Accordion
7+
8+
Accordion component is used to display large amount of content in a compress and progressive way.
9+
10+
<Primary />
11+
12+
## Properties
13+
14+
<ArgTypes of={AccordionStories} />
15+
16+
<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/components/Banner/Banner.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ type DismissFunc = () => void;
7575

7676
interface BannerProps {
7777
/**
78-
* Overrides the banner position.
78+
* Set banner position
7979
*/
8080
position?: 'top' | 'bottom';
8181
/**
8282
* Set the appropriate background color, screen position, and animation.
83+
* @default info
8384
*/
8485
variant?: 'info' | 'success' | 'danger';
8586
/**
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import React from 'react';
2+
import { Meta, StoryObj } from '@storybook/react';
3+
import { Banner } from '../Banner';
4+
import { Text } from '../../Text/Text';
5+
import { Button } from '../../Button/Button';
6+
7+
const meta: Meta = {
8+
title: 'Components/Banner',
9+
component: Banner,
10+
argTypes: {
11+
children: {
12+
description:
13+
'Content of the banner. Can be `ReactNode` or a render function that receives a dismiss method',
14+
control: { type: 'none' }
15+
},
16+
position: {
17+
table: {
18+
defaultValue: {
19+
summary: 'Depends on the variant prop value',
20+
detail: `
21+
info → top\nsuccess → top\ndanger → bottom
22+
`
23+
}
24+
}
25+
}
26+
},
27+
args: {
28+
children: (
29+
<Text inverted>
30+
In order to continuously improve our websites, and show offers and advertisements that are suited to
31+
you, we use cookies, tracking and (re-) targeting technologies. Please see our Cookie policy for more
32+
information. Tracking and (re-) targeting technologies will only be used if you click on Agree.
33+
</Text>
34+
)
35+
},
36+
decorators: [
37+
Story => (
38+
<div
39+
style={{
40+
willChange: 'transform',
41+
height: '250px',
42+
border: '1px dashed gray',
43+
display: 'flex',
44+
alignItems: 'center',
45+
justifyContent: 'center'
46+
}}
47+
>
48+
<Text secondary fontSize={3}>
49+
Page
50+
</Text>
51+
<Story />
52+
</div>
53+
)
54+
]
55+
};
56+
57+
export default meta;
58+
59+
type Story = StoryObj<typeof Banner>;
60+
61+
export const Default: Story = {
62+
args: {
63+
children: <Text inverted>Hello</Text>
64+
}
65+
};
66+
67+
export const Success: Story = {
68+
args: {
69+
variant: 'success'
70+
}
71+
};
72+
73+
export const Danger: Story = {
74+
args: {
75+
variant: 'danger',
76+
children: <Text inverted>Oops! Something went wrong</Text>
77+
}
78+
};
79+
80+
export const PositionTop: Story = {
81+
args: {
82+
position: 'top'
83+
}
84+
};
85+
86+
export const WithDismissedFn: Story = {
87+
args: {
88+
children: dismiss => (
89+
<>
90+
<Text inverted>If you are tired of this banner, hit the button 👉 </Text>
91+
<Button onClick={dismiss}>Close</Button>
92+
</>
93+
)
94+
}
95+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { Meta, ArgTypes, Primary, Story, Stories } from '@storybook/blocks';
2+
import * as BannerStories from './Banner.stories';
3+
import { Advice } from '../../../docs/Advice';
4+
5+
<Meta of={BannerStories} />
6+
7+
# Banner
8+
9+
Banner is a strong visual pattern that is used to display important information or state which remains until the
10+
cause is resolved or the banner is dismissed by the user.
11+
12+
- Banner can include any kind of content, i.e. icons, links, copy
13+
- Banner should be dismissible
14+
- Banner **info** and **success** appear at the bottom of the screen (sticky)
15+
- Banner **error** appears at the top of the screen (sticky)
16+
- Banner appears and disappears via slide in/out animation combined with soft fade and smooth easing
17+
18+
To properly hide the banner with the correct animation, it is recommended to call the dismiss function that can be used
19+
when providing a function as the child. This will also unmount the component once the animation is completed.
20+
21+
If you need the banner to be placed top or bottom without depending on the variant make sure to align with the design team
22+
and bear in mind that you can use the **position** prop for it.
23+
24+
<Primary />
25+
26+
## Properties
27+
28+
<ArgTypes of={BannerStories.Default} />
29+
30+
<Advice>
31+
The `Banner` uses `position:sticky` for positioning. It means it will always be rendered on top/bottom of the
32+
viewport ([MDN](http://developer.mozilla.org/en-US/docs/Web/CSS/position)).
33+
</Advice>
34+
35+
## Visibility management (dismiss function)
36+
37+
Banner provides a function to dismiss the component with an animation.
38+
The dismiss function is available either through render props or a hook.
39+
After the animation has finished the onClose callback will be called.
40+
41+
<Story of={BannerStories.WithDismissedFn} />
42+
43+
```tsx
44+
<Banner>
45+
{dismiss => (
46+
<>
47+
<Text inverted>If you are tired of this banner, hit the button 👉 </Text>
48+
<Button onClick={dismiss}>Close</Button>
49+
</>
50+
)}
51+
</Banner>
52+
```
53+
54+
<Stories includePrimary={false} />
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Meta, StoryObj } from '@storybook/react';
2+
import { Box } from '../Box';
3+
4+
const meta: Meta = {
5+
title: 'Components/Box',
6+
component: Box
7+
};
8+
9+
export default meta;
10+
11+
type Story = StoryObj<typeof Box>;
12+
13+
export const Default: Story = {
14+
args: {
15+
children: 'By default it is a block `div` element'
16+
}
17+
};
18+
19+
export const Inline: Story = {
20+
args: {
21+
as: 'span',
22+
children: 'I can be inline when `as` prop is used'
23+
}
24+
};
25+
26+
export const Responsive: Story = {
27+
args: {
28+
children: 'I can be responsive',
29+
bg: '#FF9CFC',
30+
width: [1, 1, 1 / 2]
31+
}
32+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Meta, Primary, Stories } from '@storybook/blocks';
2+
import * as BoxStories from './Box.stories';
3+
import { StyledSystemLinks } from '../../../docs/StyledSystemLinks';
4+
5+
<Meta of={BoxStories} />
6+
7+
# Box
8+
9+
This component serves as a wrapper component for most layout related needs. Use Box to set values such as display, width, height, and more. In practice, this component is used frequently as a wrapper around other components to achieve Box Model related styling.
10+
11+
<Primary />
12+
13+
## Properties
14+
15+
<StyledSystemLinks
16+
component="Box"
17+
supportedProps={['space', 'layout', 'position', 'color', 'flexbox', 'grid-layout', 'background']}
18+
/>
19+
20+
<Stories includePrimary={false} />

src/components/Button/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const invertedVariantStyles = variant({
142142
}
143143
});
144144

145-
const Button: React.FC<ButtonProps> = styled(BaseButton).attrs({ theme })<ButtonProps>`
145+
const Button = styled(BaseButton).attrs({ theme })<ButtonProps>`
146146
transition: background ease 200ms, border-color ease 200ms, color ease 200ms, fill ease 200ms;
147147
148148
${p => (p.inverted ? invertedVariantStyles : variantStyles)};

src/components/Button/TextButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const invertedVariantStyles = variant({
8282
}
8383
});
8484

85-
const TextButton: React.FC<TextButtonProps> = styled(BaseButton)<TextButtonProps>`
85+
const TextButton = styled(BaseButton)<TextButtonProps>`
8686
transition: color 200ms, fill 200ms;
8787
8888
${props => (props.inverted ? invertedVariantStyles(props) : variantStyles(props))};

0 commit comments

Comments
 (0)