Skip to content

Commit

Permalink
fix(plasma-new-hope, sdds-insol): icon tokens updated
Browse files Browse the repository at this point in the history
  • Loading branch information
denivladislav committed Dec 27, 2024
1 parent f6196be commit 352af87
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ export const IconArrowWrapper = styled.div<{ disabled: boolean }>`
}
`;

export const StyledArrow = styled(IconDisclosureDownCentered)``;
// TODO: Удалить после поддержки JS переменных в конфиге компонент
export const sizeMap: Record<string, string> = {
xs: '1rem',
s: '1.5rem',
};

export const StyledArrow = styled(IconDisclosureDownCentered)`
width: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
height: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
`;

export const base = css``;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ export const tokens = {

disclosureIconColor: '--plasma-combobox-disclosure-icon-color',
disclosureIconColorHover: '--plasma-combobox-disclosure-icon-color-hover',
disclosureIconSize: '--plasma-select-disclosure-icon-size',
disclosureIconMargin: '--plasma-select-disclosure-icon-margin',
};

export const constants = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { checkboxConfig, checkboxTokens } from '../../../../../../Checkbox';
import { indicatorConfig, indicatorTokens } from '../../../../../../Indicator';
import { cellConfig, cellTokens } from '../../../../../../Cell';
import type { ComboboxProps } from '../../../../Combobox.types';
import { IconDisclosureRightCentered, IconDone } from '../../../../../../_Icon';

const mergedCheckboxConfig = mergeConfig(checkboxConfig);
const Checkbox = component(mergedCheckboxConfig);
Expand Down Expand Up @@ -50,6 +51,22 @@ export const StyledIndicator = styled(Indicator)`
${indicatorTokens.color}: var(${tokens.checkboxFillColor});
`;

// TODO: Удалить после поддержки JS переменных в конфиге компонент
export const sizeMap: Record<string, string> = {
xs: '1rem',
s: '1.5rem',
};

export const StyledArrow = styled(IconDisclosureRightCentered)`
width: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
height: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
`;

export const StyledIconDone = styled(IconDone)`
width: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
height: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
`;

