From 8b5d4278d5792e75273fda647ea34053a510aeea Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Mon, 8 May 2023 13:41:46 -0400 Subject: [PATCH 01/29] Move color name and value below picker swatch --- .../components/src/color-palette/index.tsx | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/packages/components/src/color-palette/index.tsx b/packages/components/src/color-palette/index.tsx index f741e35eebef7e..140306b6f8d1b3 100644 --- a/packages/components/src/color-palette/index.tsx +++ b/packages/components/src/color-palette/index.tsx @@ -220,8 +220,6 @@ function UnforwardedColorPalette( ); - const colordColor = colord( normalizedColorValue ?? '' ); - const valueWithoutLeadingHash = value?.startsWith( '#' ) ? value.substring( 1 ) : value ?? ''; @@ -258,41 +256,43 @@ function UnforwardedColorPalette( renderContent={ renderCustomColorPicker } renderToggle={ ( { isOpen, onToggle } ) => ( - colordColor.contrast( '#000' ) - ? '#fff' - : '#000', - } - } + direction="column" + gap={ 0 } + as="div" + className="components-color-palette__custom-color__container" > - { buttonLabelName } - - - { valueWithoutLeadingHash } - + as={ 'button' } + ref={ customColorPaletteCallbackRef } + className="components-color-palette__custom-color" + aria-expanded={ isOpen } + aria-haspopup="true" + onClick={ onToggle } + aria-label={ customColorAccessibleLabel } + style={ + showTransparentBackground( value ) + ? {} + : { + background: value, + } + } + /> + { value && ( + <> + + { buttonLabelName } + + + { value } + + + ) } ) } /> From 40cf2b3c3a0eb6a172c9bdec05d00283f0794bcb Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Mon, 8 May 2023 13:42:06 -0400 Subject: [PATCH 02/29] update component styles --- .../components/src/color-palette/style.scss | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/components/src/color-palette/style.scss b/packages/components/src/color-palette/style.scss index 82f1858d64d3c4..ffb4a8b6814513 100644 --- a/packages/components/src/color-palette/style.scss +++ b/packages/components/src/color-palette/style.scss @@ -1,12 +1,20 @@ +.components-color-palette__custom-color__container { + border-radius: $radius-block-ui; + box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2); +} + .components-color-palette__custom-color { - position: relative; border: none; background: none; - border-radius: $radius-block-ui; + // border-radius: $radius-block-ui $radius-block-ui 0 0; + border-radius: + calc(#{$radius-block-ui} - #{$border-width} * 0.5) 0 0 + calc(#{$radius-block-ui} - #{$border-width} * 0.5) 0 0; height: $grid-unit-80; padding: $grid-unit-15; font-family: inherit; - width: 100%; + width: calc(100% - (#{$border-width} * 2)); + margin: $border-width auto $border-width auto; // The background image creates a checkerboard pattern. Ignore rtlcss to // make it work both in LTR and RTL. // See https://github.com/WordPress/gutenberg/pull/42510 @@ -20,7 +28,6 @@ box-sizing: border-box; color: $white; cursor: pointer; - box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2); // Show a thin outline in Windows high contrast mode. outline: 1px solid transparent; @@ -33,9 +40,18 @@ .components-color-palette__custom-color-name { text-align: left; + font-size: $default-font-size; + color: $components-color-foreground; + box-shadow: 0 (-$border-width) 0 0 rgba(0, 0, 0, 0.2); + margin: 0 $border-width; + padding-top: $grid-unit-15; + padding-left: $grid-unit-20; } .components-color-palette__custom-color-value { - margin-left: $grid-unit-20; + font-size: $default-font-size; + padding-left: $grid-unit-20; + padding-bottom: $grid-unit-15; text-transform: uppercase; + color: $gray-600; } From bd97be707afff3dba938127e6582b6037314d082 Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Tue, 9 May 2023 08:31:01 -0400 Subject: [PATCH 03/29] update CHANGELOG --- packages/components/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index b299cdf3e0c153..9e7582adaff4c8 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -21,6 +21,7 @@ ### Enhancements - `Tooltip`: Update background color so tooltip boundaries are more visible in the site editor ([#50792](https://github.com/WordPress/gutenberg/pull/50792)). +- `ColorPalette`: Improve readability of color name and value, and improve rendering of partially transparent colors ([#50450](https://github.com/WordPress/gutenberg/pull/50450)). ## 24.0.0 (2023-05-10) From f1b8099ccf159085c27d283f764aa5babe0f21a3 Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Tue, 9 May 2023 08:36:20 -0400 Subject: [PATCH 04/29] update snapshot --- .../test/__snapshots__/control.js.snap | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap b/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap index 631f8e45a6ec1d..96bceb92fb2f08 100644 --- a/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap +++ b/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap @@ -78,45 +78,44 @@ exports[`ColorPaletteControl matches the snapshot 1`] = ` display: -webkit-flex; display: -ms-flexbox; display: flex; - -webkit-align-items: flex-start; - -webkit-box-align: flex-start; - -ms-flex-align: flex-start; - align-items: flex-start; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; - gap: calc(4px * 2); + -webkit-align-items: normal; + -webkit-box-align: normal; + -ms-flex-align: normal; + align-items: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + gap: 0; -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; - width: 100%; + height: 100%; } .emotion-10>* { - min-width: 0; + min-height: 0; } -.emotion-13 { - display: block; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; +.emotion-12 { display: block; max-height: 100%; max-width: 100%; min-height: 0; min-width: 0; - -webkit-flex: 1; - -ms-flex: 1; - flex: 1; + display: block; } .emotion-15 { + display: block; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; display: block; max-height: 100%; max-width: 100%; min-height: 0; min-width: 0; + display: block; }
@@ -157,30 +156,35 @@ exports[`ColorPaletteControl matches the snapshot 1`] = ` class="components-dropdown" tabindex="-1" > - +
Date: Tue, 9 May 2023 09:42:02 -0400 Subject: [PATCH 05/29] update unit tests --- .../test/__snapshots__/index.tsx.snap | 60 ++++++++++--------- .../src/color-palette/test/index.tsx | 12 +--- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/packages/components/src/color-palette/test/__snapshots__/index.tsx.snap b/packages/components/src/color-palette/test/__snapshots__/index.tsx.snap index efbcf7a4aa4a40..5251e2774c77b4 100644 --- a/packages/components/src/color-palette/test/__snapshots__/index.tsx.snap +++ b/packages/components/src/color-palette/test/__snapshots__/index.tsx.snap @@ -127,45 +127,44 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = ` display: -webkit-flex; display: -ms-flexbox; display: flex; - -webkit-align-items: flex-start; - -webkit-box-align: flex-start; - -ms-flex-align: flex-start; - align-items: flex-start; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; - gap: calc(4px * 2); + -webkit-align-items: normal; + -webkit-box-align: normal; + -ms-flex-align: normal; + align-items: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + gap: 0; -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; - width: 100%; + height: 100%; } .emotion-2>* { - min-width: 0; + min-height: 0; } -.emotion-5 { - display: block; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; +.emotion-4 { display: block; max-height: 100%; max-width: 100%; min-height: 0; min-width: 0; - -webkit-flex: 1; - -ms-flex: 1; - flex: 1; + display: block; } .emotion-7 { + display: block; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; display: block; max-height: 100%; max-width: 100%; min-height: 0; min-width: 0; + display: block; }
@@ -178,30 +177,35 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = ` class="components-dropdown" tabindex="-1" > - +
{ expect( dropdownButton ).toBeVisible(); - expect( - within( dropdownButton ).getByText( EXAMPLE_COLORS[ 0 ].name ) - ).toBeVisible(); + expect( screen.getByText( EXAMPLE_COLORS[ 0 ].name ) ).toBeVisible(); - expect( - within( dropdownButton ).getByText( - EXAMPLE_COLORS[ 0 ].color.replace( '#', '' ) - ) - ).toBeVisible(); + expect( screen.getByText( EXAMPLE_COLORS[ 0 ].color ) ).toBeVisible(); // Check that the popover with custom color input has appeared. const dropdownColorInput = screen.getByLabelText( 'Hex color' ); From d981a96973cef990844ea32b2a6a40e7a5a99ef7 Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Wed, 10 May 2023 12:45:43 -0400 Subject: [PATCH 06/29] simplify CSS --- .../components/src/color-palette/style.scss | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/components/src/color-palette/style.scss b/packages/components/src/color-palette/style.scss index ffb4a8b6814513..462034bcedd7d3 100644 --- a/packages/components/src/color-palette/style.scss +++ b/packages/components/src/color-palette/style.scss @@ -1,20 +1,15 @@ -.components-color-palette__custom-color__container { +.components-color-palette__custom-color-container { border-radius: $radius-block-ui; - box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2); + overflow: hidden; + position: relative; + border: $border-width solid $gray-200; } -.components-color-palette__custom-color { +.components-color-palette__custom-color-button { border: none; background: none; - // border-radius: $radius-block-ui $radius-block-ui 0 0; - border-radius: - calc(#{$radius-block-ui} - #{$border-width} * 0.5) 0 0 - calc(#{$radius-block-ui} - #{$border-width} * 0.5) 0 0; height: $grid-unit-80; - padding: $grid-unit-15; - font-family: inherit; - width: calc(100% - (#{$border-width} * 2)); - margin: $border-width auto $border-width auto; + width: 100%; // The background image creates a checkerboard pattern. Ignore rtlcss to // make it work both in LTR and RTL. // See https://github.com/WordPress/gutenberg/pull/42510 @@ -26,7 +21,6 @@ /*rtl:end:ignore*/ background-size: calc(2 * 24px) calc(2 * 24px); box-sizing: border-box; - color: $white; cursor: pointer; // Show a thin outline in Windows high contrast mode. outline: 1px solid transparent; @@ -36,22 +30,26 @@ // Show a outline in Windows high contrast mode. outline-width: 2px; } + + // box shadow +} + +.components-color-palette__custom-color-text-wrapper { + padding: $grid-unit-15 $grid-unit-20; + border-top: $border-width solid $gray-200; + + // bottom border } .components-color-palette__custom-color-name { - text-align: left; font-size: $default-font-size; color: $components-color-foreground; - box-shadow: 0 (-$border-width) 0 0 rgba(0, 0, 0, 0.2); margin: 0 $border-width; - padding-top: $grid-unit-15; - padding-left: $grid-unit-20; + } .components-color-palette__custom-color-value { font-size: $default-font-size; - padding-left: $grid-unit-20; - padding-bottom: $grid-unit-15; text-transform: uppercase; color: $gray-600; } From 639be041d9181255aa7d56b826c3f314fb6ea09d Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Wed, 10 May 2023 15:47:50 -0400 Subject: [PATCH 07/29] simplify border styling --- .../components/src/color-palette/style.scss | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/components/src/color-palette/style.scss b/packages/components/src/color-palette/style.scss index 462034bcedd7d3..e52442f2e6d755 100644 --- a/packages/components/src/color-palette/style.scss +++ b/packages/components/src/color-palette/style.scss @@ -1,9 +1,4 @@ -.components-color-palette__custom-color-container { - border-radius: $radius-block-ui; - overflow: hidden; - position: relative; - border: $border-width solid $gray-200; -} +$border-as-box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2); .components-color-palette__custom-color-button { border: none; @@ -24,32 +19,39 @@ cursor: pointer; // Show a thin outline in Windows high contrast mode. outline: 1px solid transparent; + border-radius: $radius-block-ui $radius-block-ui 0 0; + box-shadow: $border-as-box-shadow; &:focus { box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent; // Show a outline in Windows high contrast mode. outline-width: 2px; } - - // box shadow } .components-color-palette__custom-color-text-wrapper { padding: $grid-unit-15 $grid-unit-20; - border-top: $border-width solid $gray-200; + border-radius: 0 0 $radius-block-ui $radius-block-ui; + position: relative; + font-size: $default-font-size; - // bottom border + // Add a border with the same technique as the button above, + // but only for left, bottom, and right sides. + box-shadow: + inset 0 -1 * $border-width 0 0 rgba(0, 0, 0, 0.2), + inset $border-width 0 0 0 rgba(0, 0, 0, 0.2), + inset -1 * $border-width 0 0 0 rgba(0, 0, 0, 0.2); } .components-color-palette__custom-color-name { - font-size: $default-font-size; color: $components-color-foreground; margin: 0 $border-width; - } .components-color-palette__custom-color-value { - font-size: $default-font-size; - text-transform: uppercase; color: $gray-600; + + &.is-hex { + text-transform: uppercase; + } } From ba7a5a85264e15594634784928cbc45963a1f1bc Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Wed, 10 May 2023 16:42:28 -0400 Subject: [PATCH 08/29] replace `Flex` with `VStack` --- .../components/src/color-palette/index.tsx | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/components/src/color-palette/index.tsx b/packages/components/src/color-palette/index.tsx index 140306b6f8d1b3..f9753a75efe402 100644 --- a/packages/components/src/color-palette/index.tsx +++ b/packages/components/src/color-palette/index.tsx @@ -5,6 +5,7 @@ import type { ForwardedRef } from 'react'; import { colord, extend } from 'colord'; import namesPlugin from 'colord/plugins/names'; import a11yPlugin from 'colord/plugins/a11y'; +import classnames from 'classnames'; /** * WordPress dependencies @@ -19,7 +20,6 @@ import Dropdown from '../dropdown'; import { ColorPicker } from '../color-picker'; import CircularOptionPicker from '../circular-option-picker'; import { VStack } from '../v-stack'; -import { Flex, FlexItem } from '../flex'; import { Truncate } from '../truncate'; import { ColorHeading } from './styles'; import DropdownContentWrapper from '../dropdown/dropdown-content-wrapper'; @@ -219,11 +219,12 @@ function UnforwardedColorPalette( /> ); - + // TODO: CSS vars should not have `VAR` or parentheses. They should also render in lowercase. Be careful of the hash, probably need a new variable. + // TODO: This variable is no longer accurate. It's only used for assistive tech now, so we can rename it. const valueWithoutLeadingHash = value?.startsWith( '#' ) ? value.substring( 1 ) : value ?? ''; - + // TODO: Check with Andrew on whether or not the hash fits here. Should it be exposed to assistive tech? If hash is okay, remove `valueWithoutLeadingHash`. Otherwise, update translator hint const customColorAccessibleLabel = !! valueWithoutLeadingHash ? sprintf( // translators: %1$s: The name of the color e.g: "vivid red". %2$s: The color's hex code e.g: "#f00". @@ -255,16 +256,10 @@ function UnforwardedColorPalette( isRenderedInSidebar={ __experimentalIsRenderedInSidebar } renderContent={ renderCustomColorPicker } renderToggle={ ( { isOpen, onToggle } ) => ( - - +
Date: Mon, 15 May 2023 07:28:24 -0400 Subject: [PATCH 11/29] display default text for no value --- packages/components/src/color-palette/index.tsx | 8 +++++--- packages/components/src/color-palette/style.scss | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/components/src/color-palette/index.tsx b/packages/components/src/color-palette/index.tsx index e21ad573013f70..da9a57c31a980e 100644 --- a/packages/components/src/color-palette/index.tsx +++ b/packages/components/src/color-palette/index.tsx @@ -270,13 +270,15 @@ function UnforwardedColorPalette( } } /> - { value && ( + { - { buttonLabelName } + { value + ? buttonLabelName + : 'No color selected' } - ) } + } ) } /> diff --git a/packages/components/src/color-palette/style.scss b/packages/components/src/color-palette/style.scss index e52442f2e6d755..e7f8e58a3f9c2d 100644 --- a/packages/components/src/color-palette/style.scss +++ b/packages/components/src/color-palette/style.scss @@ -50,6 +50,7 @@ $border-as-box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2); .components-color-palette__custom-color-value { color: $gray-600; + min-height: 15px; &.is-hex { text-transform: uppercase; From a64ed18fea11cc21054d6ff681cdbb8e9a5b7097 Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Mon, 15 May 2023 12:31:53 -0400 Subject: [PATCH 12/29] implement proper BEM notation --- packages/components/src/color-palette/index.tsx | 2 +- packages/components/src/color-palette/style.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/components/src/color-palette/index.tsx b/packages/components/src/color-palette/index.tsx index da9a57c31a980e..49d3234b67ba69 100644 --- a/packages/components/src/color-palette/index.tsx +++ b/packages/components/src/color-palette/index.tsx @@ -284,7 +284,7 @@ function UnforwardedColorPalette( className={ classnames( 'components-color-palette__custom-color-value', { - 'is-hex': + 'components-color-palette__custom-color-value--is-hex': displayValue?.startsWith( '#' ), diff --git a/packages/components/src/color-palette/style.scss b/packages/components/src/color-palette/style.scss index e7f8e58a3f9c2d..cb2d7a7359bbf6 100644 --- a/packages/components/src/color-palette/style.scss +++ b/packages/components/src/color-palette/style.scss @@ -52,7 +52,7 @@ $border-as-box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2); color: $gray-600; min-height: 15px; - &.is-hex { + &--is-hex { text-transform: uppercase; } } From 5d41512b717c7701c00790522dd45b53ac0a0dc7 Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Mon, 15 May 2023 12:38:02 -0400 Subject: [PATCH 13/29] update snapshot with BEM notation --- .../src/color-palette/test/__snapshots__/index.tsx.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/src/color-palette/test/__snapshots__/index.tsx.snap b/packages/components/src/color-palette/test/__snapshots__/index.tsx.snap index 7bdf9845eefb74..567abd74aeae4e 100644 --- a/packages/components/src/color-palette/test/__snapshots__/index.tsx.snap +++ b/packages/components/src/color-palette/test/__snapshots__/index.tsx.snap @@ -210,7 +210,7 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = ` red From 65caf9066736bc02be15d46844028775d2b36643 Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Tue, 16 May 2023 07:12:58 -0400 Subject: [PATCH 14/29] Updating block editor snapshots again --- .../test/__snapshots__/control.js.snap | 88 +++++++++++-------- 1 file changed, 50 insertions(+), 38 deletions(-) diff --git a/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap b/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap index 96bceb92fb2f08..202d8f7ffb503d 100644 --- a/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap +++ b/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap @@ -78,18 +78,18 @@ exports[`ColorPaletteControl matches the snapshot 1`] = ` display: -webkit-flex; display: -ms-flexbox; display: flex; - -webkit-align-items: normal; - -webkit-box-align: normal; - -ms-flex-align: normal; - align-items: normal; + -webkit-align-items: stretch; + -webkit-box-align: stretch; + -ms-flex-align: stretch; + align-items: stretch; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; gap: 0; - -webkit-box-pack: justify; - -webkit-justify-content: space-between; - justify-content: space-between; - height: 100%; + -webkit-box-pack: center; + -ms-flex-pack: center; + -webkit-justify-content: center; + justify-content: center; } .emotion-10>* { @@ -97,25 +97,33 @@ exports[`ColorPaletteControl matches the snapshot 1`] = ` } .emotion-12 { - display: block; - max-height: 100%; - max-width: 100%; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: stretch; + -webkit-box-align: stretch; + -ms-flex-align: stretch; + align-items: stretch; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + gap: calc(4px * 0.5); + -webkit-box-pack: center; + -ms-flex-pack: center; + -webkit-justify-content: center; + justify-content: center; +} + +.emotion-12>* { min-height: 0; - min-width: 0; - display: block; } -.emotion-15 { +.emotion-14 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; - display: block; - max-height: 100%; - max-width: 100%; - min-height: 0; - min-width: 0; - display: block; }
@@ -157,33 +165,37 @@ exports[`ColorPaletteControl matches the snapshot 1`] = ` tabindex="-1" >
Date: Wed, 17 May 2023 16:39:18 -0400 Subject: [PATCH 15/29] simplify `displayValue` declaration --- packages/components/src/color-palette/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/components/src/color-palette/index.tsx b/packages/components/src/color-palette/index.tsx index 49d3234b67ba69..27c837f4b6ead2 100644 --- a/packages/components/src/color-palette/index.tsx +++ b/packages/components/src/color-palette/index.tsx @@ -220,9 +220,7 @@ function UnforwardedColorPalette( ); // Leave hex values as-is. Remove the `var()` wrapper from CSS vars. - const displayValue = value?.startsWith( '#' ) - ? value - : value?.replace( /^var\((.+)\)$/, '$1' ); + const displayValue = value?.replace( /^var\((.+)\)$/, '$1' ); const customColorAccessibleLabel = !! displayValue ? sprintf( // translators: %1$s: The name of the color e.g: "vivid red". %2$s: The color's hex code e.g: "#f00". From b032818608f196a1d0b44623630210345cad1844 Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Wed, 17 May 2023 17:42:34 -0400 Subject: [PATCH 16/29] Remove extra curly braces --- .../components/src/color-palette/index.tsx | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/packages/components/src/color-palette/index.tsx b/packages/components/src/color-palette/index.tsx index 27c837f4b6ead2..a3af90f974827b 100644 --- a/packages/components/src/color-palette/index.tsx +++ b/packages/components/src/color-palette/index.tsx @@ -268,31 +268,27 @@ function UnforwardedColorPalette( } } /> - { - + + { value + ? buttonLabelName + : 'No color selected' } + + - - { value - ? buttonLabelName - : 'No color selected' } - - - { displayValue } - - - } + { displayValue } + + ) } /> From 1c6774a65acbfcbdbd8321729a30b491c1050951 Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Wed, 17 May 2023 17:57:19 -0400 Subject: [PATCH 17/29] Add layout comment --- packages/components/src/color-palette/index.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/components/src/color-palette/index.tsx b/packages/components/src/color-palette/index.tsx index a3af90f974827b..5fd02565544aeb 100644 --- a/packages/components/src/color-palette/index.tsx +++ b/packages/components/src/color-palette/index.tsx @@ -277,6 +277,11 @@ function UnforwardedColorPalette( ? buttonLabelName : 'No color selected' } + { /* + This `Truncate` is always rendered, even if + there is no `displayValue`, to ensure the layout + does not shift + */ } Date: Thu, 18 May 2023 13:57:49 -0400 Subject: [PATCH 18/29] fix color value span min-height --- .../components/color-palette/test/__snapshots__/control.js.snap | 1 + packages/components/src/color-palette/index.tsx | 1 + packages/components/src/color-palette/style.scss | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap b/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap index 202d8f7ffb503d..486d06d7c7bc8c 100644 --- a/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap +++ b/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap @@ -192,6 +192,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = ` class="components-truncate components-color-palette__custom-color-value components-color-palette__custom-color-value--is-hex emotion-14 emotion-5" data-wp-c16t="true" data-wp-component="Truncate" + style="min-height: 18px;" > #f00 diff --git a/packages/components/src/color-palette/index.tsx b/packages/components/src/color-palette/index.tsx index 5fd02565544aeb..179d94c5f3dd44 100644 --- a/packages/components/src/color-palette/index.tsx +++ b/packages/components/src/color-palette/index.tsx @@ -290,6 +290,7 @@ function UnforwardedColorPalette( displayValue?.startsWith( '#' ), } ) } + style={ { minHeight: '18px' } } > { displayValue } diff --git a/packages/components/src/color-palette/style.scss b/packages/components/src/color-palette/style.scss index cb2d7a7359bbf6..65e525cc0d4426 100644 --- a/packages/components/src/color-palette/style.scss +++ b/packages/components/src/color-palette/style.scss @@ -50,7 +50,6 @@ $border-as-box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2); .components-color-palette__custom-color-value { color: $gray-600; - min-height: 15px; &--is-hex { text-transform: uppercase; From af8931fa3ee5a79b103aea74067e3abba309fd6e Mon Sep 17 00:00:00 2001 From: chad1008 <13856531+chad1008@users.noreply.github.com> Date: Thu, 18 May 2023 15:53:38 -0400 Subject: [PATCH 19/29] Always show checkered background --- .../components/src/color-palette/index.tsx | 16 ++++----- .../components/src/color-palette/style.scss | 35 +++++++++++++------ 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/packages/components/src/color-palette/index.tsx b/packages/components/src/color-palette/index.tsx index 179d94c5f3dd44..316b98d08c72be 100644 --- a/packages/components/src/color-palette/index.tsx +++ b/packages/components/src/color-palette/index.tsx @@ -37,7 +37,6 @@ import { extractColorNameFromCurrentValue, isMultiplePaletteArray, normalizeColorValue, - showTransparentBackground, } from './utils'; extend( [ namesPlugin, a11yPlugin ] ); @@ -252,7 +251,10 @@ function UnforwardedColorPalette( isRenderedInSidebar={ __experimentalIsRenderedInSidebar } renderContent={ renderCustomColorPicker } renderToggle={ ( { isOpen, onToggle } ) => ( - +