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

[CssBaseline] Add colors with better constrast to <a> #38135

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

brijeshb42
Copy link
Contributor

@brijeshb42 brijeshb42 commented Jul 24, 2023

in CssBaseline component for both light and dark modes

Fixes #38017

Light
Screenshot 2023-07-24 at 3 15 11 PM

Dark
Screenshot 2023-07-24 at 3 15 03 PM

@brijeshb42 brijeshb42 added component: CssBaseline The React component package: material-ui Specific to @mui/material labels Jul 24, 2023
@brijeshb42
Copy link
Contributor Author

@danilo-leal Should this also be done for Joy UI?

@mui-bot
Copy link

mui-bot commented Jul 24, 2023

@zanivan
Copy link
Contributor

zanivan commented Jul 24, 2023

Hey @brijeshb42 thanks for tackling this!

Should this also be done for Joy UI?

If the same thing is happening on Joy UI, I see no reason not to solve it there as well

@brijeshb42
Copy link
Contributor Author

Do you want the same tokens there as well or different?

@zanivan
Copy link
Contributor

zanivan commented Jul 24, 2023

Is it possible to use the Joy default theme? If so, you can use the primary 500 #0B6BCB for light and primary 300 #97C3F0 for dark

@brijeshb42
Copy link
Contributor Author

@zanivan I don't see the colors you've mentioned in the default theme. These are the primary tokens in Joy's default theme - https://github.com/mui/material-ui/blob/master/packages/mui-joy/src/colors/colors.ts#L14

@zanivan
Copy link
Contributor

zanivan commented Jul 24, 2023

Right, sorry, my mistake 😅
I sent the colors that we're using on the new default theme #36843
That said, you can keep the same primary 500 and primary 300, but with the current token colors—and when we merge the new default theme it can be revamped.

@@ -43,6 +43,10 @@ export const styles = (theme, enableColorScheme = false) => {
'strong, b': {
fontWeight: theme.typography.fontWeightBold,
},
a: {
color:
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
color:
color: (theme.vars || theme).palette.primary.main,

I think primary.main should be the best one for links?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've followed @danilo-leal's pointer #38017 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@siriwatknp Do you still want the change to reference theme.vars ?

Copy link
Member

Choose a reason for hiding this comment

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

It might be better as identical to what Link uses for design consistency

https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Link/Link.js (color + text decoration + hover)

in CssBaseline component for both light and dark modes
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 27, 2023

Is this even needed? I would expect enableColorScheme to cover the color contrast bug report in #38017.

Now, it makes sense to me to consider if we want design consistency from CssBaseline, I would expect Tailwind CSS and Bootstrap to reset the look of links as well. For v6, I wanted to revisit all the style in CssBaseline, e.g. https://moderncss.dev/modern-css-for-dynamic-component-based-architecture/. I mentioned it in #30660

@oliviertassinari oliviertassinari changed the title [material] add colors with better constrast to <a> [CssBaseline] Add colors with better constrast to <a> Jul 27, 2023
@brijeshb42
Copy link
Contributor Author

@oliviertassinari This is mainly added so that the link colors are set to material/joy colors for both dark/light mode. Reset from tailwind or other solution don't do anything for the color.

Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

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

Looking good! The colors I provided earlier were pulled from the company's branding theme, but it does sound like a good call to use each package's default theme colors, same tokens though. In summary:

  • Material UI uses Material Design colors.
  • Joy UI uses the Joy default theme colors.
  • Continue to use 500 for light and 300 for dark mode.

docs/data/joy/components/css-baseline/css-baseline.md Outdated Show resolved Hide resolved
docs/data/material/components/css-baseline/css-baseline.md Outdated Show resolved Hide resolved
@danilo-leal danilo-leal added package: joy-ui Specific to @mui/joy design This is about UI or UX design, please involve a designer labels Jul 31, 2023
@oliviertassinari
Copy link
Member

@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 1, 2023

The more we add style resets like this, the more I think in the future we can consider isolating each reset type:

  1. One for pure default CSS coherence and ease, e.g. https://tailwindcss.com/docs/preflight
  2. One for theme design token applications, e.g. https://tailwindcss.com/docs/typography-plugin

In our case, maybe we shouldn't reset the <a> link style in CssBaseline, but to keep it focused on 1. We could cover the issue with the <a> link style under 2. with #14876. I don't know but to consider.

@@ -43,6 +43,10 @@ export const styles = (theme, enableColorScheme = false) => {
'strong, b': {
fontWeight: theme.typography.fontWeightBold,
},
a: {
color:
theme.palette.mode === 'dark' ? theme.palette.primary[300] : theme.palette.primary[700],
Copy link
Member

Choose a reason for hiding this comment

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

Regardless of which color we choose, we should also add the support for theme.vars as well. I would recommend adding this value as a palette key and use that directly instead of hardcoding the values in the CssBaseline.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mnajdova Can I ask you to double-check the second to last commit to see if I've done that correctly? 😬

a: {
color:
theme.palette.mode === 'dark'
? theme.palette.primary[300]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
? theme.palette.primary[300]
? (theme.vars || theme).palette.primary[300]

Copy link
Contributor

Choose a reason for hiding this comment

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

@brijeshb42 would an approach similar to what I pushed for the Material version work? It's following Marija's guidance and it definitely looks cleaner not having to call the dark mode ternary here 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: CssBaseline The React component design This is about UI or UX design, please involve a designer package: joy-ui Specific to @mui/joy package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<a> doesn't have proper color in dark mode
8 participants