diff --git a/.changelog/13686.txt b/.changelog/13686.txt
new file mode 100644
index 000000000..e42ee475c
--- /dev/null
+++ b/.changelog/13686.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+ui: Add new CopyableCode component and use it in certain pre-existing areas
+```
diff --git a/ui/packages/consul-ui/app/components/certificate/README.mdx b/ui/packages/consul-ui/app/components/certificate/README.mdx
deleted file mode 100644
index 34dd1bb35..000000000
--- a/ui/packages/consul-ui/app/components/certificate/README.mdx
+++ /dev/null
@@ -1,31 +0,0 @@
-# Certificate
-
-```hbs preview-template
-
{{@item}}
-{{else}}
- ` tag. + +```hbs preview-template + +``` + +```hbs preview-template + +``` + +### Arguments + +| Argument | Type | Default | Description | +| --- | --- | --- | --- | +| `value` | `String` | | The code to display/be copied | +| `name` | `String` | | The 'Name' of the thing to be displayed and copied. Mainly used for giving feedback to the user. | +| `obfuscated` | `boolean` | | Whether to obfuscate the value until the user clicks to view | + +### See + +- [Template Source Code](./index.hbs) + +--- diff --git a/ui/packages/consul-ui/app/components/copyable-code/index.hbs b/ui/packages/consul-ui/app/components/copyable-code/index.hbs new file mode 100644 index 000000000..00ae9ea8c --- /dev/null +++ b/ui/packages/consul-ui/app/components/copyable-code/index.hbs @@ -0,0 +1,45 @@ ++{{#if @obfuscated}} +\ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/copyable-code/index.scss b/ui/packages/consul-ui/app/components/copyable-code/index.scss new file mode 100644 index 000000000..7745aadb6 --- /dev/null +++ b/ui/packages/consul-ui/app/components/copyable-code/index.scss @@ -0,0 +1,65 @@ +.copyable-code { + & { + display: flex; + align-items: flex-start; + position: relative; + width: 100%; + padding: 8px 14px; + padding-bottom: 3px; + + border: var(--decor-border-100); + border-color: rgb(var(--tone-gray-200)); + border-radius: var(--decor-radius-200); + } + &.obfuscated { + padding-left: 4px; + } + &::after { + position: absolute; + top: 0; + right: 0; + width: 40px; + height: 100%; + display: block; + content: ''; + background-color: rgb(var(--tone-gray-050)); + } + .copy-button { + position: absolute; + top: 7px; + right: 12px; + } + button[aria-expanded] { + margin-top: 1px; + margin-right: 4px; + cursor: pointer; + } + button[aria-expanded]::before { + content: ''; + --icon-size: icon-000; + --icon-color: rgb(var(--tone-gray-500)); + } + button[aria-expanded=true]::before { + --icon-name: icon-eye-off; + } + button[aria-expanded=false]::before { + --icon-name: icon-eye; + } + pre { + padding-right: 30px; + } + code { + display: inline-block; + overflow: hidden; + text-overflow: ellipsis; + width: 100%; + } + hr { + width: calc(100% - 80px); + margin: 0; + margin-top: 8px; + margin-bottom: 13px; + border: 3px dashed rgb(var(--tone-gray-300)); + background-color: rgb(var(--tone-gray-000)); + } +} diff --git a/ui/packages/consul-ui/app/components/definition-table/README.mdx b/ui/packages/consul-ui/app/components/definition-table/README.mdx index 971b59ee7..390a49ed9 100644 --- a/ui/packages/consul-ui/app/components/definition-table/README.mdx +++ b/ui/packages/consul-ui/app/components/definition-table/README.mdx @@ -4,7 +4,6 @@ class: css # definition-table Simple CSS component to render a `dl` similar to a table with column headers. -Contents of the `dd` are currently inline-block'ed for CopyButton reasons. ```hbs preview-template+ + ++ + ++ ++{{@value}}
+ {{#if (not details.expanded)}} + +
+ {{/if}} ++ +{{else}} + +{{@value}}
+{{/if}} + + @@ -12,7 +11,12 @@ Contents of the `dd` are currently inline-block'ed for CopyButton reasons.``` diff --git a/ui/packages/consul-ui/app/components/definition-table/layout.scss b/ui/packages/consul-ui/app/components/definition-table/layout.scss index 3173fe175..db0c27e90 100644 --- a/ui/packages/consul-ui/app/components/definition-table/layout.scss +++ b/ui/packages/consul-ui/app/components/definition-table/layout.scss @@ -6,10 +6,3 @@ %definition-table > dl { margin-bottom: 1.4em; } -/* TODO: We currently have one instance of nested dls */ -/* and that is for nesting a bucket list */ -/* we should probably think about changing this to possibly inline flex */ -/* or individually styling the contents */ -%definition-table > dl > dd > *:not(dl) { - display: inline-block; -} diff --git a/ui/packages/consul-ui/app/components/secret-button/index.hbs b/ui/packages/consul-ui/app/components/secret-button/index.hbs deleted file mode 100644 index 539810f73..000000000 --- a/ui/packages/consul-ui/app/components/secret-button/index.hbs +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/secret-button/index.js b/ui/packages/consul-ui/app/components/secret-button/index.js deleted file mode 100644 index 557064773..000000000 --- a/ui/packages/consul-ui/app/components/secret-button/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import Component from '@ember/component'; - -export default Component.extend({}); diff --git a/ui/packages/consul-ui/app/components/secret-button/index.scss b/ui/packages/consul-ui/app/components/secret-button/index.scss deleted file mode 100644 index aafd0b942..000000000 --- a/ui/packages/consul-ui/app/components/secret-button/index.scss +++ /dev/null @@ -1,23 +0,0 @@ -@import './skin'; -@import './layout'; -.type-reveal { - @extend %secret-button; -} -%secret-button { - position: relative; -} -%secret-button span { - visibility: hidden; - position: absolute; - --icon-color: rgb(var(--tone-gray-500)); -} -%secret-button em { - margin-left: 22px; -} -%secret-button span::before { - @extend %with-visibility-show-mask, %as-pseudo; - visibility: visible; -} -%secret-button input:checked + span::before { - @extend %with-visibility-hide-mask; -} diff --git a/ui/packages/consul-ui/app/components/secret-button/layout.scss b/ui/packages/consul-ui/app/components/secret-button/layout.scss deleted file mode 100644 index 1393e5efe..000000000 --- a/ui/packages/consul-ui/app/components/secret-button/layout.scss +++ /dev/null @@ -1,23 +0,0 @@ -%secret-button { - cursor: pointer; -} -%secret-button input { - display: none; -} -%secret-button input ~ em { - visibility: hidden; - font-style: normal; -} -%secret-button input:checked ~ em { - @extend %user-select-text; - visibility: visible; - cursor: auto; -} -%secret-button input ~ em::before { - display: inline; - visibility: visible; - content: '■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■'; -} -%secret-button input:checked ~ em::before { - display: none; -} diff --git a/ui/packages/consul-ui/app/components/secret-button/skin.scss b/ui/packages/consul-ui/app/components/secret-button/skin.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/ui/packages/consul-ui/app/components/tabular-dl/layout.scss b/ui/packages/consul-ui/app/components/tabular-dl/layout.scss index edeb482a4..3e8d6b422 100644 --- a/ui/packages/consul-ui/app/components/tabular-dl/layout.scss +++ b/ui/packages/consul-ui/app/components/tabular-dl/layout.scss @@ -25,10 +25,6 @@ dd > ul li:not(:last-of-type) { padding-bottom: 12px; } - dd .copy-button button { - padding: 0 !important; - margin: 0 4px 0 0 !important; - } dt.check + dd { padding-top: 16px; } 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 4ba418ad6..ecac9fc4a 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 @@ -154,8 +154,8 @@ // @import './user-square-fill/index.scss'; // @import './user-square-outline/index.scss'; @import './user-team/index.scss'; -@import './visibility-hide/index.scss'; -@import './visibility-show/index.scss'; +// @import './visibility-hide/index.scss'; +// @import './visibility-show/index.scss'; // @import './webhook/index.scss'; // @import './activity/index.scss'; @import './alert-circle/index.scss'; @@ -316,8 +316,8 @@ // @import './event/index.scss'; // @import './exit-point/index.scss'; // @import './external-link/index.scss'; -// @import './eye/index.scss'; -// @import './eye-off/index.scss'; +@import './eye/index.scss'; +@import './eye-off/index.scss'; // @import './f5/index.scss'; // @import './f5-color/index.scss'; // @import './facebook/index.scss'; diff --git a/ui/packages/consul-ui/app/styles/components.scss b/ui/packages/consul-ui/app/styles/components.scss index 73ed5fcf1..ad39f2418 100644 --- a/ui/packages/consul-ui/app/styles/components.scss +++ b/ui/packages/consul-ui/app/styles/components.scss @@ -33,7 +33,6 @@ @import 'consul-ui/components/popover-select'; @import 'consul-ui/components/progress'; @import 'consul-ui/components/radio-group'; -@import 'consul-ui/components/secret-button'; @import 'consul-ui/components/sliding-toggle'; @import 'consul-ui/components/table'; @import 'consul-ui/components/tile'; @@ -75,7 +74,7 @@ @import 'consul-ui/components/informed-action'; @import 'consul-ui/components/tab-nav'; @import 'consul-ui/components/search-bar'; -@import 'consul-ui/components/certificate'; +@import 'consul-ui/components/copyable-code'; @import 'consul-ui/components/consul/loader'; @import 'consul-ui/components/consul/tomography/graph'; diff --git a/ui/packages/consul-ui/app/styles/debug.scss b/ui/packages/consul-ui/app/styles/debug.scss index 8209e6ac4..66cecc7ed 100644 --- a/ui/packages/consul-ui/app/styles/debug.scss +++ b/ui/packages/consul-ui/app/styles/debug.scss @@ -252,9 +252,6 @@ html.with-route-announcer .route-title { figcaption code { @extend %inline-code; } - pre code { - @extend %block-code; - } figure > [type='text'] { border: 1px solid rgb(var(--tone-gray-999)); width: 100%; diff --git a/ui/packages/consul-ui/app/templates/dc/acls/policies/edit.hbs b/ui/packages/consul-ui/app/templates/dc/acls/policies/edit.hbs index b1480fbb3..63cc8ea66 100644 --- a/ui/packages/consul-ui/app/templates/dc/acls/policies/edit.hbs +++ b/ui/packages/consul-ui/app/templates/dc/acls/policies/edit.hbs @@ -62,7 +62,10 @@ as |dc partition nspace id item create|}}Title 1 Value Title 2 -+ Value + +