Skip to content

Commit

Permalink
feat(esl-popup): add support of PopupActionParams.extraStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
ala-n committed Dec 7, 2023
1 parent 32b6d0a commit 399685b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/modules/esl-popup/core/esl-popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export interface PopupActionParams extends ESLToggleableActionParams {

/** Extra class to add to popup on activation */
extraClass?: string;
/** Extra styles to add to popup on activation */
extraStyle?: string;
}

@ExportNs('Popup')
Expand Down Expand Up @@ -105,6 +107,8 @@ export class ESLPopup extends ESLToggleable {
public $placeholder: ESLPopupPlaceholder | null;

protected _extraClass?: string;
protected _extraStyle?: string;

protected _containerEl?: HTMLElement;
protected _offsetTrigger: number;
protected _offsetContainer: number | [number, number];
Expand Down Expand Up @@ -181,6 +185,7 @@ export class ESLPopup extends ESLToggleable {
if (this.open) {
this.afterOnHide();
this._extraClass = params.extraClass;
this._extraStyle = params.extraStyle;
this.afterOnShow();
}

Expand All @@ -206,6 +211,7 @@ export class ESLPopup extends ESLToggleable {
}));

this._extraClass = params.extraClass;
this._extraStyle = params.extraStyle;
this._containerEl = params.containerEl;
this._offsetTrigger = params.offsetTrigger || 0;
this._offsetContainer = params.offsetContainer || 0;
Expand All @@ -232,7 +238,9 @@ export class ESLPopup extends ESLToggleable {
*/
protected afterOnShow(): void {
this._updatePosition();

this.style.visibility = 'visible';
this.style.cssText += this._extraStyle || '';
this.$$cls(this._extraClass || '', true);

this.$$on(this._onActivatorScroll);
Expand All @@ -253,6 +261,8 @@ export class ESLPopup extends ESLToggleable {
*/
protected afterOnHide(): void {
this._stopUpdateLoop();

this.$$attr('style', '');
this.$$cls(this._extraClass || '', false);

this.$$off(this._onActivatorScroll);
Expand Down

0 comments on commit 399685b

Please sign in to comment.