Skip to content

Commit

Permalink
feat: Add tootlip tu shadow button.
Browse files Browse the repository at this point in the history
  • Loading branch information
vipul0425 committed Sep 20, 2024
1 parent 00da47a commit 9d3d8ac
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
FlexItem,
Dropdown,
Composite,
Tooltip,
} from '@wordpress/components';
import { useMemo } from '@wordpress/element';
import { shadow as shadowIcon, Icon, check } from '@wordpress/icons';
Expand Down Expand Up @@ -79,32 +80,31 @@ export function ShadowPresets( { presets, activeShadow, onSelect } ) {

export function ShadowIndicator( { type, label, isActive, onSelect, shadow } ) {
return (
<Composite.Item
role="option"
aria-label={ label }
aria-selected={ isActive }
className={ clsx( 'block-editor-global-styles__shadow__item', {
'is-active': isActive,
} ) }
render={
<button
__next40pxDefaultSize
className={ clsx(
'block-editor-global-styles__shadow-indicator',
{
unset: type === 'unset',
}
) }
onClick={ onSelect }
label={ label }
style={ { boxShadow: shadow } }
title={ label }
aria-label={ label }
>
{ isActive && <Icon icon={ check } /> }
</button>
}
/>
<Tooltip text={ label }>
<Composite.Item
role="option"
aria-label={ label }
aria-selected={ isActive }
className={ clsx( 'block-editor-global-styles__shadow__item', {
'is-active': isActive,
} ) }
render={
<button
className={ clsx(
'block-editor-global-styles__shadow-indicator',
{
unset: type === 'unset',
}
) }
onClick={ onSelect }
style={ { boxShadow: shadow } }
aria-label={ label }
>
{ isActive && <Icon icon={ check } /> }
</button>
}
/>
</Tooltip>
);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/block-editor/src/components/global-styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@

// These styles are similar to the color palette.
.block-editor-global-styles__shadow-indicator {
appearance: none;
background: none;
color: $gray-800;
border: $gray-200 $border-width solid;
border-radius: $radius-small;
cursor: pointer;
display: inline-flex;
align-items: center;

padding: 0;

height: $button-size-small + 2 * $border-width;
Expand Down

0 comments on commit 9d3d8ac

Please sign in to comment.