export const StyledContentLeft = styled.div`
display: inline-flex;
`;
Expand All @@ -61,6 +78,7 @@ export const StyledContentRight = styled.div`

export const DisclosureIconWrapper = styled.div`
line-height: 0;
margin: var(${tokens.disclosureIconMargin});
color: var(${tokens.disclosureIconColor});
&:hover {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, { useRef, FC, useContext } from 'react';
import { sizeToIconSize, getItemId } from '../../../../utils';
import { classes } from '../../../../Combobox.tokens';
import { cx, isEmpty } from '../../../../../../../utils';
import { IconDisclosureRightCentered, IconDone } from '../../../../../../_Icon';
import { Context } from '../../../../Combobox.context';
import { useDidMountEffect } from '../../../../../../../hooks';

Expand All @@ -18,6 +17,8 @@ import {
StyledIndicator,
StyledCheckboxWrapper,
StyledCell,
StyledIconDone,
StyledArrow,
} from './Item.styles';

export const Item: FC<ItemProps> = ({
Expand Down Expand Up @@ -110,7 +111,7 @@ export const Item: FC<ItemProps> = ({
{!multiple && checked.get(item.value) === 'dot' && <StyledIndicator size="s" view="default" />}

{!multiple && checked.get(item.value) === 'done' && (
<IconDone size={sizeToIconSize(size, variant)} color="inherit" />
<StyledIconDone size={sizeToIconSize(size, variant)} color="inherit" />
)}
</IconWrapper>

Expand All @@ -132,7 +133,7 @@ export const Item: FC<ItemProps> = ({

{!isEmpty(item.items) && (
<DisclosureIconWrapper>
<IconDisclosureRightCentered size={sizeToIconSize(size, variant)} color="inherit" />
<StyledArrow size={sizeToIconSize(size, variant)} color="inherit" />
</DisclosureIconWrapper>
)}
</Wrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ export const tokens = {

disclosureIconColor: '--plasma-select-disclosure-icon-color',
disclosureIconColorHover: '--plasma-select-disclosure-icon-color-hover',
disclosureIconSize: '--plasma-select-disclosure-icon-size',
disclosureIconMargin: '--plasma-select-disclosure-icon-margin',
};

export const constants = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { checkboxConfig, checkboxTokens } from '../../../../../Checkbox';
import { cellConfig, cellTokens } from '../../../../../Cell';
import { indicatorConfig, indicatorTokens } from '../../../../../Indicator';
import type { SelectProps } from '../../../../Select.types';
import { IconDisclosureRightCentered, IconDone } from '../../../../../_Icon';

const mergedCheckboxConfig = mergeConfig(checkboxConfig);
const Checkbox = component(mergedCheckboxConfig);
Expand Down Expand Up @@ -70,7 +71,24 @@ export const StyledIndicator = styled(Indicator)`
${indicatorTokens.color}: var(${tokens.checkboxFillColor});
`;

// TODO: Удалить после поддержки JS переменных в конфиге компонент
export const sizeMap: Record<string, string> = {
xs: '1rem',
s: '1.5rem',
};

export const StyledArrow = styled(IconDisclosureRightCentered)`
width: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
height: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
`;

export const StyledIconDone = styled(IconDone)`
width: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
height: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
`;

export const DisclosureIconWrapper = styled.div`
margin: var(${tokens.disclosureIconMargin});
line-height: 0;
color: var(${tokens.disclosureIconColor});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, { useRef, FC, useContext } from 'react';
import { sizeToIconSize, getItemId } from '../../../../utils';
import { classes } from '../../../../Select.tokens';
import { cx, isEmpty } from '../../../../../../utils';
import { IconDisclosureRightCentered, IconDone } from '../../../../../_Icon';
import { Context } from '../../../../Select.context';
import { useDidMountEffect } from '../../../../../../hooks';

Expand All @@ -18,6 +17,8 @@ import {
StyledText,
Wrapper,
StyledCheckboxWrapper,
StyledArrow,
StyledIconDone,
} from './Item.styles';

export const Item: FC<ItemProps> = ({
Expand Down Expand Up @@ -111,7 +112,7 @@ export const Item: FC<ItemProps> = ({
{!multiselect && checked.get(item.value) === 'dot' && <StyledIndicator size="s" view="default" />}

{!multiselect && checked.get(item.value) === 'done' && (
<IconDone size={sizeToIconSize(size, variant)} color="inherit" />
<StyledIconDone size={sizeToIconSize(size, variant)} color="inherit" />
)}
</IconWrapper>

Expand All @@ -132,7 +133,7 @@ export const Item: FC<ItemProps> = ({

{!isEmpty(item.items) && (
<DisclosureIconWrapper>
<IconDisclosureRightCentered size={sizeToIconSize(size, variant)} color="inherit" />
<StyledArrow size={sizeToIconSize(size, variant)} color="inherit" />
</DisclosureIconWrapper>
)}
</Wrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ export const IconArrowWrapper = styled.div`
}
`;

// TODO: Удалить после поддержки JS переменных в конфиге компонент
export const sizeMap: Record<string, string> = {
xs: '1rem',
s: '1.5rem',
};

export const StyledArrow = styled(IconDisclosureDownCentered)`
transition: color 0.3s ease-in, transform 0.15s ease-in;
pointer-events: none;
user-select: none;
width: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
height: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
`;

export const ButtonWrapper = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,13 @@ export const IconArrowWrapper = styled.div<{ disabled: boolean }>`
}
`;

export const StyledArrow = styled(IconDisclosureDownCentered)``;
// TODO: Удалить после поддержки JS переменных в конфиге компонент
export const sizeMap: Record<string, string> = {
xs: '1rem',
s: '1.5rem',
};

export const StyledArrow = styled(IconDisclosureDownCentered)`
width: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
height: ${({ size = 'xs' }) => `var(${tokens.disclosureIconSize}, ${sizeMap[size]})`};
`;
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import React from 'react';
import React, { HTMLAttributes } from 'react';

import { DisclosureDownCentered } from '../Icon.assets/DisclosureDownCentered';
import { IconRoot, IconProps } from '../IconRoot';

export const IconDisclosureDownCentered: React.FC<IconProps> = ({ size = 'xs', color, className }) => {
return <IconRoot className={className} size={size} color={color} icon={DisclosureDownCentered} />;
export const IconDisclosureDownCentered: React.FC<IconProps & HTMLAttributes<HTMLDivElement>> = ({
size = 'xs',
color,
className,
...rest
}) => {
return <IconRoot className={className} size={size} color={color} icon={DisclosureDownCentered} {...rest} />;
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import React from 'react';
import React, { HTMLAttributes } from 'react';

import { DisclosureRightCentered } from '../Icon.assets/DisclosureRightCentered';
import { IconRoot, IconProps } from '../IconRoot';

export const IconDisclosureRightCentered: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} icon={DisclosureRightCentered} />;
export const IconDisclosureRightCentered: React.FC<IconProps & HTMLAttributes<HTMLDivElement>> = ({
size = 's',
color,
className,
...rest
}) => {
return <IconRoot className={className} size={size} color={color} icon={DisclosureRightCentered} {...rest} />;
};
11 changes: 8 additions & 3 deletions packages/plasma-new-hope/src/components/_Icon/Icons/IconDone.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import React from 'react';
import React, { HTMLAttributes } from 'react';

import { Done } from '../Icon.assets/Done';
import { IconRoot, IconProps } from '../IconRoot';

export const IconDone: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} icon={Done} />;
export const IconDone: React.FC<IconProps & HTMLAttributes<HTMLDivElement>> = ({
size = 's',
color,
className,
...rest
}) => {
return <IconRoot className={className} size={size} color={color} icon={Done} {...rest} />;
};
18 changes: 15 additions & 3 deletions packages/sdds-insol/src/components/Combobox/Combobox.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ export const config = {
${tokens.checkboxTriggerBorderColor}: var(--text-secondary);
${tokens.indicatorSize}: 0.375rem;
${tokens.disclosureIconSize}: 1.5rem;
${tokens.disclosureIconMargin}: 0 0 0 0.625rem;
`,
m: css`
${tokens.textFieldHeight}: 3rem;
Expand Down Expand Up @@ -393,8 +396,8 @@ export const config = {
${tokens.itemPaddingTight}: 0.5rem 0.875rem;
${tokens.itemBorderRadius}: 0.625rem;
${tokens.itemIconMargin}: 0 0.625rem 0 0;
${tokens.itemIconSize}: 1.5rem;
${tokens.itemIconSizeTight}: 1.5rem;
${tokens.itemIconSize}: 1.25rem;
${tokens.itemIconSizeTight}: 1.25rem;
${tokens.cellPadding}: 0rem;
${tokens.cellPaddingLeftContent}: 0rem;
Expand Down Expand Up @@ -425,6 +428,9 @@ export const config = {
${tokens.checkboxTriggerBorderColor}: var(--text-secondary);
${tokens.indicatorSize}: 0.375rem;
${tokens.disclosureIconSize}: 1.25rem;
${tokens.disclosureIconMargin}: 0 0 0 0.625rem;
`,
s: css`
${tokens.textFieldHeight}: 2.5rem;
Expand Down Expand Up @@ -506,7 +512,7 @@ export const config = {
${tokens.itemPadding}: 0.5rem 0.625rem;
${tokens.itemPaddingTight}: 0.5rem 0.625rem;
${tokens.itemBorderRadius}: 0.5rem;
${tokens.itemIconSize}: 1.5rem;
${tokens.itemIconSize}: 1rem;
${tokens.itemIconSizeTight}: 1rem;
${tokens.itemIconMargin}: 0 0.5rem 0 0;
Expand Down Expand Up @@ -539,6 +545,9 @@ export const config = {
${tokens.checkboxTriggerBorderColor}: var(--text-secondary);
${tokens.indicatorSize}: 0.375rem;
${tokens.disclosureIconSize}: 1rem;
${tokens.disclosureIconMargin}: 0 0 0 0.5rem;
`,
xs: css`
${tokens.textFieldHeight}: 2rem;
Expand Down Expand Up @@ -653,6 +662,9 @@ export const config = {
${tokens.checkboxTriggerBorderColor}: var(--text-secondary);
${tokens.indicatorSize}: 0.375rem;
${tokens.disclosureIconSize}: 1rem;
${tokens.disclosureIconMargin}: 0 0 0 0.375rem;
`,
},
labelPlacement: {
Expand Down
19 changes: 16 additions & 3 deletions packages/sdds-insol/src/components/Select/Select.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ export const config = {
${tokens.checkboxTriggerBorderColor}: var(--text-secondary);
${tokens.indicatorSize}: 0.375rem;
${tokens.disclosureIconSize}: 1.5rem;
${tokens.disclosureIconMargin}: 0 0 0 0.625rem;
`,
m: css`
${tokens.textFieldHeight}: 3rem;
Expand Down Expand Up @@ -466,8 +469,8 @@ export const config = {
${tokens.itemPaddingTight}: 0.5rem 0.875rem;
${tokens.itemBorderRadius}: 0.625rem;
${tokens.itemIconMargin}: 0 0.625rem 0 0;
${tokens.itemIconSize}: 1.5rem;
${tokens.itemIconSizeTight}: 1.5rem;
${tokens.itemIconSize}: 1.25rem;
${tokens.itemIconSizeTight}: 1.25rem;
${tokens.cellPadding}: 0rem;
${tokens.cellPaddingLeftContent}: 0rem;
Expand Down Expand Up @@ -498,6 +501,9 @@ export const config = {
${tokens.checkboxTriggerBorderColor}: var(--text-secondary);
${tokens.indicatorSize}: 0.375rem;
${tokens.disclosureIconSize}: 1.25rem;
${tokens.disclosureIconMargin}: 0 0 0 0.625rem;
`,
s: css`
${tokens.textFieldHeight}: 2.5rem;
Expand Down Expand Up @@ -582,7 +588,7 @@ export const config = {
${tokens.itemPadding}: 0.5rem 0.625rem;
${tokens.itemPaddingTight}: 0.5rem 0.625rem;
${tokens.itemBorderRadius}: 0.5rem;
${tokens.itemIconSize}: 1.5rem;
${tokens.itemIconSize}: 1rem;
${tokens.itemIconSizeTight}: 1rem;
${tokens.itemIconMargin}: 0 0.5rem 0 0;
Expand Down Expand Up @@ -615,6 +621,10 @@ export const config = {
${tokens.checkboxTriggerBorderColor}: var(--text-secondary);
${tokens.indicatorSize}: 0.375rem;
${tokens.disclosureIconSize}: 1rem;
${tokens.disclosureIconMargin}: 0 0 0 0.625rem;
${tokens.disclosureIconMargin}: 0 0 0 0.5rem;
`,
xs: css`
${tokens.textFieldHeight}: 2rem;
Expand Down Expand Up @@ -732,6 +742,9 @@ export const config = {
${tokens.checkboxTriggerBorderColor}: var(--text-secondary);
${tokens.indicatorSize}: 0.375rem;
${tokens.disclosureIconSize}: 1rem;
${tokens.disclosureIconMargin}: 0 0 0 0.375rem;
`,
},
labelPlacement: {
Expand Down

0 comments on commit 352af87

Please sign in to comment.