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

Adding description on <Dropdown /> #205

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 5 additions & 0 deletions components/Dropdown/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ const List = ({ theme, items, selectedItem, getItemProps }) => (
<>
<SelectedItemLabel theme={theme}>
{_getLabel(item)}
{_getLabelDescription(item) && (
<DropItemDescription>
{_getLabelDescription(item)}
</DropItemDescription>
)}
</SelectedItemLabel>

{_getImage(item) ? (
Expand Down
88 changes: 66 additions & 22 deletions stories/Dropdown/examples.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,33 @@ class Controlled extends React.Component {
selectedItem={selectedItem}
onChange={(item) => this.setState({ selectedItem: item })}
items={[
{ label: 'Amazonas', value: 'AM' },
{ label: 'Bahia', value: 'BA' },
{ label: 'Ceará', value: 'CE' },
{ label: 'Goiás', value: 'GO' },
{ label: 'Minas Gerais', value: 'MG' },
{ label: 'Paraná', value: 'PR' },
{ label: 'Pernambuco', value: 'PE' },
{ label: 'Rio de Janeiro', value: 'RJ' },
{ label: 'Rio Grande do Sul', value: 'RS' },
{ label: 'Santa Catarina', value: 'SC' },
{ label: 'São Paulo', value: 'SP' },
{ label: 'Amazonas', value: 'AM', description: 'optional description' },
tcelestino marked this conversation as resolved.
Show resolved Hide resolved
{ label: 'Bahia', value: 'BA', description: 'optional description' },
{ label: 'Ceará', value: 'CE', description: 'optional description' },
{ label: 'Goiás', value: 'GO', description: 'optional description' },
{
label: 'Minas Gerais',
value: 'MG',
description: 'optional description',
},
{ label: 'Paraná', value: 'PR', description: 'optional description' },
{ label: 'Pernambuco', value: 'PE', description: 'optional description' },
{
label: 'Rio de Janeiro',
value: 'RJ',
description: 'optional description',
},
{
label: 'Rio Grande do Sul',
value: 'RS',
description: 'optional description',
},
{
label: 'Santa Catarina',
value: 'SC',
description: 'optional description',
},
{ label: 'São Paulo', value: 'SP', description: 'optional description' },
]}
/>
)
Expand All @@ -57,17 +73,45 @@ class Controlled extends React.Component {
selectedItem={selectedItem}
onChange={item => this.setState({ selectedItem: item })}
items={[
{ label: 'Amazonas', value: 'AM' },
{ label: 'Bahia', value: 'BA' },
{ label: 'Ceará', value: 'CE' },
{ label: 'Goiás', value: 'GO' },
{ label: 'Minas Gerais', value: 'MG' },
{ label: 'Paraná', value: 'PR' },
{ label: 'Pernambuco', value: 'PE' },
{ label: 'Rio de Janeiro', value: 'RJ' },
{ label: 'Rio Grande do Sul', value: 'RS' },
{ label: 'Santa Catarina', value: 'SC' },
{ label: 'São Paulo', value: 'SP' },
{
label: 'Amazonas',
value: 'AM',
description: 'optional description',
},
{ label: 'Bahia', value: 'BA', description: 'optional description' },
{ label: 'Ceará', value: 'CE', description: 'optional description' },
{ label: 'Goiás', value: 'GO', description: 'optional description' },
{
label: 'Minas Gerais',
value: 'MG',
description: 'optional description',
},
{ label: 'Paraná', value: 'PR', description: 'optional description' },
{
label: 'Pernambuco',
value: 'PE',
description: 'optional description',
},
{
label: 'Rio de Janeiro',
value: 'RJ',
description: 'optional description',
},
{
label: 'Rio Grande do Sul',
value: 'RS',
description: 'optional description',
},
{
label: 'Santa Catarina',
value: 'SC',
description: 'optional description',
},
{
label: 'São Paulo',
value: 'SP',
description: 'optional description',
},
]}
/>
);
Expand Down