From 8b9db3dc025f73e9dad9b076c6f14394b898a9b5 Mon Sep 17 00:00:00 2001 From: James Koster Date: Tue, 2 Aug 2022 10:07:48 +0100 Subject: [PATCH] Update color button style (#41838) * Removed fixed height * Truncate color name and add title attribute Results in better support of extra long color names. --- .../src/components/colors-gradients/dropdown.js | 7 ++++++- .../src/components/colors-gradients/style.scss | 16 +++++++++++++++- .../components/global-styles/screen-colors.js | 16 ++++++++++++---- .../src/components/global-styles/style.scss | 8 ++++++++ 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/colors-gradients/dropdown.js b/packages/block-editor/src/components/colors-gradients/dropdown.js index e44ed72775ef2e..4349cbb6f49cae 100644 --- a/packages/block-editor/src/components/colors-gradients/dropdown.js +++ b/packages/block-editor/src/components/colors-gradients/dropdown.js @@ -61,7 +61,12 @@ const LabeledColorIndicator = ( { colorValue, label } ) => ( className="block-editor-panel-color-gradient-settings__color-indicator" colorValue={ colorValue } /> - { label } + + { label } + ); diff --git a/packages/block-editor/src/components/colors-gradients/style.scss b/packages/block-editor/src/components/colors-gradients/style.scss index c024d8eaad20ad..fcbdaef266107a 100644 --- a/packages/block-editor/src/components/colors-gradients/style.scss +++ b/packages/block-editor/src/components/colors-gradients/style.scss @@ -58,6 +58,7 @@ $swatch-gap: 12px; */ .block-editor-tools-panel-color-gradient-settings__item { padding: 0; + max-width: 100%; // Border styles. border-left: 1px solid rgba(0, 0, 0, 0.1); @@ -87,17 +88,30 @@ $swatch-gap: 12px; padding: 0; > button { - height: 46px; + height: auto; + padding-top: $grid-unit * 1.25; + padding-bottom: $grid-unit * 1.25; + text-align: left; &.is-open { background: $gray-100; color: var(--wp-admin-theme-color); } } + + .block-editor-panel-color-gradient-settings__color-name { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } } .block-editor-panel-color-gradient-settings__dropdown { width: 100%; + + .component-color-indicator { + flex-shrink: 0; + } } .block-editor-color-gradient-control__tab-panel { diff --git a/packages/edit-site/src/components/global-styles/screen-colors.js b/packages/edit-site/src/components/global-styles/screen-colors.js index d11d863b46f46e..b6af8f40095e69 100644 --- a/packages/edit-site/src/components/global-styles/screen-colors.js +++ b/packages/edit-site/src/components/global-styles/screen-colors.js @@ -45,7 +45,9 @@ function BackgroundColorItem( { name, parentMenu } ) { data-testid="background-color-indicator" /> - { __( 'Background' ) } + + { __( 'Background' ) } + ); @@ -72,7 +74,9 @@ function TextColorItem( { name, parentMenu } ) { data-testid="text-color-indicator" /> - { __( 'Text' ) } + + { __( 'Text' ) } + ); @@ -102,7 +106,9 @@ function LinkColorItem( { name, parentMenu } ) { - { __( 'Links' ) } + + { __( 'Links' ) } + ); @@ -129,7 +135,9 @@ function ButtonColorItem( { name, parentMenu } ) { - { __( 'Buttons' ) } + + { __( 'Buttons' ) } + ); diff --git a/packages/edit-site/src/components/global-styles/style.scss b/packages/edit-site/src/components/global-styles/style.scss index 31f6c6f888027e..f94a6dcc1620a1 100644 --- a/packages/edit-site/src/components/global-styles/style.scss +++ b/packages/edit-site/src/components/global-styles/style.scss @@ -41,6 +41,7 @@ .component-color-indicator { // Show a diagonal line (crossed out) for empty swatches. background: linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%); + flex-shrink: 0; } } @@ -107,4 +108,11 @@ .edit-site-global-styles__color-indicator-wrapper { // Match the height of the rest of the icons (24px). height: $grid-unit * 3; + flex-shrink: 0; +} + +.edit-site-global-styles__color-label { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; }