From dc769c23d43b09d3fef18d0dadcf7cee95da96e1 Mon Sep 17 00:00:00 2001 From: "ala'n (Alexey Stsefanovich)" Date: Fri, 22 Sep 2023 04:21:03 +0200 Subject: [PATCH] refactor(core): cleanup for imports and ESL usages --- src/core/base/root.ts | 11 ++++++----- src/core/preview/preview.ts | 11 +++++------ src/plugins/header/header.tsx | 8 ++++---- src/registration.less | 1 + 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/core/base/root.ts b/src/core/base/root.ts index 4f3ef065..9af8c251 100644 --- a/src/core/base/root.ts +++ b/src/core/base/root.ts @@ -1,10 +1,11 @@ -import {EventUtils} from '@exadel/esl/modules/esl-utils/dom/events'; -import {boolAttr, ESLBaseElement} from '@exadel/esl/modules/esl-base-element/core'; -import {memoize} from '@exadel/esl/modules/esl-utils/decorators/memoize'; -import type {AnyToVoidFnSignature} from '@exadel/esl/modules/esl-utils/misc/functions'; +import {ESLEventUtils} from '@exadel/esl/modules/esl-utils/dom/events'; +import {ESLBaseElement} from '@exadel/esl/modules/esl-base-element/core'; +import {memoize, boolAttr} from '@exadel/esl/modules/esl-utils/decorators'; import {SnippetTemplate, UIPStateModel} from './model'; +import type {AnyToVoidFnSignature} from '@exadel/esl/modules/esl-utils/misc/functions'; + /** * UI Playground root custom element definition * Container element for {@link UIPPlugin} components @@ -66,7 +67,7 @@ export class UIPRoot extends ESLBaseElement { } // setTimeout to let other plugins init before dispatching setTimeout(() => { - EventUtils.dispatch(this, 'uip:configchange', { + ESLEventUtils.dispatch(this, 'uip:configchange', { bubbles: false, detail: { attribute: attrName, diff --git a/src/core/preview/preview.ts b/src/core/preview/preview.ts index f1cbbf95..2003bf70 100644 --- a/src/core/preview/preview.ts +++ b/src/core/preview/preview.ts @@ -1,4 +1,5 @@ -import {bind} from '@exadel/esl/modules/esl-utils/decorators/bind'; +import {bind} from '@exadel/esl/modules/esl-utils/decorators'; + import {UIPPlugin} from '../base/plugin'; /** @@ -24,11 +25,9 @@ export class UIPPreview extends UIPPlugin { } protected attributeChangedCallback(attrName: string, oldVal: string, newVal: string): void { - if (attrName === 'resizable' && newVal === null) { - this.clearInlineSize(); - this.$inner.classList.remove('resizable'); - } else { - this.$inner.classList.add('resizable'); + if (attrName === 'resizable') { + newVal === null && this.clearInlineSize(); + this.$inner.classList.toggle('resizable', newVal !== null); } } diff --git a/src/plugins/header/header.tsx b/src/plugins/header/header.tsx index 9775d8a6..5114f3ac 100644 --- a/src/plugins/header/header.tsx +++ b/src/plugins/header/header.tsx @@ -1,10 +1,10 @@ -import {EventUtils} from '@exadel/esl/modules/esl-utils/dom/events'; +import React from 'jsx-dom'; + +import {ESLEventUtils} from '@exadel/esl/modules/esl-utils/dom/events'; import {listen} from '@exadel/esl/modules/esl-utils/decorators/listen'; import {UIPPlugin} from '../../core/base/plugin'; import {UIPOptionIcons, UIPOptions, UIPSnippets} from '../registration'; -import * as React from 'jsx-dom'; - /** * Header {@link UIPPlugin} custom element definition * Container for {@link UIPSnippets} and {@link UIPOptions} elements @@ -49,7 +49,7 @@ export class UIPHeader extends UIPPlugin { @listen({event: 'click', selector: '.copy-icon'}) protected _onCopyClick() { navigator.clipboard.writeText(this.model!.html).then(() => { - EventUtils.dispatch(this, 'esl:alert:show', { + ESLEventUtils.dispatch(this, 'esl:alert:show', { detail: { text: 'Markup copied', cls: 'uip-alert-info' diff --git a/src/registration.less b/src/registration.less index 2b54b1fa..34c8dc25 100644 --- a/src/registration.less +++ b/src/registration.less @@ -1,3 +1,4 @@ +// TODO: get rid of extra styles for outside users @import "src/common/variables"; @import "src/common/typography"; @import "src/common/mixins";