1 Commits

Author SHA1 Message Date
4439d0996d attempt custom qrcode svg rendering 2025-01-01 19:28:02 -08:00
8 changed files with 139 additions and 144 deletions

View File

@@ -1,32 +0,0 @@
when:
- event: [push]
steps:
- name: echos
image: alpine
commands:
- echo $CI_REPO
- echo $CI_REPO_REMOTE_ID
- echo $CI_REPO_URL
- echo $CI_REPO_CLONE_URL
- echo $${CI_COMMIT_BRANCH/\\//-}
- echo $USERNAME:$PASSWORD
environment:
USERNAME:
from_secret: registry-username
PASSWORD:
from_secret: registry-password
- name: build
image: woodpeckerci/plugin-kaniko
settings:
registry: gitea.cazzzer.com
username:
from_secret: registry-username
password:
from_secret: registry-password
repo: gitea.cazzzer.com/${CI_REPO}
# replace '/' with '_' in branch name
# remove 'feature/' prefix in branch name
# tags: ${CI_COMMIT_BRANCH##feature/}
# auto_tag: true
tags: ci
# cache: true

View File

@@ -44,8 +44,6 @@
--sidebar-accent-foreground: 240 5.9% 10%;
--sidebar-border: 220 13% 91%;
--sidebar-ring: 217.2 91.2% 59.8%;
--surface: 210 26% 76%;
}
@media (prefers-color-scheme: dark) {
@@ -87,8 +85,6 @@
--sidebar-accent-foreground: 240 4.8% 95.9%;
--sidebar-border: 240 3.7% 15.9%;
--sidebar-ring: 217.2 91.2% 59.8%;
--surface: 217.2 40.6% 10.5%;
}
}
}

View File

