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

[sync] theme contrast instead of contrastText when exported using Material UI Sync #378

Open
fpaz opened this issue Jul 29, 2024 · 2 comments
Labels
bug 🐛 Something doesn't work figma scope: sync Issues related to the Material UI Sync Figma plugin

Comments

@fpaz
Copy link

fpaz commented Jul 29, 2024

Steps to reproduce

When extracting the theme using Material UI Sync. The contrastText was renamed to contrast

{
  "colorSchemes": {
    "light": {
      "palette": {
        "primary": {
          "main": "#042B37",
          "dark": "#032631",
          "light": "#4F6B73",
          "_states": {
            "active": "rgba(4, 43, 55, 0.56)",
            "hover": "rgba(4, 43, 55, 0.04)",
            "selected": "rgba(4, 43, 55, 0.08)",
            "focus": "rgba(4, 43, 55, 0.12)",
            "focusVisible": "rgba(4, 43, 55, 0.3)",
            "outlinedBorder": "rgba(4, 43, 55, 0.5)",
            "disabled": "rgba(4, 43, 55, 0.38)",
            "disabledBackground": "rgba(4, 43, 55, 0.12)"
          },
          "contrast": "#FFFFFF"  // <-- contrast instead of contrastText
        },

Current behavior

When viewing the source for the root style. We get two contrast values.

:root {
    --mui-palette-primary-contrast: #FFFFFF;
    --mui-palette-primary-contrastText: #fff;
}

Expected behavior

It should only generate one value for the contrast.

:root {
    --mui-palette-primary-contrastText: #FFFFFF;
}

Context

We have to rename contrast to contrastText from the generated theme for it to work on our application. Is there any documentation around the implementation of contrast?

Your environment

Software Version
Design file version v5.16.0
Design tool Figma
etc.

Search keywords: contrast contrastText

@fpaz fpaz added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 29, 2024
@zannager zannager added the figma label Jul 29, 2024
@oliviertassinari oliviertassinari added the scope: sync Issues related to the Material UI Sync Figma plugin label Aug 1, 2024
@zannager zannager assigned adrianmanea and unassigned adrianmanea Aug 2, 2024
@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 31, 2024
@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 31, 2024

True https://mui.com/material-ui/customization/palette/#color-tokens.

Stuff like https://github.com/mui/mui-private/blob/8f4f962d53c6aa5cd8fad3e43c04b6cbb161bd1f/packages/material-ui-sync-figma/src/defaults/theme.ts#L21 looks weird.

          primary: {
            main: '#2196F3',
            dark: '#1E88E5',
            light: '#42A5F5',
            contrast: '#FFFFFF',
            _states: {
              hover: 'rgba(33, 150, 243, 0.04)',
              selected: 'rgba(33, 150, 243, 0.08)',
              focus: 'rgba(33, 150, 243, 0.12)',
              focusVisible: 'rgba(33, 150, 243, 0.3)',
              outlinedBorder: 'rgba(33, 150, 243, 0.5)',
            },
          },

packages/material-ui-sync-figma/src/defaults/theme.ts

@oliviertassinari
Copy link
Member

I can reproduce with the latest version:

SCR-20240901-bajd

I suspect that fixing #393 in the Figma Kit and updating the source in the Figma plugin, like https://github.com/mui/mui-private/blob/8f4f962d53c6aa5cd8fad3e43c04b6cbb161bd1f/packages/material-ui-sync-figma/src/defaults/theme.ts#L21 will fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work figma scope: sync Issues related to the Material UI Sync Figma plugin
Projects
None yet
Development

No branches or pull requests

4 participants