Added basic reset to design preview on nav bar interaction

refs https://github.com/TryGhost/Team/issues/1130

- when opening/closing sections or interacting with the general design or custom theme settings we want to switch back to showing the preview so the sidebar acts more like typical navigation and so form changes show their effect
This commit is contained in:
Kevin Ansfield 2021-10-11 21:09:42 +01:00
parent 870cf94b7a
commit 1d0cd80158
4 changed files with 16 additions and 15 deletions

View File

@ -1,5 +1,5 @@
<iframe
{{did-insert this.registerIframe}}
{{did-insert this.replaceIframeContents}}
{{did-update this.replaceIframeContents @html}}
...attributes>
</iframe>

View File

@ -2,19 +2,12 @@ import Component from '@glimmer/component';
import {action} from '@ember/object';
export default class GhHtmlIframeComponent extends Component {
iframe = null;
@action
registerIframe(iframe) {
this.iframe = iframe;
}
@action
replaceIframeContents(iframe, html) {
if (this.iframe) {
this.iframe.contentWindow.document.open();
this.iframe.contentWindow.document.write(html);
this.iframe.contentWindow.document.close();
replaceIframeContents(iframe) {
if (iframe) {
iframe.contentWindow.document.open();
iframe.contentWindow.document.write(this.args.html);
iframe.contentWindow.document.close();
}
}
}

View File

@ -2,7 +2,7 @@
<LinkTo @route="settings" class="gh-nav-menu-title">{{svg-jar "arrow-left-tail"}} Site design</LinkTo>
</header>
<section class="gh-nav-body">
<div class="gh-nav-top">
<div class="gh-nav-top" {{on "click" this.transitionBackToIndex}}>
<div class="pl6 pt4 pr6">
<button type="button" {{on "click" (fn this.toggleSection "brand")}} class="flex flex-row w-100">

View File

@ -6,10 +6,11 @@ import {task} from 'ember-concurrency-decorators';
import {tracked} from '@glimmer/tracking';
export default class DesignMenuComponent extends Component {
@service config;
@service customThemeSettings;
@service router;
@service settings;
@service themeManagement;
@service config;
@tracked openSections = new TrackedSet();
@ -44,4 +45,11 @@ export default class DesignMenuComponent extends Component {
*fetchThemeSettingsTask() {
yield this.customThemeSettings.load();
}
@action
transitionBackToIndex() {
if (this.router.currentRouteName !== 'settings.design.index') {
this.router.transitionTo('settings.design.index');
}
}
}