Skip to content

Commit

Permalink
Update color button style (#41838)
Browse files Browse the repository at this point in the history
* Removed fixed height
* Truncate color name and add title attribute

Results in better support of extra long color names.
  • Loading branch information
jameskoster authored Aug 2, 2022
1 parent 784b331 commit 8b9db3d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ const LabeledColorIndicator = ( { colorValue, label } ) => (
className="block-editor-panel-color-gradient-settings__color-indicator"
colorValue={ colorValue }
/>
<FlexItem>{ label }</FlexItem>
<FlexItem
className="block-editor-panel-color-gradient-settings__color-name"
title={ label }
>
{ label }
</FlexItem>
</HStack>
);

Expand Down
16 changes: 15 additions & 1 deletion packages/block-editor/src/components/colors-gradients/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 12 additions & 4 deletions packages/edit-site/src/components/global-styles/screen-colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ function BackgroundColorItem( { name, parentMenu } ) {
data-testid="background-color-indicator"
/>
</ColorIndicatorWrapper>
<FlexItem>{ __( 'Background' ) }</FlexItem>
<FlexItem className="edit-site-global-styles__color-label">
{ __( 'Background' ) }
</FlexItem>
</HStack>
</NavigationButtonAsItem>
);
Expand All @@ -72,7 +74,9 @@ function TextColorItem( { name, parentMenu } ) {
data-testid="text-color-indicator"
/>
</ColorIndicatorWrapper>
<FlexItem>{ __( 'Text' ) }</FlexItem>
<FlexItem className="edit-site-global-styles__color-label">
{ __( 'Text' ) }
</FlexItem>
</HStack>
</NavigationButtonAsItem>
);
Expand Down Expand Up @@ -102,7 +106,9 @@ function LinkColorItem( { name, parentMenu } ) {
<ColorIndicator colorValue={ colorHover } />
</ColorIndicatorWrapper>
</ZStack>
<FlexItem>{ __( 'Links' ) }</FlexItem>
<FlexItem className="edit-site-global-styles__color-label">
{ __( 'Links' ) }
</FlexItem>
</HStack>
</NavigationButtonAsItem>
);
Expand All @@ -129,7 +135,9 @@ function ButtonColorItem( { name, parentMenu } ) {
<ColorIndicator colorValue={ color } />
</ColorIndicatorWrapper>
</ZStack>
<FlexItem>{ __( 'Buttons' ) }</FlexItem>
<FlexItem className="edit-site-global-styles__color-label">
{ __( 'Buttons' ) }
</FlexItem>
</HStack>
</NavigationButtonAsItem>
);
Expand Down
8 changes: 8 additions & 0 deletions packages/edit-site/src/components/global-styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}

0 comments on commit 8b9db3d

Please sign in to comment.