web/donate: add a share card with qr and buttons

also:
- fixed more scaling quirks
- fixed thick icons
- fixed icon padding
This commit is contained in:
wukko 2024-08-09 14:35:55 +06:00
parent e45aa2bdf6
commit 21ef35ea20
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
8 changed files with 209 additions and 11 deletions

View file

@ -17,5 +17,7 @@
"card.option.15": "full lunch",
"card.option.30": "lunch for two",
"card.custom.submit": "donate custom amount"
"card.custom.submit": "donate custom amount",
"share.title": "share cobalt with a friend"
}

View file

@ -75,9 +75,10 @@
align-items: center;
font-size: 16px;
gap: 4px;
font-weight: 500;
}
@media screen and (max-width: 550px) {
@media screen and (max-width: 865px) {
:global(.donate-card) {
--donate-card-main-padding: 18px;
}

View file

@ -62,9 +62,11 @@
role="tab"
>
<div class="donation-type-icon"><IconCoin /></div>
<div class="donate-card-title">{$t("donate.card.once")}</div>
<div class="donate-card-subtitle">
{$t("donate.card.processor.stripe")}
<div class="donation-type-text">
<div class="donate-card-title">{$t("donate.card.once")}</div>
<div class="donate-card-subtitle">
{$t("donate.card.processor.stripe")}
</div>
</div>
</button>
<button
@ -76,9 +78,11 @@
role="tab"
>
<div class="donation-type-icon"><IconCalendarRepeat /></div>
<div class="donate-card-title">{$t("donate.card.monthly")}</div>
<div class="donate-card-subtitle">
{$t("donate.card.processor.liberapay")}
<div class="donation-type-text">
<div class="donate-card-title">{$t("donate.card.monthly")}</div>
<div class="donate-card-subtitle">
{$t("donate.card.processor.liberapay")}
</div>
</div>
</button>
</div>
@ -133,7 +137,7 @@
<style>
:global(#donation-box) {
max-width: 480px;
min-width: 350px;
padding: var(--donate-card-main-padding) 0;
}
@ -153,11 +157,22 @@
.donation-type {
width: 100%;
overflow: hidden;
gap: 2px;
}
.donation-type-icon {
display: flex;
}
.donation-type-icon :global(svg) {
width: 28px;
height: 28px;
stroke-width: 1.8px;
}
.donation-type-text {
display: flex;
flex-direction: column;
}
#donation-options {

View file

@ -0,0 +1,164 @@
<script lang="ts">
import { contacts } from "$lib/env";
import { t } from "$lib/i18n/translations";
import { openURL, copyURL, shareURL } from "$lib/download";
import DonateCardContainer from "$components/donate/DonateCardContainer.svelte";
import IconShare2 from "@tabler/icons-svelte/IconShare2.svelte";
import IconBrandGithub from "@tabler/icons-svelte/IconBrandGithub.svelte";
import IconBrandTwitter from "@tabler/icons-svelte/IconBrandTwitter.svelte";
import IconMoodSmileBeam from "@tabler/icons-svelte/IconMoodSmileBeam.svelte";
import CobaltQr from "$lib/icons/CobaltQR.svelte";
import CopyIcon from "$components/misc/CopyIcon.svelte";
const cobaltUrl = "https://cobalt.tools/";
let copied = false;
$: if (copied) {
setTimeout(() => {
copied = false;
}, 1500);
}
</script>
<DonateCardContainer id="share-box">
<div id="share-card-header">
<div class="share-header-icon"><IconMoodSmileBeam /></div>
<div class="donate-card-title">{$t("donate.share.title")}</div>
</div>
<div id="share-card-body">
<div id="share-qr">
<CobaltQr />
</div>
<div id="share-buttons">
<button
id="share-button-copy"
class="share-button"
on:click={async () => {
copyURL(cobaltUrl);
copied = true;
}}
aria-label={copied ? $t("a11y.dialog.saving.copied") : ""}
>
<div class="share-button-icon">
<CopyIcon check={copied} />
</div>
copy
</button>
<button
id="share-button-share"
class="share-button"
on:click={async () => shareURL(cobaltUrl)}
>
<div class="share-button-icon">
<IconShare2 />
</div>
share
</button>
<button
id="share-button-github"
class="share-button"
on:click={async () => {
openURL(contacts.github);
copied = true;
}}
>
<div class="share-button-icon">
<IconBrandGithub />
</div>
star
</button>
<button
id="share-button-twitter"
class="share-button"
on:click={async () => {
openURL(contacts.twitter);
copied = true;
}}
>
<div class="share-button-icon">
<IconBrandTwitter />
</div>
follow
</button>
</div>
</div>
<div class="donate-card-subtitle share-footer-link">cobalt.tools</div>
</DonateCardContainer>
<style>
:global(#share-box) {
padding: var(--donate-card-main-padding);
min-width: 300px;
width: fit-content;
}
#share-card-header {
display: flex;
flex-direction: column;
gap: 2px;
}
.share-header-icon {
display: flex;
}
.share-header-icon :global(svg) {
width: 28px;
height: 28px;
stroke-width: 1.8px;
}
#share-card-body {
display: flex;
flex-direction: row;
gap: 12px;
max-height: 140px;
}
#share-qr :global(svg) {
width: 140px;
height: 140px;
border-radius: 12px;
}
#share-buttons {
display: grid;
grid-template-columns: 1fr 1fr;
width: 100%;
gap: 6px;
}
.share-button {
align-items: center;
width: 100%;
padding: 0 10px;
font-size: 13px;
gap: 2px;
}
.share-button-icon {
width: 21px;
height: 21px;
display: flex;
}
.share-button-icon :global(svg) {
width: 21px;
height: 21px;
stroke-width: 1.8px;
}
@media screen and (max-width: 550px) {
:global(#share-box) {
width: calc(100% - var(--donate-card-main-padding) * 2);
}
}
</style>

