Skip to content

Commit

Permalink
Apply new tag styles in select inputs multivalue (#2780)
Browse files Browse the repository at this point in the history
* feat(select input): apply new tag styles in select inputs multivalue

* feat(select input): include background color change for readonly

* feat(create select input): extract function for hover styles

* feat(create select input): extract function for multi styles

---------

Co-authored-by: Ddouglasz <[email protected]>
  • Loading branch information
ddouglasz and Ddouglasz authored Apr 16, 2024
1 parent 0bfbd9e commit cd66594
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-grapes-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-uikit/select-utils': minor
---

Apply the new tag styles in the select input multi value tags
37 changes: 23 additions & 14 deletions packages/components/inputs/select-utils/src/create-select-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ const getInputBackgroundColor = (props: TProps) => {
return designTokens.backgroundColorForInput;
};

const getMultiValueBackgroundColor = (props: TProps) => {
if (props.isDisabled) return designTokens.backgroundColorForInputWhenDisabled;
if (props.isReadOnly) return designTokens.backgroundColorForInputWhenReadonly;
return designTokens.colorPrimary95;
};

const getInputBorderColor = (props: TProps, state: TState) => {
if (props.appearance === 'quiet') {
return designTokens.borderColorForInputAsQuiet;
Expand Down Expand Up @@ -162,6 +168,17 @@ const getHoverInputBorderColor = (props: TProps) => {
return designTokens.borderColorForInputWhenHovered;
};

const getHoverInputBackgroundColor = (props: TProps) => {
if (!props.isDisabled && !props.isReadOnly) {
if (props.appearance === 'quiet') {
return designTokens.backgroundColorForInputAsQuietWhenHovered;
} else {
return designTokens.backgroundColorForInputWhenHovered;
}
}
return null;
};

const controlStyles = (props: TProps) => (base: TBase, state: TState) => {
return {
...base,
Expand Down Expand Up @@ -208,16 +225,7 @@ const controlStyles = (props: TProps) => (base: TBase, state: TState) => {

'&:hover': {
borderColor: getHoverInputBorderColor(props),
backgroundColor: (() => {
if (!props.isDisabled && !props.isReadOnly) {
if (props.appearance === 'quiet') {
return designTokens.backgroundColorForInputAsQuietWhenHovered;
} else {
return designTokens.backgroundColorForInputWhenHovered;
}
}
return null;
})(),
backgroundColor: getHoverInputBackgroundColor(props),
},
pointerEvents: 'auto',
color:
Expand Down Expand Up @@ -449,15 +457,16 @@ const menuPortalStyles = (props: TProps) => (base: TBase) => ({
zIndex: props.menuPortalZIndex,
});

const multiValueStyles = () => (base: TBase) => {
const multiValueStyles = (props: TProps) => (base: TBase) => {
return {
...base,
display: 'flex',
alignItems: 'center',
height: '32px',
backgroundColor: designTokens.colorNeutral95,
padding: '0',
backgroundColor: getMultiValueBackgroundColor(props),
padding: designTokens.spacing20,
border: `1px solid ${designTokens.colorNeutral85}`,
borderRadius: designTokens.borderRadius20,
};
};

Expand Down Expand Up @@ -521,7 +530,7 @@ export default function createSelectStyles(props: TProps) {
clearIndicator: clearIndicatorStyles(),
menuList: menuListStyles(),
menuPortal: menuPortalStyles(props),
multiValue: multiValueStyles(),
multiValue: multiValueStyles(props),
multiValueLabel: multiValueLabelStyles(props),
multiValueRemove: multiValueRemoveStyles(props),
indicatorsContainer: indicatorsContainerStyles(),
Expand Down

0 comments on commit cd66594

Please sign in to comment.