Skip to content

Commit

Permalink
fix(settings/editor): rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
nattallius authored and Sisha0 committed Dec 20, 2022
1 parent 603379b commit ab8f18b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/plugins/editor/editor.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
border-top: 1px solid @section-border;
}

.uip-root[editor-collapsed] & {
&.collapsed {
max-height: 0;

&-inner {
Expand Down
16 changes: 9 additions & 7 deletions src/plugins/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class UIPEditor extends UIPPlugin {

/**
* Merges passed editorConfig with current editorConfig.
* @param {Partial<EditorConfig>} editorConfig - config to merge.
* @param {Partial<EditorConfig>} editorConfig - config to merge.
*/
public updateEditorConfig(editorConfig: Partial<EditorConfig>): void {
this.editorConfig = {
Expand All @@ -82,12 +82,14 @@ export class UIPEditor extends UIPPlugin {
const attr = e.detail.attribute;
const value = e.detail.value;

if (attr === 'dark-theme') {
this.updateEditorConfig({
theme: value === null ? Theme.Light : Theme.Dark
});
} else if (attr === UIPEditor.collapsedAttribute && value === null) {
this.initEditor();
switch (attr) {
case 'dark-theme':
return this.updateEditorConfig({theme: value === null ? Theme.Light : Theme.Dark});
case 'editor-collapsed':
value === null && this.initEditor();
return this.classList.toggle('collapsed', value !== null);
default:
return;
}
}
}
4 changes: 2 additions & 2 deletions src/plugins/settings/settings.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
padding: 0 5px;
}

.uip-root[settings-collapsed] & {
&.collapsed {
max-width: 0;

&-inner {
Expand All @@ -51,7 +51,7 @@
.scrollbar-expanded();
}

.uip-root[settings-collapsed] & {
&.collapsed {
max-height: 0;
max-width: 100%;

Expand Down
6 changes: 6 additions & 0 deletions src/plugins/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,10 @@ export class UIPSettings extends UIPPlugin {
protected _onRootStateChange(): void {
this.settings.forEach(setting => setting.updateFrom(this.model!));
}

@listen({event: 'uip:configchange', target: '::parent(.uip-root)'})
protected _onRootConfigChange(e: CustomEvent) {
if (e.detail.attribute !== 'settings-collapsed') return false;
this.classList.toggle('collapsed', e.detail.value !== null);
}
}

0 comments on commit ab8f18b

Please sign in to comment.