2 Commits

Author SHA1 Message Date
4439d0996d attempt custom qrcode svg rendering 2025-01-01 19:28:02 -08:00
32ab4104a7 super mega layout improvements 2025-01-01 17:15:12 -08:00
6 changed files with 52 additions and 12 deletions

View File

@@ -1,11 +1,9 @@
import type { LayoutServerLoad } from './$types'; import type { LayoutServerLoad } from "./$types";
export const trailingSlash = 'always';
export const load: LayoutServerLoad = async (event) => { export const load: LayoutServerLoad = async (event) => {
const { user } = event.locals; const { user } = event.locals;
return { return {
user, user
}; };
}; };

View File

@@ -15,14 +15,16 @@
</script> </script>
<header class="flex w-full flex-wrap justify-between gap-x-6 gap-y-4 xl:max-w-screen-xl"> <header class="flex w-full flex-wrap justify-between gap-x-6 gap-y-4 xl:max-w-screen-xl">
<a href="/" class="contents">
<span class="font-bold sm:inline-block">VPGen</span> <span class="font-bold sm:inline-block">VPGen</span>
</a>
<nav class="max-w-full"> <nav class="max-w-full">
<ul class="flex items-center gap-6 overflow-x-auto text-sm"> <ul class="flex items-center gap-6 overflow-x-auto text-sm">
<li><a href="/" class={getNavClass(/^\/$/)}>Home</a></li> <li><a href="/" class={getNavClass(/^\/$/)}>Home</a></li>
{#if user} {#if user}
<li><a href="/user/" class={getNavClass(/^\/user\/$/)}>Profile</a></li> <li><a href="/user" class={getNavClass(/^\/user$/)}>Profile</a></li>
<li><a href="/connections/" class={getNavClass(/^\/connections\/$/)}>Connections</a></li> <li><a href="/connections" class={getNavClass(/^\/connections$/)}>Connections</a></li>
<li><a href="/clients/" class={getNavClass(/^\/clients(\/\d+)?\/$/)}>Clients</a></li> <li><a href="/clients" class={getNavClass(/^\/clients(\/\d+)?$/)}>Clients</a></li>
{/if} {/if}
</ul> </ul>
</nav> </nav>

View File

@@ -21,7 +21,7 @@
<section id="get-started" class="border-l-2 pl-6"> <section id="get-started" class="border-l-2 pl-6">
<p> <p>
To get started, To get started,
<Button class="ml-2" href="/clients/?add=New+Client">Create a New Client</Button> <Button class="ml-2" href="/clients?add=New+Client">Create a New Client</Button>
</p> </p>
</section> </section>
<!-- <section id="using-wireguard">--> <!-- <section id="using-wireguard">-->

View File

@@ -15,7 +15,7 @@ export const actions = {
switch (res._tag) { switch (res._tag) {
case 'ok': { case 'ok': {
return redirect(303, `/clients/${res.value}/`); return redirect(303, `/clients/${res.value}`);
} }
case 'err': { case 'err': {
const [status, message] = res.error; const [status, message] = res.error;

View File

@@ -41,7 +41,7 @@
<Table.Row class="group hover:bg-background hover:bg-opacity-40"> <Table.Row class="group hover:bg-background hover:bg-opacity-40">
<Table.Head scope="row"> <Table.Head scope="row">
<a <a
href={`./${client.id}/`} href={`/clients/${client.id}`}
class="flex size-full items-center group-hover:underline" class="flex size-full items-center group-hover:underline"
> >
{client.name} {client.name}

View File

@@ -2,7 +2,7 @@
import type { PageData } from './$types'; import type { PageData } from './$types';
import QRCode from 'qrcode-svg'; import QRCode from 'qrcode-svg';
import { CodeSnippet } from '$lib/components/app/code-snippet'; import { CodeSnippet } from '$lib/components/app/code-snippet';
import { WireguardGuide } from '$lib/components/app/wireguard-guide/index.js'; import { WireguardGuide } from '$lib/components/app/wireguard-guide';
const { data }: { data: PageData } = $props(); const { data }: { data: PageData } = $props();
@@ -16,7 +16,39 @@
content: data.config, content: data.config,
join: true, join: true,
background: 'hsl(var(--accent-light))', background: 'hsl(var(--accent-light))',
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> </script>
<svelte:head> <svelte:head>
@@ -31,6 +63,14 @@
<div class="overflow-hidden rounded-lg"> <div class="overflow-hidden rounded-lg">
{@html qrCode.svg()} {@html qrCode.svg()}
</div> </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>
<section id="usage" class="flex w-full flex-col gap-2"> <section id="usage" class="flex w-full flex-col gap-2">
<h2 class="text-xl font-semibold">Usage</h2> <h2 class="text-xl font-semibold">Usage</h2>