-
Notifications
You must be signed in to change notification settings - Fork 90
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
Conversation
const { container } = render(<StyledClose />); | ||
const { container } = render( | ||
<StyledClose> | ||
<XStrokeIcon /> |
There was a problem hiding this comment.
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 | ||
})` |
There was a problem hiding this comment.
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.
react-components/packages/buttons/src/styled/StyledIconButton.ts
Lines 72 to 74 in 5282298
export const StyledIconButton = styled(StyledButton as 'button').attrs({ | |
'data-garden-id': COMPONENT_ID, | |
'data-garden-version': PACKAGE_VERSION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/modals/package.json
Outdated
"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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not be added as a peer dependency. Compare with https://github.com/zendeskgarden/react-components/blob/main/packages/grid/package.json
font-size: ${props => props.theme.fontSizes.md}; | ||
${props => retrieveComponentStyles(COMPONENT_ID, props)}; | ||
${props => retrieveComponentStyles(props['data-garden-id'], props)}; |
There was a problem hiding this comment.
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
border-bottom: ${({ theme }) => | ||
`${theme.borders.sm} ${getColor({ theme, variable: 'border.subtle' })}`}; |
There was a problem hiding this comment.
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 }, |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return shadows.lg(offsetY, blurRadius, color as string); | |
return shadows.lg(offsetY, blurRadius, color); |
Should no longer need the cast with getColor
.
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' })}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto re: extracting colorStyles
Do we want to toggle the system |
That's a great idea! π₯ Should individual components (in this case Setting it at the component level is more error-prone since we may forget to add the rule. Leaving that responsibility to |
β¦ ze-flo/modal-recolor
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 |
|
||
& > svg { | ||
vertical-align: middle; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π§Ή
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
There was a problem hiding this 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.
const color = getColor({ | ||
theme, | ||
hue: 'neutralHue', | ||
shade: 1200, | ||
light: { transparency: theme.opacity[200] }, | ||
dark: { transparency: theme.opacity[800] } | ||
}); | ||
|
||
return shadows.lg(offsetY, blurRadius, color); | ||
}; |
There was a problem hiding this comment.
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.
β¦ ze-flo/modal-recolor
const offsetY = `${theme.space.base * 5}px`; | ||
const blurRadius = `${theme.space.base * 7}px`; |
There was a problem hiding this comment.
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:
react-components/packages/theming/src/utils/menuStyles.ts
Lines 67 to 71 in 9f82a02
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 | |
)}; |
There was a problem hiding this comment.
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. π
There was a problem hiding this comment.
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.
took a peak and it looks gr8!! just to clarify, i am just reviewing |
${colorStyles}; | ||
|
There was a problem hiding this comment.
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};
.
Description
Adds dark / light mode support to
Modal
Detail
Modal
IconButton
to remove duplicated css forStyledClose
buttonLight
Dark
Checklist
npm start
)π€ renders as expected with Bedrock CSS (?bedrock
)