Skip to content

Commit

Permalink
fix(Banner): update alignment of actions when Banner is dismissible (#…
Browse files Browse the repository at this point in the history
…4954)

* fix(Banner): update alignment of actions when Banner is dismissible

* chore: add changeset

* test(vrt): update snapshots

* fix(Banner): update actions order

* test(vrt): update snapshots

* Update .changeset/spicy-eggs-melt.md

Co-authored-by: Siddharth Kshetrapal <siddharthkp@github.com>

---------

Co-authored-by: Josh Black <joshblack@users.noreply.github.com>
Co-authored-by: Siddharth Kshetrapal <siddharthkp@github.com>
  • Loading branch information
3 people authored Sep 13, 2024
1 parent fda3031 commit af7f589
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-eggs-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Banner: Update alignment of actions when it is dismissible and has a hidden title
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions e2e/components/Banner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ const stories: Array<{title: string; id: string; viewports?: Array<keyof typeof
id: 'drafts-components-banner-features--with-hidden-title-and-actions',
viewports: ['primer.breakpoint.xs', 'primer.breakpoint.sm'],
},
{
title: 'DismissibleWithHiddenTitleAndActions',
id: 'drafts-components-banner-features--dismissible-with-hidden-title-and-actions',
viewports: ['primer.breakpoint.xs', 'primer.breakpoint.sm'],
},
{
title: 'InSidebar',
id: 'drafts-components-banner-examples--in-sidebar',
Expand Down
22 changes: 22 additions & 0 deletions packages/react/src/Banner/Banner.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,28 @@ export const WithHiddenTitleAndActions = () => {
)
}

export const DismissibleWithHiddenTitleAndActions = () => {
return (
<Banner
title="Warning"
hideTitle
description={
<>
GitHub users are{' '}
<Link inline underline href="#">
now required
</Link>{' '}
to enable two-factor authentication as an additional security measure.
</>
}
onDismiss={action('onDismiss')}
variant="warning"
primaryAction={<Banner.PrimaryAction>Button</Banner.PrimaryAction>}
secondaryAction={<Banner.SecondaryAction>Button</Banner.SecondaryAction>}
/>
)
}

export const WithActions = () => {
return (
<Banner
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/Banner/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ const StyledBanner = styled.div`
justify-content: space-between;
}
&[data-dismissible] .BannerContainer {
&[data-dismissible]:not([data-title-hidden='']) .BannerContainer {
display: grid;
grid-template-columns: auto;
grid-template-rows: auto;
Expand Down Expand Up @@ -304,11 +304,11 @@ const StyledBanner = styled.div`
margin-block-end: var(--base-size-6, 0.375rem);
}
&[data-dismissible] .BannerActionsContainer[data-primary-action='trailing'] {
&[data-dismissible]:not([data-title-hidden]) .BannerActionsContainer[data-primary-action='trailing'] {
display: none;
}
&[data-dismissible] .BannerActionsContainer[data-primary-action='leading'] {
&[data-dismissible]:not([data-title-hidden]) .BannerActionsContainer[data-primary-action='leading'] {
display: flex;
}
Expand Down

0 comments on commit af7f589

Please sign in to comment.