Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Modal): new light/dark mode colors #1808

Merged
merged 10 commits into from
May 22, 2024
Merged

feat(Modal): new light/dark mode colors #1808

merged 10 commits into from
May 22, 2024

Conversation

ze-flo
Copy link
Contributor

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

Description

Adds dark / light mode support to Modal

Detail

  • Adds dark / light mode support to Modal
  • Reuse IconButton to remove duplicated css for StyledClose button

Light

Screenshot 2024-05-16 at 2 10 54β€―PM

Dark

Screenshot 2024-05-16 at 2 10 10β€―PM

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

const { container } = render(<StyledClose />);
const { container } = render(
<StyledClose>
<XStrokeIcon />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

StyledClose extends IconButton and now requires a child.

* 1. Remove dotted outline from Firefox on focus.
*/
export const StyledClose = styled.button.attrs({
export const StyledClose = styled(IconButton).attrs({
'data-garden-id': COMPONENT_ID,
'data-garden-version': PACKAGE_VERSION
})`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Keeping as is for now even though attributes set on StyledIconButton take precedence.

export const StyledIconButton = styled(StyledButton as 'button').attrs({
'data-garden-id': COMPONENT_ID,
'data-garden-version': PACKAGE_VERSION

Copy link
Member

Choose a reason for hiding this comment

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

Hey @ze-flo, I have a commit on the buttons PR that resolves the issue πŸ™Œ

packages/modals/src/styled/StyledClose.ts Show resolved Hide resolved
@ze-flo ze-flo marked this pull request as ready for review May 14, 2024 22:56
@ze-flo ze-flo requested a review from a team as a code owner May 14, 2024 22:56
Copy link
Member

@jzempel jzempel left a comment

Choose a reason for hiding this comment

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

Let's remove all breaking change (title, description, tags) mention on this PR in favor of having that discussion in #1804 which will resolve the matter. Also, let's get #1807 merged before obtaining designer review here.

"dom-helpers": "^5.1.0",
"prop-types": "^15.5.7",
"react-merge-refs": "^2.0.0",
"react-transition-group": "^4.4.2"
},
"peerDependencies": {
"@zendeskgarden/react-buttons": ">=9.0.0-next",
Copy link
Member

Choose a reason for hiding this comment

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

font-size: ${props => props.theme.fontSizes.md};
${props => retrieveComponentStyles(COMPONENT_ID, props)};
${props => retrieveComponentStyles(props['data-garden-id'], props)};
Copy link
Member

Choose a reason for hiding this comment

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

Let's revert to COMPONENT_ID and keep the current pattern consistent. Defer discussion to #1804

packages/modals/src/styled/StyledClose.ts Show resolved Hide resolved
Comment on lines 36 to 37
border-bottom: ${({ theme }) =>
`${theme.borders.sm} ${getColor({ theme, variable: 'border.subtle' })}`};
Copy link
Member

Choose a reason for hiding this comment

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

When there are > 1 color-related styles, let's consolidate into a colorStyles function as directed by the API docs (and dark mode RFC). The border-bottom: ${props => props.theme.borders.sm}; stays here, and border-bottom-color can move to the colorStyles function.

Per RFC, consider opportunities to also extract sizeStyles when the lift isn't too big (I would probably do that here, as it would alleviate a lot of the inline styling clunkiness in favor of variable declaration clarity)

theme,
hue: 'neutralHue',
shade: 1200,
light: { transparency: 0.15 },
Copy link
Member

Choose a reason for hiding this comment

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

This transparency looks incorrect. Please consult design re: theme.opacity[200]

shade: 1200,
light: { transparency: 0.15 },
dark: { transparency: theme.opacity['800'] }
});

return shadows.lg(offsetY, blurRadius, color as string);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return shadows.lg(offsetY, blurRadius, color as string);
return shadows.lg(offsetY, blurRadius, color);

Should no longer need the cast with getColor.

Comment on lines 86 to 90
border: ${({ theme }) =>
`${theme.borders.sm} ${getColor({ theme, variable: 'border.default' })}`};
border-radius: ${props => props.theme.borderRadii.md};
box-shadow: ${boxShadow};
background-color: ${props => getColorV8('background', 600 /* default shade */, props.theme)};
background-color: ${({ theme }) => getColor({ theme, variable: 'background.raised' })};
Copy link
Member

Choose a reason for hiding this comment

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

ditto re: extracting colorStyles

@geotrev
Copy link
Contributor

geotrev commented May 16, 2024

Do we want to toggle the system color-scheme: dark property so scrollbars look correct? https://stackoverflow.com/questions/65940522/how-do-i-switch-to-chromes-dark-scrollbar-like-github-does

@ze-flo
Copy link
Contributor Author

ze-flo commented May 16, 2024

Do we want to toggle the system color-scheme: dark property so scrollbars look correct? https://stackoverflow.com/questions/65940522/how-do-i-switch-to-chromes-dark-scrollbar-like-github-does

That's a great idea! πŸ”₯

Should individual components (in this case Modal.Body) or ThemeProvider dynamically set the color-scheme: dark | light?

Setting it at the component level is more error-prone since we may forget to add the rule.

Leaving that responsibility to ThemeProvider, by creating a global CSS rule via createGlobalStyle, offers a great benefit: every component will automatically inherit the color-scheme related styles.

@jzempel
Copy link
Member

jzempel commented May 16, 2024

Do we want to toggle the system color-scheme: dark property so scrollbars look correct? https://stackoverflow.com/questions/65940522/how-do-i-switch-to-chromes-dark-scrollbar-like-github-does

That's a great idea! πŸ”₯

Should individual components (in this case Modal.Body) or ThemeProvider dynamically set the color-scheme: dark | light?

Setting it at the component level is more error-prone since we may forget to add the rule.

Leaving that responsibility to ThemeProvider, by creating a global CSS rule via createGlobalStyle, offers a great benefit: every component will automatically inherit the color-scheme related styles.

I was going to say no, since consumers can use components without a theming parent. But then they could never toggle dark mode πŸ˜…. So I think ThemeProvider is a solid choice that also benefits custom components rendered within the theme.

@ze-flo ze-flo changed the title feat!(Modal): new light/dark mode colors feat(Modal): new light/dark mode colors May 17, 2024
@ze-flo ze-flo requested a review from steue May 17, 2024 00:33
@ze-flo
Copy link
Contributor Author

ze-flo commented May 17, 2024

Do we want to toggle the system color-scheme: dark property so scrollbars look correct? https://stackoverflow.com/questions/65940522/how-do-i-switch-to-chromes-dark-scrollbar-like-github-does

That's a great idea! πŸ”₯
Should individual components (in this case Modal.Body) or ThemeProvider dynamically set the color-scheme: dark | light?
Setting it at the component level is more error-prone since we may forget to add the rule.
Leaving that responsibility to ThemeProvider, by creating a global CSS rule via createGlobalStyle, offers a great benefit: every component will automatically inherit the color-scheme related styles.

I was going to say no, since consumers can use components without a theming parent. But then they could never toggle dark mode πŸ˜…. So I think ThemeProvider is a solid choice that also benefits custom components rendered within the theme.

@steue Modal is ready for your VQA. Don't worry about the intensely-bright scrollbar in dark mode. This issue isn't solely connected to this component and will be addressed a follow-up PR.

Screenshot 2024-05-16 at 2 36 05β€―PM


& > svg {
vertical-align: middle;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹

Copy link
Contributor

@geotrev geotrev left a comment

Choose a reason for hiding this comment

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

Very nice!

Copy link
Member

@jzempel jzempel left a comment

Choose a reason for hiding this comment

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

[nit] consider setting up local variables in your colorStyles functions rather than inlining in the generated CSS. It benefits CSS readability and future debug maintenance.

Comment on lines 55 to 64
const color = getColor({
theme,
hue: 'neutralHue',
shade: 1200,
light: { transparency: theme.opacity[200] },
dark: { transparency: theme.opacity[800] }
});

return shadows.lg(offsetY, blurRadius, color);
};
Copy link
Member

Choose a reason for hiding this comment

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

Consistent with other Styled components, it would be preferable to ditch the boxShadow function in favor of consolidating the box-shadow property declaration within colorStyles below. See https://github.com/zendeskgarden/react-components/blob/main/docs/api.md#rules ${colorStyles} section for details.

@coveralls
Copy link

coveralls commented May 17, 2024

Coverage Status

coverage: 96.075% (-0.01%) from 96.089%
when pulling 239cff0 on ze-flo/modal-recolor
into 12c7917 on next.

Comment on lines 51 to 52
const offsetY = `${theme.space.base * 5}px`;
const blurRadius = `${theme.space.base * 7}px`;
Copy link
Member

Choose a reason for hiding this comment

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

The spread is different for dark mode. Please compare with in-progress branch:

box-shadow: ${theme.shadows.lg(
`${theme.space.base * (theme.colors.base === 'dark' ? 4 : 5)}px`,
`${theme.space.base * (theme.colors.base === 'dark' ? 5 : 6)}px`,
boxShadowColor
)};

Copy link
Contributor Author

@ze-flo ze-flo May 20, 2024

Choose a reason for hiding this comment

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

Good catch! πŸ’― There is difference in Dark mode. I'll update.

Unrelated... but should we raise these 1px shadow spread differences with design? They seem questionable. πŸ€”

Never mind. It's a multiplier. πŸ˜…

Copy link
Member

Choose a reason for hiding this comment

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

Already did πŸ˜‰; @lucijanblagonic confirmed the difference is intentional.

@steue
Copy link

steue commented May 20, 2024

took a peak and it looks gr8!! just to clarify, i am just reviewing Modal and not tooltip and drawer? if so, then LGTM! thanks @ze-flo

Comment on lines 101 to 102
${colorStyles};

Copy link
Member

Choose a reason for hiding this comment

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

[nit] per https://github.com/zendeskgarden/react-components/blob/main/docs/api.md#rules, ${colorStyles}; should follow ${sizeStyles};.

@ze-flo ze-flo merged commit 2649a2a into next May 22, 2024
5 checks passed
@ze-flo ze-flo deleted the ze-flo/modal-recolor branch May 22, 2024 16:28
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.

None yet

6 participants