-
Notifications
You must be signed in to change notification settings - Fork 646
feat(Popover): Add Popover component #703
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
298764b
Update to doctocat@0.17.0
BinaryMuse 19ed689
Initial take on Popover
BinaryMuse 55ca841
remove unused imports
BinaryMuse 635e204
:art:
BinaryMuse 613ec51
Merge remote-tracking branch 'origin/master' into mkt/popover-component
BinaryMuse 1cd2244
Fix theme namespace for Popover
BinaryMuse 1e3078d
Give Popover a background color
BinaryMuse 7a8019f
Fix typo
BinaryMuse 27b5744
Remove unnecessary props
BinaryMuse 1de4a78
Add Popover typings
BinaryMuse 78d5455
Remove redundant system props
BinaryMuse 7cc88b8
Refactor caret positions
BinaryMuse d21ba83
Add Popover tests
BinaryMuse e5821ef
Update snapshots from theme change
BinaryMuse 5da5a2a
Remove old copy-paste CSS
BinaryMuse f40da92
Reword positioning docs
BinaryMuse b9a7f4a
Fix Popover typings
BinaryMuse 2777673
Add System Props section to Popover docs
BinaryMuse 623f55e
Fix system props style overrides for Popover
BinaryMuse 2cd0ec7
Let's get some bundle sizes in here
BinaryMuse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,23 @@ | ||
| name: 💾 Bundlesize | ||
| on: | ||
| push: | ||
| branches-ignore: | ||
| - master | ||
|
|
||
| jobs: | ||
| bundlesize: | ||
| name: Check Bundle Size | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| with: | ||
| path: 'old' | ||
| ref: 'master' | ||
| - uses: actions/checkout@v2 | ||
| with: | ||
| path: 'new' | ||
|
|
||
| - name: Check Bundle Size Change | ||
| uses: "BinaryMuse/action-bundlesize@master" | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or 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,110 @@ | ||
| --- | ||
| title: Popover | ||
| --- | ||
|
|
||
| Popovers are used to bring attention to specific user interface elements, typically to suggest an action or to guide users through a new experience. | ||
|
|
||
| Two components make up a popover; the `Popover` component controls the absolute positioning of the popover, and `Popover.Content` renders the inner content of the popover as well as the caret. | ||
|
|
||
| By default, the popover renders with absolute positioning, meaning it should usually be wrapped in an element with a relative position in order to be positioned properly. To render the popover with relative positioning, use the `relative` property. | ||
|
|
||
| It can be useful to give the `Popover.Content` element a margin to help align the popover. | ||
|
|
||
| ## Default Example | ||
|
|
||
| ```jxs live | ||
| <Relative> | ||
| <Text textAlign="center" display="block"> | ||
| <ButtonPrimary>Hello!</ButtonPrimary> | ||
| </Text> | ||
|
|
||
| <Popover relative open={true} caret="top"> | ||
| <Popover.Content mt={2}> | ||
| <Heading fontSize={2}>Popover heading</Heading> | ||
| <Text as="p">Message about this particular piece of UI.</Text> | ||
| <Button>Got it!</Button> | ||
| </Popover.Content> | ||
| </Popover> | ||
| </Relative> | ||
| ``` | ||
|
|
||
| ## Caret position | ||
|
|
||
| `Popover` supports various caret positions, which you can specify via the `caret` property. This demo shows all the valid values for the prop. The default is `top`. Note that the `top-left`, `bottom-left`, `top-right`, and `bottom-right` values modify the horizontal alignment of the popover. | ||
|
|
||
| ```javascript live noinline | ||
| function PopoverDemo(props) { | ||
| const [pos, setPos] = React.useState('top') | ||
| const [open, setOpen] = React.useState(true) | ||
|
|
||
| return ( | ||
| <Box> | ||
| <Heading as="h3" fontSize={3}>Caret Position</Heading> | ||
| <CaretSelector current={pos} onChange={setPos} /> | ||
| <Heading as="h3" fontSize={3}>Popover Visibility</Heading> | ||
| <Box my={2}> | ||
| <label> | ||
| <input type="checkbox" value={open} checked={open} | ||
| onChange={() => setOpen(open => !open)}/> Open | ||
| </label> | ||
| </Box> | ||
|
|
||
| <Relative pt={4}> | ||
| <Popover relative open={open} caret={pos}> | ||
| <Popover.Content> | ||
| <Heading fontSize={2}><code>{pos}</code> caret</Heading> | ||
| <Text as="p">Message about this particular piece of UI.</Text> | ||
| <Button onClick={() => setOpen(false)}>Got it!</Button> | ||
| </Popover.Content> | ||
| </Popover> | ||
| </Relative> | ||
| </Box> | ||
| ) | ||
| } | ||
|
|
||
| function CaretSelector(props) { | ||
| const choices = [ | ||
| 'top', 'bottom', 'left', 'right', | ||
| 'left-bottom', 'left-top', 'right-bottom', 'right-top', | ||
| 'top-left', 'bottom-left', 'top-right', 'bottom-right' | ||
| ].map((dir) => ( | ||
| <label> | ||
| <input key={dir} type='radio' name='caret' value={dir} | ||
| checked={dir === props.current} onChange={() => props.onChange(dir)} /> {dir} | ||
| </label> | ||
| )) | ||
|
|
||
| return ( | ||
| <Grid gridTemplateColumns="repeat(4, auto)" gridGap={3} my={2}> | ||
| {choices} | ||
| </Grid> | ||
| ) | ||
| } | ||
|
|
||
| render(<PopoverDemo />) | ||
| ``` | ||
|
|
||
| ## System props | ||
|
|
||
| `Popover` components get `COMMON`, `LAYOUT`, and `POSITION` system props. `Popover.Content` components get `COMMON`, `LAYOUT`, and `BORDER` system props. Read our [System Props](/system-props) doc page for a full list of available props. | ||
|
|
||
| ## Component props | ||
|
|
||
| ### Popover | ||
|
|
||
| | Name | Type | Default | Description | | ||
| | :- | :- | :-: | :- | | ||
| | as | String | 'div' | Sets the HTML tag for the component. | | ||
| | caret | String | 'top' | Controls the position of the caret. See below for the list of caret positions. | | ||
| | open | Boolean | false | Controls the visibility of the popover. | | ||
| | relative | Boolean | false | Set to true to render the popover using relative positioning. | | ||
|
|
||
| #### Caret Positions | ||
|
|
||
| The `caret` prop can be one of the following values: `top`, `bottom`, `left`, `right`, `bottom-left`, `bottom-right`, `top-left`, `top-right`, `left-bottom`, `left-top`, `right-bottom`, or `right-top`. | ||
|
|
||
| ### Popover.Content | ||
|
|
||
| | Name | Type | Default | Description | | ||
| | :- | :- | :-: | :- | | ||
| | as | String | 'div' | Sets the HTML tag for the component. | | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.