View file

@ -22,6 +22,7 @@
.donation-option :global(svg) {
width: 20px;
height: 20px;
stroke-width: 1.8px;
}
@media screen and (max-width: 550px) {

View file

@ -7,6 +7,11 @@ const variables = {
DEFAULT_API: env.PUBLIC_DEFAULT_API,
}
const contacts = {
github: "https://github.com/imputnet/cobalt",
twitter: "https://x.com/justusecobalt",
}
const donate = {
stripe: 'https://donate.stripe.com/3cs2cc6ew1Qda4wbII',
liberapay: 'https://liberapay.com/imput/donate',
@ -23,5 +28,5 @@ const donate = {
const apiURL = "https://api.cobalt.tools";
export { donate, apiURL };
export { donate, apiURL, contacts };
export default variables;

View file

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="378" height="378" viewBox="0 0 29 29">
<rect width="100%" height="100%" style="fill:#fff"/>
<path d="M4 4h1v1H4zm1 0h1v1H5zm1 0h1v1H6zm1 0h1v1H7zm1 0h1v1H8zm1 0h1v1H9zm1 0h1v1h-1zm3 0h1v1h-1zm1 0h1v1h-1zm4 0h1v1h-1zm1 0h1v1h-1zm1 0h1v1h-1zm1 0h1v1h-1zm1 0h1v1h-1zm1 0h1v1h-1zm1 0h1v1h-1zM4 5h1v1H4zm6 0h1v1h-1zm2 0h1v1h-1zm1 0h1v1h-1zm5 0h1v1h-1zm6 0h1v1h-1zM4 6h1v1H4zm2 0h1v1H6zm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m1 0h1v1h-1zm3 0h1v1h-1zm2 0h1v1h-1zm1 0h1v1h-1zM4 24h1v1H4zm1 0h1v1H5zm1 0h1v1H6zm1 0h1v1H7zm1 0h1v1H8zm1 0h1v1H9zm1 0h1v1h-1zm2 0h1v1h-1zm3 0h1v1h-1zm2 0h1v1h-1zm2 0h1v1h-1zm2 0h1v1h-1zm3 0h1v1h-1z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -5,6 +5,7 @@
import DonateBanner from "$components/donate/DonateBanner.svelte";
import DonateOptionsCard from "$components/donate/DonateOptionsCard.svelte";
import DonateShareCard from "$components/donate/DonateShareCard.svelte";
</script>
<svelte:head>
@ -17,6 +18,7 @@
<DonateBanner />
<section id="support-options">
<DonateOptionsCard />
<DonateShareCard />
</section>
<section id="donate-text" class="long-text-noto">
<p>
@ -63,7 +65,11 @@
padding: 0 24px;
}
@media screen and (max-width: 535px) {
@media screen and (max-width: 550px) {
#support-options {
flex-direction: column;
}
#donate-text {
padding: 0 6px;
}