This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b287187
commit a5d7fcf
Showing
6 changed files
with
122 additions
and
0 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,47 @@ | ||
import UiContextualContainer, { | ||
SelectorStrategies, | ||
TriggerEvents, | ||
} from '../-internals/contextual-container/component'; | ||
|
||
/** | ||
* | ||
*/ | ||
export default class UiPopoverContextContainer extends UiContextualContainer { | ||
/** | ||
* The amount of time, in milliseconds, between the triggering interaction | ||
* and when the tooltip is displayed. | ||
*/ | ||
delay = 150; | ||
|
||
distance = 11; | ||
|
||
/** @hidden */ | ||
ariaAttachAs = 'aria-controls'; | ||
|
||
/** @hidden */ | ||
closeOnOutsideClick = false; | ||
|
||
/** @hidden */ | ||
triggerEvents = TriggerEvents.CLICK; | ||
|
||
/** @hidden */ | ||
triggerSelector = SelectorStrategies.PARENT; | ||
|
||
/** @hidden */ | ||
readonly overlayComponent = 'ui-popover/element'; | ||
|
||
public didInsertElement() { | ||
super.didInsertElement(); | ||
this.getAriaElement()?.setAttribute('aria-expanded', 'false'); | ||
} | ||
|
||
/** @hidden */ | ||
onShow = () => { | ||
this.getAriaElement()?.setAttribute('aria-expanded', 'true'); | ||
}; | ||
|
||
/** @hidden */ | ||
onHide = () => { | ||
this.getAriaElement()?.setAttribute('aria-expanded', 'false'); | ||
}; | ||
} |
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,27 @@ | ||
import UiContextualElement from '@nsf-open/ember-ui-foundation/components/-internals/contextual-container/element/component'; | ||
import { computed } from '@ember/object'; | ||
|
||
export default class UiPopoverContextElement extends UiContextualElement { | ||
arrowClassName = 'arrow'; | ||
|
||
innerClassName = 'popover-content'; | ||
|
||
titleTextClassName = 'popover-title'; | ||
|
||
ariaRole = 'region'; | ||
|
||
@computed('fade', 'actualPlacement', 'showContent') | ||
public get popperClassNames() { | ||
const classNames = ['popover', this.actualPlacement]; | ||
|
||
if (this.fade) { | ||
classNames.push('fade'); | ||
} | ||
|
||
if (this.showContent) { | ||
classNames.push('in'); | ||
} | ||
|
||
return classNames; | ||
} | ||
} |
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,35 @@ | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
|
||
export default { | ||
title: 'Elements/ui-popover', | ||
component: 'components/ui-popover/component', | ||
|
||
parameters: { | ||
layout: 'centered', | ||
}, | ||
|
||
args: { | ||
textContent: 'Hello World', | ||
}, | ||
}; | ||
|
||
const Template = (context: unknown) => { | ||
return { | ||
context: Object.assign({}, context), | ||
|
||
// language=handlebars | ||
template: hbs` | ||
<div class="text-center"> | ||
<UiButton @variant="primary"> | ||
Log In | ||
<UiPopover @title="Hello World"> | ||
Username and password go here | ||
</UiPopover> | ||
</UiButton> | ||
</div> | ||
`, | ||
}; | ||
}; | ||
|
||
export const Default = Template.bind({}); | ||
Default.storyName = 'ui-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
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 @@ | ||
export { default } from '@nsf-open/ember-ui-foundation/components/ui-popover/component'; |
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 @@ | ||
export { default } from '@nsf-open/ember-ui-foundation/components/ui-popover/element/component'; |