-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat: add option of copy to info row component #25682
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3180a0d
Adding copy option to info row component
jpuri 566c451
updating
jpuri 6211b8b
updating
jpuri 90b949f
updating
jpuri 54a405c
update
jpuri 40586f1
update
jpuri dd67ae4
update
jpuri 9d22922
update
jpuri 41d0945
Update
jpuri 368c2ca
merge
jpuri 8e068c8
update
jpuri 39e1c67
update
jpuri 6e9e762
Merge branch 'develop' into info_row_copy_icon
jpuri 49701b4
Merge branch 'develop' into info_row_copy_icon
jpuri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
ui/components/app/confirm/info/row/__snapshots__/copy-icon.test.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`CopyIcon should match snapshot 1`] = ` | ||
| <div> | ||
| <span | ||
| class="mm-box mm-icon mm-icon--size-sm mm-box--display-inline-block mm-box--color-icon-alternative" | ||
| style="mask-image: url('./images/icons/copy.svg'); cursor: pointer; position: absolute; right: 0px; top: 2px;" | ||
| /> | ||
| </div> | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
ui/components/app/confirm/info/row/__snapshots__/row.test.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`ConfirmInfoRow should match snapshot 1`] = ` | ||
| <div> | ||
| <div | ||
| class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg" | ||
| style="overflow-wrap: anywhere; min-height: 24px; position: relative;" | ||
| > | ||
| <div | ||
| class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-center" | ||
| > | ||
| <p | ||
| class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit" | ||
| > | ||
| some label | ||
| </p> | ||
| </div> | ||
| <p | ||
| class="mm-box mm-text mm-text--body-md mm-box--color-text-default" | ||
| > | ||
| Some text | ||
| </p> | ||
| </div> | ||
| </div> | ||
| `; | ||
|
|
||
| exports[`ConfirmInfoRow should match snapshot when copy is enabled 1`] = ` | ||
| <div> | ||
| <div | ||
| class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-5 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg" | ||
| style="overflow-wrap: anywhere; min-height: 24px; position: relative;" | ||
| > | ||
| <span | ||
| class="mm-box mm-icon mm-icon--size-sm mm-box--display-inline-block mm-box--color-icon-alternative" | ||
| style="mask-image: url('./images/icons/copy.svg'); cursor: pointer; position: absolute; right: 0px; top: 2px;" | ||
| /> | ||
| <div | ||
| class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-center" | ||
| > | ||
| <p | ||
| class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit" | ||
| > | ||
| some label | ||
| </p> | ||
| </div> | ||
| <p | ||
| class="mm-box mm-text mm-text--body-md mm-box--color-text-default" | ||
| > | ||
| Some text | ||
| </p> | ||
| </div> | ||
| </div> | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import React from 'react'; | ||
| import { render } from '@testing-library/react'; | ||
|
|
||
| import { CopyIcon } from './copy-icon'; | ||
|
|
||
| describe('CopyIcon', () => { | ||
| it('should match snapshot', () => { | ||
| const { container } = render(<CopyIcon copyText="dummy text" />); | ||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import React, { useCallback } from 'react'; | ||
|
|
||
| import { useCopyToClipboard } from '../../../../../hooks/useCopyToClipboard'; | ||
| import { IconColor } from '../../../../../helpers/constants/design-system'; | ||
| import { Icon, IconName, IconSize } from '../../../../component-library'; | ||
|
|
||
| type CopyCallback = (text: string) => void; | ||
|
|
||
| export const CopyIcon: React.FC<{ copyText: string }> = ({ copyText }) => { | ||
| const [copied, handleCopy] = useCopyToClipboard(); | ||
|
|
||
| const handleClick = useCallback(async () => { | ||
| (handleCopy as CopyCallback)(copyText); | ||
| }, [copyText]); | ||
|
|
||
| return ( | ||
| <Icon | ||
| color={IconColor.iconAlternative} | ||
| name={copied ? IconName.CopySuccess : IconName.Copy} | ||
| size={IconSize.Sm} | ||
| style={{ cursor: 'pointer', position: 'absolute', right: 0, top: 2 }} | ||
| onClick={handleClick} | ||
| /> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import React from 'react'; | ||
| import { render } from '@testing-library/react'; | ||
|
|
||
| import { Text } from '../../../../component-library'; | ||
| import { ConfirmInfoRow } from './row'; | ||
|
|
||
| describe('ConfirmInfoRow', () => { | ||
| it('should match snapshot', () => { | ||
| const { container } = render( | ||
| <ConfirmInfoRow label="some label"> | ||
| <Text>Some text</Text> | ||
| </ConfirmInfoRow>, | ||
| ); | ||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('should match snapshot when copy is enabled', () => { | ||
| const { container } = render( | ||
| <ConfirmInfoRow label="some label" copyEnabled copyText="dummy text"> | ||
| <Text>Some text</Text> | ||
| </ConfirmInfoRow>, | ||
| ); | ||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.