-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document listboxOverflow Select prop
- Loading branch information
Showing
4 changed files
with
136 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useId, useState } from 'preact/hooks'; | ||
|
||
import { Select } from '../..'; | ||
|
||
const items = [ | ||
{ | ||
id: '1', | ||
name: 'All students - content is very long and will not fit the listbox', | ||
}, | ||
{ | ||
id: '2', | ||
name: 'Albert Banana - content is very long and will not fit the listbox', | ||
}, | ||
{ | ||
id: '3', | ||
name: 'Bernard California - content is very long and will not fit the listbox', | ||
}, | ||
{ | ||
id: '4', | ||
name: 'Cecelia Davenport - content is very long and will not fit the listbox', | ||
}, | ||
{ | ||
id: '5', | ||
name: 'Doris Evanescence - content is very long and will not fit the listbox', | ||
}, | ||
]; | ||
|
||
export default function App() { | ||
const [value, setSelected] = useState<{ id: string; name: string }>(); | ||
const selectId = useId(); | ||
|
||
return ( | ||
<div className="w-96 mx-auto"> | ||
<label htmlFor={selectId}>Select a person</label> | ||
<Select | ||
value={value} | ||
onChange={newValue => setSelected(newValue)} | ||
buttonId={selectId} | ||
buttonContent={value ? value.name : <>Select one…</>} | ||
listboxClasses="w-36" | ||
listboxOverflow="truncate" | ||
> | ||
{items.map(item => ( | ||
<Select.Option value={item} key={item.id}> | ||
{item.name} | ||
</Select.Option> | ||
))} | ||
</Select> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useId, useState } from 'preact/hooks'; | ||
|
||
import { Select } from '../..'; | ||
|
||
const items = [ | ||
{ | ||
id: '1', | ||
name: 'All students - content is very long and will not fit the listbox', | ||
}, | ||
{ | ||
id: '2', | ||
name: 'Albert Banana - content is very long and will not fit the listbox', | ||
}, | ||
{ | ||
id: '3', | ||
name: 'Bernard California - content is very long and will not fit the listbox', | ||
}, | ||
{ | ||
id: '4', | ||
name: 'Cecelia Davenport - content is very long and will not fit the listbox', | ||
}, | ||
{ | ||
id: '5', | ||
name: 'Doris Evanescence - content is very long and will not fit the listbox', | ||
}, | ||
]; | ||
|
||
export default function App() { | ||
const [value, setSelected] = useState<{ id: string; name: string }>(); | ||
const selectId = useId(); | ||
|
||
return ( | ||
<div className="w-96 mx-auto"> | ||
<label htmlFor={selectId}>Select a person</label> | ||
<Select | ||
value={value} | ||
onChange={newValue => setSelected(newValue)} | ||
buttonId={selectId} | ||
buttonContent={value ? value.name : <>Select one…</>} | ||
listboxClasses="w-36" | ||
listboxOverflow="wrap" | ||
> | ||
{items.map(item => ( | ||
<Select.Option value={item} key={item.id}> | ||
{item.name} | ||
</Select.Option> | ||
))} | ||
</Select> | ||
</div> | ||
); | ||
} |