Skip to content

Conversation

@ze-flo
Copy link
Contributor

@ze-flo ze-flo commented May 29, 2024

Description

Adds dark / light mode support for loaders.

Detail

  • Adds dark / light mode support for loaders
  • Removes duplicate specs

Important

Spinner, Dots, and Inline now default to the agreed mode-specific color rather than inheriting it from the parent container.

Checklist

  • 👌 design updates will be Garden Designer approved (add the designer as a reviewer)
  • 🌐 demo is up-to-date (npm start)
  • ⬅️ renders as expected with reversed (RTL) direction
  • 🤘 renders as expected with Bedrock CSS (?bedrock)
  • 💂‍♂️ includes new unit tests. Maintain existing coverage (always >= 96%)
  • ♿ tested for WCAG 2.1 AA accessibility compliance
  • 📝 tested in Chrome, Firefox, Safari, and Edge

<div
style={{
backgroundColor: backgroundColor || (args.isLight ? PALETTE.kale[600] : undefined),
backgroundColor: backgroundColor || (args.isLight ? PALETTE.kale[800] : undefined),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumping the shade in accordance to the handy-dandy v8-to-v9 color mapping tool. 👍

@ze-flo ze-flo marked this pull request as ready for review May 29, 2024 19:50
@ze-flo ze-flo requested a review from a team as a code owner May 29, 2024 19:50
@ze-flo ze-flo requested review from lucijanblagonic and steue May 29, 2024 19:50
@lucijanblagonic
Copy link

Spinner, Dots, and Inline now default to the agreed mode-specific color rather than inheriting it from the parent container.

@ze-flo Could you expand a bit on why that is the case?

Skeleton isLight loader
image

The color on this one seems a bit off, it should be white, .16%. I see we didn't have that specced up in our inventory.

image
(default switched to dark on the top, isLight in dark mode on the bottom)

Overall, the isLight in dark mode is a bit ligther in dark mode when it's using white. Is that doable?

And another question, is there an easy way to see which variable is being used and where in Storybook? Inspector is showing the color value only, and Variables section shows main variables only.

@ze-flo
Copy link
Contributor Author

ze-flo commented May 30, 2024

Spinner, Dots, and Inline now default to the agreed mode-specific color rather than inheriting it from the parent container.

@ze-flo Could you expand a bit on why that is the case?

Skeleton isLight loader
image

The color on this one seems a bit off, it should be white, .16%. I see we didn't have that specced up in our inventory.

image (default switched to dark on the top, isLight in dark mode on the bottom)

Overall, the isLight in dark mode is a bit ligther in dark mode when it's using white. Is that doable?

And another question, is there an easy way to see which variable is being used and where in Storybook? Inspector is showing the color value only, and Variables section shows main variables only.


@ze-flo Could you expand a bit on why that is the case?

Based on @jzempel's comment, we need to align on whether we should keep the color inheritance or set the default color ourselves.

Overall, the isLight in dark mode is a bit ligther in dark mode when it's using white. Is that doable?

Absolutely doable! 💯

Let me recap for clarity:

Regular Skeleton

Light mode

neutral[700] / 16%

Dark mode

neutral[500] / 16%

Light Skeleton

Light mode

neutral[500] / 16% // the regular Skeleton's color in Dark mode

Dark mode

white / 16%

@lucijanblagonic Is this correct?

And another question, is there an easy way to see which variable is being used and where in Storybook? Inspector is showing the color value only, and Variables section shows main variables only.

Sadly, it's impossible at this time. 😞 Garden components do not reference CSS variables. Instead they get their calculated color values at runtime from our getColor function.

@lucijanblagonic
Copy link

lucijanblagonic commented May 31, 2024

Light Skeleton

Light mode

neutral[500] / 16% // the regular Skeleton's color in Dark mode

Dark mode

white / 16%

Light mode should also be white / 16%. The reason is that isLight might be used to place a Skeleton on a filled (color) surface and we don't want to overlay grey loader on top of it. Light skeleton is a deliberate styling decision so it should be white at all times.

Sadly, it's impossible at this time. 😞 Garden components do not reference CSS variables. Instead they get their calculated color values at runtime from our getColor function.

OK, so we can only review color values, and we are counting on eng to implement correct variables (e.g. progress loaders might use bg group, not border and it should be 100% clear from the inventory)?

@coveralls
Copy link

coveralls commented May 31, 2024

Coverage Status

coverage: 96.084%. remained the same
when pulling 58139ad on ze-flo/loaders-recolor
into cffdb06 on next.

Comment on lines +37 to +44
const backgroundColor = getColor({
theme,
hue: 'neutralHue',
transparency: theme.opacity[200],
light: { shade: 700 },
dark: { shade: 500 }
});
const foregroundColor = color || getColor({ theme, variable: 'border.successEmphasis' });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so we can only review color values, and we are counting on eng to implement correct variables (e.g. progress loaders might use bg group, not border and it should be 100% clear from the inventory)?

@lucijanblagonic I always define colors using the variables found in the inventory first.

For Progress bar, the foregroundColor uses border.successEmphasis. It exists in our collection of border variables so I used it.

The backgroundColor uses WIP_opacity/neutral (700 : 500)/200, which is the same as foreground.subtle. However, because we don't have a background variable that matches the hue / shade combo per mode, I build it using advanced getColor options.

I hope this answers your question. If this isn't the right approach, let me know.

Thanks!

}: IStyledProgressBackgroundProps & ThemeProps<DefaultTheme>) => {
const backgroundColor = getColor({
theme,
hue: 'neutralHue',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this inherit from a background variable? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed with Design, we're not tying this one to a variable, but rather build it from scratch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, I think @geotrev's point of tying this to foreground.subtle actually does make sense as the background of this loader actually functions as a subtle foreground color when Progress is applied to a page. Let's not make any adjustments now, but I want to reserve space to triple-check semantics with design before v9 wraps up.

Comment on lines 14 to 24

const PULSE_ANIMATION = keyframes`
0%, 100% {
opacity: .2;
const retrieveAnimation = ({ theme }: ThemeProps<DefaultTheme>) => keyframes`
0% {
opacity: 1;
}
50% {
opacity: .8;
opacity: ${theme.opacity[600]};
}
100% {
opacity: ${theme.opacity[200]};
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did the 0% portion of the animation change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aligning with Figma, where the first dot has 100% opacity.

Screenshot 2024-06-06 at 7 26 45 AM

Copy link
Member

@jzempel jzempel Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I checked with @lucijanblagonic and he wasn't expecting the animation to materially change based on Figma. And now we're seeing some odd animation with the Inline loader (no longer smooth as it was before). I think we should revert here (while retaining the theme.opacity usage).

}: IStyledProgressBackgroundProps & ThemeProps<DefaultTheme>) => {
const backgroundColor = getColor({
theme,
hue: 'neutralHue',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, I think @geotrev's point of tying this to foreground.subtle actually does make sense as the background of this loader actually functions as a subtle foreground color when Progress is applied to a page. Let's not make any adjustments now, but I want to reserve space to triple-check semantics with design before v9 wraps up.

@ze-flo ze-flo merged commit dd386ec into next Jun 7, 2024
@ze-flo ze-flo deleted the ze-flo/loaders-recolor branch June 7, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

7 participants