@@ -16,59 +16,51 @@
let wasCopied = $state(false);
const roundedPre = copy || download ? 'rounded-b-lg' : 'rounded-lg';
async function copyToClipboard() {
await navigator.clipboard.writeText(data);
wasCopied = true;
}
</script>
<div class="flex max-w-full flex-grow flex-col rounded-lg bg-accent">
<div class="relative flex-grow overflow-x-hidden rounded-lg bg-accent">
<div class="flex items-start overflow-x-auto p-2">
<pre><code>{data}</code></pre>
{#if copy || download}
<!--Copy and download buttons-->
<div class="b flex flex-wrap items-center justify-between gap-4 rounded-t-lg p-2">
Configuration
<div class="flex gap-2">
<!--Copy button-->
<!--Flex reverse for peer hover to work properly-->
<div class="absolute right-2 flex flex-col gap-2">
{#if copy}
<div class="flex flex-row-reverse items-center gap-1">
<Button
class="action-button group"
class="peer size-10 p-2"
onclick={copyToClipboard}
onmouseleave={() => (wasCopied = false)}
>
<LucideClipboardCopy />
<span class="group-hover:block">
</Button>
<span class="hidden rounded-lg bg-background p-2 text-xs peer-hover:block">
{wasCopied ? 'Copied' : 'Copy to clipboard'}
</span>
</Button>
</div>
{/if}
{#if download}
<div class="flex flex-row-reverse items-center gap-1">
<a
class="contents"
class="peer contents"
href={`data:application/octet-stream;charset=utf-8,${encodeURIComponent(data)}`}
download={filename}
>
<Button class="action-button group">
<Button class="size-10 p-2">
<LucideDownload />
<span class="group-hover:block">Download</span>
</Button>
</a>
{/if}
</div>
<span class="hidden rounded-lg bg-background p-2 text-xs peer-hover:block">
Download
</span>
</div>
{/if}
</div>
{/if}
<div class="bg-surface flex items-start overflow-x-auto {roundedPre} p-2">
<pre><code>{data}</code></pre>
</div>
</div>
<style>
:global(.action-button) {
@apply relative size-auto p-2;
}
:global(.action-button > span) {
@apply absolute bottom-full mb-3 hidden rounded-lg bg-muted p-2 text-xs text-foreground;
}
</style>

View File

@@ -29,7 +29,7 @@
</ul>
</nav>
</header>
<main class="flex min-w-full max-w-full flex-grow flex-col gap-4 xl:min-w-[78rem]">
<main class="flex min-w-full max-w-full flex-grow flex-col gap-4 xl:min-w-[1280px]">
{@render children()}
</main>

View File

@@ -38,7 +38,7 @@
</Table.Header>
<Table.Body class="divide-y-2 divide-background">
{#each data.clients as client}
<Table.Row class="hover:bg-surface group">
<Table.Row class="group hover:bg-background hover:bg-opacity-40">
<Table.Head scope="row">
<a
href={`/clients/${client.id}`}

View File

@@ -16,9 +16,39 @@
content: data.config,
join: true,
background: 'hsl(var(--accent-light))',
width: 296,
height: 296,
xmlDeclaration: false,
// predefined: true,
});
const modules = qrCode.qrcode.modules;
const length = modules.length;
const s = 1;
// Rectangles representing modules
// let pathData = '';
//
// for (let y = 0; y < length; y++) {
// for (let x = 0; x < length; x++) {
// let module = modules[x][y];
// if (module) {
// pathData += `M${x*s},${y*s} h${s} v${s} h-${s} Z `
// }
// }
// }
// const path = modules.reduce((acc, row, y) => {
// return acc + row.reduce((rowAcc, module, x) => {
// return module ? rowAcc + `M${x*s},${y*s} h${s} v${s} h-${s} Z ` : rowAcc;
// }, '');
// }, '');
const path = modules.flat().reduce((acc, module, i) => {
const x = Math.floor(i / length)
const y = i % length;
return module ? acc + `M${x*s},${y*s} h${s} v${s} h-${s} Z ` : acc;
}, '');
</script>
<svelte:head>
@@ -27,12 +57,20 @@
<h1 class="w-fit rounded-lg bg-accent p-2 text-lg">{data.client.name}</h1>
<section id="client-configuration" class="flex flex-wrap items-center justify-center gap-4">
<section id="client-configuration" class="flex flex-wrap justify-center gap-4">
<CodeSnippet data={data.config} filename={clientWgCleanedName} copy download />
<div class="size-fit overflow-auto rounded-lg">
<div class="overflow-hidden rounded-lg">
{@html qrCode.svg()}
</div>
<!--{qrCode.svg({ container: 'none' })}-->
<!--{qrCode.sv}-->
<div class="aspect-square min-h-64 p-3 bg-white rounded-lg">
<svg viewBox="0 0 {length*s*0.5} {length*s*0.5}" shape-rendering="crispEdges" image-rendering="optimizeQuality">
<path transform="scale(0.5)" d={path} />
</svg>
</div>
<!--{pathdata}-->
</section>
<section id="usage" class="flex w-full flex-col gap-2">
<h2 class="text-xl font-semibold">Usage</h2>

View File

@@ -17,11 +17,13 @@
});
function getSize(size: number) {
let sizes = ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
let sizes = ['Bytes', 'KiB', 'MiB', 'GiB',
'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
for (let i = 1; i < sizes.length; i++) {
if (size < Math.pow(1024, i))
return Math.round((size / Math.pow(1024, i - 1)) * 100) / 100 + ' ' + sizes[i - 1];
return (Math.round((size / Math.pow(
1024, i - 1)) * 100) / 100) + ' ' + sizes[i - 1];
}
return size;
}
@@ -31,7 +33,7 @@
<title>Connections</title>
</svelte:head>
<Table.Root class="divide-y-2 divide-background overflow-hidden rounded-lg bg-accent">
<Table.Root class="bg-accent rounded-lg overflow-hidden divide-y-2 divide-background">
<Table.Header>
<Table.Row>
<Table.Head scope="col">Name</Table.Head>
@@ -47,14 +49,14 @@
</Table.Header>
<Table.Body class="divide-y-2 divide-background">
{#each data.peers.rows as peer}
<Table.Row class="hover:bg-surface">
<Table.Row class="hover:bg-background hover:bg-opacity-40">
<Table.Head scope="row">{peer.name}</Table.Head>
<Table.Cell class="max-w-[10ch] truncate">{peer['public-key']}</Table.Cell>
<Table.Cell class="truncate max-w-[10ch]">{peer['public-key']}</Table.Cell>
<Table.Cell>{peer.endpoint}</Table.Cell>
<Table.Cell>
<div class="flex flex-wrap gap-1">
{#each peer['allowed-ips'].split(',') as addr}
<Badge class="select-auto bg-background" variant="secondary">{addr}</Badge>
<Badge class="bg-background select-auto" variant="secondary">{addr}</Badge>
{/each}
</div>
</Table.Cell>

View File

@@ -1,93 +1,92 @@
import { fontFamily } from 'tailwindcss/defaultTheme';
import type { Config } from 'tailwindcss';
import tailwindcssAnimate from 'tailwindcss-animate';
import { fontFamily } from "tailwindcss/defaultTheme";
import type { Config } from "tailwindcss";
import tailwindcssAnimate from "tailwindcss-animate";
const config: Config = {
darkMode: ['media'],
content: ['./src/**/*.{html,js,svelte,ts}'],
safelist: ['dark'],
darkMode: ["media"],
content: ["./src/**/*.{html,js,svelte,ts}"],
safelist: ["dark"],
theme: {
container: {
center: true,
padding: '2rem',
padding: "2rem",
screens: {
'2xl': '1400px',
},
"2xl": "1400px"
}
},
extend: {
colors: {
border: 'hsl(var(--border) / <alpha-value>)',
input: 'hsl(var(--input) / <alpha-value>)',
ring: 'hsl(var(--ring) / <alpha-value>)',
background: 'hsl(var(--background) / <alpha-value>)',
foreground: 'hsl(var(--foreground) / <alpha-value>)',
border: "hsl(var(--border) / <alpha-value>)",
input: "hsl(var(--input) / <alpha-value>)",
ring: "hsl(var(--ring) / <alpha-value>)",
background: "hsl(var(--background) / <alpha-value>)",
foreground: "hsl(var(--foreground) / <alpha-value>)",
primary: {
DEFAULT: 'hsl(var(--primary) / <alpha-value>)',
foreground: 'hsl(var(--primary-foreground) / <alpha-value>)',
DEFAULT: "hsl(var(--primary) / <alpha-value>)",
foreground: "hsl(var(--primary-foreground) / <alpha-value>)"
},
secondary: {
DEFAULT: 'hsl(var(--secondary) / <alpha-value>)',
foreground: 'hsl(var(--secondary-foreground) / <alpha-value>)',
DEFAULT: "hsl(var(--secondary) / <alpha-value>)",
foreground: "hsl(var(--secondary-foreground) / <alpha-value>)"
},
destructive: {
DEFAULT: 'hsl(var(--destructive) / <alpha-value>)',
foreground: 'hsl(var(--destructive-foreground) / <alpha-value>)',
DEFAULT: "hsl(var(--destructive) / <alpha-value>)",
foreground: "hsl(var(--destructive-foreground) / <alpha-value>)"
},
muted: {
DEFAULT: 'hsl(var(--muted) / <alpha-value>)',
foreground: 'hsl(var(--muted-foreground) / <alpha-value>)',
DEFAULT: "hsl(var(--muted) / <alpha-value>)",
foreground: "hsl(var(--muted-foreground) / <alpha-value>)"
},
accent: {
DEFAULT: 'hsl(var(--accent) / <alpha-value>)',
foreground: 'hsl(var(--accent-foreground) / <alpha-value>)',
DEFAULT: "hsl(var(--accent) / <alpha-value>)",
foreground: "hsl(var(--accent-foreground) / <alpha-value>)"
},
popover: {
DEFAULT: 'hsl(var(--popover) / <alpha-value>)',
foreground: 'hsl(var(--popover-foreground) / <alpha-value>)',
DEFAULT: "hsl(var(--popover) / <alpha-value>)",
foreground: "hsl(var(--popover-foreground) / <alpha-value>)"
},
card: {
DEFAULT: 'hsl(var(--card) / <alpha-value>)',
foreground: 'hsl(var(--card-foreground) / <alpha-value>)',
DEFAULT: "hsl(var(--card) / <alpha-value>)",
foreground: "hsl(var(--card-foreground) / <alpha-value>)"
},
sidebar: {
DEFAULT: 'hsl(var(--sidebar-background))',
foreground: 'hsl(var(--sidebar-foreground))',
primary: 'hsl(var(--sidebar-primary))',
'primary-foreground': 'hsl(var(--sidebar-primary-foreground))',
accent: 'hsl(var(--sidebar-accent))',
'accent-foreground': 'hsl(var(--sidebar-accent-foreground))',
border: 'hsl(var(--sidebar-border))',
ring: 'hsl(var(--sidebar-ring))',
DEFAULT: "hsl(var(--sidebar-background))",
foreground: "hsl(var(--sidebar-foreground))",
primary: "hsl(var(--sidebar-primary))",
"primary-foreground": "hsl(var(--sidebar-primary-foreground))",
accent: "hsl(var(--sidebar-accent))",
"accent-foreground": "hsl(var(--sidebar-accent-foreground))",
border: "hsl(var(--sidebar-border))",
ring: "hsl(var(--sidebar-ring))",
},
surface: 'hsl(var(--surface) / <alpha-value>)',
},
borderRadius: {
xl: 'calc(var(--radius) + 4px)',
lg: 'var(--radius)',
md: 'calc(var(--radius) - 2px)',
sm: 'calc(var(--radius) - 4px)',
xl: "calc(var(--radius) + 4px)",
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)"
},
fontFamily: {
sans: [...fontFamily.sans],
sans: [...fontFamily.sans]
},
keyframes: {
'accordion-down': {
from: { height: '0' },
to: { height: 'var(--bits-accordion-content-height)' },
"accordion-down": {
from: { height: "0" },
to: { height: "var(--bits-accordion-content-height)" },
},
'accordion-up': {
from: { height: 'var(--bits-accordion-content-height)' },
to: { height: '0' },
"accordion-up": {
from: { height: "var(--bits-accordion-content-height)" },
to: { height: "0" },
},
'caret-blink': {
'0%,70%,100%': { opacity: '1' },
'20%,50%': { opacity: '0' },
"caret-blink": {
"0%,70%,100%": { opacity: "1" },
"20%,50%": { opacity: "0" },
},
},
animation: {
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out',
'caret-blink': 'caret-blink 1.25s ease-out infinite',
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
"caret-blink": "caret-blink 1.25s ease-out infinite",
},
},
},