-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backstage: refactor o3-tooltip and create 2 components out of it inst…
…ead of one - update t sconfiguration
- Loading branch information
Showing
20 changed files
with
287 additions
and
253 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,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
import './tooltip' | ||
import './onboardingTooltip' | ||
import './toggleTooltip' |
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,37 @@ | ||
import {ToolTip} from './tooltip'; | ||
import type {TooltipProps} from '../types'; | ||
|
||
export class OnboardingToolTip extends ToolTip implements TooltipProps { | ||
private _closeButton!: HTMLElement; | ||
|
||
connectedCallback() { | ||
super.connectedCallback(); | ||
this._closeButton = this.querySelector('.o3-tooltip-close') as HTMLElement; | ||
this._addEventListeners(); | ||
} | ||
|
||
disconnectedCallback() { | ||
super.disconnectedCallback(); | ||
this._removeEventListeners(); | ||
} | ||
|
||
private _clickHandler = () => { | ||
this.remove(); | ||
}; | ||
|
||
private _addEventListeners() { | ||
this._closeButton.addEventListener('click', this._clickHandler); | ||
} | ||
|
||
private _removeEventListeners() { | ||
this._closeButton.removeEventListener('click', this._clickHandler); | ||
} | ||
} | ||
|
||
customElements.define('o3-tooltip-onboarding', OnboardingToolTip); | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'o3-tooltip-onboarding': OnboardingToolTip; | ||
} | ||
} |
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,40 @@ | ||
import {ToolTip} from './tooltip'; | ||
import {TooltipProps} from '../types'; | ||
|
||
export class ToggleToolTip extends ToolTip implements TooltipProps { | ||
connectedCallback() { | ||
super.connectedCallback(); | ||
this._addEventListeners(); | ||
this.style.display = 'none'; | ||
} | ||
|
||
disconnectedCallback() { | ||
super.disconnectedCallback(); | ||
this._removeEventListeners(); | ||
} | ||
|
||
private _clickHandler = () => { | ||
if (this.style.display === 'none') { | ||
this.render(); | ||
this.style.display = 'block'; | ||
return | ||
} | ||
this.style.display = 'none'; | ||
}; | ||
|
||
private _addEventListeners() { | ||
this._targetNode.addEventListener('click', this._clickHandler); | ||
} | ||
|
||
private _removeEventListeners() { | ||
this._targetNode.removeEventListener('click', this._clickHandler); | ||
} | ||
} | ||
|
||
customElements.define('o3-tooltip-toggle', ToggleToolTip); | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'o3-tooltip-toggle': ToggleToolTip; | ||
} | ||
} |
Oops, something went wrong.