Skip to content

Commit

Permalink
feat: add trigger esl-tooltip to esl-note
Browse files Browse the repository at this point in the history
  • Loading branch information
dshovchko committed Jun 15, 2021
1 parent 5723b38 commit ff13d74
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/modules/esl-note/core/esl-note.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ esl-note {
line-height: 0;
vertical-align: baseline;
top: -.5em;
cursor: pointer;

&::before {
content: '[';
Expand Down
35 changes: 34 additions & 1 deletion src/modules/esl-note/core/esl-note.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {ExportNs} from '../../esl-utils/environment/export-ns';
import {bind} from '../../esl-utils/decorators/bind';
import {ESLBaseElement, attr, jsonAttr, boolAttr} from '../../esl-base-element/core';
import {attr, boolAttr} from '../../esl-base-element/core';
import {ESLTrigger} from '../../esl-trigger/core';
import {ESLTooltip} from '../../esl-tooltip/core';
import {ESLFootnotes} from '../../esl-footnotes/core/esl-footnotes';
import {EventUtils} from '../../esl-utils/dom/events';

Expand All @@ -13,6 +14,11 @@ export class ESLNote extends ESLTrigger {
/** Linked state marker */
@boolAttr() public linked: boolean;

@attr({defaultValue: 'toggle'}) public mode: string;
@attr({defaultValue: 'hover'}) public event: string;

public target = 'body';

protected _$footnotes: ESLFootnotes | null;
protected _index: number;
protected _text: string;
Expand Down Expand Up @@ -69,4 +75,31 @@ export class ESLNote extends ESLTrigger {
EventUtils.dispatch(this, `${ESLNote.eventNs}:ready`);
}
}

/** Handles trigger open type of event */
@bind
protected _onShowEvent(event: Event) {
if (this._isIgnored(event.target)) return;
ESLTooltip.show({
activator: this,
delay: this.showDelayValue,
text: this.text,
//behavior: 'none',
//disableArrow: true,
event
});
event.preventDefault();
}

/** Handles trigger hide type of event */
@bind
protected _onHideEvent(event: Event) {
if (this._isIgnored(event.target)) return;
ESLTooltip.hide({
activator: this,
delay: this.hideDelayValue,
event
});
event.preventDefault();
}
}

0 comments on commit ff13d74

Please sign in to comment.