forked from appwrite/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-toc-showing-on-desktop
- Loading branch information
Showing
109 changed files
with
3,754 additions
and
89 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
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,95 @@ | ||
<script lang="ts"> | ||
import { platformMap } from '$lib/utils/references'; | ||
import { writable } from 'svelte/store'; | ||
import { getCodeHtml, type Language } from '$lib/utils/code'; | ||
import { copy } from '$lib/utils/copy'; | ||
import { Select, Tooltip } from '$lib/components'; | ||
export let selected: Language = 'js'; | ||
export let data: { language: string; content: string; platform?: string }[] = []; | ||
export let width: number | null = null; | ||
export let height: number | null = null; | ||
$: snippets = writable(new Set(data.map((d) => d.language))); | ||
$: content = data.find((d) => d.language === selected)?.content ?? ''; | ||
$: platform = data.find((d) => d.language === selected)?.platform ?? ''; | ||
snippets?.subscribe((n) => { | ||
if (selected === null && n.size > 0) { | ||
selected = Array.from(n)[0] as Language; | ||
} | ||
}); | ||
enum CopyStatus { | ||
Copy = 'Copy', | ||
Copied = 'Copied!' | ||
} | ||
let copyText = CopyStatus.Copy; | ||
async function handleCopy() { | ||
await copy(content); | ||
copyText = CopyStatus.Copied; | ||
setTimeout(() => { | ||
copyText = CopyStatus.Copy; | ||
}, 1000); | ||
} | ||
$: result = getCodeHtml({ | ||
content, | ||
language: selected ?? 'sh', | ||
withLineNumbers: true | ||
}); | ||
$: options = Array.from($snippets).map((language) => ({ | ||
value: language, | ||
label: platformMap[language] | ||
})); | ||
</script> | ||
|
||
<section | ||
class="dark web-code-snippet mx-auto lg:!max-w-[90vw]" | ||
aria-label="code-snippet panel" | ||
style={`width: ${width ? width / 16 + 'rem' : 'inherit'}; height: ${ | ||
height ? height / 16 + 'rem' : 'inherit' | ||
}`} | ||
> | ||
<header class="web-code-snippet-header"> | ||
<div class="web-code-snippet-header-start"> | ||
<div class="flex gap-4"> | ||
{#if platform} | ||
<div class="web-tag"><span class="text">{platform}</span></div> | ||
{/if} | ||
</div> | ||
</div> | ||
<div class="web-code-snippet-header-end"> | ||
<ul class="buttons-list flex gap-3"> | ||
{#if $snippets.entries.length} | ||
<li class="buttons-list-item flex self-center"> | ||
<Select bind:value={selected} bind:options /> | ||
</li> | ||
{/if} | ||
<li class="buttons-list-item" style="padding-inline-start: 13px"> | ||
<Tooltip> | ||
<button | ||
on:click={handleCopy} | ||
class="web-icon-button" | ||
aria-label="copy code from code-snippet" | ||
><span class="web-icon-copy" aria-hidden="true" /></button | ||
> | ||
<svelte:fragment slot="tooltip"> | ||
{copyText} | ||
</svelte:fragment> | ||
</Tooltip> | ||
</li> | ||
</ul> | ||
</div> | ||
</header> | ||
<div | ||
class="web-code-snippet-content" | ||
style={`height: ${height ? height / 16 + 'rem' : 'inherit'}`} | ||
> | ||
<!-- eslint-disable-next-line svelte/no-at-html-tags --> | ||
{@html result} | ||
</div> | ||
</section> |
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
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,78 @@ | ||
<script lang="ts"> | ||
import { classNames } from '$lib/utils/classnames'; | ||
type $$Props = { | ||
eyebrow: { | ||
label: string; | ||
icon: string; | ||
}; | ||
title: string; | ||
description: string; | ||
cta: { | ||
label: string; | ||
url: string; | ||
}; | ||
secondaryCta?: { | ||
label: string; | ||
url: string; | ||
}; | ||
image: { | ||
url: string; | ||
alt?: string; | ||
}; | ||
mobileImage?: { | ||
url: string; | ||
alt?: string; | ||
}; | ||
}; | ||
export let eyebrow: $$Props['eyebrow']; | ||
export let title: $$Props['title']; | ||
export let description: $$Props['description']; | ||
export let cta: $$Props['cta']; | ||
export let secondaryCta: $$Props['secondaryCta'] = undefined; | ||
export let image: $$Props['image']; | ||
export let mobileImage: $$Props['mobileImage'] = undefined; | ||
</script> | ||
|
||
<div | ||
class="border-smooth box-content flex items-center border-b bg-[url(/images/bgs/mobile-hero.png)] bg-cover bg-bottom py-12 px-5 md:bg-[url(/images/bgs/hero.png)] md:bg-center md:pt-32 md:pb-40 lg:px-8 xl:px-16" | ||
> | ||
<div class="mx-auto grid max-w-[75rem] items-center gap-16 md:grid-cols-2"> | ||
<div class="space-y-8"> | ||
<div class="flex items-center gap-2"> | ||
<img src={eyebrow.icon} class="size-8" alt="" /> | ||
<span class="text-micro font-aeonik-fono tracking-loose text-primary uppercase"> | ||
{eyebrow.label}<span class="web-u-color-text-accent">_</span> | ||
</span> | ||
</div> | ||
<h1 | ||
class="text-display font-aeonik-pro text-primary text-pretty max-sm:max-w-[300px] md:max-w-md" | ||
> | ||
{title} | ||
</h1> | ||
<p class="text-description text-secondary text-pretty font-medium"> | ||
{description} | ||
</p> | ||
|
||
<div class="flex flex-col items-center gap-2 md:flex-row"> | ||
<a href={cta.url} class="web-button !w-full md:!w-fit"> | ||
{cta.label} | ||
</a> | ||
{#if secondaryCta} | ||
<a href={secondaryCta.url} class="web-button is-secondary !w-full md:!w-fit"> | ||
{secondaryCta.label} | ||
</a> | ||
{/if} | ||
</div> | ||
</div> | ||
<img | ||
class={classNames({ 'hidden md:block': mobileImage })} | ||
src={image.url} | ||
alt={image.alt ?? ''} | ||
/> | ||
{#if mobileImage} | ||
<img class="block md:hidden" src={mobileImage.url} alt={mobileImage.alt ?? ''} /> | ||
{/if} | ||
</div> | ||
</div> |
Oops, something went wrong.