-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Flex: Convert component to TypeScript #42537
Conversation
Size Change: +2 B (0%) Total Size: 1.26 MB
ℹ️ View Unchanged
|
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.
Great job, thanks for all the test and story improvements!
const GrayBox = ( { children }: { children: string } ) => ( | ||
<View style={ { backgroundColor: '#eee', padding: 10 } }>{ children }</View> | ||
); |
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 styling makes it a lot more understandable 💛
}; | ||
Default.args = {}; | ||
|
||
export const ResponsiveDirection: ComponentStory< typeof Flex > = ( { |
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 can't decide between "add an explanation of the useResponsiveValue
system, which we might not want to encourage" or "remove this story and risk everyone forgetting that the feature exists". So maybe for now we go with the path of least resistance: Keep the story but without a description 😂
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.
Agreed. I would at most add a comment discouraging usage of useResponsiveValue
system as it may be soon deprecated (or do nothing as you suggested)
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.
Yep. Lets keep it as it is 👍
|
||
**Type**: `[number | string]` | ||
### `gap`: `number` |
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 another change that we may consider: I personally find it confusing that we exposed align
and justify
behaving exactly like the CSS properties, while we use an internal grid system for gap
(which is also a valid CSS prop for flex layouts)
@mirka what are your thoughts on this one?
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 problem with SpaceInput
values in general, but I agree that the polymorphic nature of those values can be confusing. (Especially since React style
props interpret unitless number
values to be pixels by default!) Unfortunately I can't think of an easy way around it, other than removing SpaceInput support from the components themselves and make the consumer use space()
from the outside, if they need to.
As an aside, I believe the internal gap
-to-margin implementation we have right now was kind of meant as a polyfill, since Safari didn't support flex gap when the Flex
component was first written. I don't know if there are active bugs in there, but we can look into removing it in a separate issue. It would be nice to simply rely on native CSS 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.
This is a problem with SpaceInput values in general, but I agree that the polymorphic nature of those values can be confusing. (Especially since React style props interpret unitless number values to be pixels by default!) Unfortunately I can't think of an easy way around it, other than removing SpaceInput support from the components themselves and make the consumer use space() from the outside, if they need to.
Yeah, this may require some more investigation
As an aside, I believe the internal gap-to-margin implementation we have right now was kind of meant as a polyfill, since Safari didn't support flex gap when the Flex component was first written. I don't know if there are active bugs in there, but we can look into removing it in a separate issue. It would be nice to simply rely on native CSS gap.
I get the same feeling — it would be definitely great to rely on native CSS though
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.
Yes. I would be great exploring if the native gap can be used. I guess its out of scope for this PR tough.
Co-authored-by: Lena Morita <lena@jaguchi.com>
Co-authored-by: Lena Morita <lena@jaguchi.com>
Anything feedback I missed or is this PR ready to 🚢 ? |
🚢 |
What?
Converts the
Flex
,FlexItem
andFlexBlock
components to TypeScript.Why?
Part of the @wordpress/components's TypeScript migration (#35744).
How?
Flex
,FlexItem
andFlexBlock
to TypeScript.Testing Instructions
Flex
continues to function as expected