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 labelDescription to OptionWithDescription #786

Merged
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
13 changes: 8 additions & 5 deletions src/Select/OptionWithDescription.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ import './OptionWithDescription.scss';
// See: https://react-select.com/components#replaceable-components

/* eslint-disable react/prop-types */
const OptionWithDescription = ({ ...props }) => (
const OptionWithDescription = ({ hideDescription, ...props }) => (
<components.Option
innerProps={{ 'aria-label': `${props.label}. ${props.data.description}` }}
{...props}
>
<div className="OptionWithDescription">
<label className="OptionWithDescription__label">
{props.label}
{props.label}&nbsp;
{props.data.labelDescription}
</label>
<div className="OptionWithDescription__description">
{props.data.description}
</div>
{!hideDescription && (
<div className="OptionWithDescription__description">
{props.data.description}
</div>
)}
</div>
</components.Option>
);
Expand Down
16 changes: 12 additions & 4 deletions src/Select/SingleSelect.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,18 @@ export const InModal = () => (

export const CustomOptionWithDescription = () => {
const optionsWithDescriptions = [
{ label: 'Org Admin', value: 1, description: 'Short description of role capabilities' },
{ label: 'Administrator', value: 2, description: 'Short description of role capabilities' },
{ label: 'Researcher', value: 3, description: 'Short description of role capabilities' },
{ label: 'Teammate', value: 4, description: 'Short description of role capabilities' },
{
label: 'Org Admin', value: 1, description: 'Short description of role capabilities', labelDescription: '(Full access)',
},
{
label: 'Administrator', value: 2, description: 'Short description of role capabilities', labelDescription: '(Full access)',
},
{
label: 'Researcher', value: 3, description: 'Short description of role capabilities', labelDescription: '(Standard access)',
},
{
label: 'Teammate', value: 4, description: 'Short description of role capabilities', labelDescription: '(Limited access)',
},
];

return (
Expand Down