-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OGUI-1607] Add dropdown component (#2739)
* [OGUI-1497] Add copy-to-clipboard component * Fix linter * [OGUI-1497] Add dropdown component * Add popover styles * Fix linter
- Loading branch information
1 parent
464eeb7
commit f445a1d
Showing
12 changed files
with
1,231 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
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,16 @@ | ||
/** | ||
* @license | ||
* Copyright CERN and copyright holders of ALICE O2. This software is | ||
* distributed under the terms of the GNU General Public License v3 (GPL | ||
* Version 3), copied verbatim in the file "COPYING". | ||
* | ||
* See http://alice-o2.web.cern.ch/license for full licensing information. | ||
* | ||
* In applying this license CERN does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an Intergovernmental Organization | ||
* or submit itself to any jurisdiction. | ||
*/ | ||
|
||
/** | ||
* @typedef {(vnode|string|number|Array<(vnode|string|number)>|null)} 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
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,45 @@ | ||
/** | ||
* @license | ||
* Copyright CERN and copyright holders of ALICE O2. This software is | ||
* distributed under the terms of the GNU General Public License v3 (GPL | ||
* Version 3), copied verbatim in the file "COPYING". | ||
* | ||
* See http://alice-o2.web.cern.ch/license for full licensing information. | ||
* | ||
* In applying this license CERN does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an Intergovernmental Organization | ||
* or submit itself to any jurisdiction. | ||
*/ | ||
|
||
import { h } from '../renderer.js'; | ||
import { PopoverTriggerPreConfiguration } from './PopoverPreConfigurations.js'; | ||
import { PopoverAnchors } from './PopoverEngine.js'; | ||
import { popover } from './popover.js'; | ||
|
||
/** | ||
* Renders a dropdown component | ||
* | ||
* @param {Component} trigger the component triggering the dropdown opening trigger | ||
* @param {Component} content the content of the dropdown | ||
* @param {Object} [configuration] dropdown configuration | ||
* @param {'left'|'right'} [configuration.alignment='left'] defines the alignment of the dropdown | ||
* @param {popoverVisibilityChangeCallback} [configuration.onVisibilityChange] function called when the visibility changes | ||
* @return {Component} the dropdown component | ||
*/ | ||
export const DropdownComponent = ( | ||
trigger, | ||
content, | ||
configuration, | ||
) => { | ||
configuration = configuration || {}; | ||
const { alignment = 'left' } = configuration; | ||
return popover( | ||
trigger, | ||
h('.dropdown', content), | ||
{ | ||
...PopoverTriggerPreConfiguration.click, | ||
anchor: alignment === 'left' ? PopoverAnchors.BOTTOM_START : PopoverAnchors.BOTTOM_END, | ||
onVisibilityChange: configuration.onVisibilityChange, | ||
}, | ||
); | ||
}; |
Oops, something went wrong.