-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic docs for
AnchoredOverlay
(#1192)
- Loading branch information
Showing
4 changed files
with
48 additions
and
2 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/components": patch | ||
--- | ||
|
||
Add basic docs for `AnchoredOverlay` |
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,39 @@ | ||
--- | ||
title: AnchoredOverlay | ||
status: Alpha | ||
--- | ||
|
||
An `AnchoredOverlay` provides an anchor that will open a floating overlay positioned relative to the anchor. | ||
The overlay can be opened and navigated using keyboard or mouse. | ||
|
||
## Example | ||
|
||
```jsx live | ||
<State default={false}> | ||
{([isOpen, setIsOpen]) => { | ||
const openOverlay = React.useCallback(() => setIsOpen(true), [setIsOpen]) | ||
const closeOverlay = React.useCallback(() => setIsOpen(false), [setIsOpen]) | ||
return ( | ||
<AnchoredOverlay | ||
renderAnchor={(anchorProps) => ( | ||
<DropdownButton {...anchorProps}> | ||
Click me to open | ||
</DropdownButton> | ||
)} | ||
open={isOpen} | ||
onOpen={openOverlay} | ||
onClose={closeOverlay} | ||
> | ||
<Flex flexDirection="column" maxWidth="300px" padding={2}> | ||
<p> | ||
This menu automatically receives a focus trap and focus zone. Use up/down keys to navigate between buttons | ||
</p> | ||
<Button mb={1}>Button 1</Button> | ||
<Button mb={1}>Button 2</Button> | ||
<Button>Button 3</Button> | ||
</Flex> | ||
</AnchoredOverlay> | ||
) | ||
}} | ||
</State> | ||
``` |
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
17957f2
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.
Successfully deployed to the following URLs: