-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[system] Add spacing
theme token to be used in theme.spacing()
#40224
Conversation
Netlify deploy previewhttps://deploy-preview-40224--material-ui.netlify.app/ @material-ui/core: parsed: +0.08% , gzip: +0.08% Bundle size reportDetails of bundle changes (Toolpad) |
spacingSize
theme token to be used in theme.spacing()
spacing
theme token to be used in theme.spacing()
spacing
theme token to be used in theme.spacing()
spacing
theme token to be used in theme.spacing()
spacing
theme token to be used in theme.spacing()
spacing
theme token to be used in theme.spacing()
@DiegoAndai This is not a breaking change but do you think it should a part of v5 or v6? |
Moved to v6. |
Being so close to v5 freezing, I agree with you to not merge it to |
@@ -27,6 +27,9 @@ import gridClasses, { getGridUtilityClass } from './gridClasses'; | |||
|
|||
function getOffset(val) { | |||
const parse = parseFloat(val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val
could be a CSS expression.
if (/jsdom/.test(window.navigator.userAgent)) { | ||
this.skip(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing margin values should use Karma
@siriwatknp let me know when this is ready for review 😊 |
It's ready! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great addition! A couple of questions
if (typeof abs === 'string') { | ||
return abs; | ||
if (typeof themeSpacing === 'number' || typeof themeSpacing === 'string') { | ||
return (val) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the variable name to reflect what we expect because the val
is no longer an absolute of the user input. It's the user input without any modification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
theme.generateSpacing = function generateSpacing() { | ||
return createSpacing(input.spacing, createUnarySpacing(this)); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we do this?
theme.generateSpacing = function generateSpacing() { | |
return createSpacing(input.spacing, createUnarySpacing(this)); | |
}; |
Why do we need generateSpacing
in the first place, and even more in the public API? It seems that using theme.spacing
directly is simple enough.
theme.getColorSchemeSelector = (colorScheme) => `[${theme.attribute}="${colorScheme}"] &`; | ||
theme.spacing = theme.generateSpacing(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theme.spacing = theme.generateSpacing(); | |
theme.spacing = createSpacing(input.spacing, createUnarySpacing(theme)); |
There is a regression visible in the video description of these changes: I opened to try to fix it #42574. |
part of #40225
closes #37911
Changes
When using
extendTheme({ spacing: string | number })
, a new token (--mui-spacing
) is created for use with CSS calc function.Screen.Recording.2567-03-13.at.15.52.46.mov