-
Notifications
You must be signed in to change notification settings - Fork 371
chore(card): added header wrap example #11765
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
chore(card): added header wrap example #11765
Conversation
Preview: https://patternfly-react-pr-11765.surge.sh A11y report: https://patternfly-react-pr-11765-a11y.surge.sh |
@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? |
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.
<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> |
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 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):
<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> |
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.
Didn't realise actions
are this useful. Will make the necessary changes
In addition to changes suggested, I have also added the |
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.
🚀
Your changes have been released in:
Thanks for your contribution! 🎉 |
Closes #11668