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

Add Select component to core package #152

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
157 changes: 157 additions & 0 deletions apps/storybook/src/stories/select/Select.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Select

import { Controls, Canvas, Meta } from '@storybook/blocks';
import * as SelectStories from './Select.stories';

<Meta of={SelectStories} />

- [Import](#import)
- [Overview](#overview)
- [Props](#props)
- [Examples](#examples)

## Import

```jsx
import { Select } from 'yorkie-ui';
```

## Overview

The `Select` element presents a collection of choices for the user to select from.

<Canvas
of={SelectStories.Overview}
source={{
format: true,
code: `
const items = [
{ label: 'React', value: 'react' },
{ label: 'Solid', value: 'solid' },
{ label: 'Svelte', value: 'svelte', disabled: true },
{ label: 'Vue', value: 'vue' },
];
return (
<Select.Root positioning={{ sameWidth: true }} width="2xs" items={items}>
<Select.Label>Framework</Select.Label>
<Select.Control>
<Select.Trigger>
<Select.ValueText placeholder={'Select a Framework'} />
<Icons.IconArrow />
</Select.Trigger>
</Select.Control>
<Select.Positioner>
<Select.Content>
<Select.ItemGroup id="framework">
<Select.ItemGroupLabel htmlFor="framework">Framework</Select.ItemGroupLabel>
{items.map((item) => (
<Select.Item key={item.value} item={item}>
<Select.ItemText>{item.label}</Select.ItemText>
<Select.ItemIndicator>
<Icons.IconArrow />
</Select.ItemIndicator>
</Select.Item>
))}
</Select.ItemGroup>
</Select.Content>
</Select.Positioner>
</Select.Root>
);
`,
}}
/>

## Props

<Controls />

## Examples

### [Customization](#select-customization)

For advanced customizations and like `disabled` item properties.

<Canvas
of={SelectStories.Customization}
source={{
format: true,
code: `
<Select.Root items={items} positioning={{ sameWidth: true }} width="2xs" height="280px">
<Select.Label>Framework</Select.Label>
<Select.Control>
<Select.Trigger>
<Select.ValueText placeholder="Select a Framework" />
<Select.Indicator>
<Icons.IconArrow />
</Select.Indicator>
</Select.Trigger>
<Select.ClearTrigger>
<Button variant="solid">Clear</Button>
</Select.ClearTrigger>
</Select.Control>
<Select.Positioner>
<Select.Content>
<Select.ItemGroup id="framework">
<Select.ItemGroupLabel htmlFor="framework">Frameworks</Select.ItemGroupLabel>
{items.map((item) => (
<Select.Item key={item.value} item={item}>
<Select.ItemText>{item.label}</Select.ItemText>
<Select.ItemIndicator>✓</Select.ItemIndicator>
</Select.Item>
))}
</Select.ItemGroup>
</Select.Content>
</Select.Positioner>
</Select.Root>
`,
}}
/>

### [Multiple Selection](#multiple-selection)

To allow for the selection of multiple items, follow these steps:

<Canvas
of={SelectStories.MultipleSelection}
source={{
format: true,
code: `
type Item = { label: string; value: string; disabled?: boolean }
const items: Item[] = [
{ label: 'React', value: 'react' },
{ label: 'Solid', value: 'solid' },
{ label: 'Vue', value: 'vue' },
{ label: 'Svelte', value: 'svelte', disabled: true },
]
return (
<Select.Root items={items} multiple positioning={{ sameWidth: true }} width="2xs" height="280px">
<Select.Label>Framework</Select.Label>
<Select.Control>
<Select.Trigger>
<Select.ValueText placeholder="Select a Framework" />
<Select.Indicator>
<ChevronIcons.IconArrow />
</Select.Indicator>
</Select.Trigger>
<Select.ClearTrigger>Clear</Select.ClearTrigger>
</Select.Control>
<Portal>
<Select.Positioner>
<Select.Content>
<Select.ItemGroup id="framework">
<Select.ItemGroupLabel htmlFor="framework">Frameworks</Select.ItemGroupLabel>
{items.map((item) => (
<Select.Item key={item.value} item={item}>
<Select.ItemText>{item.label}</Select.ItemText>
<Select.ItemIndicator>✓</Select.ItemIndicator>
</Select.Item>
))}
</Select.ItemGroup>
</Select.Content>
</Select.Positioner>
</Portal>
</Select.Root>
);
`,
}}
/>
Loading
Loading