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

[Common actions] Add Copy To Clipboard recipe #11645

Merged
merged 22 commits into from
Mar 27, 2024

Conversation

aaronccasanova
Copy link
Member

@aaronccasanova aaronccasanova commented Feb 22, 2024

WHY are these changes introduced?

Closes https://github.com/Shopify/polaris-internal/issues/1521

WHAT is this pull request doing?

This PR introduces a minimal Copy to Clipboard recipe following the Common Actions guidance. Additionally, a new useCopyToClipboard hook was added to facilitate the native copy behavior and state management for the copied timeout.

Screen.Recording.2024-03-26.at.11.53.20.AM.mov

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

🎩 checklist

@aaronccasanova aaronccasanova added the 🤖Skip Changelog Causes CI to ignore changelog update check. label Feb 22, 2024
@aaronccasanova aaronccasanova changed the title Initial Copy To Clipboard recipe [Common actions] Add Copy To Clipboard recipe Mar 14, 2024
@aaronccasanova aaronccasanova self-assigned this Mar 14, 2024
@aaronccasanova aaronccasanova added #gsd:38421 Polaris Common Action Patterns and removed 🤖Skip Changelog Causes CI to ignore changelog update check. labels Mar 14, 2024
@aaronccasanova aaronccasanova marked this pull request as ready for review March 14, 2024 23:09
@sarahill
Copy link
Contributor

sarahill commented Mar 15, 2024

@aaronccasanova It's feeling a little flashy even when I wait the full transition time for the initial "Copy" tooltip. There's a flash the first couple times and then it goes into a flicker the next couple (see gif).

2024-03-15 08 46 41

Copy link
Member

@sam-b-rose sam-b-rose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 💯

Comment on lines 161 to 168
if (
event.key !== 'Escape' &&
event.key !== 'Enter' &&
event.key !== ' '
) {
return;
}
handleClose?.();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates the Tooltip to dismiss on enter/space key interactions (matching the behavior onClick)

Screen.Recording.2024-03-26.at.4.56.22.PM.mov

Comment on lines 214 to +218
onBlur={() => {
if (hoverDelayTimeout.current) {
clearTimeout(hoverDelayTimeout.current);
hoverDelayTimeout.current = null;
}
Copy link
Member Author

@aaronccasanova aaronccasanova Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents the Tooltip from flickering/reopening when clicking the activator before the hoverDelayTimeout (video at 25% speed)

Screen.Recording.2024-03-26.at.4.58.06.PM.mov

Copy link
Contributor

@sarahill sarahill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and feels pretty smooth and easy to interact with 👏

Copy link
Member

@chloerice chloerice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Member

@sam-b-rose sam-b-rose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@aaronccasanova aaronccasanova merged commit b726dad into main Mar 27, 2024
14 checks passed
@aaronccasanova aaronccasanova deleted the copy-to-clipboard-recipe branch March 27, 2024 22:03
sam-b-rose pushed a commit that referenced this pull request Apr 1, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @shopify/polaris@12.24.0

### Minor Changes

- [#11547](#11547)
[`df5276317`](df52763)
Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Applied semantic
type styles using the `Text` component


- [#11728](#11728)
[`281c8f8e9`](281c8f8)
Thanks [@kyledurand](https://github.com/kyledurand)! - Added new
AlphaPicker component


- [#11645](#11645)
[`b726dadbb`](b726dad)
Thanks [@aaronccasanova](https://github.com/aaronccasanova)! - Added
`useCopyToClipboard` hook for building copy actions matching common
actions guidelines


- [#11780](#11780)
[`4fffc2dcc`](4fffc2d)
Thanks [@itwasmattgregg](https://github.com/itwasmattgregg)! - allows
icons to be displayed on primary actions on Page component


- [#11547](#11547)
[`df5276317`](df52763)
Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Added
`base`,`inherit`, `disabled`, and `text-inverse` tone options for Text
component


- [#11547](#11547)
[`df5276317`](df52763)
Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Updated
plain/monochrome Button text size to bodySm for micro

### Patch Changes

- [#11789](#11789)
[`36df1aa6c`](36df1aa)
Thanks [@laurkim](https://github.com/laurkim)! - Fixed logo spacing on
`ContextualSaveBar`


- [#11794](#11794)
[`ffdcf1df7`](ffdcf1d)
Thanks [@kyledurand](https://github.com/kyledurand)! - Set default
scrollbar width to thin on scrollable


- [#11804](#11804)
[`d1b46c25c`](d1b46c2)
Thanks [@laurkim](https://github.com/laurkim)! - Fixed layout shift on
`EmptyState` when image is loading with skeleton image

## @shopify/stylelint-polaris@15.5.0

### Minor Changes

- [#11547](#11547)
[`df5276317`](df52763)
Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Added warning for
`font-size`, `line-height`, and `font-weight` properties. Use the `Text`
component as a preferred option.

## @shopify/polaris-migrator@0.28.4

### Patch Changes

- Updated dependencies
\[[`df5276317`](df52763)]:
    -   @shopify/stylelint-polaris@15.5.0

## polaris.shopify.com@0.67.0

### Minor Changes

- [#11779](#11779)
[`86a6ba44a`](86a6ba4)
Thanks [@itwasmattgregg](https://github.com/itwasmattgregg)! - Added
examples for `Card` and `Page` with icon actions

### Patch Changes

- [#11547](#11547)
[`df5276317`](df52763)
Thanks [@sam-b-rose](https://github.com/sam-b-rose)! - Added page for
`typography/property-disallow-list` Stylelint rule

- Updated dependencies
\[[`df5276317`](df52763),
[`281c8f8e9`](281c8f8),
[`b726dadbb`](b726dad),
[`4fffc2dcc`](4fffc2d),
[`df5276317`](df52763),
[`36df1aa6c`](36df1aa),
[`df5276317`](df52763),
[`ffdcf1df7`](ffdcf1d),
[`d1b46c25c`](d1b46c2)]:
    -   @shopify/polaris@12.24.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AnnaCheba pushed a commit to AnnaCheba/polaris that referenced this pull request Apr 22, 2024
Co-authored-by: Chloe Rice <chloerice@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#gsd:38421 Polaris Common Action Patterns
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants