Skip to content

Commit

Permalink
chore(react): add overflow example to select
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Apr 28, 2024
1 parent 009c02d commit 3e76ffe
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 2 deletions.
78 changes: 78 additions & 0 deletions frameworks/react/src/components/select/examples/overflow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { Portal, Select } from '../..'

const items = [
'Name 1',
'Name 2',
'Name 3',
'Name 4',
'Name 5',
'Name 6',
'Name 7',
'Name 8',
'Name 9',
'Name 10',
'Name 11',
'Name 12',
'Name 13',
'Name 14',
]

export const Overflow = () => {
return (
<main>
<h1>Welcome to Ark UI</h1>
<p>Please edit src/App.tsx and save to reload.</p>
<Select.Root
items={items}
positioning={{
fitViewport: true,
placement: 'bottom-start',
sameWidth: true,
}}
>
<Select.Label>Framework</Select.Label>
<Select.Control>
<Select.Trigger>
<Select.ValueText placeholder="Select a Framework" />
</Select.Trigger>
<Select.ClearTrigger>Clear</Select.ClearTrigger>
</Select.Control>
<Portal>
<Select.Positioner>
<Select.Content style={{ maxHeight: '120px', overflow: 'auto' }}>
<Select.ItemGroup>
<Select.ItemGroupLabel>Frameworks</Select.ItemGroupLabel>
{items.map((item) => (
<Select.Item
key={item}
item={item}
style={{
display: 'flex',
alignItems: 'center',
gap: 2,
}}
>
<Select.ItemContext>
{(itemState) => (
<Select.ItemText
style={{
flex: '1',
fontSize: '16px',
background: itemState.highlighted ? 'blue' : 'white',
}}
>
{item}
</Select.ItemText>
)}
</Select.ItemContext>
<Select.ItemIndicator></Select.ItemIndicator>
</Select.Item>
))}
</Select.ItemGroup>
</Select.Content>
</Select.Positioner>
</Portal>
</Select.Root>
</main>
)
}
5 changes: 3 additions & 2 deletions frameworks/react/src/components/select/select.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const meta: Meta = {

export default meta

export { Basic } from './examples/basic'
export { Advanced } from './examples/advanced'
export { Multiple } from './examples/multiple'
export { Basic } from './examples/basic'
export { Controlled } from './examples/controlled'
export { FormLibrary } from './examples/form-library'
export { Multiple } from './examples/multiple'
export { Overflow } from './examples/overflow'

0 comments on commit 3e76ffe

Please sign in to comment.