From 57c686dad6a877c88437086e812baebb4126028f Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 16 May 2018 03:06:25 -0400 Subject: [PATCH] Adds expand/collapse toggle to settings editor --- src/ui/scss/main.scss | 52 ++++++++++++++++++++++++++---------------- src/ui/settings/app.ts | 28 +++++++++++++++++++++++ src/ui/settings/index.html | 35 ++++++++++++++++------------ src/webviews/settingsEditor.ts | 4 ++-- 4 files changed, 82 insertions(+), 37 deletions(-) diff --git a/src/ui/scss/main.scss b/src/ui/scss/main.scss index 9f1dbee..b12134d 100644 --- a/src/ui/scss/main.scss +++ b/src/ui/scss/main.scss @@ -666,14 +666,42 @@ ul { z-index: 1; } +.page-header__row { + display: flex; + flex-wrap: nowrap; + justify-content: space-between; +} + .page-header__title { + flex: 0 0 auto; font-size: 3em; margin: 0; } +.page-header__title-actions { + flex: 0 0 auto; + margin: 1.75em 1em 0 1em; +} + +.page-header__toolbar { + display: flex; + flex: 1 1 100%; + justify-content: flex-end; + margin: 1.5em 208px 0 0; // 208px ~ the width of the sidebar + white-space: nowrap; + + @media all and (max-width: 860px) { + margin-right: -9px; + } + + select, option { + background-color: var(--background-color) !important; + } +} + .page-header__subtitle { color: var(--color--50); - margin: 0; + margin: 0.25em 0 0 0; } .section__preview { @@ -756,7 +784,8 @@ ul { .section-group__sidebar { align-self: flex-start; - margin: -1em 0 0 3em; + margin: -6.4em 0 0 3em; + max-width: 179px; position: sticky; top: 0; z-index: 2; @@ -875,25 +904,8 @@ ul { margin: -1em 0 1em 1em; } -.settings-toolbar { - display: flex; - margin: 1.6em 185px 0 0; - position: absolute; - right: 0; - top: -2px; - white-space: nowrap; - - @media all and (max-width: 860px) { - margin-right: -9px; - } - - select, option { - background-color: var(--background-color) !important; - } -} - .settings-scope { - flex: 1 1 auto; + flex: 0 0 auto; } .sidebar-group { diff --git a/src/ui/settings/app.ts b/src/ui/settings/app.ts index 32bad13..15aeb3c 100644 --- a/src/ui/settings/app.ts +++ b/src/ui/settings/app.ts @@ -35,6 +35,9 @@ export class SettingsApp extends App { protected onBind() { const onSectionHeaderClicked = this.onSectionHeaderClicked.bind(this); DOM.listenAll('.section__header', 'click', function(this: HTMLInputElement) { return onSectionHeaderClicked(this, ...arguments); }); + + const onActionLinkClicked = this.onActionLinkClicked.bind(this); + DOM.listenAll('[data-action]', 'click', function(this: HTMLAnchorElement) { return onActionLinkClicked(this, ...arguments); }); } protected getSettingsScope(): 'user' | 'workspace' { @@ -43,6 +46,31 @@ export class SettingsApp extends App { : 'user'; } + private onActionLinkClicked(element: HTMLElement, e: MouseEvent) { + switch (element.dataset.action) { + case 'collapse': + for (const el of document.querySelectorAll('.section__header')) { + el.classList.add('collapsed'); + } + + document.querySelector('[data-action="collapse"]')!.classList.add('hidden'); + document.querySelector('[data-action="expand"]')!.classList.remove('hidden'); + break; + + case 'expand': + for (const el of document.querySelectorAll('.section__header')) { + el.classList.remove('collapsed'); + } + + document.querySelector('[data-action="collapse"]')!.classList.remove('hidden'); + document.querySelector('[data-action="expand"]')!.classList.add('hidden'); + break; + } + + e.preventDefault(); + e.stopPropagation(); + } + protected onInputSelected(element: HTMLSelectElement) { if (element === this._scopes) return; diff --git a/src/ui/settings/index.html b/src/ui/settings/index.html index 37914b8..ba01f4b 100644 --- a/src/ui/settings/index.html +++ b/src/ui/settings/index.html @@ -29,24 +29,29 @@