-
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(Popover): Convert Popover to CSS modules behind team feature flag (
#5300) * chore(Popover): convert popover to css modules -- partial * chore(Popover): add dev story and small caret refactor * Create three-falcons-compete.md * test(vrt): update snapshots * fix(Popover): format --------- Co-authored-by: francinelucca <francinelucca@users.noreply.github.com>
- Loading branch information
1 parent
7d6842a
commit 65802fc
Showing
14 changed files
with
480 additions
and
190 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 `Popover` component to use CSS modules behind the feature flag primer_react_css_modules_team |
Binary file added
BIN
+9.79 KB
...components/Popover.test.ts-snapshots/Popover-SX-Props-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.56 KB
...ots/components/Popover.test.ts-snapshots/Popover-SX-Props-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.1 KB
...ponents/Popover.test.ts-snapshots/Popover-SX-Props-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.81 KB
.../snapshots/components/Popover.test.ts-snapshots/Popover-SX-Props-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.81 KB
...components/Popover.test.ts-snapshots/Popover-SX-Props-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.41 KB
...omponents/Popover.test.ts-snapshots/Popover-SX-Props-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.53 KB
...onents/Popover.test.ts-snapshots/Popover-SX-Props-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.49 KB
...snapshots/components/Popover.test.ts-snapshots/Popover-SX-Props-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.49 KB
...omponents/Popover.test.ts-snapshots/Popover-SX-Props-light-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,38 @@ | ||
import React from 'react' | ||
import type {Meta} from '@storybook/react' | ||
import Heading from '../Heading' | ||
import Popover from './Popover' | ||
import Text from '../Text' | ||
import {Button} from '../Button' | ||
|
||
export default { | ||
title: 'Components/Popover/Dev', | ||
component: Popover, | ||
} as Meta<typeof Popover> | ||
|
||
export const SxProps = () => ( | ||
<Popover | ||
relative | ||
open={true} | ||
caret="top-right" | ||
sx={{ | ||
left: '50%', | ||
transform: 'translateX(-50%)', | ||
mt: 2, | ||
color: 'var(--bgColor-danger-muted)', | ||
}} | ||
style={{padding: '16px'}} | ||
> | ||
<Popover.Content | ||
sx={{ | ||
minWidth: '260px', | ||
width: '40%', | ||
}} | ||
style={{padding: '32px'}} | ||
> | ||
<Heading sx={{fontSize: 2}}>Popover heading</Heading> | ||
<Text as="p">Message about popovers</Text> | ||
<Button>Got it!</Button> | ||
</Popover.Content> | ||
</Popover> | ||
) |
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,208 @@ | ||
.Popover { | ||
position: absolute; | ||
z-index: 100; | ||
display: none; | ||
|
||
&:where([data-open]) { | ||
display: block; | ||
} | ||
|
||
&:where([data-relative]) { | ||
position: relative; | ||
} | ||
} | ||
|
||
.PopoverContent { | ||
position: relative; | ||
width: 232px; | ||
padding: var(--base-size-24); | ||
margin-right: auto; | ||
margin-left: auto; | ||
background-color: var(--overlay-bgColor); | ||
border: var(--borderWidth-thin) solid var(--borderColor-default); | ||
border-radius: var(--borderRadius-medium); | ||
|
||
/* Carets */ | ||
&::before, | ||
&::after { | ||
position: absolute; | ||
left: 50%; | ||
display: inline-block; | ||
content: ''; | ||
} | ||
|
||
&::before { | ||
top: calc(-1 * var(--base-size-16)); | ||
/* stylelint-disable-next-line primer/spacing */ | ||
margin-left: -9px; | ||
|
||
/* TODO: solid? */ | ||
/* stylelint-disable-next-line primer/borders */ | ||
border: var(--base-size-8) solid transparent; | ||
border-bottom-color: var(--borderColor-default); | ||
} | ||
|
||
&::after { | ||
/* stylelint-disable-next-line primer/spacing */ | ||
top: -14px; | ||
margin-left: calc(-1 * var(--base-size-8)); | ||
|
||
/* // todo: solid */ | ||
/* stylelint-disable-next-line primer/borders */ | ||
border: 7px solid transparent; | ||
/* stylelint-disable-next-line primer/colors */ | ||
border-bottom-color: var(--overlay-bgColor); | ||
} | ||
|
||
/* Bottom-oriented carets */ | ||
:where([data-caret='bottom']) &, | ||
:where([data-caret='bottom-right']) &, | ||
:where([data-caret='bottom-left']) & { | ||
&::before, | ||
&::after { | ||
top: auto; | ||
border-bottom-color: transparent; | ||
} | ||
|
||
&::before { | ||
bottom: calc(-1 * var(--base-size-16)); | ||
border-top-color: var(--borderColor-default); | ||
} | ||
|
||
&::after { | ||
/* stylelint-disable-next-line primer/spacing */ | ||
bottom: -14px; | ||
/* stylelint-disable-next-line primer/colors */ | ||
border-top-color: var(--overlay-bgColor); | ||
} | ||
} | ||
|
||
/* Top & Bottom: Right-oriented carets */ | ||
:where([data-caret='top-right']) &, | ||
:where([data-caret='bottom-right']) & { | ||
/* stylelint-disable-next-line primer/spacing */ | ||
right: -9px; | ||
margin-right: 0; | ||
|
||
&::before, | ||
&::after { | ||
left: auto; | ||
margin-left: 0; | ||
} | ||
|
||
&::before { | ||
/* stylelint-disable-next-line primer/spacing */ | ||
right: 20px; | ||
} | ||
|
||
&::after { | ||
/* stylelint-disable-next-line primer/spacing */ | ||
right: 21px; | ||
} | ||
} | ||
|
||
/* Top & Bottom: Left-oriented carets */ | ||
:where([data-caret='top-left']) &, | ||
:where([data-caret='bottom-left']) & { | ||
/* stylelint-disable-next-line primer/spacing */ | ||
left: -9px; | ||
margin-left: 0; | ||
|
||
&::before, | ||
&::after { | ||
left: var(--base-size-24); | ||
margin-left: 0; | ||
} | ||
|
||
&::after { | ||
/* stylelint-disable-next-line primer/spacing */ | ||
left: calc(var(--base-size-24) + 1px); | ||
} | ||
} | ||
|
||
/* Right- & Left-oriented carets */ | ||
:where([data-caret='right']) &, | ||
:where([data-caret='right-top']) &, | ||
:where([data-caret='right-bottom']) &, | ||
:where([data-caret='left']) &, | ||
:where([data-caret='left-top']) &, | ||
:where([data-caret='left-bottom']) & { | ||
&::before, | ||
&::after { | ||
top: 50%; | ||
left: auto; | ||
margin-left: 0; | ||
border-bottom-color: transparent; | ||
} | ||
|
||
&::before { | ||
/* stylelint-disable-next-line primer/spacing */ | ||
margin-top: calc((var(--base-size-8) + 1px) * -1); | ||
} | ||
|
||
&::after { | ||
margin-top: calc(-1 * var(--base-size-8)); | ||
} | ||
} | ||
|
||
/* Right-oriented carets */ | ||
:where([data-caret='right']) &, | ||
:where([data-caret='right-top']) &, | ||
:where([data-caret='right-bottom']) & { | ||
&::before { | ||
right: calc(-1 * var(--base-size-16)); | ||
border-left-color: var(--borderColor-default); | ||
} | ||
|
||
&::after { | ||
/* stylelint-disable-next-line primer/spacing */ | ||
right: -14px; | ||
/* stylelint-disable-next-line primer/colors */ | ||
border-left-color: var(--overlay-bgColor); | ||
} | ||
} | ||
|
||
/* Left-oriented carets */ | ||
:where([data-caret='left']) &, | ||
:where([data-caret='left-top']) &, | ||
:where([data-caret='left-bottom']) & { | ||
&::before { | ||
left: calc(-1 * var(--base-size-16)); | ||
border-right-color: var(--borderColor-default); | ||
} | ||
|
||
&::after { | ||
/* stylelint-disable-next-line primer/spacing */ | ||
left: -14px; | ||
/* stylelint-disable-next-line primer/colors */ | ||
border-right-color: var(--overlay-bgColor); | ||
} | ||
} | ||
|
||
/* Right & Left: Top-oriented carets */ | ||
:where([data-caret='right-top']) &, | ||
:where([data-caret='left-top']) & { | ||
&::before, | ||
&::after { | ||
top: var(--base-size-24); | ||
} | ||
} | ||
|
||
/* Right & Left: Bottom-oriented carets */ | ||
:where([data-caret='right-bottom']) &, | ||
:where([data-caret='left-bottom']) & { | ||
&::before, | ||
&::after { | ||
top: auto; | ||
} | ||
|
||
&::before { | ||
bottom: var(--base-size-16); | ||
} | ||
|
||
&::after { | ||
/* stylelint-disable-next-line primer/spacing */ | ||
bottom: calc(var(--base-size-16) + 1px); | ||
} | ||
} | ||
} |
Oops, something went wrong.