-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathtool-tip.js
56 lines (51 loc) · 1.28 KB
/
tool-tip.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { debounce } from '@ember/runloop';
/**
* @deprecated
* @module ToolTip
*
* @example
* <ToolTip @verticalPosition="above" as |T|>
* <T.Trigger>
* <Icon @name="check-circle" class="has-text-success" />
* </T.Trigger>
* <T.Content @defaultClass="tool-tip">
* <div class="box">
* My tooltip text
* </div>
* </T.Content>
* </ToolTip>
*
* * Use HDS tooltip instead
* @param {string} [verticalPosition] - vertical position specification (above, below)
* @param {string} [horizontalPosition] - horizontal position specification (center, auto-right)
*
*/
export default class ToolTipComponent extends Component {
get delay() {
return this.args.delay || 200;
}
get horizontalPosition() {
return this.args.horizontalPosition || 'auto-right';
}
toggleState({ dropdown, action }) {
dropdown.actions[action]();
}
@action
open(dropdown) {
debounce(this, 'toggleState', { dropdown, action: 'open' }, this.delay);
}
@action
close(dropdown) {
debounce(this, 'toggleState', { dropdown, action: 'close' }, this.delay);
}
@action
prevent() {
return false;
}
}