-
Notifications
You must be signed in to change notification settings - Fork 50
Add pop-up notifs + show a notif when an address has been copied #1012
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
3 commits
Select commit
Hold shift + click to select a range
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
158 changes: 158 additions & 0 deletions
158
src/app/components/AddressBox/__tests__/__snapshots__/index.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,158 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`<AddressBox /> should render address properly 1`] = ` | ||
| .c2 { | ||
| display: inline-block; | ||
| -webkit-flex: 0 0 auto; | ||
| -ms-flex: 0 0 auto; | ||
| flex: 0 0 auto; | ||
| width: 18px; | ||
| height: 18px; | ||
| fill: #666666; | ||
| stroke: #666666; | ||
| } | ||
|
|
||
| .c2 g { | ||
| fill: inherit; | ||
| stroke: inherit; | ||
| } | ||
|
|
||
| .c2 *:not([stroke])[fill="none"] { | ||
| stroke-width: 0; | ||
| } | ||
|
|
||
| .c2 *[stroke*="#"],.c2 *[STROKE*="#"] { | ||
| stroke: inherit; | ||
| fill: none; | ||
| } | ||
|
|
||
| .c2 *[fill-rule], | ||
| .c2 *[FILL-RULE], | ||
| .c2 *[fill*="#"],.c2 *[FILL*="#"] { | ||
| fill: inherit; | ||
| stroke: none; | ||
| } | ||
|
|
||
| .c0 { | ||
| display: -webkit-box; | ||
| display: -webkit-flex; | ||
| display: -ms-flexbox; | ||
| display: flex; | ||
| box-sizing: border-box; | ||
| max-width: 100%; | ||
| -webkit-align-items: center; | ||
| -webkit-box-align: center; | ||
| -ms-flex-align: center; | ||
| align-items: center; | ||
| min-width: 0; | ||
| min-height: 0; | ||
| -webkit-flex-direction: row; | ||
| -ms-flex-direction: row; | ||
| flex-direction: row; | ||
| width: -webkit-fit-content; | ||
| width: -moz-fit-content; | ||
| width: fit-content; | ||
| padding-right: 12px; | ||
| border-radius: 5px; | ||
| } | ||
|
|
||
| .c3 { | ||
| font-size: 18px; | ||
| line-height: 24px; | ||
| font-weight: bold; | ||
| word-break: break-word; | ||
| } | ||
|
|
||
| .c1 { | ||
| display: inline-block; | ||
| box-sizing: border-box; | ||
| cursor: pointer; | ||
| font: inherit; | ||
| -webkit-text-decoration: none; | ||
| text-decoration: none; | ||
| margin: 0; | ||
| background: transparent; | ||
| overflow: visible; | ||
| text-transform: none; | ||
| color: inherit; | ||
| outline: none; | ||
| border: none; | ||
| padding: 0; | ||
| text-align: inherit; | ||
| line-height: 0; | ||
| padding: 12px; | ||
| } | ||
|
|
||
| .c1:focus { | ||
| outline: none; | ||
| box-shadow: 0 0 2px 2px #6FFFB0; | ||
| } | ||
|
|
||
| .c1:focus > circle, | ||
| .c1:focus > ellipse, | ||
| .c1:focus > line, | ||
| .c1:focus > path, | ||
| .c1:focus > polygon, | ||
| .c1:focus > polyline, | ||
| .c1:focus > rect { | ||
| outline: none; | ||
| box-shadow: 0 0 2px 2px #6FFFB0; | ||
| } | ||
|
|
||
| .c1:focus::-moz-focus-inner { | ||
| border: 0; | ||
| } | ||
|
|
||
| .c1:focus:not(:focus-visible) { | ||
| outline: none; | ||
| box-shadow: none; | ||
| } | ||
|
|
||
| .c1:focus:not(:focus-visible) > circle,.c1:focus:not(:focus-visible) > ellipse, | ||
| .c1:focus:not(:focus-visible) > line,.c1:focus:not(:focus-visible) > path, | ||
| .c1:focus:not(:focus-visible) > polygon,.c1:focus:not(:focus-visible) > polyline, | ||
| .c1:focus:not(:focus-visible) > rect { | ||
| outline: none; | ||
| box-shadow: none; | ||
| } | ||
|
|
||
| .c1:focus:not(:focus-visible)::-moz-focus-inner { | ||
| border: 0; | ||
| } | ||
|
|
||
| @media only screen and (max-width:768px) { | ||
| .c0 { | ||
| padding-right: 6px; | ||
| } | ||
| } | ||
|
|
||
| <div> | ||
| <div | ||
| class="c0" | ||
| > | ||
| <button | ||
| class="c1" | ||
| data-testid="copy-address" | ||
| type="button" | ||
| > | ||
| <svg | ||
| aria-label="Copy" | ||
| class="c2" | ||
| viewBox="0 0 24 24" | ||
| > | ||
| <path | ||
| d="M9 15h8-8zm0-4h10H9zm0-4h4-4zm7-6v6h6M6 5H2v18h16v-4m4 0H6V1h11l5 5v13z" | ||
| fill="none" | ||
| stroke="#000" | ||
| stroke-width="2" | ||
| /> | ||
| </svg> | ||
| </button> | ||
| <span | ||
| class="c3" | ||
| > | ||
| oasis1 qqur xkga vtcj jytn eume clx5 9ds3 avja qg7f tqph | ||
| </span> | ||
| </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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import * as React from 'react' | ||
| import copy from 'copy-to-clipboard' | ||
| import { screen } from '@testing-library/dom' | ||
| import { render } from '@testing-library/react' | ||
| import userEvent from '@testing-library/user-event' | ||
|
|
||
| import { AddressBox } from '../index' | ||
|
|
||
| jest.mock('copy-to-clipboard') | ||
|
|
||
| const testAddress = 'oasis1qqurxkgavtcjjytneumeclx59ds3avjaqg7ftqph' | ||
|
|
||
| const renderComponent = () => render(<AddressBox address={testAddress} />) | ||
|
|
||
| describe('<AddressBox />', () => { | ||
| it('should render address properly', () => { | ||
| const { container } = renderComponent() | ||
| expect(container).toMatchSnapshot() | ||
| }) | ||
|
|
||
| it('should be able to copy address to clipboard', async () => { | ||
| renderComponent() | ||
| await userEvent.click(screen.getByTestId('copy-address')) | ||
| expect(copy).toHaveBeenCalledWith(testAddress) | ||
| }) | ||
|
|
||
| it('should be able to show a notification', async () => { | ||
| renderComponent() | ||
| jest.mocked(copy).mockReturnValue(true) // Copy must return true so that the notification is actually displayed | ||
| await userEvent.click(screen.getByTestId('copy-address')) | ||
| expect(await screen.getByText('account.addressCopied')).toBeInTheDocument() | ||
| }) | ||
| }) |
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.