From 78a6b517f994553990c3fbd5268f222253333ee9 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Wed, 23 Mar 2022 10:34:26 +0000 Subject: [PATCH] ui: Tile CSS component (#12570) * ui: Tile CSS component * ui: Consul ServerCard component (#12576) --- .../components/consul/server/card/README.mdx | 118 ++++++++++++++++++ .../components/consul/server/card/index.hbs | 41 ++++++ .../components/consul/server/card/index.scss | 5 + .../components/consul/server/card/layout.scss | 24 ++++ .../components/consul/server/card/skin.scss | 40 ++++++ .../components/consul/server/list/index.hbs | 17 +++ .../components/consul/server/list/index.scss | 9 ++ .../consul-ui/app/components/tile/README.mdx | 20 +++ .../consul-ui/app/components/tile/debug.scss | 6 + .../consul-ui/app/components/tile/index.scss | 37 ++++++ .../app/styles/base/component/index.scss | 6 + .../base/decoration/base-variables.scss | 1 + .../app/styles/base/icons/icons/index.scss | 12 +- .../consul-ui/app/styles/base/index.scss | 1 + .../base/typography/base-keyframes.scss | 7 ++ .../base/typography/base-variables.scss | 1 + .../app/styles/base/typography/index.scss | 1 + .../consul-ui/app/styles/components.scss | 3 + ui/packages/consul-ui/app/styles/debug.scss | 1 + 19 files changed, 344 insertions(+), 6 deletions(-) create mode 100644 ui/packages/consul-ui/app/components/consul/server/card/README.mdx create mode 100644 ui/packages/consul-ui/app/components/consul/server/card/index.hbs create mode 100644 ui/packages/consul-ui/app/components/consul/server/card/index.scss create mode 100644 ui/packages/consul-ui/app/components/consul/server/card/layout.scss create mode 100644 ui/packages/consul-ui/app/components/consul/server/card/skin.scss create mode 100644 ui/packages/consul-ui/app/components/consul/server/list/index.hbs create mode 100644 ui/packages/consul-ui/app/components/consul/server/list/index.scss create mode 100644 ui/packages/consul-ui/app/components/tile/README.mdx create mode 100644 ui/packages/consul-ui/app/components/tile/debug.scss create mode 100644 ui/packages/consul-ui/app/components/tile/index.scss create mode 100644 ui/packages/consul-ui/app/styles/base/component/index.scss create mode 100644 ui/packages/consul-ui/app/styles/base/typography/base-keyframes.scss diff --git a/ui/packages/consul-ui/app/components/consul/server/card/README.mdx b/ui/packages/consul-ui/app/components/consul/server/card/README.mdx new file mode 100644 index 0000000000..a4b2ebc7dd --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/server/card/README.mdx @@ -0,0 +1,118 @@ + +# Consul::Server::Card + + + +A presentational component representing a Consul Server + + +```hbs preview-template +
+
+ Read Replicas just show the name of the Server +
+ + +
+ +
+
+ Leaders have a special icon-tile +
+ + +
+ +
+
+ Unhealthy voters have a differently colored badge +
+ + +
+ +
+
+ Non-voters have different text and coloring +
+ + +
+
+ + +
+``` + +## Attributes + + + + +## Arguments + + + +| Argument | Type | Default | Description | +| :------- | :----- | :------ | :----------------------------------------- | +| item | object | | Consul Server shaped object | + + + +## Slots + + + + +## CSS Parts + + + + +## CSS Properties + + + + +## Contextual Components + + + diff --git a/ui/packages/consul-ui/app/components/consul/server/card/index.hbs b/ui/packages/consul-ui/app/components/consul/server/card/index.hbs new file mode 100644 index 0000000000..333ebd6678 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/server/card/index.hbs @@ -0,0 +1,41 @@ +
+
+ +
+
+
+ {{@item.Name}} +
+ +{{#if (not @item.ReadReplica)}} +
+ Status +
+
+ {{if (contains @item.Status (array 'leader' 'voter')) 'Active voter' 'Backup voter'}} +
+{{/if}} + +
+
+ diff --git a/ui/packages/consul-ui/app/components/consul/server/card/index.scss b/ui/packages/consul-ui/app/components/consul/server/card/index.scss new file mode 100644 index 0000000000..284860e701 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/server/card/index.scss @@ -0,0 +1,5 @@ +@import './skin'; +@import './layout'; +.consul-server-card { + @extend %consul-server-card; +} diff --git a/ui/packages/consul-ui/app/components/consul/server/card/layout.scss b/ui/packages/consul-ui/app/components/consul/server/card/layout.scss new file mode 100644 index 0000000000..8ca116a8fe --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/server/card/layout.scss @@ -0,0 +1,24 @@ +%consul-server-card { + position: relative; + overflow: hidden; + + @extend %panel; + --padding-x: 24px; + --padding-y: 24px; + padding: var(--padding-y) var(--padding-x); + + --tile-size: 3rem; /* 48px */ +} +%consul-server-card.voting-status-leader .name { + position: absolute !important; +} +%consul-server-card dd:not(:last-of-type) { + margin-bottom: calc(var(--padding-y) / 2); +} +%consul-server-card.voting-status-leader dd { + margin-left: calc(var(--tile-size) + var(--padding-x)); +} + + + + diff --git a/ui/packages/consul-ui/app/components/consul/server/card/skin.scss b/ui/packages/consul-ui/app/components/consul/server/card/skin.scss new file mode 100644 index 0000000000..1478ac3fac --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/server/card/skin.scss @@ -0,0 +1,40 @@ +%consul-server-card dt:not(.name) { + @extend %visually-hidden; +} +%consul-server-card.voting-status-leader .name { + @extend %with-leader-tile; +} +%consul-server-card .name + dd { + @extend %h300; + color: rgb(var(--tone-gray-999)); + animation-name: typo-truncate; +} +%consul-server-card .health-status + dd { + @extend %pill-200; + font-size: var(--typo-size-700); +} +%consul-server-card.voting-status-non-voter .health-status + dd { + background-color: rgb(var(--tone-gray-100)); + color: rgb(var(--tone-gray-600)); +} +%consul-server-card:not(.voting-status-non-voter) .health-status.healthy + dd { + background-color: rgb(var(--tone-green-050)); + color: rgb(var(--tone-green-800)); +} +%consul-server-card:not(.voting-status-non-voter) .health-status:not(.healthy) + dd { + background-color: rgb(var(--tone-red-050)); + color: rgb(var(--tone-red-500)); +} +%consul-server-card .health-status + dd::before { + --icon-size: icon-000; + content: ''; +} +%consul-server-card .health-status.healthy + dd::before { + --icon-name: icon-check; + --icon-color: rgb(var(--tone-green-800)); +} +%consul-server-card .health-status:not(.healthy) + dd::before { + --icon-name: icon-x; + --icon-color: rgb(var(--tone-red-500)); +} + diff --git a/ui/packages/consul-ui/app/components/consul/server/list/index.hbs b/ui/packages/consul-ui/app/components/consul/server/list/index.hbs new file mode 100644 index 0000000000..4f9d1b50a2 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/server/list/index.hbs @@ -0,0 +1,17 @@ +
+ +
+ diff --git a/ui/packages/consul-ui/app/components/consul/server/list/index.scss b/ui/packages/consul-ui/app/components/consul/server/list/index.scss new file mode 100644 index 0000000000..4f8256b910 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/server/list/index.scss @@ -0,0 +1,9 @@ +%consul-server-list ul { + display: grid; + grid-template-columns: repeat(4, minmax(215px, 25%)); + gap: 12px; +} + +.consul-server-list { + @extend %consul-server-list; +} diff --git a/ui/packages/consul-ui/app/components/tile/README.mdx b/ui/packages/consul-ui/app/components/tile/README.mdx new file mode 100644 index 0000000000..be13611834 --- /dev/null +++ b/ui/packages/consul-ui/app/components/tile/README.mdx @@ -0,0 +1,20 @@ +# tile + + +```hbs preview-template +
+
+ Leader tile +
+
+ +
+
+ +``` + +```css +.tile { + @extend %with-tile, %with-leader-tile; +} +``` diff --git a/ui/packages/consul-ui/app/components/tile/debug.scss b/ui/packages/consul-ui/app/components/tile/debug.scss new file mode 100644 index 0000000000..8b3e0797de --- /dev/null +++ b/ui/packages/consul-ui/app/components/tile/debug.scss @@ -0,0 +1,6 @@ +#docfy-demo-preview-tile { + .tile { + @extend %with-tile, %with-leader-tile; + } +} + diff --git a/ui/packages/consul-ui/app/components/tile/index.scss b/ui/packages/consul-ui/app/components/tile/index.scss new file mode 100644 index 0000000000..7754657eb7 --- /dev/null +++ b/ui/packages/consul-ui/app/components/tile/index.scss @@ -0,0 +1,37 @@ + +%with-tile { + position: relative; + width: var(--tile-size, 3rem); + height: var(--tile-size, 3rem); +} +%with-tile::before { + display: block; + content: ''; + width: 100%; + height: 100%; + border-radius: var(--decor-radius-250); + border: var(--decor-border-100); +} +%with-tile::after { + content: ''; + position: absolute; + top: calc(var(--tile-size, 3rem) / 4); + left: calc(var(--tile-size, 3rem) / 4); +} + +%with-leader-tile { + @extend %with-tile; +} +%with-leader-tile::before { + background-image: linear-gradient(135deg, + rgb(var(--strawberry-010)) 0%, + rgb(var(--strawberry-200)) 100% + ); + border-color: rgb(var(--tone-gray-999) / 10%); +} +%with-leader-tile::after { + --icon-name: icon-star-circle; + --icon-size: icon-700; + color: rgb(var(--strawberry-500)); +} + diff --git a/ui/packages/consul-ui/app/styles/base/component/index.scss b/ui/packages/consul-ui/app/styles/base/component/index.scss new file mode 100644 index 0000000000..821ce98daf --- /dev/null +++ b/ui/packages/consul-ui/app/styles/base/component/index.scss @@ -0,0 +1,6 @@ +/* allows easy application of animation-name based composition */ +*, *::before, *::after { + animation-play-state: paused; + animation-fill-mode: forwards; +} + diff --git a/ui/packages/consul-ui/app/styles/base/decoration/base-variables.scss b/ui/packages/consul-ui/app/styles/base/decoration/base-variables.scss index 1aff329e2b..e97f8df127 100644 --- a/ui/packages/consul-ui/app/styles/base/decoration/base-variables.scss +++ b/ui/packages/consul-ui/app/styles/base/decoration/base-variables.scss @@ -3,6 +3,7 @@ --decor-radius-000: 0; --decor-radius-100: 2px; --decor-radius-200: 4px; + --decor-radius-250: 6px; --decor-radius-300: 7px; --decor-radius-999: 9999px; --decor-radius-full: 100%; diff --git a/ui/packages/consul-ui/app/styles/base/icons/icons/index.scss b/ui/packages/consul-ui/app/styles/base/icons/icons/index.scss index fc3360b031..8eb65d2921 100644 --- a/ui/packages/consul-ui/app/styles/base/icons/icons/index.scss +++ b/ui/packages/consul-ui/app/styles/base/icons/icons/index.scss @@ -236,8 +236,8 @@ // @import './change/index.scss'; // @import './change-circle/index.scss'; // @import './change-square/index.scss'; -// @import './check/index.scss'; -// @import './check-circle/index.scss'; +@import './check/index.scss'; +@import './check-circle/index.scss'; @import './check-circle-fill/index.scss'; // @import './check-diamond/index.scss'; // @import './check-diamond-fill/index.scss'; @@ -392,7 +392,7 @@ // @import './identity-user/index.scss'; // @import './image/index.scss'; // @import './inbox/index.scss'; -// @import './info/index.scss'; +@import './info/index.scss'; // @import './jump-link/index.scss'; // @import './key/index.scss'; // @import './key-values/index.scss'; @@ -542,7 +542,7 @@ // @import './square/index.scss'; // @import './square-fill/index.scss'; // @import './star/index.scss'; -// @import './star-circle/index.scss'; +@import './star-circle/index.scss'; @import './star-fill/index.scss'; // @import './star-off/index.scss'; // @import './stop-circle/index.scss'; @@ -614,8 +614,8 @@ // @import './wifi/index.scss'; // @import './wifi-off/index.scss'; // @import './wrench/index.scss'; -// @import './x/index.scss'; -// @import './x-circle/index.scss'; +@import './x/index.scss'; +@import './x-circle/index.scss'; // @import './x-circle-fill/index.scss'; // @import './x-diamond/index.scss'; // @import './x-diamond-fill/index.scss'; diff --git a/ui/packages/consul-ui/app/styles/base/index.scss b/ui/packages/consul-ui/app/styles/base/index.scss index 8fed6a285c..c352c682ed 100644 --- a/ui/packages/consul-ui/app/styles/base/index.scss +++ b/ui/packages/consul-ui/app/styles/base/index.scss @@ -1,3 +1,4 @@ +@import './component/index'; @import './decoration/index'; @import './color/index'; @import './animation/index'; diff --git a/ui/packages/consul-ui/app/styles/base/typography/base-keyframes.scss b/ui/packages/consul-ui/app/styles/base/typography/base-keyframes.scss new file mode 100644 index 0000000000..7f29930ebb --- /dev/null +++ b/ui/packages/consul-ui/app/styles/base/typography/base-keyframes.scss @@ -0,0 +1,7 @@ +@keyframes typo-truncate { + 100% { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } +} diff --git a/ui/packages/consul-ui/app/styles/base/typography/base-variables.scss b/ui/packages/consul-ui/app/styles/base/typography/base-variables.scss index 0c271067ec..0d4294737e 100644 --- a/ui/packages/consul-ui/app/styles/base/typography/base-variables.scss +++ b/ui/packages/consul-ui/app/styles/base/typography/base-variables.scss @@ -11,6 +11,7 @@ /* also maybe use 100, 200 etc like colors */ --typo-size-100: 3.5rem; --typo-size-200: 1.8rem; + --typo-size-250: 1.750rem; /* 28px */ --typo-size-300: 1.3rem; /* mktg only ^ */ --typo-size-400: 1.2rem; /* $size-large? 24 */ diff --git a/ui/packages/consul-ui/app/styles/base/typography/index.scss b/ui/packages/consul-ui/app/styles/base/typography/index.scss index 3fe0d277f0..72abf8e5aa 100644 --- a/ui/packages/consul-ui/app/styles/base/typography/index.scss +++ b/ui/packages/consul-ui/app/styles/base/typography/index.scss @@ -1,2 +1,3 @@ @import './base-variables'; +@import './base-keyframes'; @import './base-placeholders'; diff --git a/ui/packages/consul-ui/app/styles/components.scss b/ui/packages/consul-ui/app/styles/components.scss index 143c305e69..875e3a142f 100644 --- a/ui/packages/consul-ui/app/styles/components.scss +++ b/ui/packages/consul-ui/app/styles/components.scss @@ -36,6 +36,7 @@ @import 'consul-ui/components/secret-button'; @import 'consul-ui/components/sliding-toggle'; @import 'consul-ui/components/table'; +@import 'consul-ui/components/tile'; @import 'consul-ui/components/toggle-button'; @import 'consul-ui/components/tabular-collection'; @import 'consul-ui/components/tabular-details'; @@ -91,6 +92,8 @@ @import 'consul-ui/components/consul/intention'; @import 'consul-ui/components/consul/lock-session/list'; @import 'consul-ui/components/consul/lock-session/form'; +@import 'consul-ui/components/consul/server/list'; +@import 'consul-ui/components/consul/server/card'; @import 'consul-ui/components/consul/auth-method'; @import 'consul-ui/components/role-selector'; diff --git a/ui/packages/consul-ui/app/styles/debug.scss b/ui/packages/consul-ui/app/styles/debug.scss index f99e263a23..8209e6ac4e 100644 --- a/ui/packages/consul-ui/app/styles/debug.scss +++ b/ui/packages/consul-ui/app/styles/debug.scss @@ -4,6 +4,7 @@ @import 'consul-ui/components/main-nav-vertical/debug'; @import 'consul-ui/components/badge/debug'; @import 'consul-ui/components/panel/debug'; +@import 'consul-ui/components/tile/debug'; @import 'consul-ui/components/shadow-template/debug'; @import 'consul-ui/components/csv-list/debug'; @import 'consul-ui/components/horizontal-kv-list/debug';