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 3 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 @@ -8,6 +8,7 @@

### Bug Fixes

- `ColorPicker`: Replace color copy button icon with visible text ([#57168](https://github.com/WordPress/gutenberg/pull/57168)).
- `ComboboxControl`: Fix ComboboxControl reset button when using the keyboard. ([#63410](https://github.com/WordPress/gutenberg/pull/63410))
- `Button`: Never apply `aria-disabled` to anchor ([#63376](https://github.com/WordPress/gutenberg/pull/63376)).

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

/**
* Internal dependencies
*/
import { CopyButton } from './styles';
import Tooltip from '../tooltip';

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

export const ColorCopyButton = ( props: ColorCopyButtonProps ) => {
const { color, colorType } = props;
Expand Down Expand Up @@ -54,19 +51,8 @@ export const ColorCopyButton = ( props: ColorCopyButtonProps ) => {
}, [] );

return (
<Tooltip
delay={ 0 }
hideOnClick={ false }
text={
copiedColor === color.toHex() ? __( 'Copied!' ) : __( 'Copy' )
}
>
<CopyButton
size="small"
ref={ copyRef }
icon={ copy }
showTooltip={ false }
/>
</Tooltip>
<Button variant="secondary" ref={ copyRef } __next40pxDefaultSize>
{ 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 @@ -96,18 +96,22 @@ const UnconnectedColorPicker = (
hideLabelFromVision
variant="minimal"
/>
<ColorCopyButton
color={ safeColordColor }
colorType={ copyFormat || colorType }
/>
</AuxiliaryColorArtefactHStackHeader>
<ColorInputWrapper direction="column" gap={ 2 }>
<ColorInputWrapper
direction={ colorType === 'hex' ? 'row' : '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
12 changes: 0 additions & 12 deletions packages/components/src/color-picker/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import InnerSelectControl from '../select-control';
import InnerRangeControl from '../range-control';
import { space } from '../utils/space';
import { boxSizingReset } from '../utils';
import Button from '../button';
import { Flex } from '../flex';
import { HStack } from '../h-stack';
import CONFIG from '../utils/config-values';
Expand Down Expand Up @@ -101,14 +100,3 @@ export const ColorfulWrapper = styled.div`

${ interactiveHueStyles }
`;

export const CopyButton = styled( Button )`
&&&&& {
min-width: ${ space( 6 ) };
padding: 0;

> svg {
margin-right: 0;
}
}
`;
Loading