-
Notifications
You must be signed in to change notification settings - Fork 0
Add share button #22
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
Add share button #22
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e449334
Add share button (#21)
da6c171
Add share dialogue and scrolling to main section (#21)
4f5c860
Fix share query parameter, extend config files for debugging
18276db
Remove share= URL parameter
v-ji 46e6063
Fix scroll on load timing issues, wait for DOM to be ready
v-ji 34d3790
Use for Sharing URL, use showShareButton
9b71475
Update config files
f5bdf43
Bind sequence to Carousel component to keep URL updated
aa183ed
Remove comment
v-ji 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,4 @@ node_modules | |
| !.env.example | ||
| vite.config.js.timestamp-* | ||
| vite.config.ts.timestamp-* | ||
| .vscode | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,90 @@ | ||
| <script lang="ts"> | ||
| import { locale } from "$lib/stores/locale" | ||
| import { fade } from "svelte/transition" | ||
|
|
||
| let { sequence } = $props<{ sequence: number[] }>() | ||
|
|
||
| // track if url has been copied to clipboard | ||
| let urlCopied: boolean = $state(false) | ||
|
|
||
| const getShareUrl = () => | ||
| window.location.origin + window.location.pathname + "#" + sequence.join("") | ||
| // function to copy url including sequence to clipboard | ||
| async function copyUrlToClipboard(event: MouseEvent) { | ||
| try { | ||
| const url = getShareUrl() | ||
| console.log("URL: ", url) | ||
|
v-ji marked this conversation as resolved.
Outdated
|
||
| await navigator.clipboard.writeText(url) | ||
| urlCopied = true | ||
|
|
||
| setTimeout(() => { | ||
| urlCopied = false | ||
| ;(event.target as HTMLButtonElement).blur() // remove focus ring from the clicked button | ||
| }, 3000) | ||
| } catch (err) { | ||
| console.error("Failed to copy URL to clipboard:", err) | ||
| } | ||
| } | ||
|
|
||
| let showDialogue: boolean = $state(false) | ||
| function toggleDialogue(event: MouseEvent) { | ||
| showDialogue = !showDialogue | ||
| ;(event.target as HTMLButtonElement).blur() | ||
| } | ||
| </script> | ||
|
|
||
| <!-- Share Button that opens dialogue for copying url with current sequence --> | ||
| <div class="fixed right-6 bottom-6 flex items-center space-x-2"> | ||
| <!-- {#if urlCopied} | ||
| <div class="rounded-full bg-sky-800 px-3 py-2 text-white shadow-lg"> | ||
| {$locale === "de" ? "Link zum Teilen kopiert!" : "Link copied for sharing!"} | ||
| </div> | ||
| {/if} --> | ||
| {#if showDialogue} | ||
| <div | ||
| transition:fade={{ duration: 200 }} | ||
| class="absolute right-20 bottom-0 rounded-lg border border-gray-300 bg-white p-3 shadow-lg" | ||
| > | ||
| <button | ||
| class="absolute top-2 right-2 text-gray-500 hover:text-gray-700 focus:outline-none" | ||
| onclick={toggleDialogue} | ||
| > | ||
| ✕ | ||
| </button> | ||
| <p class="text-gray-700"> | ||
| {$locale === "de" | ||
| ? "Teile deinen gewürfelten Einakter:" | ||
| : "Share your randomised one-act play:"} | ||
| </p> | ||
| <div | ||
| class="mt-2 flex flex-col items-center space-y-2 space-x-2 sm:flex-row sm:space-y-0 sm:space-x-2" | ||
| > | ||
| <input type="text" class="rounded border bg-gray-100 p-1" value={getShareUrl()} readonly /> | ||
| <button | ||
| class="w-32 rounded bg-sky-800 p-1 text-white transition hover:bg-sky-700 focus:ring-2 focus:ring-sky-500 focus:ring-offset-2" | ||
| onclick={copyUrlToClipboard} | ||
| > | ||
| {urlCopied | ||
| ? $locale === "de" | ||
| ? "Link kopiert!" | ||
| : "Link copied!" | ||
| : $locale === "de" | ||
| ? "Link kopieren" | ||
| : "Copy link"} | ||
| </button> | ||
| </div> | ||
| </div> | ||
| {/if} | ||
|
|
||
| <!-- Share Button --> | ||
| <button | ||
| onclick={toggleDialogue} | ||
| transition:fade={{ duration: 300 }} | ||
| class="flex h-18 w-18 cursor-pointer items-center justify-center rounded-full bg-sky-800 text-white shadow-lg transition-all hover:bg-sky-700 focus:ring-2 focus:ring-sky-500 focus:ring-offset-2 focus:outline-none" | ||
| aria-label={$locale === "de" ? "Dialog zum Teilen öffnen" : "Open share dialogue"} | ||
| title={$locale === "de" ? "Dialog zum Teilen öffnen" : "Open share dialogue"} | ||
| > | ||
| <!-- Share Icon --> | ||
| <img src="/src/lib/assets/share-icon.svg" alt="Share" class="h-5 w-5" /> | ||
| </button> | ||
| </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
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.