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

Wrapping MUI components with styled not working in pigment with vite after version 0.0.20 #352

Open
yishay-at-bay opened this issue Dec 19, 2024 · 6 comments
Assignees
Labels
status: waiting for maintainer These issues haven't been looked at yet by a maintainer vite
Milestone

Comments

@yishay-at-bay
Copy link

yishay-at-bay commented Dec 19, 2024

Steps to reproduce

Steps:

  1. Create a new vite project with: yarn create vite vite-app --template react-ts (vite v5 or v6, yarn v1)
  2. install versions 0.0.28 of @pigment-css/react, pigment-css/vite-plugin and @mui/material v6
  3. define a StyledButton with:
    import { Button } from "@mui/material";
    import { styled } from "@pigment-css/react";
    
    const CustomButton: React.FC = () => {
      return <StyledButton>Click it</StyledButton>;
    };
    
    const StyledButton = styled(Button)(() => ({
      color: "green",
      backgroundColor: "orange",
    }));
    
    export default CustomButton;
    

Current behavior

When using @pigment-css/react and pigment-css/vite-plugin after version 0.0.20 I get the a lot of errors like:
Internal server error: node_modules/@mui/material/Tooltip/Tooltip.js Cannot read properties of undefined (reading 'vars')
Internal server error: /node_modules/@mui/material/Typography/Typography.js: Cannot read properties of undefined (reading 'typography')

Expected behavior

Latest versions (currently from 0.0.21 - 0.0.28) should work like version 0.0.20 or earlier

Context

No response

Your environment

No response

Search keywords: pigment vite version 0.0.20

@yishay-at-bay yishay-at-bay added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 19, 2024
@zannager zannager added the vite label Dec 20, 2024
@brijeshb42
Copy link
Contributor

Have you configured the theme correctly in your vite config.
Check - https://github.com/mui/material-ui/blob/master/apps/pigment-css-vite-app/vite.config.ts#L41

@brijeshb42 brijeshb42 added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 14, 2025
@yishay-at-bay
Copy link
Author

Hi @brijeshb42
Thanks for replying :)
This indeed solved the issue. Just added the theme to the config and it runs

So do I always have to define a theme when working like that (wrapping MUI components with styled) with pigment?

Another unrelated question...
Is pigment a production ready lib? Is it recommended to start working with it in real projects?

Thanks

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Jan 17, 2025
@brijeshb42
Copy link
Contributor

do I always have to define a theme when working like that (wrapping MUI components with styled) with pigment

Yes. You'll have to provide the theme as per the current implementation. Maybe we can improvde this experience by using the default theme when none is provided.

Is pigment a production ready lib

It is not recommended while its in v0.0.x. We are looking for user reported issues when trying in new projects.
We have plan to release v1 stable and with that, it'll be prod ready.

@brijeshb42 brijeshb42 added this to the Road to v1 milestone Jan 17, 2025
@yishay-at-bay
Copy link
Author

yishay-at-bay commented Jan 17, 2025

It is not recommended while its in v0.0.x. We are looking for user reported issues when trying in new projects.
We have plan to release v1 stable and with that, it'll be prod ready

Do you have a rough estimation of when v1 will be released?

@brijeshb42
Copy link
Contributor

We are targetting by March end.

@yishay-at-bay
Copy link
Author

@brijeshb42 Thanks !! I really appreciate your help 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for maintainer These issues haven't been looked at yet by a maintainer vite
Projects
None yet
Development

No branches or pull requests

4 participants