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

[blog] Introducing callback support in style overrides #30668

Merged
merged 36 commits into from
Jan 27, 2022

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Jan 17, 2022

🔗 Preview site: https://deploy-preview-30668--material-ui.netlify.app/blog/callback-support-in-style-overrides/

This PR should be merged after #30121

  • toggle ON the blog index page (@danilo-leal I forgot to do this in the previous PR 🥲)
  • remove theme variant deprecation

Once this PR is merged, will deploy the docs manually.


@mui-bot
Copy link

mui-bot commented Jan 17, 2022

No bundle size changes

Generated by 🚫 dangerJS against 2bb4d30

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Looks 🚀 Well done @siriwatknp

docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
@siriwatknp siriwatknp marked this pull request as ready for review January 18, 2022 06:08
docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

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

Awesome! This minor is one of those that would benefit from a video with more hands-on demos, for noobies like me to understand better 😅 Great work. Left a few copywriting tweaks only.

docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
docs/pages/blog/mui-material-v5-3.md Outdated Show resolved Hide resolved
siriwatknp and others added 3 commits January 20, 2022 09:31
Co-authored-by: danilo leal <67129314+danilo-leal@users.noreply.github.com>
Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

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

Awesome! 🤟

docs/pages/blog/callback-support-in-style-overrides.md Outdated Show resolved Hide resolved
docs/pages/blog/callback-support-in-style-overrides.md Outdated Show resolved Hide resolved
Co-authored-by: danilo leal <67129314+danilo-leal@users.noreply.github.com>
@siriwatknp siriwatknp mentioned this pull request Jan 21, 2022
1 task
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 24, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 25, 2022
Copy link
Member

@mbrookes mbrookes left a comment

Choose a reason for hiding this comment

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

Nice

docs/pages/blog/callback-support-in-style-overrides.md Outdated Show resolved Hide resolved
docs/pages/blog/callback-support-in-style-overrides.md Outdated Show resolved Hide resolved
docs/pages/blog/callback-support-in-style-overrides.md Outdated Show resolved Hide resolved
docs/pages/blog/callback-support-in-style-overrides.md Outdated Show resolved Hide resolved
docs/pages/blog/callback-support-in-style-overrides.md Outdated Show resolved Hide resolved
docs/pages/blog/callback-support-in-style-overrides.md Outdated Show resolved Hide resolved
</Box>;
```

> 💡 All MUI components are created with `styled` API, so they accept `sx` prop by default.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
> 💡 All MUI components are created with `styled` API, so they accept `sx` prop by default.
> 💡 All MUI components are created with the `styled` API, so they accept `sx` prop by default.


> 💡 All MUI components are created with `styled` API, so they accept `sx` prop by default.

`sx` helps developers write less code and be more productive once they are familiar with the API. With the callback support in `styleOverrides`, it is now possible to use `sx` like syntax at the global theme overrides.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
`sx` helps developers write less code and be more productive once they are familiar with the API. With the callback support in `styleOverrides`, it is now possible to use `sx` like syntax at the global theme overrides.
`sx` helps developers write less code and be more productive once they are familiar with the API. With the callback support in `styleOverrides`, it is now possible to use an `sx`-like syntax in global theme overrides.

</ThemeProvider>;
```

If you want to create a dynamic style based on props, you can return an array from the callback:
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps explain the example? Either: "In the following example" or with inline comments (or both). Also consider if other examples would benefit from further explanation.

docs/pages/blog/callback-support-in-style-overrides.md Outdated Show resolved Hide resolved
Co-authored-by: Matt <github@nospam.33m.co>
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

All good from my end, looks really good!

@oliviertassinari oliviertassinari changed the title [blog] Add material v5.3 announcement [blog] Introducing callback support in style overrides Jan 26, 2022
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

Great to see this one in 👍 also, I got this feedback

I have renamed the PR title to be a 1:1 with the blog post title.

---
title: Introducing callback support in style overrides
description: We're excited to introduce callback support for global theme overrides in this minor version update!
date: 2022-01-20T00:00:00.000Z
Copy link
Member

Choose a reason for hiding this comment

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

Are we good with the date? Do we want to use the release date of v5.3.0 or the blog post publish date?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, I will mark the next Monday as the blog post released date.

docs/pages/blog/callback-support-in-style-overrides.md Outdated Show resolved Hide resolved
docs/pages/blog/callback-support-in-style-overrides.md Outdated Show resolved Hide resolved
...(ownerState.variant === 'outlined' && {
borderWidth: '2px',
...(ownerState.variant === 'primary' && {
borderColor: theme.palette.primary.light,
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that there is any risk for circular references.

</ThemeProvider>;
```

> 💡 The side benefit of using a callback is that you can use the runtime theme without creating the outer scoped variable.
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 it is just a side benefit which is not the main purpose.

We have multiple threads where developers complain about this. But from what I remember, it was a step before. The main pain is for building the core set of design tokens, not so much for the customization of components.

Copy link
Member

@mbrookes mbrookes left a comment

Choose a reason for hiding this comment

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

👌

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
@siriwatknp siriwatknp merged commit 0a91a2e into mui:master Jan 27, 2022
wladimirguerra pushed a commit to wladimirguerra/material-ui that referenced this pull request Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants