Skip to content

Commit

Permalink
refactor: patched preview plugin, minor fixes (#62)
Browse files Browse the repository at this point in the history
Co-authored-by: Bazukevich Aliaksandr <abazukevich@exadel.net>
  • Loading branch information
AlexanderBazukevich and Bazukevich Aliaksandr authored May 13, 2021
1 parent 3884e36 commit b3938df
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/core/root.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {bind} from '@exadel/esl';
import {ESLBaseElement} from '@exadel/esl/modules/esl-base-element/core';
import {EventUtils} from '@exadel/esl/modules/esl-utils/dom/events';

Expand Down Expand Up @@ -27,6 +28,7 @@ export class UIPRoot extends ESLBaseElement {
this.removeEventListener('request:change', this._onStateChange);
}

@bind
protected _onStateChange(e: CustomEvent) {
this._state = e.detail.markup;
const detail = Object.assign({
Expand Down
1 change: 1 addition & 0 deletions src/preview/preview.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ uip-preview {
height: max-content;
width: max-content;
max-width: 100%;

.uip-preview-inner {
display: block;
height: 100vh;
Expand Down
16 changes: 11 additions & 5 deletions src/preview/preview.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import {memoize} from '@exadel/esl';
import {bind} from '@exadel/esl/modules/esl-utils/decorators/bind';
import {UIPPlugin} from '../core/plugin';

export class UIPPreview extends UIPPlugin {
static is = 'uip-preview';

@memoize()
get $inner() {
const $inner = document.createElement('div');
$inner.classList.add('uip-preview-inner');
return $inner;
}

@bind
protected handleChange(e: CustomEvent): void {
const {markup} = e.detail;
const $inner = document.createElement('div');
$inner.classList.add('uip-preview-inner');
$inner.innerHTML = markup;
this.innerHTML = $inner.outerHTML;
this.$inner.innerHTML = markup;
this.innerHTML = '';
this.appendChild(this.$inner);
}
}

1 change: 1 addition & 0 deletions src/settings/setting/bool-setting/bool-setting.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ uip-bool-setting {

input {
margin-left: 3px;
width: 100%;
}
}

Expand Down

0 comments on commit b3938df

Please # to comment.