-
Notifications
You must be signed in to change notification settings - Fork 1
Spread the word dialog #81
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
Open
aaronashby
wants to merge
13
commits into
main
Choose a base branch
from
spread-the-word-dialog
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
eccc9d2
Added share button
aaronashby 7132cc7
Installed font awesome packages
aaronashby 6676ffb
Merge main into branch
aaronashby 81b963a
Merge branch 'main' into spread-the-word-dialog
aaronashby c96edaf
Created "Spread the word!" copy button
aaronashby edff1bf
Added icons and fixed spacing
aaronashby 63dc662
Migrated icons to react-share
aaronashby 5ce701c
Move ShareOptions component to AutoRotatingTestimonialCarousel
aaronashby 9147e50
Add image copy and split share buttons
aaronashby 9ed8db0
Removed font awesome
aaronashby 2b35521
Merge branch 'main' into spread-the-word-dialog
aaronashby 27505d1
Reran yarn install and added CopyButton parent component for share bu…
aaronashby b3f1480
Changed share button url attrs to placeholder links
aaronashby 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
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
144 changes: 144 additions & 0 deletions
144
apps/frontend/src/containers/donations/ShareOptions.tsx
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,144 @@ | ||
| import { Button } from '@components/ui/button'; | ||
| import React, { useState } from 'react'; | ||
| import { | ||
| FacebookShareButton, | ||
| FacebookIcon, | ||
| XIcon, | ||
| TwitterShareButton, | ||
| LinkedinShareButton, | ||
| LinkedinIcon, | ||
| } from 'react-share'; | ||
|
|
||
| const ShareOptions = ({ activeSlideUrl }: { activeSlideUrl: string }) => { | ||
| const [isCopyingText, setIsCopyingText] = useState(false); | ||
| const [isCopyingImage, setIsCopyingImage] = useState(false); | ||
| const message = `Want to support your community? Join me in donating to the Fenway Community Center!\n\n${window.location.href}`; | ||
|
|
||
| const handleCopyTextClick = async () => { | ||
| try { | ||
| setIsCopyingText(true); | ||
| await navigator.clipboard.writeText(message); | ||
| setTimeout(() => setIsCopyingText(false), 1000); | ||
| } catch (err) { | ||
| console.error('Failed to copy message to clipboard'); | ||
| alert('Failed to copy message to clipboard'); | ||
| } | ||
| }; | ||
|
|
||
| const handleCopyImageClick = async () => { | ||
| try { | ||
| const response = await fetch(activeSlideUrl); | ||
| if (!response.ok) { | ||
| throw new Error('Failed to fetch image'); | ||
| } | ||
|
|
||
| const blob = await response.blob(); | ||
| const imageType = blob.type || 'image/png'; | ||
| const imageItem = new ClipboardItem({ [imageType]: blob }); | ||
| await navigator.clipboard.write([imageItem]); | ||
|
|
||
| setIsCopyingImage(true); | ||
| setTimeout(() => setIsCopyingImage(false), 1000); | ||
| } catch (err) { | ||
| console.error('Failed to copy image to clipboard', err); | ||
| alert('Failed to copy image to clipboard'); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div> | ||
| <div | ||
| className="flex flex-wrap justify-center gap-3" | ||
| style={{ marginTop: '1.5rem' }} | ||
| > | ||
| <Button | ||
| variant="unstyled" | ||
| size="sm" | ||
| style={{ | ||
| backgroundColor: '#007b64', | ||
| color: 'white', | ||
| padding: '1.5rem', | ||
| fontWeight: 'bold', | ||
| }} | ||
| className="w-[13rem] gap-3 rounded-[10px] min-h-[2.5rem] flex justify-center items-center text-center text-[1.3rem] hover:opacity-90 transition-opacity" | ||
| onClick={handleCopyTextClick} | ||
| > | ||
| {isCopyingText ? 'Copied!' : 'Copy message'} | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| viewBox="0 0 24 24" | ||
| width="24" | ||
| height="24" | ||
| fill="none" | ||
| stroke="#FFFFFF" | ||
| strokeWidth="2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| style={{ marginLeft: '10px' }} | ||
| > | ||
| <path | ||
| fill="none" | ||
| d="M12 2v13m4-9l-4-4l-4 4m-4 6v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8" | ||
| /> | ||
| </svg> | ||
| </Button> | ||
| <Button | ||
| variant="unstyled" | ||
| size="sm" | ||
| style={{ | ||
| backgroundColor: '#007b64', | ||
| color: 'white', | ||
| padding: '1.5rem', | ||
| fontWeight: 'bold', | ||
| }} | ||
| className="w-[13rem] gap-3 rounded-[10px] min-h-[2.5rem] flex justify-center items-center text-center text-[1.3rem] hover:opacity-90 transition-opacity" | ||
| onClick={handleCopyImageClick} | ||
| > | ||
| {isCopyingImage ? 'Copied!' : 'Copy image'} | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| viewBox="0 0 24 24" | ||
| width="24" | ||
| height="24" | ||
| fill="none" | ||
| stroke="#FFFFFF" | ||
| strokeWidth="2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| style={{ marginLeft: '10px' }} | ||
| > | ||
| <path | ||
| fill="none" | ||
| d="M12 2v13m4-9l-4-4l-4 4m-4 6v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8" | ||
| /> | ||
| </svg> | ||
| </Button> | ||
|
aaronashby marked this conversation as resolved.
Outdated
|
||
| </div> | ||
| <div | ||
| className="flex justify-center" | ||
| style={{ gap: '3rem', marginTop: '2rem' }} | ||
| > | ||
| <FacebookShareButton url={window.location.href}> | ||
| <FacebookIcon | ||
| className="rounded-full" | ||
| style={{ maxWidth: '2.5rem', height: 'auto' }} | ||
| /> | ||
| </FacebookShareButton> | ||
| <TwitterShareButton url={window.location.href}> | ||
| <XIcon | ||
| className="rounded-full" | ||
| style={{ maxWidth: '2.5rem', height: 'auto' }} | ||
| /> | ||
| </TwitterShareButton> | ||
| <LinkedinShareButton url={window.location.href}> | ||
| <LinkedinIcon | ||
| className="rounded-full" | ||
| style={{ maxWidth: '2.5rem', height: 'auto' }} | ||
| /> | ||
| </LinkedinShareButton> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ShareOptions; | ||
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
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
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.