Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace color copy button icon with visible text #57168

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

### Bug Fixes

- `ColorPicker`: Replace color copy button icon with visible text ([#57168](https://github.com/WordPress/gutenberg/pull/57168)).
- `BoxControl`: Better respect for the `min` prop in the Range Slider ([#67819](https://github.com/WordPress/gutenberg/pull/67819)).

### Experimental
Expand Down
17 changes: 3 additions & 14 deletions packages/components/src/color-picker/color-copy-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
*/
import { useCopyToClipboard } from '@wordpress/compose';
import { useState, useEffect, useRef } from '@wordpress/element';
import { copy } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { Button } from '../button';
import Tooltip from '../tooltip';

import type { ColorCopyButtonProps } from './types';

Expand Down Expand Up @@ -55,18 +53,9 @@ export const ColorCopyButton = ( props: ColorCopyButtonProps ) => {
};
}, [] );

const label =
copiedColor === color.toHex() ? __( 'Copied!' ) : __( 'Copy' );

return (
<Tooltip delay={ 0 } hideOnClick={ false } text={ label }>
<Button
size="compact"
aria-label={ label }
ref={ copyRef }
icon={ copy }
showTooltip={ false }
/>
</Tooltip>
<Button variant="secondary" ref={ copyRef } size="compact">
{ copiedColor === color.toHex() ? __( 'Copied!' ) : __( 'Copy' ) }
</Button>
);
};
14 changes: 9 additions & 5 deletions packages/components/src/color-picker/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,22 @@ const UnconnectedColorPicker = (
hideLabelFromVision
variant="minimal"
/>
<ColorCopyButton
color={ safeColordColor }
colorType={ copyFormat || colorType }
/>
</AuxiliaryColorArtefactHStackHeader>
<ColorInputWrapper direction="column" gap={ 2 }>
<ColorInputWrapper
direction="column"
align="flex-start"
gap={ 2 }
>
<ColorInput
colorType={ colorType }
color={ safeColordColor }
onChange={ handleChange }
enableAlpha={ enableAlpha }
/>
<ColorCopyButton
color={ safeColordColor }
colorType={ copyFormat || colorType }
/>
</ColorInputWrapper>
</AuxiliaryColorArtefactWrapper>
</ColorfulWrapper>
Expand Down
Loading