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

[core] Update typings for theme's components #26125

Merged
merged 2 commits into from
May 7, 2021

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented May 4, 2021

Updates the theme.components.styleOverrides and theme.components.variants to use the same typigns for the styles as the experimentalStyled().

@mui-pr-bot
Copy link

mui-pr-bot commented May 4, 2021

No bundle size changes

Generated by 🚫 dangerJS against ded02ef

@mnajdova mnajdova marked this pull request as ready for review May 4, 2021 10:46
@mnajdova mnajdova requested review from eps1lon and removed request for oliviertassinari May 6, 2021 12:21
// JSS property bag where values are based on props
| CreateCSSProperties<Partial<ComponentsPropsList[Name]>>
// JSS property bag based on props
| PropsFunc<
Copy link
Member

Choose a reason for hiding this comment

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

As a side note (of the scope of the PR). There might be something to consider regarding PropsFunc. It's currently not implemented but the type accepts it: https://codesandbox.io/s/globalthemeoverride-material-demo-forked-x099w?file=/demo.tsx.

import * as React from "react";
import { ThemeProvider, createMuiTheme } from "@material-ui/core/styles";
import Button from "@material-ui/core/Button";

const theme = createMuiTheme({
  components: {
    MuiButton: {
      styleOverrides: {
        root: () => ({
          fontSize: "1rem"
        })
      },
      variants: [
        {
          props: { variant: "text" },
          style: () => ({
            textTransform: "none"
          })
        }
      ]
    }
  }
});

export default function GlobalThemeOverride() {
  return (
    <ThemeProvider theme={theme}>
      <Button>font-size: 1rem</Button>
    </ThemeProvider>
  );
}

Copy link
Member

Choose a reason for hiding this comment

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

I'm not aware we have an open issue about it, I would propose we open one.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll look into this next week 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Should it be a function of the theme? Not sure if props makes sense

Copy link
Member

Choose a reason for hiding this comment

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

I think that it depends on what we want to support for the API?

I would personally use the props & styleProps from the styleOverrides key. As for the variants key, unclear.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok let's start the discussion on an dedicated PR 👍

@mnajdova mnajdova merged commit f2cd26d into mui:next May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants