Skip to content

Conversation

Mash707
Copy link
Contributor

@Mash707 Mash707 commented Apr 16, 2025

Closes #11668

@patternfly-build
Copy link
Contributor

patternfly-build commented Apr 16, 2025

@Mash707
Copy link
Contributor Author

Mash707 commented Apr 16, 2025

@thatblindgeye have a look at this. I wanted to ask that how can we put spacing between the buttons? I did find a approach using nesting in flex https://www.patternfly.org/layouts/flex#nesting. Do you know a better approach?

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Change below. Also @mcoker @sg00dwin looks like Core may be missing a wrapper element. In React any child passed to CardHeader (in this example a CardTitle) gets wrapped in a pf-v6-c-card__header-main element. The Core header wraps example is missing that wrapper.

Comment on lines 5 to 23
<CardHeader hasWrap>
{' '}
<Flex columnGap={{ default: 'columnGapXl' }} justifyContent={{ default: 'justifyContentSpaceBetween' }}>
<FlexItem>
<CardTitle>This is a longer card title that takes up more space</CardTitle>
</FlexItem>
<FlexItem>
<Button variant="primary" ouiaId="Primary">
Primary action
</Button>
<Button variant="secondary" ouiaId="Secondary">
Secondary action
</Button>
<Button variant="tertiary" ouiaId="Tertiary">
Tertiary action
</Button>
</FlexItem>
</Flex>
</CardHeader>
Copy link
Contributor

Choose a reason for hiding this comment

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

So for the content inside CardHeader, we can keep the CardTitle inside it as a child. The Buttons we want to pass to CardHeader's actions prop (and remove all of the Flex components):

Suggested change
<CardHeader hasWrap>
{' '}
<Flex columnGap={{ default: 'columnGapXl' }} justifyContent={{ default: 'justifyContentSpaceBetween' }}>
<FlexItem>
<CardTitle>This is a longer card title that takes up more space</CardTitle>
</FlexItem>
<FlexItem>
<Button variant="primary" ouiaId="Primary">
Primary action
</Button>
<Button variant="secondary" ouiaId="Secondary">
Secondary action
</Button>
<Button variant="tertiary" ouiaId="Tertiary">
Tertiary action
</Button>
</FlexItem>
</Flex>
</CardHeader>
<CardHeader
hasWrap
actions={{
hasNoOffset: true,
actions: [
<Button variant="primary" ouiaId="Primary">
Primary action
</Button>,
<Button variant="secondary" ouiaId="Secondary">
Secondary action
</Button>,
<Button variant="tertiary" ouiaId="Tertiary">
Tertiary action
</Button>
]
}}
>
<CardTitle>This is a longer card title that takes up more space</CardTitle>
</CardHeader>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't realise actions are this useful. Will make the necessary changes

@Mash707 Mash707 requested a review from thatblindgeye April 18, 2025 21:07
@Mash707
Copy link
Contributor Author

Mash707 commented Apr 18, 2025

In addition to changes suggested, I have also added the key prop in the actions array as I was getting lint errors for "missing key prop"

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

🚀

@thatblindgeye thatblindgeye merged commit e677c94 into patternfly:main Apr 21, 2025
13 checks passed
@patternfly-build
Copy link
Contributor

Your changes have been released in:

Thanks for your contribution! 🎉

@Mash707 Mash707 deleted the card-add-header-wrap-example branch April 21, 2025 17:17
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.

Card - Add header wrap example to match Core

5 participants