From 270e1f4ff99717eae7dc4cf4952f559cd26dffa6 Mon Sep 17 00:00:00 2001 From: nikitaorliak-cengage Date: Tue, 15 Oct 2024 19:03:13 +0200 Subject: [PATCH] fix(Select): Fix the placeholder's color (#1489) Co-authored-by: Nikita Orliak --- .changeset/fix-select-placeholder-color.md | 5 +++++ .../src/components/Select/MultiSelect.tsx | 15 +++++++++---- .../src/components/Select/Select.tsx | 19 +++++++++++----- .../src/components/Select/shared.ts | 22 +++++++++++++++++-- 4 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 .changeset/fix-select-placeholder-color.md diff --git a/.changeset/fix-select-placeholder-color.md b/.changeset/fix-select-placeholder-color.md new file mode 100644 index 000000000..e4b9e576a --- /dev/null +++ b/.changeset/fix-select-placeholder-color.md @@ -0,0 +1,5 @@ +--- +'react-magma-dom': patch +--- + +fix(Select): Fix placeholder color. \ No newline at end of file diff --git a/packages/react-magma-dom/src/components/Select/MultiSelect.tsx b/packages/react-magma-dom/src/components/Select/MultiSelect.tsx index 85b6fda11..3907c2408 100644 --- a/packages/react-magma-dom/src/components/Select/MultiSelect.tsx +++ b/packages/react-magma-dom/src/components/Select/MultiSelect.tsx @@ -256,10 +256,17 @@ export function MultiSelect(props: MultiSelectProps) { ); }) - ) : typeof placeholder === 'string' ? ( - {placeholder} ) : ( - {i18n.multiSelect.placeholder} + + {typeof placeholder === 'string' + ? placeholder + : i18n.multiSelect.placeholder} + )} @@ -277,7 +284,7 @@ export function MultiSelect(props: MultiSelectProps) { position: 'absolute', right: '3.25em', top: '50%', - transform: 'translateY(-50%)' + transform: 'translateY(-50%)', }} /> )} diff --git a/packages/react-magma-dom/src/components/Select/Select.tsx b/packages/react-magma-dom/src/components/Select/Select.tsx index bbdb7efee..a3b672cba 100644 --- a/packages/react-magma-dom/src/components/Select/Select.tsx +++ b/packages/react-magma-dom/src/components/Select/Select.tsx @@ -186,7 +186,16 @@ export function Select(props: SelectProps) { style={inputStyle} toggleButtonProps={toggleButtonProps} > - {selectText} + + {selectText} + {isClearable && selectedItem && ( @@ -196,11 +205,11 @@ export function Select(props: SelectProps) { onClick={defaultHandleClearIndicatorClick} isInverse={isInverse} size={ButtonSize.small} - style={{ - position: 'absolute', - right: '3.25em', + style={{ + position: 'absolute', + right: '3.25em', top: '50%', - transform: 'translateY(-50%)' + transform: 'translateY(-50%)', }} testId="clearIndicator" variant={ButtonVariant.link} diff --git a/packages/react-magma-dom/src/components/Select/shared.ts b/packages/react-magma-dom/src/components/Select/shared.ts index 0991ecd30..cbc9c4113 100644 --- a/packages/react-magma-dom/src/components/Select/shared.ts +++ b/packages/react-magma-dom/src/components/Select/shared.ts @@ -2,6 +2,8 @@ import { inputBaseStyles } from '../InputBase'; import { Card } from '../Card'; import { transparentize } from 'polished'; import styled from '@emotion/styled'; +import { ThemeInterface } from '../../theme/magma'; +import { css } from '@emotion/react'; function buildListHoverColor(props) { if (props.isFocused) { @@ -34,12 +36,28 @@ export const StyledButton = styled.div` text-align: left; `; -export const SelectText = styled.span<{ isClearable?: boolean }>` +export const SelectText = styled.span<{ + isClearable?: boolean; + isShowPlaceholder?: boolean; + isInverse?: boolean; + isDisabled?: boolean; + theme?: ThemeInterface; +}>` padding-left: 4px; - padding-right: ${props => props.isClearable ? '2.5em' : '1.5em'}; + padding-right: ${props => (props.isClearable ? '2.5em' : '1.5em')}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + color: ${props => { + if (props.isShowPlaceholder) { + return props.isInverse + ? transparentize(0.3, props.theme.colors.neutral100) + : props.theme.colors.neutral500; + } + }}; + ${props => props.isDisabled && props.isShowPlaceholder && css` + opacity: ${props.isInverse ? 0.4 : 0.6} + `} `; export const StyledCard = styled(Card)<{