Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

feat(Popup): added on prop for triggering the popup on click, hover or focus #622

Merged
merged 28 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
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…
Dec 17, 2018
56d26aa
Merge branch 'master' into feat/popup-open-on-hover
Dec 17, 2018
dc3142d
-updated changelog
Dec 17, 2018
da52a33
-wip: adding focus, click, hover combinations for the on prop
Dec 19, 2018
f1fe2b4
-fixed some issues
Dec 20, 2018
5d173c2
-added escape key handler on the trigger
Dec 20, 2018
80f827b
Merge branch 'master' into feat/popup-open-on-hover
Dec 20, 2018
0b4c4d4
-fixed focus handlers
Dec 20, 2018
22bd970
-fixed focus
Dec 21, 2018
1bbe26d
-added focus usage example
Dec 21, 2018
982ddd4
-fixed on prop type
Jan 2, 2019
600de37
-handle timeout for closing only if mouseLeaveDelay is greater then 0
Jan 2, 2019
4627a97
-adding comments on the handlers created
Jan 2, 2019
77ef894
Merge branch 'master' into feat/popup-open-on-hover
Jan 2, 2019
d0fd941
-rearranged usage example and added example using the trap focus beha…
Jan 2, 2019
dcb40ec
-improved typing for the on prop in the Popup
Jan 2, 2019
28f3e67
-removed expressions for strings in the examples
Jan 2, 2019
f51ef3a
-replaced double quotes with single quotes
Jan 2, 2019
c31494d
-added aria-label on the popup examples
Jan 2, 2019
56fd18b
-reverted condition for not adding timeout if the mouse delay is 0
Jan 2, 2019
9ecbb0b
-removed alert in the Popup examples
Jan 2, 2019
0c17a69
Merge branch 'master' into feat/popup-open-on-hover
Jan 4, 2019
318b09b
-refactoring the timeout handling and added clear logic
Jan 4, 2019
f8e2bca
-small refactorings
Jan 4, 2019
da204e0
docs: simplify popup usage examples
levithomason Jan 7, 2019
efd9d52
-fix focus + click opening
Jan 8, 2019
295e312
Merge branch 'master' into feat/popup-open-on-hover
Jan 8, 2019
8fa0a2c
-fixed changelog after merging master
Jan 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Features
- Add `on` and `mouseLeaveDelay` props to `Popup` component @mnajdova ([#622](https://github.com/stardust-ui/react/pull/622))

<!--------------------------------[ v0.16.0 ]------------------------------- -->
## [v0.16.0](https://github.com/stardust-ui/react/tree/v0.16.0) (2019-01-07)
[Compare changes](https://github.com/stardust-ui/react/compare/v0.15.0...v0.16.0)
Expand Down
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
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
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
26 changes: 26 additions & 0 deletions docs/src/examples/components/Popup/Usage/index.tsx
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>
)

export default Usage
2 changes: 2 additions & 0 deletions docs/src/examples/components/Popup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import * as React from 'react'
import Types from './Types'
import Variations from './Variations'
import Usage from './Usage'

const PopupExamples = () => (
<div>
<Types />
<Variations />
<Usage />
</div>
)

Expand Down
Loading