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

fix(select): fix chevron disabled color #1481

Merged
merged 1 commit into from
Dec 13, 2024
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
5 changes: 5 additions & 0 deletions .changeset/lovely-rockets-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alfalab/core-components-select': patch
---

Исправлен цвет шеврона для заблокированного состояния
9 changes: 9 additions & 0 deletions packages/select/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
OptionsListProps,
OptionProps,
useSelectWithApply,
Arrow,
} from './shared';
import { SelectDesktop as Select } from './desktop';
import { SelectMobile, SelectModalMobile } from './mobile';
Expand Down Expand Up @@ -1025,4 +1026,12 @@ describe('Select', () => {
expect(container.querySelectorAll('select option').length).toBe(options.length);
});
});

describe('Chevron tests', () => {
it('should set `disabled` className', () => {
const { container } = render(<Arrow disabled={true} />);

expect(container.firstElementChild).toHaveClass('disabled');
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions packages/select/src/component.screenshots.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@ describe('Select', () => {
size: { width: 300, height: 120 },
}),
],
[
`${theme} theme — disabled props`,
createSpriteStorybookUrl({
packageName: 'select',
componentName: 'SelectDesktop',
knobs: {
options: [[]],
block: true,
placeholder: 'Выберите элемент',
size: [48],
label: ['Элемент'],
disabled: [true, false],
},
size: { width: 300, height: 120 },
}),
],
],
screenshotOpts: {
fullPage: true,
Expand Down
9 changes: 7 additions & 2 deletions packages/select/src/components/arrow/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { ArrowProps } from '../../typings';

import styles from './index.module.css';

export const Arrow = ({ open, className }: ArrowProps) => (
<ChevronDownMIcon className={cn(styles.arrow, className, { [styles.open]: open })} />
export const Arrow = ({ open, disabled, className }: ArrowProps) => (
<ChevronDownMIcon
className={cn(styles.arrow, className, {
[styles.open]: open,
[styles.disabled]: disabled,
})}
/>
);
4 changes: 4 additions & 0 deletions packages/select/src/components/arrow/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
color: var(--select-arrow-color);

transition: transform 0.15s ease-in-out, opacity 0.2s ease;

&.disabled {
color: var(--select-arrow-disabled-color);
}
}

.open {
Expand Down
2 changes: 1 addition & 1 deletion packages/select/src/components/base-select/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ export const BaseSelect = forwardRef<unknown, ComponentProps>(
placeholder={placeholder}
label={label && <span {...getLabelProps()}>{label}</span>}
labelView={labelView}
Arrow={Arrow && <Arrow open={open} />}
Arrow={Arrow && <Arrow open={open} disabled={disabled} />}
error={error}
hint={hint}
valueRenderer={valueRenderer}
Expand Down
5 changes: 5 additions & 0 deletions packages/select/src/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ export type ArrowProps = {
* Флаг, открыто ли меню
*/
open?: boolean;

/**
* Флаг блокировки select'а
*/
disabled?: boolean;
};

export type OptionsListProps = {
Expand Down
1 change: 1 addition & 0 deletions packages/select/src/vars.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
:root {
--select-error-color: var(--color-light-text-negative);
--select-arrow-color: var(--color-light-neutral-translucent-700);
--select-arrow-disabled-color: var(--color-light-neutral-translucent-500);
--select-arrow-hover-opacity: 0.7;

/* options list */
Expand Down
Loading