From 8cd76f7cff475794c1bffd08e98d11be286b4e3c Mon Sep 17 00:00:00 2001 From: Aleksandra Danilina Date: Wed, 25 Jan 2023 14:12:56 +0100 Subject: [PATCH 1/2] fix: Option description has sufficient color contrast in dark mode --- src/autosuggest/autosuggest-option.tsx | 2 +- src/internal/components/option/constants.scss | 1 + src/internal/components/option/index.tsx | 20 ++++++- src/internal/components/option/interfaces.ts | 2 + .../components/option/option-parts.tsx | 54 ++++++++++++++----- src/internal/components/option/styles.scss | 8 +++ src/select/parts/item.tsx | 7 ++- src/select/parts/multiselect-item.tsx | 8 ++- style-dictionary/utils/token-names.ts | 2 +- style-dictionary/visual-refresh/colors.ts | 1 + 10 files changed, 86 insertions(+), 19 deletions(-) diff --git a/src/autosuggest/autosuggest-option.tsx b/src/autosuggest/autosuggest-option.tsx index 4e312994fb..4009cf03ff 100644 --- a/src/autosuggest/autosuggest-option.tsx +++ b/src/autosuggest/autosuggest-option.tsx @@ -61,7 +61,7 @@ const AutosuggestOption = ( optionContent = (
- +
); } diff --git a/src/internal/components/option/constants.scss b/src/internal/components/option/constants.scss index f4d0eca5a5..01690004c7 100644 --- a/src/internal/components/option/constants.scss +++ b/src/internal/components/option/constants.scss @@ -7,3 +7,4 @@ @use '../../styles/tokens' as awsui; $tags-description-color: awsui.$color-text-dropdown-item-secondary; +$tags-description-color-hover: awsui.$color-text-dropdown-item-secondary-hover; diff --git a/src/internal/components/option/index.tsx b/src/internal/components/option/index.tsx index b64b740930..80e1cca222 100644 --- a/src/internal/components/option/index.tsx +++ b/src/internal/components/option/index.tsx @@ -25,6 +25,8 @@ const Option = ({ highlightText, triggerVariant = false, isGroupOption = false, + highlightedOption = false, + selectedOption = false, ...restProps }: OptionProps) => { if (!option) { @@ -76,10 +78,24 @@ const Option = ({ /> - - + + diff --git a/src/internal/components/option/interfaces.ts b/src/internal/components/option/interfaces.ts index 52db0595b7..6ca579e31c 100644 --- a/src/internal/components/option/interfaces.ts +++ b/src/internal/components/option/interfaces.ts @@ -40,5 +40,7 @@ export interface OptionProps extends BaseComponentProps { option?: InternalOptionDefinition; triggerVariant?: boolean; highlightText?: string; + highlightedOption?: boolean; + selectedOption?: boolean; isGroupOption?: boolean; } diff --git a/src/internal/components/option/option-parts.tsx b/src/internal/components/option/option-parts.tsx index 48d10e819e..a6c88a9b13 100644 --- a/src/internal/components/option/option-parts.tsx +++ b/src/internal/components/option/option-parts.tsx @@ -36,30 +36,47 @@ export const LabelTag = ({ labelTag, highlightText, triggerVariant }: LabelTagPr interface DescriptionProps { description?: string; + highlightedOption: boolean; highlightText?: string; + selectedOption: boolean; triggerVariant: boolean; } -export const Description = ({ description, highlightText, triggerVariant }: DescriptionProps) => +export const Description = ({ + description, + highlightedOption, + highlightText, + selectedOption, + triggerVariant, +}: DescriptionProps) => description ? ( - // We do not reach AA compliance in Dark mode for highlighted state - // TODO: Remove aria-disabled={true} when we fix AWSUI-10333 - + ) : null; interface TagsProps { tags?: ReadonlyArray; + highlightedOption: boolean; highlightText?: string; + selectedOption: boolean; triggerVariant: boolean; } -export const Tags = ({ tags, highlightText, triggerVariant }: TagsProps) => +export const Tags = ({ tags, highlightedOption, highlightText, selectedOption, triggerVariant }: TagsProps) => tags ? ( - + {tags.map((tag, idx) => ( - // We do not reach AA compliance in Dark mode for highlighted state - // TODO: Remove aria-disabled={true} when we fix AWSUI-10333 - + ))} @@ -68,10 +85,18 @@ export const Tags = ({ tags, highlightText, triggerVariant }: TagsProps) => interface FilteringTagProps { filteringTags?: ReadonlyArray; + highlightedOption: boolean; highlightText?: string; + selectedOption: boolean; triggerVariant: boolean; } -export const FilteringTags = ({ filteringTags, highlightText, triggerVariant }: FilteringTagProps) => { +export const FilteringTags = ({ + filteringTags, + highlightedOption, + highlightText, + selectedOption, + triggerVariant, +}: FilteringTagProps) => { if (!highlightText || !filteringTags) { return null; } @@ -79,13 +104,16 @@ export const FilteringTags = ({ filteringTags, highlightText, triggerVariant }: const searchElement = highlightText.toLowerCase(); return ( - + {filteringTags.map((filteringTag, key) => { const match = filteringTag.toLowerCase().indexOf(searchElement) !== -1; if (match) { return ( - // We do not reach AA compliance in Dark mode for highlighted state - // TODO: Remove aria-disabled={true} when we fix AWSUI-10333 +