8000 fix(split/stack): allow pf-m-fill to apply to any direct child by mcoker · Pull Request #7201 · patternfly/patternfly · GitHub
[go: up one dir, main page]

Skip to content

fix(split/stack): allow pf-m-fill to apply to any direct child#7201

Merged
mcoker merged 3 commits intopatternfly:mainfrom
mcoker:issue-7190
Nov 19, 2024
Merged

fix(split/stack): allow pf-m-fill to apply to any direct child#7201
mcoker merged 3 commits intopatternfly:mainfrom
mcoker:issue-7190

Conversation

@mcoker
Copy link
Contributor
@mcoker mcoker commented Nov 7, 2024

fixes #7190

## Documentation
### Overview
The split layout is designed to position items horizontally, with one item filling the available horizontal space.
The split layout is designed to position items horizontally.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK there is no expectation that any (or just one) item(s) need to fill the space.

| -- | -- | -- |
| `.pf-v6-l-split` | `<div>`, `<section>`, or `<article>` | Initiates the split layout. |
| `.pf-v6-l-split__item` | `<div>` | Initiates a split item. **Required** |
| `.pf-v6-l-split` | `*` | Initiates the split layout. |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be any element, <Split /> in pf-react allows a component prop to let you use any element here.

@patternfly-build
Copy link
Collaborator
patternfly-build commented Nov 7, 2024

| `.pf-v6-l-split` | `<div>`, `<section>`, or `<article>` | Initiates the split layout. |
| `.pf-v6-l-split__item` | `<div>` | Initiates a split item. **Required** |
| `.pf-v6-l-split` | `*` | Initiates the split layout. |
| `.pf-v6-l-split__item` | `*` | Initiates a split item. |
Copy link
Contributor Author
@mcoker mcoker Nov 7, 2024

Choose a reason for hiding this comment

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

This is not required - prior to this PR, it was only required for .pf-m-fill, but with this PR it isn't required at all.

And while <SplitItem> always renders as a <div> in react, I checked with @tlabaj and we want to allow for a component prop here, too, since without it you could end up with invalid HTML. For example, if you do something like <Stack component="span"><StackItem>, you'll get <span><div>.

Here's the react issue and PR for the component prop on the split/stack items

patternfly/patternfly-react#11169
patternfly/patternfly-react#11170

.#{$split}__item.pf-m-fill {
flex-grow: 1;
@at-root .#{$split}__item.pf-m-fill,
& > .pf-m-fill {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now this rule renders as

.pf-v6-l-stack__item.pf-m-fill,
.pf-v6-l-stack > .pf-m-fill {
    flex-grow: 1;
}

@andrewballantyne
Copy link

Is there a react rendering of this that I can test out my expectations @mcoker ?

@mcoker
Copy link
Contributor Author
mcoker commented Nov 7, 2024

@andrewballantyne sure! Here's a basic <Split /> codesandbox and <Stack /> codesandbox with

  • the CSS from this PR imported as pf-item-update.css
  • updated the examples a little to show passing other children to the layout
  • using isFilled on an item
  • mimicking isFilled on a <div> (passing className="pf-m-fill")

@andrewballantyne
Copy link

Looks good to me @mcoker -- that's what I was looking for. I can't edit the sandboxes (don't have an account) but visually inspecting the examples looks to fit what I was after. Thanks!

Copy link
Member
@srambach srambach left a comment

Choose a reason for hiding this comment

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

Looks good - one question, would you want to adjust the custom workspace styling (that adds the dashed outline) to also work without the _item classes?
Also, is this change useful on the level layout?

@mcoker
Copy link
Contributor Author
mcoker commented Nov 13, 2024

@srambach sure I don't see why not. Added .pf-m-fill to level - just to confirm, was that what you were asking? We'll need a react follow up to add a prop for that. Also updated the level examples so the boxes are different heights since one of the things the level does is vertically center its items.

@mcoker mcoker requested a review from srambach November 13, 2024 04:09
Copy link
Member
@srambach srambach left a comment

Choose a reason for hiding this comment

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

I think in discussions we decided we don't need to add a pf-m-fill on the level layout, but keep the local workspace styling to show that __item isn't required.

@mcoker
Copy link
Contributor Author
mcoker commented Nov 18, 2024

@srambach backed out the level layout's .pf-m-fill change a2bfe80

Copy link
Member
@srambach srambach left a comment

Choose a reason for hiding this comment

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

Looks 🌽 to me

4D24

@mcoker mcoker merged commit 6dc6143 into patternfly:main Nov 19, 2024
@patternfly-build
Copy link
Collaborator

🎉 This PR is included in version 6.1.0-prerelease.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

[Stack/Split] - Easier interface to use

4 participants

0