Skip to content

Commit

Permalink
fix: Improve progress bar color contrast in warning flash message (#2480
Browse files Browse the repository at this point in the history
)
  • Loading branch information
avinashbot committed Jul 24, 2024
1 parent e23c109 commit f46ab18
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 34 deletions.
8 changes: 8 additions & 0 deletions pages/progress-bar/permutations-flash.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ export default function ProgressBarPermutations() {
statusIconAriaLabel: 'info',
}))}
/>
<Flashbar
items={permutations.map(permutation => ({
type: 'warning',
content: <ProgressBar {...permutation} variant="flash" />,
buttonText: permutation.resultButtonText,
statusIconAriaLabel: 'warning',
}))}
/>
</ScreenshotArea>
</article>
);
Expand Down
41 changes: 7 additions & 34 deletions src/progress-bar/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

.label {
&-flash {
color: 'inherit';
color: inherit;
font-weight: styles.$font-weight-bold;
}
&-key-value {
Expand Down Expand Up @@ -94,14 +94,11 @@ $background-color-in-flash: awsui.$color-background-progress-bar-layout-in-flash
$bar-color: awsui.$color-background-progress-bar-content-default;
$bar-color-in-flash: awsui.$color-background-progress-bar-content-in-flash;

// Current version of Edge has a known bug with CSS variables used in pseudo elements.
$bar-color-edge: #0073bb;
$bar-color-edge-in-flash: rgba(255, 255, 255, 0.7);

.progress {
inline-size: 100%;
margin-inline-end: awsui.$space-s;
min-inline-size: 0;

@include general-progress-background-style;
background-color: $background-color;

Expand All @@ -110,31 +107,13 @@ $bar-color-edge-in-flash: rgba(255, 255, 255, 0.7);
background-color: $background-color;
}

&::-webkit-progress-value {
@include general-progress-bar-style;
background-color: $bar-color;
}

&.complete::-webkit-progress-value {
border-start-start-radius: 10px;
border-start-end-radius: 10px;
border-end-start-radius: 10px;
border-end-end-radius: 10px;
}

&::-webkit-progress-value,
&::-moz-progress-bar {
@include general-progress-bar-style;
background-color: $bar-color;
}

&::-ms-fill {
@include general-progress-bar-style;
background-color: $bar-color-edge;
border-block: none;
border-inline: none;
}

&.complete::-ms-fill {
&.complete::-webkit-progress-value {
border-start-start-radius: 10px;
border-start-end-radius: 10px;
border-end-start-radius: 10px;
Expand All @@ -143,22 +122,16 @@ $bar-color-edge-in-flash: rgba(255, 255, 255, 0.7);

&.progress-in-flash {
background-color: $background-color-in-flash;
&::-moz-progress-bar {
background-color: $bar-color-in-flash;
}

&::-webkit-progress-bar {
background-color: $background-color-in-flash;
}

&::-webkit-progress-value {
background-color: $bar-color-in-flash;
}

&::-moz-progress-bar {
background-color: $bar-color-in-flash;
}

&::-ms-fill {
background-color: $bar-color-edge-in-flash;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions style-dictionary/utils/token-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export type ColorChartsTokenName =
| 'colorChartsPaletteCategorical49'
| 'colorChartsPaletteCategorical50';
export type ColorsTokenName =
| 'colorGreyOpaque10'
| 'colorGreyOpaque25'
| 'colorGreyOpaque40'
| 'colorGreyOpaque50'
Expand Down
1 change: 1 addition & 0 deletions style-dictionary/visual-refresh/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { expandColorDictionary } from '../utils';
import { StyleDictionary } from '../utils/interfaces';

const tokens: StyleDictionary.ColorsDictionary = {
colorGreyOpaque10: 'rgba(0, 0, 0, 0.1)',
colorGreyOpaque25: 'rgba(255, 255, 255, 0.25)',
colorGreyOpaque40: 'rgba(0, 0, 0, 0.4)',
colorGreyOpaque50: 'rgba(0, 0, 0, 0.5)',
Expand Down
5 changes: 5 additions & 0 deletions style-dictionary/visual-refresh/contexts/flashbar-warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export const sharedTokens: StyleDictionary.ColorsDictionary = {
colorTextInteractiveInvertedDefault: '{colorGrey600}',
colorTextInteractiveInvertedHover: '{colorGrey900}',

// Progress bars in flashbars should be using variant="flash" (which uses a white background by default).
// For the warning state, it should use colorGrey900.
colorBackgroundProgressBarContentInFlash: '{colorGrey900}',
colorBackgroundProgressBarLayoutInFlash: '{colorGreyOpaque10}',

// Expandable sections
colorTextExpandableSectionDefault: '{colorTextNotificationYellow}',
colorTextExpandableSectionHover: '{colorTextNotificationYellow}',
Expand Down

0 comments on commit f46ab18

Please sign in to comment.