-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* new ShareBtn component * add ShareBtn to control center * share button calls function to set the current URL, copy to the clipboard, and alert the user
- Loading branch information
1 parent
662f06e
commit 42ea6e4
Showing
6 changed files
with
60 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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
12 changes: 12 additions & 0 deletions
12
src/components/Tree/ControlCenter/Controls/ShareBtn/ShareBtn.spec.tsx
This file contains 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,12 @@ | ||
import '@testing-library/jest-dom'; | ||
import { screen } from '@testing-library/react'; | ||
import { ShareBtn } from 'components/Tree/ControlCenter/Controls/ShareBtn/ShareBtn'; | ||
import { renderWithProviders } from 'test-utils'; | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
describe('ShareBtn', () => { | ||
test('render a button with aria label "share" ', () => { | ||
renderWithProviders(<ShareBtn />); | ||
expect(screen.getByRole('button', { name: /share/i })).toBeInTheDocument(); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
src/components/Tree/ControlCenter/Controls/ShareBtn/ShareBtn.tsx
This file contains 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,14 @@ | ||
import { useUrl } from 'hooks/useUrl/useUrl'; | ||
import { LuShare } from 'react-icons/lu'; | ||
import { ControlButton } from 'reactflow'; | ||
|
||
/** Button to generate a shareable URL .*/ | ||
export const ShareBtn = () => { | ||
const { copyTreeUrlToClipboard } = useUrl(); | ||
|
||
return ( | ||
<ControlButton aria-label="share diagram" onClick={copyTreeUrlToClipboard}> | ||
<LuShare className="font-bold" /> | ||
</ControlButton> | ||
); | ||
}; |
This file contains 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 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