-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
[react] Create Stack component #118
Conversation
'normal', | ||
'stretch', | ||
], | ||
gap: ['--Stack-gap'], |
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.
Do we need more properties to be added here?
Adding more commits with tests. |
export interface BreakpointOverrides {} | ||
|
||
export type Breakpoint = OverridableStringUnion< | ||
'xs' | 'sm' | 'md' | 'lg' | 'xl', |
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.
Seeing this makes me think of mui/material-ui#26168
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.
We'll still need to continue supporting this unless we want breaking changes.
We could also introduce a way to alias breakpoints, ie, xs -> mobile
etc.
We will need to be careful with how we document this if we have
|
@brijeshb42 correct me if I am wrong, but we decided to create this in the Material UI package, no? |
@mnajdova Creating |
We did
Why is that? Isn't it possible to migrate the layout components the same way the other components were migrated? |
This is the last conversation we had around this. I would be happy with any solution we pick right now, as long as the components come from Material UI. Why add technical debt when we know we are going to want this done anyway. |
The current solution does not package things with Material UI. We have yet to start on the exploration for generating css before publishing. |
I reiterate my question 😅: Isn't it possible to migrate the layout components the same way the other components were migrated? |
2262486
to
2d8a118
Compare
direction: ['flexDirection'], | ||
spacing: ['gap'], | ||
}, | ||
multiplier: 8, |
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.
Did you figure out how to take this from the theme?
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.
@siriwatknp What's your opinion here? theme.spacing()
without arguments does not guarantee a numeric value.
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 think it should always be a string, then use CSS calc()
as a value. To leverage the theme, use
multiplier: theme.vars.spacing, // it can be a string or an array.
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 am a bit confused. Is this a Stack component for Pigment CSS or for Material UI?
If it's for Material UI, based on the existing implementation createStack
, only direction
and spacing
are the props because the rest of the system props are deprecated.
return; | ||
} | ||
classes.push(propertyClasses[condition]); | ||
handlePrimitive(propertyClasses[condition], condition); |
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 should be:
handlePrimitive(propertyClasses[condition], condition); | |
classes.push(propertyClasses[condition]); |
right?
Otherwise the class is never applied
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.
It's working correctly, see the test should work with shorthands
.
In that case, it's for property like flexDirection
that has multiple possible values.
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.
The test works correctly because it uses an array for the direction value, which is handled here:
} else if (Array.isArray(propertyValue)) { |
The test fails if you provide direction: { xs: 'row', sm: 'column' }
, which should also be supported, and it's handled in the line we're discussing.
So besides changing this line we should add a test with all supported formats.
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.
You are right. I pushed a fix with all the test cases that also cover null
, undefined
from the values.
This is the PigmentStack that Material UI will export. You're correct, following mui/material-ui#42259, we can remove the |
@DiegoAndai I pushed changes that simplify the logic in ff1ef61:
|
/** | ||
* @type {PigmentOptions} | ||
*/ | ||
const pigmentOptions = { | ||
theme, | ||
transformLibraries: ['local-ui-lib', '@mui/material'], | ||
sourceMap: true, | ||
displayName: true, | ||
overrideContext: (context) => { |
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.
To prevent an error Cannot redefine property toString
.
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'm not very familiar with the Pigment setup, why is this required in detail?
Is displayName
no longer required?
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'm not sure why @brijeshb42 removes the displayName
, but for overrideContext
it's a workaround for an error related to MUI System to make the app runnable (I will open a separate issue to discuss the options).
The setup is not related to Stack.
<Stack spacing={{ xs: 2, md: 3 }}> | ||
<div>Item1</div> | ||
<div>Item1</div> | ||
<div>Item1</div> | ||
</Stack> |
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.
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.
My last question is how this is going to be used in Material UI?
/** | ||
* @type {PigmentOptions} | ||
*/ | ||
const pigmentOptions = { | ||
theme, | ||
transformLibraries: ['local-ui-lib', '@mui/material'], | ||
sourceMap: true, | ||
displayName: true, | ||
overrideContext: (context) => { |
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'm not very familiar with the Pigment setup, why is this required in detail?
Is displayName
no longer required?
It will be reexported from Material UI as PigmentStack. Pigment will be an optional peer dependency, and the import will fail if the user doesn't have pigment installed. |
flexDirection: { | ||
column: { | ||
xs: 'flex-direction-column-xs', | ||
$$default: 'flex-direction-column-xs', |
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.
What are you assuming the default breakpoint in case someone passed this ?
<Stack spacing={1} />
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.
Where is that $$default
coming from? Isn't the defaultCondition
enough to know the default breakpoint?
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.
Ok. It was a remnant of the first implementation of the Box
component.
This uses atomic class generation utility to cover all the scenarios of rendering a Stack.