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: update select examples #2562

Merged
merged 4 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
34 changes: 34 additions & 0 deletions packages/components/forms/examples/SelectSizes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { Select, SectionHeading, Stack } from '@contentful/f36-components';

export default function SelectSizes() {
return (
<Stack>
<SectionHeading>Size Medium</SectionHeading>
<Select
id="optionSelect-6"
name="optionSelect-6"
defaultValue="optionTwo"
>
<Select.Option value="optionOne">Option 1</Select.Option>
<Select.Option value="optionTwo">Option 2</Select.Option>
<Select.Option value="optionThree" isDisabled>
Disabled option
</Select.Option>
</Select>
<SectionHeading>Size Small</SectionHeading>
<Select
id="optionSelect-6"
name="optionSelect-6"
size="small"
defaultValue="optionTwo"
>
<Select.Option value="optionOne">Option 1</Select.Option>
<Select.Option value="optionTwo">Option 2</Select.Option>
<Select.Option value="optionThree" isDisabled>
Disabled option
</Select.Option>
</Select>
</Stack>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { Select, FormControl } from '@contentful/f36-components';

export default function SelectWithLabelExample() {
return (
<FormControl>
<FormControl.Label>Label for select</FormControl.Label>
<FormControl as="fieldset">
<FormControl.Label as="legend">Label for select</FormControl.Label>
<Select id="optionSelect" name="optionSelect">
<Select.Option value="optionOne">Option 1</Select.Option>
<Select.Option value="optionTwo">Long Option 2</Select.Option>
</Select>
<FormControl.HelpText>Select one of the options</FormControl.HelpText>
</FormControl>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Select, FormControl } from '@contentful/f36-components';

export default function SelectWithValidationExample() {
return (
<FormControl>
<FormControl.Label>Label for select</FormControl.Label>
<FormControl as="fieldset">
Lelith marked this conversation as resolved.
Show resolved Hide resolved
<FormControl.Label as="legend">Label for select</FormControl.Label>
<Select id="optionSelect" name="optionSelect">
<Select.Option value="optionOne">Option 1</Select.Option>
<Select.Option value="optionTwo">Long Option 2</Select.Option>
Expand Down
6 changes: 6 additions & 0 deletions packages/components/forms/src/Select/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ There might be cases where you would need to include the help text or validation

```

### Select available sizes

```tsx file=../../examples/SelectSizes.tsx

```

### Select disabled state

```tsx file=../../examples/SelectDisabledExample.tsx
Expand Down
Loading