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

Update Material UI code export feature #100

Open
1 task done
Ivanmatthew opened this issue Dec 6, 2023 · 4 comments
Open
1 task done

Update Material UI code export feature #100

Ivanmatthew opened this issue Dec 6, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@Ivanmatthew
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the problem

Currently, the code export for Material UI doesn't work, and will give typing errors, neither the V5, as well as adaptV4Theme works to convert the code export to a readable format by Material UI.

Solution

An updated code export, or an option to pick between Material UI versions

Alternatives

Remaking the theme myself in another open source project dedicated to making a Material UI theme editor, however accents don't seem to be properly conveyed.

Additional context

No response

@Ivanmatthew Ivanmatthew added the enhancement New feature or request label Dec 6, 2023
@juxtopposed
Copy link
Owner

What format exactly are you looking for? Can you link me to an example?

@Ivanmatthew
Copy link
Author

What format exactly are you looking for? Can you link me to an example?

First of all, sorry didn't get the notification.

The current MUI preset code export doesn't work, as it will error when directly entering in your MUI project.

The current generated code will error (see image)
Code_-_Insiders_43BHeCALrB
It has no accent key in the palette, neither does it have a main key for both text and background.

I tried to use the 'adaptV4Theme', but to no avail.
It lead me to believe the custom code generator for mui was made in V3, but I can not find any trace of it.
I did find an up-to-date code of generating a V5 MUI theme:
https://github.com/Zenoo/mui-theme-creator/blob/master/src/state/editor/reducers.ts

I'd rather expect a working format like so:

import { ThemeOptions } from '@mui/material/styles';

export const themeOptions: ThemeOptions = {
  palette: {
    mode: 'dark',
    primary: {
      main: '#4caf50',
      contrastText: 'rgba(255,255,255,0.87)',
    },
    secondary: {
      main: '#af4cac',
      contrastText: '#ffffff',
    },
    divider: '#bdbdbd',
    text: {
      primary: '#edfff1',
      secondary: '#f9f9f9',
      disabled: '#757575',
      hint: '#22194d',
    },
    background: {
      default: '#cacceb',
      paper: '#4f4caf',
    },
  },
};

An example of this can be found at https://zenoo.github.io/mui-theme-creator/

@juxtopposed
Copy link
Owner

Thank you for the explanation. This has been updated. Let me know if it works.

@Ivanmatthew
Copy link
Author

Thank you for the explanation. This has been updated. Let me know if it works.

Hey, thank you for this.
I checked it out quickly and realized the pallete.text.hint key does not exist (anymore) and was never put to use in any MUI components.
See https://mui.com/material-ui/migration/v5-style-changes/#restore-theme-palette-text-hint-key-if-needed
Other than that, it seems to be working correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants