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

[theme] Rename theme keys to defaultProps and styleOverrides #22347

Merged
merged 21 commits into from
Aug 28, 2020

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Aug 24, 2020

This PR continues the work from #22293 by applying the following renaming:

  • props => defaultProps
  • overrides => styleOverrides
  • variant's styles => style

@mui-pr-bot
Copy link

mui-pr-bot commented Aug 24, 2020

Details of bundle changes

Generated by 🚫 dangerJS against eeb65be

const theme = {
...other,
components: {},
};

Object.keys(variants).forEach((component) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

The changes to the variants are not part of v4 theme, so that logic was removed

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Since it isn't restricted to CSS I'd prefer a more generic name such as stylesOverrides

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 25, 2020
@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 25, 2020

Since it isn't restricted to CSS I'd prefer a more generic name such as stylesOverrides

This would match the vision in https://react-select.com/styles. Maybe?

  • props => defaultProps
  • overrides => styleOverrides
  • variants.styles => variants.style

@mnajdova
Copy link
Member Author

Regarding style vs css wording, there was a #21923 (comment) for it that I think made sense, as with html style you cannot use any sub-selector, or pseudo elements, so it may sound confusing, but css gives this association by default.

This was the only reason why I went for css, but I would be fine with also using styleOverrides and styles, as long we don't mix up both of them (style for one and css for the other)

@oliviertassinari
Copy link
Member

Right, the above proposal is in opposition with #21923 (comment). It's motivated by:

  • we don't write CSS, but an object with multiple values that are converted into CSS, later on.
  • defaultProps because if we allow the same object configuration to be used in the theme or at the component level, it would be confusing.

@mnajdova
Copy link
Member Author

I would say then let's go with the ones proposed from @oliviertassinari

props => defaultProps
overrides => styleOverrides
variants.styles => variants.style

Will update the PR later. @eps1lon do you agree with these names?

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 25, 2020
@mnajdova
Copy link
Member Author

I did the renaming

@oliviertassinari oliviertassinari changed the title [Theme] Rename components keys to defaultProps and cssOverrides [Theme] Rename theme keys to defaultProps and styleOverrides Aug 25, 2020
@mnajdova mnajdova requested a review from eps1lon August 25, 2020 21:18
@mbrookes
Copy link
Member

variants.styles => variants.style

A bit late to the party (sorry) considering that @mnajdova has already made the change, but I'm not sure about that one. variants.styles feels more natural (to me at least), especially alongside variants.props. Isn't it a list of styles (plural)?

@mnajdova
Copy link
Member Author

variants.styles => variants.style

A bit late to the party (sorry) considering that @mnajdova has already made the change, but I'm not sure about that one. variants.styles feels more natural (to me at least), especially alongside variants.props. Isn't it a list of styles (plural)?

@mbrookes not really, we support here only styles for the root, which are applied based on the given props.

@mnajdova
Copy link
Member Author

That makes sense @oliviertassinari let me revert my reverted changes :D

@mnajdova
Copy link
Member Author

I've updated the PR description to reflect current state of things, I think we are all on the same page now 👍

@mbrookes
Copy link
Member

mbrookes commented Aug 25, 2020

It's not the case of variant.styles, it takes a single value

That isn't true:

https://github.com/mui-org/material-ui/pull/22347/files#diff-7df98e40ad908a04619a4dbfbabab223L25-L29

const theme = createMuiTheme({
  components: {
    MuiButton: {
      variants: [
        {
          props: { variant: 'dashed' },
          styles: {
            textTransform: 'none',
            border: `2px dashed ${defaultTheme.palette.primary.main}`,
            color: defaultTheme.palette.primary.main,
          },
        },
        [...]
      ],
    },
  },
});

@mnajdova
Copy link
Member Author

mnajdova commented Aug 25, 2020

Those are different variants, we are still always specifying style only for the root, not the slots for for example

@mbrookes
Copy link
Member

mbrookes commented Aug 25, 2020

I highlighted a single variant with multiple styles, but GitHub screws up the page scroll. While you were replying, I was editing the comment to include the same example, in which styles contains multiple... styles.

@mnajdova

This comment has been minimized.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 26, 2020
@eps1lon
Copy link
Member

eps1lon commented Aug 26, 2020

We use the plural in all other places

In all these cases, we accept an object with multiple keys (root, label, etc), it's not the case of variant.styles, it takes a single value. Also, consider the singular or StyleSheet.

I was not arguing about variant.styles but styleOverrides. I agree with variant.style which mirrors the style attribute on HTML elements.

@mbrookes
Copy link
Member

variant.style [...] mirrors the style attribute on HTML elements.

Fair point.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 26, 2020
@mnajdova
Copy link
Member Author

After some thoughts, it look strange that on one place we have style and in the other stylesOverrides. As a developer I would not like to think when I type whether I should use style or styles. styleOverrides as a term already has the plurality in itself, so I am leaning forward towards using styleOverrides instead, so that at least we are consistent with the style wording...

@mbrookes
Copy link
Member

I'm inclined to agree. stylesOverrides may be technically more correct, but it's unlikely to be the first thing a developer tries.

I think we should go with the simplest most consistent alternative, in the spirit of: "Don't make me think" (design affordance), "principal of least surprise" (UI/UX design), "programmer happiness" (Ruby programming language)...

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 27, 2020
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 28, 2020
@mnajdova mnajdova merged commit 1365cd3 into mui:next Aug 28, 2020
@oliviertassinari oliviertassinari changed the title [Theme] Rename theme keys to defaultProps and styleOverrides [theme] Rename theme keys to defaultProps and styleOverrides Aug 29, 2020
Copy link

@jimmyandrade jimmyandrade left a comment

Choose a reason for hiding this comment

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

LGTM

@eps1lon eps1lon modified the milestones: 16.8 React.StrictMode, v5 Sep 15, 2020
@oliviertassinari oliviertassinari mentioned this pull request Sep 15, 2020
42 tasks
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.

6 participants