-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added action that copies event link to clipboard (#311)
* set up logs to test new description parser * Resolved bug in #309 * Started making progress on fix/281 * Added sliding effect and clipboard interaction * Move copy to clipboard button to right side * Update clipboard.svelte * Renamed icon to CopyLinkIcon * Made toast animation one dimensional * Added highlight effects to toasts per path * Fixed lint error, unused import
- Loading branch information
1 parent
c7e6310
commit 2969cd8
Showing
9 changed files
with
240 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512" | ||
><title>Link</title><path | ||
d="M208 352h-64a96 96 0 010-192h64M304 160h64a96 96 0 010 192h-64M163.29 256h187.42" | ||
fill="none" | ||
stroke="currentColor" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="36" /></svg> |
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,65 @@ | ||
<script lang="ts"> | ||
import { fly } from 'svelte/transition'; | ||
import { toasts, ToastType } from '$lib/stores/toasts'; | ||
</script> | ||
|
||
<section> | ||
{#each $toasts as toastItem (toastItem.id)} | ||
<div | ||
class="toast-item" | ||
class:error={toastItem.type === ToastType.Error} | ||
class:success={toastItem.type === ToastType.Success} | ||
class:info={toastItem.type === ToastType.Info} | ||
in:fly={{ y: 20 }} | ||
out:fly={{ y: -20 }} | ||
style={`--highlights: var(--acm-${toastItem.path}-rgb)`}> | ||
<img src="/assets/png/acm-shark.png" alt="acmCSUF Mascot: Frank the Shark" /> | ||
<p>{@html toastItem.content}</p> | ||
</div> | ||
{/each} | ||
</section> | ||
|
||
<style> | ||
:root { | ||
--success-rgb: 157, 231, 53; | ||
--error-rgb: 255, 67, 101; | ||
--info-rgb: 30, 108, 255; | ||
} | ||
section { | ||
position: fixed; | ||
z-index: 10000; | ||
bottom: 0; | ||
right: 50%; | ||
transform: translateX(50%); | ||
min-width: min(390px, 100%); | ||
} | ||
.toast-item { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 1em; | ||
margin: 32px 32px; | ||
padding: 2em; | ||
transition: all 0.15s ease-in-out; | ||
box-shadow: 0 6px 24px rgba(var(--highlights, --acm-general-rgb), 0.75); | ||
border: 2px solid rgb(var(--highlights, --acm-general-rgb)); | ||
transition: all 0.25s ease-in-out; | ||
border-radius: 30px; | ||
background-color: var(--acm-light); | ||
} | ||
.toast-item img { | ||
--img-width: 50px; | ||
width: var(--img-width); | ||
height: calc(var(--img-width) * 0.56); | ||
align-self: center; | ||
} | ||
@media (min-width: 800px) { | ||
section { | ||
right: 0; | ||
transform: translateX(0); | ||
} | ||
} | ||
</style> |
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
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,66 @@ | ||
import { acmGeneral } from '$lib/constants'; | ||
import { writable } from 'svelte/store'; | ||
|
||
const MAX_TOASTS = 4; | ||
const TOAST_TIMEOUT = 2e3; | ||
|
||
const numToasts = writable<number>(0); | ||
|
||
export enum ToastType { | ||
Success = 'success', | ||
Error = 'error', | ||
Info = 'info', | ||
} | ||
|
||
export interface Toast { | ||
id: number; | ||
content: string; | ||
type?: ToastType; | ||
dismissible?: boolean; | ||
timeout?: number; | ||
path?: string; | ||
} | ||
|
||
export const toasts = writable<Toast[]>([]); | ||
|
||
function makeToast( | ||
id: number, | ||
{ content, type, dismissible, timeout, path }: Omit<Toast, 'id'> | ||
): Required<Toast> { | ||
return { | ||
id, | ||
content: content, | ||
type: type ?? ToastType.Info, | ||
dismissible: dismissible ?? true, | ||
timeout: timeout ?? TOAST_TIMEOUT, | ||
path: path ?? acmGeneral.slug, | ||
}; | ||
} | ||
|
||
export function toast(props: Omit<Toast, 'id'>): void { | ||
numToasts.update((value: number) => { | ||
const nextToast = makeToast(value + 1, props); | ||
|
||
toasts.update((allToasts) => { | ||
postponeDismissal(nextToast.id, nextToast.timeout); | ||
|
||
while (allToasts.length > MAX_TOASTS - 1) { | ||
const currId = allToasts[0].id; | ||
dismissToast(currId); | ||
allToasts.shift(); | ||
} | ||
|
||
return [...allToasts, nextToast]; | ||
}); | ||
|
||
return nextToast.id; | ||
}); | ||
} | ||
|
||
export function postponeDismissal(id: number, timeout: number): void { | ||
setTimeout(() => dismissToast(id), timeout); | ||
} | ||
|
||
export function dismissToast(id: number): void { | ||
toasts.update((all) => all.filter((t) => t.id !== id)); | ||
} |
Oops, something went wrong.
2969cd8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: