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

[OSCI] Adding props for shrink and basis for OuiFlexItem #1126

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

BigSamu
Copy link
Contributor

@BigSamu BigSamu commented Oct 30, 2023

Description

Props shrink and basis have been added for OuiFlexItem. Behaviour similar to grow prop. Accepted values:

  • shrink: true, false, null, 1..10
  • basis: true, false, null, 'auto', 'max-content', 'min-content', 'fit-content',

Issues Resolved

Fixes issue #776

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • All tests pass
    • yarn lint
    • yarn test-unit
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

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.

Signed-off-by: Samuel Valdes Gutierrez <[email protected]>
@BigSamu
Copy link
Contributor Author

BigSamu commented Nov 1, 2023

@BSFishy @joshuarrrr,

Final updates in PR are ready, with documentation added for props shrink and basis. I would appreciate your feedback on the entire PR.

Just one thing from my side. I think it is a bit cumbersome to consider OuiFlexItem to have the properties flex-grow: 1 and flex-basis: 0%, by default. I feel that we should follow an approach like the one here in W3School, where we can explain the props grow, shrink and basis altogether in one section and also not considering a default behaviour of growing.

Not sure. Maybe the UX team have something to say here.

Regards,

Samuel

Copy link
Contributor

@BSFishy BSFishy left a 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 Show resolved Hide resolved
@@ -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
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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)

Copy link
Contributor Author

@BigSamu BigSamu Nov 8, 2023

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.

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
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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:

  1. If basis isn't null, use that value
  2. If grow is not falsy, set basis to 0% (add option for 0)
  3. If grow is falsy, set basis to auto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My comments here:

  1. 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
  2. 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
  3. If grow is falsy, set basis to auto Already done when you say grow=false using the class ouiFlexItem--flexGrowZero

CHANGELOG.md Outdated Show resolved Hide resolved
@BSFishy BSFishy added the OSCI label Nov 2, 2023
Signed-off-by: Samuel Valdes Gutierrez <[email protected]>
@BigSamu
Copy link
Contributor Author

BigSamu commented Nov 4, 2023

Hi @BSFishy,

I already replied to your comments for your code review. Looking forward your reply to see how I proceed.

Regards,

Samuel

Copy link
Contributor

@BSFishy BSFishy left a 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.

src/components/flex/flex_item.tsx Outdated Show resolved Hide resolved
src/components/flex/flex_item.tsx Show resolved Hide resolved
src/components/flex/flex_item.tsx Outdated Show resolved Hide resolved
@BigSamu
Copy link
Contributor Author

BigSamu commented Nov 21, 2023

@BSFishy,

Updates are ready with the last code review done from your side! Any comments, let me know.

Regards,

Samuel

@BSFishy
Copy link
Contributor

BSFishy commented Dec 5, 2023

Looks great!

@BigSamu
Copy link
Contributor Author

BigSamu commented Jan 1, 2024

Hi @BSFishy, @joshuarrrr

Are we good to go with this PR? The branch was recently updated with main bracnh.

@BSFishy
Copy link
Contributor

BSFishy commented Jan 2, 2024

Are we good to go with this PR? The branch was recently updated with main bracnh.

Just need another approval

<div>
<OuiFlexGroup>
<OuiFlexItem basis={'auto'}>
Auto
Copy link
Collaborator

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.

@kgcreative

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AMoo-Miki,

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?

BigSamu and others added 6 commits January 12, 2024 12:06
Update to new format copyright and license comments at beginning of file

Co-authored-by: Miki <[email protected]>
Signed-off-by: Samuel Valdes Gutierrez <[email protected]>
Update to new format copyright and license comments at beginning of file

Co-authored-by: Miki <[email protected]>
Signed-off-by: Samuel Valdes Gutierrez <[email protected]>
…Size and FlexItemShrinkSize types

Signed-off-by: Samuel Valdes Gutierrez <[email protected]>
…emShrinkSize deprecated and add a TODO comment to remove them for next major release

Signed-off-by: Samuel Valdes Gutierrez <[email protected]>
Signed-off-by: Samuel Valdes Gutierrez <[email protected]>
@BigSamu
Copy link
Contributor Author

BigSamu commented Jan 20, 2024

@AMoo-Miki, @kolchfa-aws,

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

@kolchfa-aws
Copy link

@BigSamu I made suggestions where Miki flagged the doc team. Let me know if you need any other help from me.

@BigSamu
Copy link
Contributor Author

BigSamu commented Jan 29, 2024

@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.

@AMoo-Miki,

Any feedback from the suggestions from @kolchfa-aws and also the questions I post on your comments?

Regards,

Samuel

@BigSamu
Copy link
Contributor Author

BigSamu commented Feb 14, 2024

@AMoo-Miki,

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants