Skip to content

Commit c89f128

Browse files
author
Nikolai Lopin
committed
docs: migrate RadioButton docs to csf3
1 parent a97cdd9 commit c89f128

File tree

4 files changed

+81
-144
lines changed

4 files changed

+81
-144
lines changed

src/components/RadioButton/RadioButtonProps.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface RadioButtonProps extends ComponentPropsWithoutRef<'input'>, ClassNameP
2121
error?: boolean;
2222
/**
2323
* Align the label text relatively to the radio button
24+
* @default center
2425
*/
2526
textVerticalAlign?: 'top' | 'center';
2627
}

src/components/RadioButton/docs/RadioButton.stories.mdx

Lines changed: 0 additions & 144 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { Meta, StoryObj } from '@storybook/react';
2+
import { RadioButton } from '../RadioButton';
3+
4+
const meta: Meta = {
5+
title: 'Form Elements/RadioButton',
6+
component: RadioButton,
7+
argTypes: {
8+
textVerticalAlign: {
9+
options: ['top', 'center'],
10+
defaultValue: 'center',
11+
control: 'radio'
12+
}
13+
},
14+
args: {
15+
label: 'First Name'
16+
}
17+
};
18+
19+
export default meta;
20+
21+
type Story = StoryObj<typeof RadioButton>;
22+
23+
export const Default: Story = {
24+
args: {
25+
label: undefined
26+
}
27+
};
28+
29+
export const WithLabel: Story = {
30+
args: {}
31+
};
32+
33+
export const Checked: Story = {
34+
args: {
35+
checked: true
36+
}
37+
};
38+
39+
export const WithError: Story = {
40+
args: {
41+
error: true
42+
}
43+
};
44+
45+
export const Disabled: Story = {
46+
args: {
47+
disabled: true
48+
}
49+
};
50+
51+
export const WithVerticalAlignment: Story = {
52+
args: {
53+
label: 'By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. The author accepts no liability whatsoever in respect of the current relevance, accuracy, completeness or quality of the information on this website. The author accepts no liability whatsoever with respect to either material or immaterial losses incurred as a result of the use or non-use of the information presented here or the use of inaccurate or incomplete information unless the author is demonstrably guilty of acts of wilful or gross negligence. All services offered are subject to change and are without obligation. The author specifically reserves the right to change, amplify or delete parts of the pages or the whole of the services offered without prior notification or to cease publication, either temporarily or definitively.',
54+
textVerticalAlign: 'top'
55+
}
56+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Primary, Stories, ArgTypes, Meta } from '@storybook/blocks';
2+
3+
import { StyledSystemLinks } from '../../../docs/StyledSystemLinks';
4+
import * as RadioButtonStories from './RadioButton.stories';
5+
6+
<Meta of={RadioButtonStories} />
7+
8+
# RadioButton
9+
10+
Use radio buttons when you have a few options that a user can choose from. Never use radio buttons if the user can
11+
select more than one option from a list (consider using a [Checkbox](/components/Checkbox) instead).
12+
13+
You can provide the label as either a `string` or as a react component. If a `string` is provided as the label, it
14+
will be wrapped with the [Text](/components/text) component.
15+
16+
<Primary />
17+
18+
## Properties
19+
20+
<ArgTypes of={RadioButtonStories} />
21+
22+
<StyledSystemLinks component="RadioButton" supportedProps={['margin']} />
23+
24+
<Stories includePrimary={false} />

0 commit comments

Comments
 (0)