From 606c8de6882b9f54687844ffaa43a6ccee8d1e7c Mon Sep 17 00:00:00 2001 From: Josefina Mancilla <32556167+jnm2377@users.noreply.github.com> Date: Tue, 29 Mar 2022 13:21:02 -0500 Subject: [PATCH] feat(CopyButton, CodeSnippet): migrate v11 components to use IconButton (#11054) * feat: migrate v11 copy to icon btn * fix: add default tooltip text for inline copy * fix: copy btn styles * chore: update codesnippet snapshot Co-authored-by: Josh Black Co-authored-by: Alessandra Davila --- .../__snapshots__/PublicAPI-test.js.snap | 2 + .../src/components/CodeSnippet/CodeSnippet.js | 2 + packages/react/src/components/Copy/Copy.js | 24 ++++++ .../code-snippet/_code-snippet.scss | 79 ++++++++----------- .../components/copy-button/_copy-button.scss | 59 -------------- 5 files changed, 60 insertions(+), 106 deletions(-) diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index 144e0c788c70..86ae476e114c 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -441,6 +441,8 @@ Map { }, "CodeSnippet" => Object { "defaultProps": Object { + "ariaLabel": "Copy to clipboard", + "copyLabel": "Copy to clipboard", "showLessText": "Show less", "showMoreText": "Show more", "type": "single", diff --git a/packages/react/src/components/CodeSnippet/CodeSnippet.js b/packages/react/src/components/CodeSnippet/CodeSnippet.js index abd0bf52cd5f..133efd1b95e0 100644 --- a/packages/react/src/components/CodeSnippet/CodeSnippet.js +++ b/packages/react/src/components/CodeSnippet/CodeSnippet.js @@ -387,6 +387,8 @@ CodeSnippet.propTypes = { }; CodeSnippet.defaultProps = { + ariaLabel: 'Copy to clipboard', + copyLabel: 'Copy to clipboard', type: 'single', showMoreText: 'Show more', showLessText: 'Show less', diff --git a/packages/react/src/components/Copy/Copy.js b/packages/react/src/components/Copy/Copy.js index b98e8cd350d2..44c46246c25b 100644 --- a/packages/react/src/components/Copy/Copy.js +++ b/packages/react/src/components/Copy/Copy.js @@ -11,6 +11,8 @@ import debounce from 'lodash.debounce'; import classnames from 'classnames'; import { composeEventHandlers } from '../../tools/events'; import { usePrefix } from '../../internal/usePrefix'; +import { IconButton } from '../IconButton'; +import * as FeatureFlags from '@carbon/feature-flags'; export default function Copy({ children, @@ -39,6 +41,7 @@ export default function Copy({ setAnimation('fade-in'); handleFadeOut(); }, [handleFadeOut]); + const handleAnimationEnd = (event) => { if (event.animationName === 'hide-feedback') { setAnimation(''); @@ -52,6 +55,27 @@ export default function Copy({ [handleFadeOut] ); + if (FeatureFlags.enabled('enable-v11-release')) { + return ( + + {children} + + ); + } + return (