From 4ad8a0cfefee9391d4199fe5cea8ce2acde69598 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Mon, 21 Feb 2022 12:22:59 +0000 Subject: [PATCH] ui: Transition App Chrome to use new Disclosure Menus (#12334) * Add %panel CSS component * Deprecate old menu-panel component * Various smallish tweaks to disclosure-menu * Move all menus in the app chrome to use new DisclosureMenu * Follow up CSS to move all app chrome menus to new components * Don't prevent default any events from anchors * Add a tick to click steps --- .changelog/12334.txt | 3 + .../consul/token/selector/index.hbs | 48 ++--- .../consul/nspace/selector/index.hbs | 133 +++++++------- .../consul/partition/selector/index.hbs | 79 ++++---- .../consul-ui/app/components/app/index.scss | 17 +- .../consul/datacenter/selector/index.hbs | 49 +++++ .../app/components/disclosure-menu/README.mdx | 32 ++-- .../app/components/disclosure-menu/index.hbs | 6 +- .../app/components/disclosure-menu/index.scss | 3 + .../components/disclosure-menu/menu/index.hbs | 20 +-- .../app/components/hashicorp-consul/index.hbs | 120 +++++-------- .../components/hashicorp-consul/index.scss | 13 +- .../components/hashicorp-consul/pageobject.js | 2 +- .../components/main-nav-horizontal/index.scss | 1 + .../components/main-nav-horizontal/skin.scss | 9 + .../components/main-nav-vertical/index.scss | 34 +--- .../components/main-nav-vertical/layout.scss | 19 +- .../components/main-nav-vertical/skin.scss | 42 +++-- .../app/components/menu-panel/README.mdx | 169 +++++++++++++++++ .../app/components/menu-panel/deprecated.scss | 58 ++++++ .../app/components/menu-panel/index.hbs | 11 +- .../app/components/menu-panel/index.scss | 40 ++++- .../app/components/menu-panel/layout.scss | 170 +++++++----------- .../app/components/menu-panel/skin.scss | 44 +++-- .../app/components/menu/action/index.hbs | 3 + .../consul-ui/app/components/menu/index.hbs | 2 +- .../app/components/menu/separator/index.hbs | 4 +- .../consul-ui/app/components/panel/README.mdx | 126 +++++++++++++ .../consul-ui/app/components/panel/debug.scss | 8 + .../consul-ui/app/components/panel/index.scss | 2 + .../app/components/panel/layout.scss | 11 ++ .../consul-ui/app/components/panel/skin.scss | 17 ++ .../app/components/popover-select/index.scss | 3 + .../app/components/state-chart/index.js | 4 +- .../consul-ui/app/styles/components.scss | 1 + ui/packages/consul-ui/app/styles/debug.scss | 4 + .../tests/steps/interactions/click.js | 3 +- 37 files changed, 875 insertions(+), 435 deletions(-) create mode 100644 .changelog/12334.txt create mode 100644 ui/packages/consul-ui/app/components/consul/datacenter/selector/index.hbs create mode 100644 ui/packages/consul-ui/app/components/menu-panel/README.mdx create mode 100644 ui/packages/consul-ui/app/components/menu-panel/deprecated.scss create mode 100644 ui/packages/consul-ui/app/components/panel/README.mdx create mode 100644 ui/packages/consul-ui/app/components/panel/debug.scss create mode 100644 ui/packages/consul-ui/app/components/panel/index.scss create mode 100644 ui/packages/consul-ui/app/components/panel/layout.scss create mode 100644 ui/packages/consul-ui/app/components/panel/skin.scss diff --git a/.changelog/12334.txt b/.changelog/12334.txt new file mode 100644 index 000000000..d691cd909 --- /dev/null +++ b/.changelog/12334.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +ui: Slightly improve usability of main navigation +``` diff --git a/ui/packages/consul-acls/app/components/consul/token/selector/index.hbs b/ui/packages/consul-acls/app/components/consul/token/selector/index.hbs index b60b2526d..dd372e95c 100644 --- a/ui/packages/consul-acls/app/components/consul/token/selector/index.hbs +++ b/ui/packages/consul-acls/app/components/consul/token/selector/index.hbs @@ -119,32 +119,32 @@ Logout - - + + Logout - - - {{#let components.MenuItem components.MenuSeparator as |MenuItem MenuSeparator|}} -{{!TODO: It might be nice to use one of our recursive components here}} -{{#if authDialog.token.AccessorID}} -
  • - -
  • - -{{/if}} - + + {{#if authDialog.token.AccessorID}} + + {{/if}} + + + + - - Logout - - - {{/let}} -
    -
    + Logout + + + + + diff --git a/ui/packages/consul-nspaces/app/components/consul/nspace/selector/index.hbs b/ui/packages/consul-nspaces/app/components/consul/nspace/selector/index.hbs index c3296dff2..3d39896cb 100644 --- a/ui/packages/consul-nspaces/app/components/consul/nspace/selector/index.hbs +++ b/ui/packages/consul-nspaces/app/components/consul/nspace/selector/index.hbs @@ -1,74 +1,77 @@ {{#if (can "use nspaces")}} - {{#if (can "choose nspaces")}} -{{#let - (or @nspace 'default') -as |nspace|}} -
  • - - - {{nspace}} - - - {{#let components.MenuItem components.MenuSeparator as |MenuItem MenuSeparator|}} - {{#if (gt @nspaces.length 0)}} - - {{else}} - - {{/if}} - {{#each (reject-by 'DeletedAt' @nspaces) as |item|}} - + + + {{nspace}} + + + {{#if (gt @nspaces.length 0)}} + + {{else}} + + {{/if}} + + {{#each (reject-by 'DeletedAt' @nspaces) as |item|}} + + - - {{item.Name}} - - - {{/each}} - {{#if (can 'manage nspaces')}} - - + + {{/each}} + {{#if (can 'manage nspaces')}} + + + - - Manage Namespaces - - - {{/if}} - {{/let}} - - -
  • -{{/let}} - {{/if}} + Manage Namespaces + + + {{/if}} + + + + + {{/let}} {{/if}} - +{{/if}} diff --git a/ui/packages/consul-partitions/app/components/consul/partition/selector/index.hbs b/ui/packages/consul-partitions/app/components/consul/partition/selector/index.hbs index 91a9c8845..2855842c1 100644 --- a/ui/packages/consul-partitions/app/components/consul/partition/selector/index.hbs +++ b/ui/packages/consul-partitions/app/components/consul/partition/selector/index.hbs @@ -6,51 +6,56 @@ as |partition|}} class="partitions" data-test-partition-menu > - - - {{partition}} - - - {{#let components.MenuItem components.MenuSeparator as |MenuItem MenuSeparator|}} - + + + {{partition}} + + + + {{#each (reject-by 'DeletedAt' @partitions) as |item|}} - - + {{item.Name}} - - + + {{/each}} - {{#if (can 'manage partitions')}} - - + - + Manage Partitions - - - {{/if}} - {{/let}} - - + + + {{/if}} + + + {{else}}
  • .popover-menu > label > button { +%main-nav-vertical-hoisted [aria-label]::before { + display: none !important; +} +%main-nav-horizontal [aria-haspopup='menu'] ~ * { + position: absolute; + right: 0; + min-width: 192px; +} +%main-nav-horizontal [aria-expanded], +%main-nav-vertical-hoisted [aria-expanded] { + @extend %main-nav-horizontal-popover-menu-trigger; @extend %main-nav-horizontal-action; - border: none; } -%main-nav-vertical-hoisted.is-active > label > * { +%main-nav-horizontal-popover-menu-trigger { @extend %main-nav-horizontal-action-active; } %footer, diff --git a/ui/packages/consul-ui/app/components/consul/datacenter/selector/index.hbs b/ui/packages/consul-ui/app/components/consul/datacenter/selector/index.hbs new file mode 100644 index 000000000..e5b1021e3 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/datacenter/selector/index.hbs @@ -0,0 +1,49 @@ +
  • + + + {{@dc.Name}} + + + + + {{#each (sort-by 'Name' @dcs) as |item|}} + + + {{item.Name}} + {{#if item.Primary}} + Primary + {{/if}} + {{#if item.Local}} + Local + {{/if}} + + + {{/each}} + + + +
  • + diff --git a/ui/packages/consul-ui/app/components/disclosure-menu/README.mdx b/ui/packages/consul-ui/app/components/disclosure-menu/README.mdx index be5381c2d..77ef278dd 100644 --- a/ui/packages/consul-ui/app/components/disclosure-menu/README.mdx +++ b/ui/packages/consul-ui/app/components/disclosure-menu/README.mdx @@ -19,13 +19,15 @@ common usecase of having a floating menu. > {{if disclosure.expanded 'Close' 'Open'}} - - - Item 1 - - - Item 2 - + + + + Item 1 + + + Item 2 + + @@ -46,13 +48,15 @@ common usecase of having a floating menu. (array 'top' this.height) (array 'background-color' 'rgb(var(--tone-gray-000))') }} - as |menu|> - - Item 1 - - - Item 2 - + as |panel|> + + + Item 1 + + + Item 2 + + diff --git a/ui/packages/consul-ui/app/components/disclosure-menu/index.hbs b/ui/packages/consul-ui/app/components/disclosure-menu/index.hbs index 040113e41..ab05bdd8d 100644 --- a/ui/packages/consul-ui/app/components/disclosure-menu/index.hbs +++ b/ui/packages/consul-ui/app/components/disclosure-menu/index.hbs @@ -4,12 +4,16 @@ }} ...attributes > - + {{yield (hash Action=(component 'disclosure-menu/action' disclosure=disclosure) Menu=(component 'disclosure-menu/menu' disclosure=disclosure) disclosure=disclosure toggle=disclosure.toggle + close=disclosure.close + open=disclosure.open expanded=disclosure.expanded )}} diff --git a/ui/packages/consul-ui/app/components/disclosure-menu/index.scss b/ui/packages/consul-ui/app/components/disclosure-menu/index.scss index f9f374c2c..cca70fbf5 100644 --- a/ui/packages/consul-ui/app/components/disclosure-menu/index.scss +++ b/ui/packages/consul-ui/app/components/disclosure-menu/index.scss @@ -1,3 +1,6 @@ .disclosure-menu { position: relative; } +.disclosure-menu [aria-expanded] ~ * { + @extend %menu-panel; +} diff --git a/ui/packages/consul-ui/app/components/disclosure-menu/menu/index.hbs b/ui/packages/consul-ui/app/components/disclosure-menu/menu/index.hbs index 4287d66b9..a37d86d24 100644 --- a/ui/packages/consul-ui/app/components/disclosure-menu/menu/index.hbs +++ b/ui/packages/consul-ui/app/components/disclosure-menu/menu/index.hbs @@ -1,15 +1,11 @@ <@disclosure.Details as |details|> - - {{yield (hash - items=menu.items - Item=menu.Item - Action=menu.Action - Separator=menu.Separator - )}} - +
    + {{yield (hash + Menu=(component 'menu' disclosure=@disclosure) + )}} +
    diff --git a/ui/packages/consul-ui/app/components/hashicorp-consul/index.hbs b/ui/packages/consul-ui/app/components/hashicorp-consul/index.hbs index 108370296..e67251163 100644 --- a/ui/packages/consul-ui/app/components/hashicorp-consul/index.hbs +++ b/ui/packages/consul-ui/app/components/hashicorp-consul/index.hbs @@ -87,53 +87,12 @@ <:main-nav>