Merge pull request #3160 from appwrite/refactor/remove-cloud-card-route

Remove the Cloud public beta card route
This commit is contained in:
Harsh Mahajan authored and GitHub committed 2026-08-14 18:18:56 +05:30
commit 36236db1ef
12 files changed
+8 -1019

No files matched your search

-3
View File
@@ -41,7 +41,6 @@
"nanotar": "^0.3.0",
"pretty-bytes": "^6.1.1",
"remarkable": "^2.0.1",
"svelte-confetti": "^1.4.0",
"three": "^0.181.2",
"tippy.js": "^6.3.7",
},
@@ -1339,8 +1338,6 @@
"svelte-check": ["svelte-check@4.5.0", "", { "dependencies": { "@jridgewell/trace-mapping": "^0.3.25", "chokidar": "^4.0.1", "fdir": "^6.2.0", "picocolors": "^1.0.0", "sade": "^1.7.4" }, "peerDependencies": { "svelte": "^4.0.0 || ^5.0.0-next.0", "typescript": ">=5.0.0" }, "bin": { "svelte-check": "bin/svelte-check" } }, "sha512-9lNwPxCLWniFvQIcEv1LFqjIxcFtO3smb5+5BKbRJ3ttL4o2lXCej5rLF4DAnfLPI66oaA81vAxw6ILdIWI7kA=="],
"svelte-confetti": ["svelte-confetti@1.4.0", "", { "peerDependencies": { "svelte": "^4.0.0" } }, "sha512-B0woNwpsFGwhkEoP48BIDQgvW0bMxPhavLVD+E+tsTWevlpr1aiz1S2wA8ArIXX957BiaZWHRHKmI5/pFRDbdg=="],
"svelte-eslint-parser": ["svelte-eslint-parser@1.7.1", "", { "dependencies": { "eslint-scope": "^8.2.0", "eslint-visitor-keys": "^4.0.0", "espree": "^10.0.0", "postcss": "^8.4.49", "postcss-scss": "^4.0.9", "postcss-selector-parser": "^7.0.0", "semver": "^7.7.2" }, "peerDependencies": { "svelte": "^3.37.0 || ^4.0.0 || ^5.0.0" }, "optionalPeers": ["svelte"] }, "sha512-mmwwKL9L/MB0QyBKdfyWxGjDuQfEyzxWy5S9Kkd0O/V5XD57MQ33KQtXrO6vKLuP6PIt8CRozvOX1mxpcRTqUg=="],
"svelte-motion": ["svelte-motion@0.12.2", "", { "dependencies": { "@types/react": "^18.2.42", "framesync": "^6.1.2", "popmotion": "^11.0.5", "style-value-types": "5.1.2", "tslib": "^2.6.2" }, "peerDependencies": { "svelte": ">=3.35.0 || ^4.0.0 || ^5.0.0 || ^5.0.0-next.0" } }, "sha512-7RrdRz9iVP55B9HT/C0hYW3pyrKlF61kAby/AkDtOAP0uHFQDrfd0qQetDC81cEsK9b40jt+jfcqSAXcA7LPEw=="],
-1
View File
@@ -55,7 +55,6 @@
"nanotar": "^0.3.0",
"pretty-bytes": "^6.1.1",
"remarkable": "^2.0.1",
"svelte-confetti": "^1.4.0",
"three": "^0.181.2",
"tippy.js": "^6.3.7"
},
+7
View File
@@ -0,0 +1,7 @@
import { getApiEndpoint } from '$lib/stores/sdk';
export function getCampaignImageUrl(image: string) {
const endpoint = getApiEndpoint();
const url = new URL(image, endpoint);
return url.toString();
}
+1 -1
View File
@@ -7,7 +7,7 @@
import LoginLight from '$lib/images/login/login-light-mode.png';
import { app } from '$lib/stores/app';
import { Typography, Layout, Avatar } from '@appwrite.io/pink-svelte';
import { getCampaignImageUrl } from '$routes/(public)/card/helpers';
import { getCampaignImageUrl } from '$lib/helpers/campaign';
import { isSmallViewport } from '$lib/stores/viewport';
import type { Models } from '@appwrite.io/console';
-29
View File
@@ -1,29 +0,0 @@
import { readable, type Readable } from 'svelte/store';
function isCurrentWindowFocused(): boolean {
if (!window) return false;
if (!window.document) return false;
if (typeof window.document.hasFocus !== 'function') return false;
return window.document.hasFocus();
}
export function windowFocusStore(): Readable<boolean> {
const visibility = readable(isCurrentWindowFocused(), (set) => {
function handler() {
set(isCurrentWindowFocused());
}
if (window) {
window.addEventListener('focus', handler);
window.addEventListener('blur', handler);
return () => {
window.removeEventListener('focus', handler);
window.removeEventListener('blur', handler);
};
}
});
return visibility;
}
-1
View File
@@ -331,7 +331,6 @@
<CommandCenter />
<Shell
showSideNavigation={page.url.pathname !== '/' &&
!page.url.pathname.includes(base + '/card') &&
!page.url.pathname.includes(base + '/onboarding')}
showHeader={!page.url.pathname.includes(base + '/onboarding/create-project')}
showFooter={!page.url.pathname.includes(base + '/onboarding/create-project')}
-9
View File
@@ -1,9 +0,0 @@
<script>
import { Shell } from '$lib/layout';
import Footer from '$lib/layout/footer.svelte';
</script>
<Shell>
<slot />
<Footer slot="footer" />
</Shell>
-10
View File
@@ -1,10 +0,0 @@
import { isCloud } from '$lib/system';
import { redirect } from '@sveltejs/kit';
export async function load({ parent }) {
if (!isCloud) redirect(303, '/');
const { account } = await parent();
if (!account) redirect(303, '/login');
redirect(303, `/card/${account.$id}`);
}
-458
View File
@@ -1,458 +0,0 @@
<script lang="ts" context="module">
// Helpers
const round = (num: number, fix = 3) => parseFloat(num.toFixed(fix));
const clamp = (num: number, min = -20, max = 20) => Math.min(Math.max(num, min), max);
function isTouchEvent(e: MouseEvent | TouchEvent): e is TouchEvent {
return e.type === 'touchmove';
}
</script>
<script lang="ts">
import { windowFocusStore } from '$lib/stores/windowFocus';
import { spring } from 'svelte/motion';
let cardEl: HTMLDivElement | undefined;
export let active = false;
export let isFlipped = false;
export let base64: { front: string; back: string };
let interacting = false;
const springR = { stiffness: 0.066, damping: 0.25 };
const springD = { stiffness: 0.03, damping: 0.45 };
const THICKNESS = 3;
let springRotate = spring({ x: 0, y: 0 }, springR);
let springGlare = spring({ x: 50, y: 50, o: 0.25 }, springR);
let springBackground = spring({ x: 50, y: 50 }, springR);
let springRotateDelta = spring({ x: 0, y: 0 }, springD);
let springTranslate = spring({ x: 0, y: 0 }, springD);
let springScale = spring(1, springD);
let angle = 0;
let centerProximity = spring(0, springR);
let springRotateZ = spring(-15, springD);
// Events
const interact = (e: MouseEvent | TouchEvent) => {
if (!active) return;
interacting = true;
const clientX = isTouchEvent(e) ? e.touches[0].clientX : e.clientX;
const clientY = isTouchEvent(e) ? e.touches[0].clientY : e.clientY;
const el = e.target as HTMLElement;
const rect = el.getBoundingClientRect(); // get element's current size/position
const absolute = {
x: clientX - rect.left, // get mouse position from left
y: clientY - rect.top // get mouse position from right
};
const percent = {
x: round((100 / rect.width) * absolute.x),
y: round((100 / rect.height) * absolute.y)
};
const center = {
x: percent.x - 50,
y: (percent.y - 50) * (isFlipped ? -1 : 1)
};
springBackground.stiffness = springR.stiffness;
springBackground.damping = springR.damping;
springBackground.set({
x: round(50 + percent.x / 4 - 12.5),
y: round(50 + percent.y / 3 - 16.67)
});
springRotate.stiffness = springR.stiffness;
springRotate.damping = springR.damping;
springRotate.set({
x: round(-(center.x / 3.5)),
y: round(center.y / 2)
});
springGlare.stiffness = springR.stiffness;
springGlare.damping = springR.damping;
springGlare.set({
x: percent.x,
y: percent.y,
o: 1
});
// get angle of mouse position relative to center of element
angle = Math.atan2(center.y, center.x) * (180 / Math.PI);
// get proximity to center of element. 0 = center, 1 = edge
$centerProximity = Math.sqrt(center.x * center.x + center.y * center.y) / 50 - 0.1;
};
const interactEnd = (_: unknown, delay = 500) => {
if (!active) return;
setTimeout(function () {
const snapStiff = 0.01;
const snapDamp = 0.06;
interacting = false;
springRotate.stiffness = snapStiff;
springRotate.damping = snapDamp;
springRotate.set({ x: 0, y: 0 });
springGlare.stiffness = snapStiff;
springGlare.damping = snapDamp;
springGlare.set({ x: 50, y: 50, o: 0 });
springBackground.stiffness = snapStiff;
springBackground.damping = snapDamp;
springBackground.set({ x: 50, y: 50 });
$centerProximity = 0;
}, delay);
};
const setCenter = () => {
if (!cardEl) return;
const rect = cardEl.getBoundingClientRect(); // get element's size/position
const view = document.documentElement; // get window/viewport size
const delta = {
x: round(view.clientWidth / 2 - rect.x - rect.width / 2),
y: round(view.clientHeight / 2 - rect.y - rect.height / 2)
};
springTranslate.set({
x: delta.x,
y: delta.y
});
};
const popover = () => {
if (!cardEl) return;
const rect = cardEl.getBoundingClientRect(); // get element's size/position
let delay = 100;
let scaleW = (window.innerWidth / rect.width) * 0.65;
let scaleH = (window.innerHeight / rect.height) * 0.65;
let scaleF = 1.5;
setCenter();
delay = 1000;
springRotateDelta.set({
x: 360,
y: 0
});
springRotateZ.set(0);
springScale.set(Math.min(scaleW, scaleH, scaleF));
interactEnd(null, delay);
};
const retreat = () => {
springScale.set(1);
springTranslate.set({ x: 0, y: 0 });
springRotateDelta.set({ x: 0, y: 0 });
springRotate.set({ x: 0, y: 0 });
springGlare.set({ x: 50, y: 50, o: 0 });
$centerProximity = 0;
springRotateZ.set(-15);
};
const handleClick = () => {
active = !active;
};
const windowKeyDown = (e: KeyboardEvent) => {
if (e.key === 'q') {
springRotateDelta.update((old) => {
return {
...old,
x: old.x + 360
};
});
}
if (!active) return;
if (e.key === 'q') {
isFlipped = !isFlipped;
} else if (e.key === 'Escape') {
active = false;
}
};
$: if (!active) {
isFlipped = false;
} else {
springRotateDelta.update((old) => ({
x: isFlipped ? 180 : 360,
y: old.y
}));
}
// Reactive
$: if (active) {
popover();
interacting = true;
} else {
retreat();
}
windowFocusStore().subscribe((focused) => {
if (focused) {
active = false;
springScale.set(1, { hard: true });
springTranslate.set({ x: 0, y: 0 }, { hard: true });
springRotateDelta.set({ x: 0, y: 0 }, { hard: true });
springRotate.set({ x: 0, y: 0 }, { hard: true });
springRotateZ.set(-15, { hard: true });
centerProximity.set(0, { hard: true });
}
});
$: styles = `
--mx: ${$springGlare.x}%;
--my: ${$springGlare.y}%;
--tx: ${$springTranslate.x}px;
--ty: ${$springTranslate.y}px;
--s: ${$springScale};
--o: ${$springGlare.o};
--rx: ${$springRotate.x + $springRotateDelta.x}deg;
--ry: ${$springRotate.y + $springRotateDelta.y}deg;
--rz: ${$springRotateZ}deg;
--pos: ${$springBackground.x}% ${$springBackground.y}%;
--posx: ${$springBackground.x}%;
--posy: ${$springBackground.y}%;
--hyp: ${clamp(
Math.sqrt(
($springGlare.y - 50) * ($springGlare.y - 50) +
($springGlare.x - 50) * ($springGlare.x - 50)
) / 50,
0,
1
)};
--angle: ${angle}deg;
--center: ${$centerProximity};
`;
</script>
<svelte:window on:keydown={windowKeyDown} />
<div class="cb-card" class:active class:interacting style={styles} bind:this={cardEl}>
<div class="card__translator">
<button
class="card__rotator"
aria-label="Expand the Card"
tabindex="0"
on:pointermove={interact}
on:mouseout={interactEnd}
on:click={handleClick}
on:blur={() => {
/* noop */
}}>
<div class="card__back">
<img
class="invisible"
src={base64.back}
alt="The back of the Card"
loading="lazy"
width="450"
height="274" />
<img
class="abs"
src={base64.back}
alt="The back of the Card"
loading="lazy"
width="450"
height="274" />
<div class="card__glare"></div>
</div>
{#each new Array(THICKNESS) as _, i (i)}
<div class="card__thick" style:--i={i + 1}></div>
{/each}
<div class="card__front" style:--thickness={THICKNESS}>
<img class="invisible" src={base64.front} alt="" />
<img class="abs" src={base64.front} alt="The front of the card" />
<div class="card__glare"></div>
</div>
</button>
</div>
</div>
<style lang="scss">
.invisible {
opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
.cb-card,
.cb-card * {
transition: none !important;
animation: none !important;
pointer-events: none !important;
}
}
:root {
--mx: 50%;
--my: 50%;
--s: 1;
--o: 0;
--tx: 0px;
--ty: 0px;
--rx: 0deg;
--ry: 0deg;
--pos: 50% 50%;
--posx: 50%;
--posy: 50%;
--hyp: 0;
}
:global(.theme-dark) .cb-card {
--shadow-clr: transparent;
}
.cb-card {
--radius: 12px;
--shadow-clr: hsl(var(--color-neutral-30));
z-index: calc(var(--s) * 100);
transform: translate3d(0, 0, 0.1px);
-webkit-transform: translate3d(0, 0, 0.1px);
will-change: transform, visibility;
transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
&.interacting {
z-index: calc(var(--s) * 120);
}
}
.cb-card.active .card__translator,
.cb-card.active .card__rotator {
touch-action: none;
}
.card__translator,
.card__rotator {
display: grid;
perspective: 600px;
transform-origin: center;
-webkit-transform-origin: center;
will-change: transform;
}
.card__translator {
width: auto;
position: relative;
transform: translate3d(var(--tx), var(--ty), 0) scale(var(--s));
-webkit-transform: translate3d(var(--tx), var(--ty), 0) scale(var(--s));
}
.card__rotator {
-webkit-transform: rotateY(var(--rx)) rotateX(var(--ry)) rotateZ(var(--rz));
-webkit-transform-style: preserve-3d;
transform: rotateY(var(--rx)) rotateX(var(--ry)) rotateZ(var(--rz));
transform-style: preserve-3d;
box-shadow: 0px 10px 20px -5px var(--shadow-clr);
border-radius: var(--radius);
outline: none;
appearance: none;
-webkit-appearance: none;
border: none;
background: top;
padding: 0;
:global(*) {
width: 100%;
display: grid;
grid-area: 1/1;
border-radius: var(--radius);
image-rendering: optimizeQuality;
transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
}
img {
outline: 1px solid transparent;
height: auto;
}
}
.card__thick {
background-color: transparent;
position: absolute;
width: 100%;
height: 100%;
transform: translateZ(calc(var(--i) * 1px));
}
.card__back {
transform: rotateY(180deg) translateZ(0px);
-webkit-transform: rotateY(180deg) translateZ(0px);
backface-visibility: hidden;
&::before {
--resolved-angle: calc(calc(var(--angle) * -1) + 60deg);
}
}
.card__front {
opacity: 1;
transition: opacity 0.33s ease-out;
transform: translateZ(calc(var(--thickness) * 1px));
position: relative;
backface-visibility: hidden;
* {
backface-visibility: hidden;
}
&::before {
--resolved-angle: calc(var(--angle) + 65deg);
}
}
.card__front,
.card__back {
.abs {
display: block;
position: absolute;
left: 50%;
top: 50%;
translate: -50% -50%;
width: 200%;
scale: calc(100 / 200);
max-inline-size: initial;
max-block-size: initial;
}
}
.card__front::before,
.card__back::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: conic-gradient(
from var(--resolved-angle),
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, 1) 7.5%,
rgba(255, 255, 255, 0) 15%
);
scale: 1.01;
border-radius: calc(var(--radius) * 1.2);
opacity: var(--center);
}
.card__glare {
border-radius: calc(var(--radius) + 3px);
transform: translateZ(1px);
z-index: 4;
background: radial-gradient(
farthest-corner circle at var(--mx) var(--my),
rgba(255, 255, 255, 0.8) 10%,
rgba(255, 255, 255, 0.65) 20%,
rgba(0, 0, 0, 0.5) 90%
);
mix-blend-mode: overlay;
opacity: calc(var(--o) * 0.5);
}
</style>
-433
View File
@@ -1,433 +0,0 @@
<script lang="ts">
import { browser } from '$app/environment';
import { Modal } from '$lib/components';
import Code from '$lib/components/code.svelte';
import Button from '$lib/elements/forms/button.svelte';
import { copy } from '$lib/helpers/copy';
import { addNotification } from '$lib/stores/notifications';
import { Confetti } from 'svelte-confetti';
import { fade } from 'svelte/transition';
import Card from '../Card.svelte';
import { base } from '$app/paths';
export let data;
const base64 = data.base64;
const variant = data.isOwner ? 'owner' : 'external';
const userId = data.userId;
const { frontImg } = data.imgUrls;
let triggerConfettiKey = 1;
const confettiColors = [
'hsl(var(--color-primary-100))',
'hsl(var(--color-primary-200))',
'hsl(var(--color-primary-300))',
'#F05088',
'#FF86BB',
'#FFFFFF80'
];
let cardActive = false;
let cardIsFlipped = false;
let showEmbedCode = false;
$: title =
variant === 'owner' ? 'Welcome to Cloud Public Beta' : 'Join Appwrite Cloud Public Beta';
$: shareableLink =
typeof window !== 'undefined' ? `${window.location.origin}/card/${userId}` : '';
$: embedCode = [
`<a href="${shareableLink}">`,
`\t<img width="350" src="${frontImg}" alt="Appwrite Cloud Card" />`,
`</a>`
].join('\n');
$: twitterText = encodeURIComponent(
[
`Guess what I just received? 💳 My personalized Cloud card from @appwrite! 🚀`,
``,
`Appwrite Cloud just announced their Public Beta!`,
``,
`🌥️ Sign up now and claim your own card at ${shareableLink}`,
``,
`#AppwriteCloud`
].join('\n')
);
function copyShareableLink() {
copy(shareableLink);
addNotification({
message: 'The link has been copied',
type: 'success'
});
}
function copyEmbedCode() {
copy(embedCode);
addNotification({
message: 'Embed code has been copied',
type: 'success'
});
showEmbedCode = false;
}
const seo = {
title: 'Appwrite Cloud Card',
description:
'Cloud is live in public beta, create your Cloud account and unlock your exclusive card!'
};
</script>
<svelte:head>
<!-- HTML Meta Tags -->
<title>{seo.title}</title>
<meta name="description" content={seo.description} />
</svelte:head>
<div class="wrapper">
<div class="card">
<h3 class="heading-level-3 no-text-select">
{title}
<button class="confetti-btn" on:click={() => triggerConfettiKey++}>
🎉
{#each Array(triggerConfettiKey) as _, i (i)}
<Confetti
delay={i === 0 ? [500, 500] : [0, 100]}
x={[0.5, 2]}
y={[0, 1.5]}
amount={30}
fallDistance="50px"
colorArray={confettiColors} />
{/each}
</button>
</h3>
<div class="content">
<div>
{#if variant === 'owner'}
<h4 class="eyebrow-heading-3 is-only-desktop">Share your card</h4>
{:else if variant === 'external'}
<h4 class="eyebrow-heading-3 is-only-desktop">Share card</h4>
{/if}
{#if variant === 'external'}
<a
href={`${base}/register`}
class="button u-width-full-line u-main-center u-margin-block-start-16 external-btn-top"
data-sveltekit-reload>Claim your card</a>
{/if}
</div>
</div>
<img class="card-preview" src={base64.front} alt="The front of the card" />
<ul class="buttons-list u-margin-block-start-16">
<li class="buttons-list-item">
<a
class="button is-text"
href="https://twitter.com/intent/tweet?text={twitterText}"
target="_blank"
rel="noreferrer">
<span class="icon-twitter" aria-hidden="true"></span>
<span class="text">Tweet it</span>
</a>
</li>
{#if variant === 'owner'}
<li class="buttons-list-item embed-btn">
<button class="button is-text" on:click={() => (showEmbedCode = true)}>
<span class="icon-code" aria-hidden="true"></span>
<span class="text">Get embed code</span>
</button>
</li>
{/if}
<li class="buttons-list-item">
<button class="button is-text" on:click={copyShareableLink}>
<span class="icon-link" aria-hidden="true"></span>
<span class="text">Get a link</span>
</button>
</li>
</ul>
<div class="card-footer">
{#if variant === 'owner'}
<a data-sveltekit-reload href={base} class="button">Go to console</a>
{:else}
<a data-sveltekit-reload href={`${base}/card`} class="button external-btn-bottom"
>Claim your card</a>
{/if}
</div>
</div>
<div class="cbc-wrapper">
{#if !cardActive}
<div class="cbc-confetti" transition:fade>
<Confetti
x={[-1.75, 1.85]}
y={[-1.875, 1]}
amount={100}
size={10}
infinite
delay={[2000, 7000]}
colorArray={confettiColors}
fallDistance="50px" />
</div>
{/if}
{#if browser}
<Card bind:active={cardActive} bind:isFlipped={cardIsFlipped} {base64} />
{/if}
</div>
{#if cardActive}
<div
class="overlay"
on:click={() => (cardActive = false)}
on:keydown={() => {
/* no-op */
}}
transition:fade
role="button"
tabindex="0">
</div>
{/if}
<div class="controls" class:invisible={!cardActive}>
<button
class="button is-text"
on:click={() => (cardIsFlipped = !cardIsFlipped)}
aria-label="Rotate card">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true">
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M2 11C2 8.2 6.5 6 12 6C17.5 6 22 8.2 22 11C22 12.8414 20.0779 14.3752 17.2449 15.2644C16.615 15.4621 16 14.9707 16 14.3105C16 13.8351 16.3283 13.4267 16.7816 13.2837C18.8093 12.6442 20 11.6237 20 11C20 9.9 17 8 12 8C7 8 4 9.9 4 11C4 11.7821 6.79551 13.1137 9.91054 13.7336C10.0265 13.7566 10.1405 13.7886 10.2509 13.8305C10.308 13.8187 10.3669 13.8125 10.4273 13.8125L9.26357 12.6004C8.9121 12.2343 8.9121 11.6407 9.26357 11.2746C9.61504 10.9085 10.1849 10.9085 10.5364 11.2746L13.2364 14.0871C13.4051 14.2629 13.5 14.5013 13.5 14.75C13.5 14.9986 13.4051 15.2371 13.2364 15.4129L10.5364 18.2254C10.1849 18.5915 9.61504 18.5915 9.26357 18.2254C8.9121 17.8593 8.9121 17.2657 9.26357 16.8996L10.2838 15.8369C6.24683 15.1056 2 13.1614 2 11Z"
fill="currentColor" />
</svg>
<span class="text">Spin</span>
</button>
</div>
</div>
<Modal title="Get Embed Code" bind:show={showEmbedCode}>
<div class="u-overflow-hidden">
<Code language="html" code={embedCode} noMargin />
</div>
<svelte:fragment slot="footer">
<Button on:click={copyEmbedCode}>Copy</Button>
</svelte:fragment>
</Modal>
<style lang="scss">
:global(.theme-dark) .wrapper {
--glow: hsl(var(--color-primary-100));
--beta-bg: hsl(var(--color-neutral-120));
--beta-fg: hsl(var(--color-neutral-0));
--sep-clr: hsl(var(--color-neutral-150));
}
:global(.main-content) {
display: flex;
flex-direction: column;
align-items: stretch;
flex-grow: 1;
}
.wrapper {
--glow: transparent;
--beta-bg: rgba(240, 46, 101, 0.16);
--beta-fg: rgba(240, 46, 101, 0.8);
--sep-clr: hsl(var(--color-neutral-10));
display: grid;
place-items: center;
justify-content: center;
flex-grow: 1;
position: relative;
grid-template-columns: 620px 400px;
padding-block: 4rem;
gap: max(4rem, 10vw);
overflow: hidden;
}
.card {
max-width: 660px;
.content {
display: flex;
align-items: center;
gap: 1.5rem;
margin-block-start: 2.5rem;
}
.card-preview {
display: none;
}
.card-footer {
display: flex;
justify-content: flex-end;
border-top: 1px solid var(--sep-clr);
margin-block-start: 2rem;
padding-block-start: 2rem;
margin-inline: -2rem;
padding-inline: 2rem;
}
}
.cbc-wrapper {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 500px;
position: relative;
}
.cbc-confetti {
position: absolute;
top: 30%;
left: 50%;
translate: -50% -50%;
}
@keyframes shake {
0% {
translate: 0;
}
25% {
translate: 0 -4px;
}
50% {
translate: 0 0px;
}
75% {
translate: 0 0px;
}
100% {
translate: 0 0px;
}
}
.confetti-btn {
animation: shake 2000ms ease infinite;
user-select: none;
display: inline-flex;
place-items: center;
position: relative;
:global(.confetti-holder) {
position: absolute !important;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
.controls {
display: flex;
align-items: center;
gap: 0.5rem;
position: absolute;
bottom: 5vh;
left: 50%;
translate: -50%;
transition: opacity 250ms ease;
&.invisible {
opacity: 0;
}
}
.buttons-list-item:first-child .button {
padding-inline-start: 0;
}
.overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: hsl(var(--p-body-bg-color));
backdrop-filter: blur(80px);
opacity: 0.5;
}
.external-btn-top {
display: none;
}
.no-text-select {
user-select: none;
}
@media (max-width: 1024px) {
.external-btn-top {
display: flex;
}
.external-btn-bottom {
display: none !important;
}
.embed-btn {
order: 2;
border: none !important;
}
.wrapper {
display: block;
padding-block: 2rem;
max-width: min(100%, 500px);
margin: 0 auto;
}
.card {
background-color: transparent;
border: none;
padding-inline: 1rem;
padding-block: 0;
.content {
flex-direction: column;
align-items: stretch;
margin-block-start: 1rem;
padding-block-end: 2rem;
// border-block-end: 1px solid var(--sep-clr);
}
.card-preview {
display: block;
margin-block-start: 2rem;
}
.buttons-list {
flex-wrap: wrap;
justify-content: center;
.buttons-list-item:last-child {
border: none !important;
}
}
.card-footer {
border: none;
padding-block-start: 0;
.button {
display: grid;
place-items: center;
text-align: center;
width: 100%;
}
}
}
.cbc-wrapper {
display: none;
}
}
</style>
-57
View File
@@ -1,57 +0,0 @@
import { getApiEndpoint } from '$lib/stores/sdk';
import { redirect } from '@sveltejs/kit';
function getCardImgUrls(userId: string, endpoint: string) {
const resolved = endpoint;
const frontImg = `${resolved}/cards/cloud?userId=${userId}`;
const backImg = `${resolved}/cards/cloud-back?userId=${userId}`;
const ogImg = `${resolved}/cards/cloud-og?userId=${userId}`;
return { frontImg, backImg, ogImg };
}
async function urlContentToDataUri(url: string): Promise<string> {
const res = await fetch(url);
const blob = await res.blob();
return await new Promise((callback) => {
const reader = new FileReader();
reader.onload = function () {
if (typeof this.result !== 'string') return '';
callback(this.result);
};
reader.readAsDataURL(blob);
});
}
export async function load({ params, parent }) {
const { account } = await parent();
const endpoint = getApiEndpoint();
const userId = params.uid;
const { frontImg, backImg } = getCardImgUrls(userId, endpoint);
try {
const res = await fetch(frontImg);
if (!res.ok) {
redirect(303, '/');
}
return {
userId: params.uid,
base64: {
front: await urlContentToDataUri(frontImg),
back: await urlContentToDataUri(backImg)
},
isOwner: account && account.$id === userId,
imgUrls: {
frontImg,
backImg
}
};
} catch (e) {
console.error(e);
redirect(303, '/');
}
}
-17
View File
@@ -1,17 +0,0 @@
import { getApiEndpoint } from '$lib/stores/sdk';
export function getCardImgUrls(userId: string, endpoint: string) {
const resolved = endpoint;
const frontImg = `${resolved}/cards/cloud?userId=${userId}`;
const backImg = `${resolved}/cards/cloud-back?userId=${userId}`;
const ogImg = `${resolved}/cards/cloud-og?userId=${userId}`;
return { frontImg, backImg, ogImg };
}
export function getCampaignImageUrl(image: string) {
const endpoint = getApiEndpoint();
const url = new URL(image, endpoint);
return url.toString();
}