This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
feat(Popup): added on
prop for triggering the popup on click, hover or focus
#622
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
5634808
-added on prop in the Popup for allowing the user to change the trigg…
56d26aa
Merge branch 'master' into feat/popup-open-on-hover
dc3142d
-updated changelog
da52a33
-wip: adding focus, click, hover combinations for the on prop
f1fe2b4
-fixed some issues
5d173c2
-added escape key handler on the trigger
80f827b
Merge branch 'master' into feat/popup-open-on-hover
0b4c4d4
-fixed focus handlers
22bd970
-fixed focus
1bbe26d
-added focus usage example
982ddd4
-fixed on prop type
600de37
-handle timeout for closing only if mouseLeaveDelay is greater then 0
4627a97
-adding comments on the handlers created
77ef894
Merge branch 'master' into feat/popup-open-on-hover
d0fd941
-rearranged usage example and added example using the trap focus beha…
dcb40ec
-improved typing for the on prop in the Popup
28f3e67
-removed expressions for strings in the examples
f51ef3a
-replaced double quotes with single quotes
c31494d
-added aria-label on the popup examples
56fd18b
-reverted condition for not adding timeout if the mouse delay is 0
9ecbb0b
-removed alert in the Popup examples
0c17a69
Merge branch 'master' into feat/popup-open-on-hover
318b09b
-refactoring the timeout handling and added clear logic
f8e2bca
-small refactorings
da204e0
docs: simplify popup usage examples
levithomason efd9d52
-fix focus + click opening
295e312
Merge branch 'master' into feat/popup-open-on-hover
8fa0a2c
-fixed changelog after merging master
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
24 changes: 24 additions & 0 deletions
24
docs/src/examples/components/Popup/Usage/PopupExampleOn.shorthand.tsx
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,24 @@ | ||
import * as React from 'react' | ||
import { Button, Popup } from '@stardust-ui/react' | ||
|
||
const PopupExampleOn = () => ( | ||
<div> | ||
<Popup | ||
trigger={<Button icon="expand" content="Click" aria-label="Click button" />} | ||
content="Hello from popup on click!" | ||
on="click" | ||
/> | ||
<Popup | ||
trigger={<Button icon="expand" content="Hover" aria-label="Hover button" />} | ||
content="Hello from popup on hover!" | ||
on="hover" | ||
/> | ||
<Popup | ||
trigger={<Button icon="expand" content="Focus" aria-label="Focus button" />} | ||
content="Hello from popup on focus!" | ||
on="focus" | ||
/> | ||
</div> | ||
) | ||
|
||
export default PopupExampleOn |
19 changes: 19 additions & 0 deletions
19
docs/src/examples/components/Popup/Usage/PopupExampleOnMultiple.shorthand.tsx
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,19 @@ | ||
import * as React from 'react' | ||
import { Button, Popup } from '@stardust-ui/react' | ||
|
||
const PopupExampleOnMultiple = () => ( | ||
<div> | ||
<Popup | ||
trigger={<Button icon="expand" content="Click + Focus" aria-label="Click or focus button" />} | ||
content="Hello from popup on click!" | ||
on={['click', 'focus']} | ||
/> | ||
<Popup | ||
trigger={<Button icon="expand" content="Hover + Focus" aria-label="Hover or focus button" />} | ||
content="Hello from popup on hover!" | ||
on={['hover', 'focus']} | ||
/> | ||
</div> | ||
) | ||
|
||
export default PopupExampleOnMultiple |
36 changes: 36 additions & 0 deletions
36
docs/src/examples/components/Popup/Usage/PopupExampleOnWithFocusTrap.shorthand.tsx
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,36 @@ | ||
import * as React from 'react' | ||
import { Button, Popup, popupFocusTrapBehavior } from '@stardust-ui/react' | ||
|
||
const contentWithButtons = { | ||
content: ( | ||
<> | ||
<Button>First</Button> | ||
<Button primary>Second</Button> | ||
</> | ||
), | ||
} | ||
|
||
const PopupExampleOnWithFocusTrap = () => ( | ||
<div> | ||
<Popup | ||
trigger={<Button icon="expand" content="Click" aria-label="Click button" />} | ||
content={contentWithButtons} | ||
accessibility={popupFocusTrapBehavior} | ||
on="click" | ||
/> | ||
<Popup | ||
trigger={<Button icon="expand" content="Hover" aria-label="Hover button" />} | ||
content={contentWithButtons} | ||
accessibility={popupFocusTrapBehavior} | ||
on="hover" | ||
/> | ||
<Popup | ||
trigger={<Button icon="expand" content="Focus" aria-label="Focus button" />} | ||
content={contentWithButtons} | ||
accessibility={popupFocusTrapBehavior} | ||
on="focus" | ||
/> | ||
</div> | ||
) | ||
|
||
export default PopupExampleOnWithFocusTrap |
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,26 @@ | ||
import * as React from 'react' | ||
|
||
import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample' | ||
import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection' | ||
|
||
const Usage = () => ( | ||
<ExampleSection title="Usage"> | ||
<ComponentExample | ||
title="Triggering popup on different actions" | ||
description="A popup can be triggered on click, hover or focus." | ||
examplePath="components/Popup/Usage/PopupExampleOn" | ||
/> | ||
<ComponentExample | ||
title="Using the focus trap behavior" | ||
description="Combining the triggers with popup focus trap behavior, will focus the first focusable element inside the content of the popup." | ||
examplePath="components/Popup/Usage/PopupExampleOnWithFocusTrap" | ||
/> | ||
<ComponentExample | ||
title="Combined triggering actions" | ||
description="The triggering actions can be combined." | ||
examplePath="components/Popup/Usage/PopupExampleOnMultiple" | ||
/> | ||
</ExampleSection> | ||
mnajdova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
export default Usage |
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.