Skip to content

Commit 8902acc

Browse files
author
Nikolai Lopin
committed
docs: migrate Popover docs to csf3
1 parent 5f31507 commit 8902acc

File tree

3 files changed

+124
-175
lines changed

3 files changed

+124
-175
lines changed

src/components/Popover/docs/Popover.stories.mdx

Lines changed: 0 additions & 175 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import React from 'react';
2+
import { StoryObj, Meta } from '@storybook/react';
3+
import { Popover } from '../Popover';
4+
import { Text } from '../../Text/Text';
5+
import { Button } from '../../Button/Button';
6+
import SettingsIcon from '../../../icons/options/SettingsIcon';
7+
import { Link } from '../../Link/Link';
8+
9+
const meta: Meta<typeof Popover> = {
10+
title: 'Components/Popover',
11+
component: Popover,
12+
argTypes: {
13+
placement: {
14+
options: [
15+
'top-start',
16+
'top-end',
17+
'bottom-start',
18+
'bottom-end',
19+
'right-start',
20+
'right-end',
21+
'left-start',
22+
'left-end',
23+
'auto',
24+
'auto-start',
25+
'auto-end',
26+
'top',
27+
'left',
28+
'right',
29+
'bottom'
30+
],
31+
defaultValue: 'bottom-start',
32+
control: 'select'
33+
},
34+
offset: {
35+
defaultValue: 5,
36+
control: 'number'
37+
},
38+
padding: {
39+
defaultValue: 0,
40+
control: 'number'
41+
}
42+
},
43+
args: {
44+
content: <Text>Content for the Popover. Can contain Icons, Forms or other elements.</Text>,
45+
children: 'Trigger'
46+
}
47+
};
48+
49+
export default meta;
50+
51+
type Story = StoryObj<typeof Popover>;
52+
53+
export const Default: Story = {};
54+
55+
export const WithButtonTrigger: Story = {
56+
args: {
57+
content: (
58+
<Link href="free-now.com" target="_blank">
59+
Open in Payment CRM
60+
</Link>
61+
),
62+
children: (
63+
<Button size="small" variant="primary">
64+
<SettingsIcon size={20} /> Manage Booking
65+
</Button>
66+
)
67+
}
68+
};
69+
70+
export const WithoutPadding: Story = {
71+
args: {
72+
padding: 0
73+
}
74+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { Stories, ArgTypes, Meta, Primary } from '@storybook/blocks';
2+
import PopoverStories from './Popover.stories';
3+
4+
<Meta of={PopoverStories} />
5+
6+
# Popover
7+
8+
**Primary UI element for content whose visibility can be toggled with a click on a trigger element**
9+
10+
Renders a UI component that opens a popup dialog when user clicks on a trigger element.
11+
12+
<Primary />
13+
14+
## Properties
15+
16+
<ArgTypes of={PopoverStories} />
17+
18+
## Usage
19+
20+
### Popover Trigger & Content
21+
22+
Popover components consist of 2 main elements:
23+
24+
- **Popover Trigger** – an element that shows/hides the Popover.
25+
- **Popover Content** – card with content that is toggled by the Trigger.
26+
27+
For **Trigger** you can use just a plain string (for default variant), or following components from Wave:
28+
29+
- **&lt;Text&gt;**
30+
- **&lt;Button&gt;**
31+
- **&lt;Button&gt; with Icon**
32+
- **&lt;Icon&gt;**
33+
- **&lt;Link&gt;**
34+
35+
The **Popover Content** acts as a container for any content: text, form, or anything else...
36+
37+
### Difference from a Tooltip component
38+
39+
- Popover is toggled by clicking on (not hovering over) the Trigger. The second click (or click outside the Popover) hides the Popover.
40+
- Popover scrolls with the page
41+
- Popover content and trigger are not limited to text.
42+
43+
### Style Props
44+
45+
The Popover supports:
46+
47+
- **placement** prop for specifying the Popover content attachment in relation to the Popover trigger
48+
- **offset** prop for the margin between Trigger and Popover card.
49+
50+
<Stories includePrimary={false} />

0 commit comments

Comments
 (0)