-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Banner): update Banner to use CSS Modules behind feature flag (#…
…4913) * feat(Banner): update Banner to use CSS Modules behind feature flag * chore: add changeset * chore: remove autogenerated pnpm packageManager change * chore: fix stylelint errors * chore: add back in underline for fallback case * refactor: update autofix and eslint warning * chore: update class order for tests * chore: fix stylelint errors * Update packages/react/src/Banner/Banner.module.css Co-authored-by: Katie Langerman <[email protected]> --------- Co-authored-by: Josh Black <[email protected]> Co-authored-by: Katie Langerman <[email protected]>
- Loading branch information
Showing
8 changed files
with
507 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/react': minor | ||
--- | ||
|
||
Update Banner to use CSS Modules behind feature flag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
.Banner { | ||
display: grid; | ||
padding: var(--base-size-8); | ||
background-color: var(--banner-bgColor); | ||
border: var(--borderWidth-thin, 1px) solid var(--banner-borderColor); | ||
border-radius: var(--borderRadius-medium); | ||
grid-template-columns: auto minmax(0, 1fr) auto; | ||
align-items: start; | ||
|
||
@supports (container-type: inline-size) { | ||
container: banner / inline-size; | ||
} | ||
|
||
&[data-variant='critical'] { | ||
--banner-bgColor: var(--bgColor-danger-muted); | ||
--banner-borderColor: var(--borderColor-danger-muted); | ||
--banner-icon-fgColor: var(--fgColor-danger); | ||
} | ||
|
||
&[data-variant='info'] { | ||
--banner-bgColor: var(--bgColor-accent-muted); | ||
--banner-borderColor: var(--borderColor-accent-muted); | ||
--banner-icon-fgColor: var(--fgColor-accent); | ||
} | ||
|
||
&[data-variant='success'] { | ||
--banner-bgColor: var(--bgColor-success-muted); | ||
--banner-borderColor: var(--borderColor-success-muted); | ||
--banner-icon-fgColor: var(--fgColor-success); | ||
} | ||
|
||
&[data-variant='upsell'] { | ||
--banner-bgColor: var(--bgColor-upsell-muted); | ||
--banner-borderColor: var(--borderColor-upsell-muted); | ||
--banner-icon-fgColor: var(--fgColor-upsell); | ||
} | ||
|
||
&[data-variant='warning'] { | ||
--banner-bgColor: var(--bgColor-attention-muted); | ||
--banner-borderColor: var(--borderColor-attention-muted); | ||
--banner-icon-fgColor: var(--fgColor-attention); | ||
} | ||
} | ||
|
||
/* BannerContainer -------------------------------------------------------- */ | ||
|
||
.BannerContainer { | ||
font-size: var(--text-body-size-medium); | ||
align-items: start; | ||
line-height: var(--text-body-lineHeight-medium); | ||
row-gap: var(--base-size-4); | ||
column-gap: var(--base-size-4); | ||
} | ||
|
||
.Banner :where(.BannerContainer) { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: space-between; | ||
} | ||
|
||
.Banner[data-dismissible]:not([data-title-hidden='']) .BannerContainer { | ||
display: grid; | ||
grid-template-columns: auto; | ||
grid-template-rows: auto; | ||
} | ||
|
||
/* BannerContent ---------------------------------------------------------- */ | ||
|
||
.BannerContent { | ||
display: grid; | ||
row-gap: var(--base-size-4); | ||
grid-column-start: 1; | ||
margin-block: var(--base-size-8); | ||
} | ||
|
||
.Banner[data-title-hidden] .BannerContent { | ||
margin-block: var(--base-size-6); | ||
} | ||
|
||
@media screen and (min-width: 544px) { | ||
.BannerContent { | ||
flex: 1 1 0%; | ||
} | ||
} | ||
|
||
.BannerTitle { | ||
margin: 0; | ||
font-size: inherit; | ||
font-weight: var(--base-text-weight-semibold); | ||
} | ||
|
||
/* BannerIcon ------------------------------------------------------------- */ | ||
|
||
.BannerIcon { | ||
display: grid; | ||
place-items: center; | ||
padding: var(--base-size-8); | ||
} | ||
|
||
.BannerIcon svg { | ||
/* 20px is the line box height of the trailing action buttons */ | ||
height: var(--base-size-20); | ||
color: var(--banner-icon-fgColor); | ||
fill: var(--banner-icon-fgColor); | ||
} | ||
|
||
.Banner[data-title-hidden] .BannerIcon svg { | ||
height: var(--base-size-16); | ||
} | ||
|
||
/* BannerDismiss ---------------------------------------------------------- */ | ||
|
||
.BannerDismiss { | ||
display: grid; | ||
place-items: center; | ||
padding: var(--base-size-8); | ||
margin-inline-start: var(--base-size-4); | ||
} | ||
|
||
.BannerDismiss svg { | ||
color: var(--banner-icon-fgColor); | ||
} | ||
|
||
/* BannerActions ---------------------------------------------------------- */ | ||
|
||
.BannerActionsContainer { | ||
display: flex; | ||
column-gap: var(--base-size-12); | ||
align-items: center; | ||
} | ||
|
||
.BannerActions :where([data-primary-action='trailing']) { | ||
display: none; | ||
} | ||
|
||
@media screen and (--viewportRange-regular) { | ||
.BannerActions :where([data-primary-action='trailing']) { | ||
display: flex; | ||
} | ||
|
||
.BannerActions :where([data-primary-action='leading']) { | ||
display: none; | ||
} | ||
} | ||
|
||
.Banner[data-dismissible] .BannerActions { | ||
margin-block-end: var(--base-size-6); | ||
} | ||
|
||
/* stylelint-disable-next-line selector-max-specificity */ | ||
.Banner[data-dismissible]:not([data-title-hidden]) .BannerActionsContainer[data-primary-action='trailing'] { | ||
display: none; | ||
} | ||
|
||
/* stylelint-disable-next-line selector-max-specificity */ | ||
.Banner[data-dismissible]:not([data-title-hidden]) .BannerActionsContainer[data-primary-action='leading'] { | ||
display: flex; | ||
} | ||
|
||
/* Layout ------------------------------------------------------------------- */ | ||
|
||
/* stylelint-disable-next-line plugin/no-unsupported-browser-features */ | ||
@container banner (max-width: 500px) { | ||
.BannerContainer { | ||
display: grid; | ||
grid-template-rows: auto auto; | ||
} | ||
|
||
.BannerActions { | ||
margin-block-end: var(--base-size-6); | ||
} | ||
|
||
.BannerActions [data-primary-action='trailing'] { | ||
display: none; | ||
} | ||
|
||
.BannerActions [data-primary-action='leading'] { | ||
display: flex; | ||
} | ||
} | ||
|
||
/* stylelint-disable-next-line plugin/no-unsupported-browser-features */ | ||
@container banner (min-width: 500px) { | ||
.BannerContainer { | ||
display: grid; | ||
grid-template-columns: auto auto; | ||
} | ||
|
||
.BannerActions [data-primary-action='trailing'] { | ||
display: flex; | ||
} | ||
|
||
.BannerActions [data-primary-action='leading'] { | ||
display: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.