-
Notifications
You must be signed in to change notification settings - Fork 71
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
[OSCI] Adding props for shrink and basis for OuiFlexItem #1126
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
…ts tests for testing Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
… place Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
…flex_item.tsx Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Final updates in PR are ready, with documentation added for props Just one thing from my side. I think it is a bit cumbersome to consider Not sure. Maybe the UX team have something to say here. Regards, Samuel |
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.
Just a few things, looping in @kgcreative for advice on how the docsite should be updated
src/components/flex/flex_item.tsx
Outdated
@@ -61,18 +96,30 @@ export const OuiFlexItem: FunctionComponent< | |||
> = ({ | |||
children, | |||
className, | |||
grow = true, | |||
grow = true, // default true -> flex-grow: 1 and flex-basis: 0% | |||
shrink = null, // default null for flex-shrink |
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 default value for this is 1
: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-shrink#formal_definition. Should we make that the default value here?
cc @kgcreative
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.
Hi Matt, Yes, you are right; the default value for the flex-grow
CSS property is 1
according to Mozilla docs. However, the way how an OuiFlexItem
is defined in OUI considers that these elements always grow inside the flex parent OuiFlexGroup
by default (this was the initial design for that element). Thus the prop grow=true
, which allows keeping the CSS properties flex-grow: 1
and flex-basis: 0%
, both of them coming from _flex_group.scss file.
I'm not sure why in _flex_group.scss
we are defining these properties for a OuiFlexItem
. The styling for the latter ones should only be allocated in the _flex_item.scss file, in my opinion.
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.
Right, I think we should maintain functionality as much as possible. Since flex-shrink
isn't specified anywhere, I think we should make it default to what it would have been previous to this change
(For clarity, this comment is referring to the shrink
default 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.
So, when you define the default value for shrink
as null
(i.e.shrink=null
), this prop does not apply any CSS property related to flex-shrink. The OuiFlexElement
inherits what comes from the parent (OuiFlexGroup
) or the default from the Browser (which is flex-shrink:1
). So, the default value I use works for this case without changing the design implementation for the whole element.
src/components/flex/flex_item.tsx
Outdated
grow = true, | ||
grow = true, // default true -> flex-grow: 1 and flex-basis: 0% | ||
shrink = null, // default null for flex-shrink | ||
basis = null, // default null flex-basis |
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 the default value for basis should be auto
: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis#formal_definition
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.
Same as above, If I change the default value of the prop basis
to auto
, then you will change the default behaviour of grow=true
, which means flex-grow:1
and flex-basis: 0%
. I agree with what you suggest, but this change will need a whole new design of an OuiFlexItem
in terms that they should not grow by default inside an OuiFlexGroup
element. Make sense?
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.
Right, that makes sense, so I think we should have some special logic here:
- If
basis
isn'tnull
, use that value - If
grow
is not falsy, setbasis
to0%
(add option for0
) - If
grow
is falsy, setbasis
toauto
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 comments here:
- If basis isn't null, use that value It is done when you use one of these options in the prop
basis
: auto, max-content, min-content, fit-content - If grow is not falsy, set basis to 0% (add option for 0)
flex-basis: 0%
is already setup by default. For whatever not falsy value this CSS property will kept. Coming from_flex_group.scss
- If grow is falsy, set basis to auto Already done when you say
grow=false
using the classouiFlexItem--flexGrowZero
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Hi @BSFishy, I already replied to your comments for your code review. Looking forward your reply to see how I proceed. Regards, Samuel |
…pective snapshoots Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
…inkZero Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
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 main thing is in one of these comments. Basically, we don't want to apply new styles unless the builder specifies new props.
…ntainers Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Updates are ready with the last code review done from your side! Any comments, let me know. Regards, Samuel |
Looks great! |
Hi @BSFishy, @joshuarrrr Are we good to go with this PR? The branch was recently updated with |
Just need another approval |
<div> | ||
<OuiFlexGroup> | ||
<OuiFlexItem basis={'auto'}> | ||
Auto |
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.
Because the actual value of the prop we want users to use is auto
, we should use auto
here and not Auto
. Also, we should perhaps wrap it in OuiCode
?
The same goes for all of the other values too.
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.
Updated text in examples for Basis in Flex Item for all basis properties (e.g.Auto
to auto
). Just one question what is this suggestion of wrapping with OuiCode
?
Update to new format copyright and license comments at beginning of file Co-authored-by: Miki <amoo_miki@yahoo.com> Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Update to new format copyright and license comments at beginning of file Co-authored-by: Miki <amoo_miki@yahoo.com> Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
…Size and FlexItemShrinkSize types Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
…emShrinkSize deprecated and add a TODO comment to remove them for next major release Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Signed-off-by: Samuel Valdes Gutierrez <valdesgutierrez@gmail.com>
Sorry bothering again with this PR, but I would appreciate your feedback on the reviews Mikki sent to see what other changes you need from my side. Regards, Samuel |
@BigSamu I made suggestions where Miki flagged the doc team. Let me know if you need any other help from me. |
Thanks @kolchfa-aws, I will review this week. Any feedback from the suggestions from @kolchfa-aws and also the questions I post on your comments? Regards, Samuel |
Have you had the chance to review the comments from @kolchfa-aws? I would appreciate your feedback for moving forward on this PR. Regards, Samuel |
Description
Props
shrink
andbasis
have been added for OuiFlexItem. Behaviour similar togrow
prop. Accepted values:shrink
: true, false, null, 1..10basis
: true, false, null, 'auto', 'max-content', 'min-content', 'fit-content',Issues Resolved
Fixes issue #776
Check List
yarn lint
yarn test-unit
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.