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

feat(Select): remove pointer cursor for disabled option #638

Merged
merged 1 commit into from
Apr 19, 2023
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
11 changes: 11 additions & 0 deletions src/components/Select/__stories__/SelectShowcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
EXAMPLE_CHILDREN_OPTIONS,
EXAMPLE_GROUP_JSON_OPTIONS,
EXAMPLE_GROUP_CHILDREN_OPTIONS,
EXAMPLE_DISABLED_OPTIONS,
EXAMPLE_USER_OPTIONS,
EXAMPLE_USER_CONTROL,
EXAMPLE_CUSTOM_RENDERER_WITH_DISABLED_ITEM,
Expand Down Expand Up @@ -172,6 +173,16 @@ export const SelectShowcase = (props: SelectProps) => {
<Select.Option value="val4" content="Value4" />
</Select.OptionGroup>
</ExampleItem>
<ExampleItem
title="Select with disabled options"
code={[EXAMPLE_DISABLED_OPTIONS]}
selectProps={props}
>
<Select.Option value="val1" content="Value1" />
<Select.Option value="val2" content="Value2" disabled />
<Select.Option value="val3" content="Value3" disabled />
<Select.Option value="val4" content="Value4" />
</ExampleItem>
<ExampleItem
title="Select with user options"
code={[EXAMPLE_USER_OPTIONS]}
Expand Down
14 changes: 14 additions & 0 deletions src/components/Select/__stories__/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ export const EXAMPLE_GROUP_CHILDREN_OPTIONS = `const [value, setValue] = React.u
</Select>
`;

export const EXAMPLE_DISABLED_OPTIONS = `const [value, setValue] = React.useState<string[]>([]);

<Select
value={value}
placeholder="Values",
onUpdate={(nextValue) => setValue1(nextValue)}
>
<Select.Option value="val1" content="Value1" />
<Select.Option value="val2" content="Value2" disabled />
<Select.Option value="val3" content="Value3" disabled />
<Select.Option value="val4" content="Value4" />
</Select>
`;

export const EXAMPLE_USER_OPTIONS = `const [value, setValue] = React.useState<string[]>([]);

<Select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export const OptionWrap = (props: OptionWrapProps) => {
const optionContent = renderOption ? renderOption(option) : <DefaultOption option={option} />;

return (
<div data-qa={option.qa} className={b('option', {colored: selected && !multiple})}>
<div
data-qa={option.qa}
className={b('option', {colored: selected && !multiple, disabled: option.disabled})}
>
{optionContent}
{multiple && (
<Icon className={b('tick-icon', {shown: selected && multiple})} data={Tick} />
Expand Down
4 changes: 4 additions & 0 deletions src/components/Select/components/SelectList/SelectList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ $xl-right-padding: '12px';
&_colored {
background-color: var(--yc-color-base-selection);
}

&_disabled {
cursor: default;
}
}

&__option-default-label {
Expand Down