Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(checkbox, radio-group): add suffix section #4075

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,55 @@ render(
)
`.trim();

export const suffixExample = `
const DateRadioGroup = () => {
const [value, setValue] = React.useState('lowest');
return (
<RadioGroup
name="date"
value={value}
legend="Select date"
onChange={newValue => {
setValue(newValue);
}}
>
<Radio
id="today"
value="today"
name="date"
>
Today
</Radio>
<Radio
id="last-15-days"
value="last-15-days"
name="date"
>
Last 15 days
</Radio>
<Radio
id="last-month"
value="last-month"
name="date"
>
Last month
</Radio>
<Radio
id="custom"
value="custom"
name="date"
>
<Box display="flex" columnGap="space30">Custom <Badge variant="success" size="small">Premium</Badge></Box>
</Radio>
</RadioGroup>
);
};

render(
<DateRadioGroup />
)
`.trim();

export const requiredExample = `
const SslRadioGroup = () => {
const [value, setValue] = React.useState('on');
Expand Down
26 changes: 26 additions & 0 deletions packages/paste-website/src/pages/components/checkbox/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const meta = {

import {Checkbox, CheckboxGroup, CheckboxDisclaimer} from '@twilio-paste/checkbox';
import {Box} from '@twilio-paste/box';
import {Badge} from '@twilio-paste/badge';
import {Text} from '@twilio-paste/text';
import {Paragraph} from '@twilio-paste/paragraph';
import {Anchor} from '@twilio-paste/anchor';
Expand Down Expand Up @@ -177,6 +178,31 @@ You can provide additional information about the group with the use of help text
</CheckboxGroup>`}
</LivePreview>

### Checkbox with suffix

You can provide additional information about an individual item by adding a non-string element as a suffix. The suffix can be any non-string element that is not interactive.

<LivePreview scope={{Checkbox, CheckboxGroup, Badge, Box}} language="jsx">
{`<CheckboxGroup
name="call logs status"
legend="Call logs status"
helpText="Select at least 1 status to view results"
>
<Checkbox id="busy" value="busy">
<Box display="flex" columnGap="space30">Busy <Badge variant="new" size="small">New</Badge></Box>
</Checkbox>
<Checkbox id="canceled" value="canceled">
Canceled
</Checkbox>
<Checkbox id="completed" value="completed">
Completed
</Checkbox>
<Checkbox id="queued" value="queued">
Queued
</Checkbox>
</CheckboxGroup>`}
</LivePreview>

### Checkbox Disclaimer

<LivePreview scope={{CheckboxDisclaimer, Text}} language="jsx">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const meta = {

import {Radio, RadioGroup} from '@twilio-paste/radio-group';
import {Box} from '@twilio-paste/box';
import {Badge} from '@twilio-paste/badge';
import {useUID} from '@twilio-paste/uid-library';
import {Paragraph} from '@twilio-paste/paragraph';
import {SiteLink} from '../../../components/SiteLink';
Expand All @@ -24,6 +25,7 @@ import {
uncontrolledRadioGroup,
controlledRadioGroup,
i18nExample,
suffixExample,
} from '../../../component-examples/RadioGroupExamples';
import packageJson from '@twilio-paste/radio-group/package.json';
import ComponentPageLayout from '../../../layouts/ComponentPageLayout';
Expand Down Expand Up @@ -137,6 +139,14 @@ Help text appears after the group label but before the first radio option.
{defaultExample}
</LivePreview>

### With suffix

You can provide additional information about an individual item by adding a non-string element as a suffix. The suffix can be any non-string element that is not interactive.

<LivePreview scope={{Radio, RadioGroup, Box, Badge}} noInline>
{suffixExample}
</LivePreview>

### Required usage

Use the required dot to denote a required field. The required dot appears before the fieldset legend.
Expand Down
Loading