This commit is contained in:
2026-10-29 17:39:02 -03:00
parent bf00317e95
commit 3a0414a057
19 changed files with 214 additions and 56 deletions
-2
View File
@@ -1,5 +1,3 @@
Do not style anything for now
Do not add libraries without asking first or giving me the option to choose a different library
## Commands
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+72 -8
View File
@@ -1,10 +1,74 @@
@import "tailwindcss";
.fresh-gradient {
background-color: rgb(134, 239, 172);
background-image: linear-gradient(
to right bottom,
rgb(219, 234, 254),
rgb(187, 247, 208),
rgb(254, 249, 195)
);
/* Palette, shadows and font from Mozilla Send (__paula/send/tailwind.config.js), Send's -10..-90 scale mapped to 100..900 */
@theme {
--color-*: initial;
--color-white: #ffffff;
--color-black: #000000;
--color-gray-100: #f9f9fa;
--color-gray-200: #ededf0;
--color-gray-300: #d7d7db;
--color-gray-400: #b1b1b3;
--color-gray-500: #737373;
--color-gray-600: #4a4a4f;
--color-gray-700: #38383d;
--color-gray-800: #2a2a2e;
--color-gray-900: #0c0c0d;
--color-primary-200: #cce6ff;
--color-primary-300: #99ccff;
--color-primary-400: #45a1ff;
--color-primary-500: #0a84ff;
--color-primary-600: #0060df;
--color-primary-700: #003eaa;
--color-primary-800: #002275;
--color-primary-900: #000f40;
--color-error-300: #ff99aa;
--color-error-400: #ff3363;
--color-error-500: #ff0039;
--color-error-600: #d70022;
--color-error-700: #a4000f;
--color-error-800: #5a0002;
--color-error-900: #3e0200;
--font-sans:
"Inter", system-ui, BlinkMacSystemFont, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
--shadow-light: 0 0 8px 0 rgba(12, 12, 13, 0.1);
--shadow-big:
0 12px 18px 2px rgba(34, 0, 51, 0.04), 0 6px 22px 4px rgba(7, 48, 114, 0.12), 0 6px 10px -4px rgba(14, 13, 26, 0.12);
}
@font-face {
font-family: "Inter";
font-style: normal;
font-weight: 400;
font-display: optional;
src: url("./fonts/Inter-Regular.woff2") format("woff2");
}
@font-face {
font-family: "Inter";
font-style: normal;
font-weight: 500;
font-display: optional;
src: url("./fonts/Inter-Medium.woff2") format("woff2");
}
@font-face {
font-family: "Inter";
font-style: normal;
font-weight: 600;
font-display: optional;
src: url("./fonts/Inter-SemiBold.woff2") format("woff2");
}
@font-face {
font-family: "Inter";
font-style: normal;
font-weight: 700;
font-display: optional;
src: url("./fonts/Inter-Bold.woff2") format("woff2");
}
+26
View File
@@ -0,0 +1,26 @@
import type { JSX } from "preact";
import { twMerge } from "@/src/tw.ts";
const VARIANT_CLASSES = {
primary:
"rounded-lg bg-primary-600 px-6 py-4 font-semibold text-white hover:bg-primary-700 focus:bg-primary-700 disabled:cursor-not-allowed disabled:bg-gray-900/20 dark:bg-primary-400 dark:hover:bg-primary-500 dark:focus:bg-primary-500 dark:disabled:bg-gray-800",
link:
"font-medium text-primary-600 hover:text-primary-700 focus:text-primary-700 disabled:cursor-not-allowed disabled:opacity-50 dark:text-primary-400 dark:hover:text-primary-500 dark:focus:text-primary-500",
};
export type ButtonVariant = keyof typeof VARIANT_CLASSES;
// For elements that should look like a button, e.g. a label wrapping a file input
export function button_class(variant: ButtonVariant = "primary", extra = "") {
return twMerge("cursor-pointer", VARIANT_CLASSES[variant], extra);
}
interface ButtonProps extends Omit<JSX.ButtonHTMLAttributes<HTMLButtonElement>, "class"> {
variant?: ButtonVariant;
class?: string;
}
export default function Button({ variant, class: extra, type = "button", ...props }: ButtonProps) {
return <button type={type} class={button_class(variant, extra)} {...props} />;
}
+14
View File
@@ -0,0 +1,14 @@
import type { JSX } from "preact";
import { twMerge } from "@/src/tw.ts";
export const FIELD_CLASS =
"w-full rounded-lg border border-gray-300 px-2 py-1 leading-loose dark:border-gray-700 dark:bg-gray-800";
interface InputFieldProps extends Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "class"> {
class?: string;
}
export default function InputField({ class: extra, ...props }: InputFieldProps) {
return <input class={twMerge(FIELD_CLASS, "h-12", extra)} {...props} />;
}
+12
View File
@@ -0,0 +1,12 @@
import type { JSX } from "preact";
import { twMerge } from "@/src/tw.ts";
import { FIELD_CLASS } from "./InputField.tsx";
interface TextAreaFieldProps extends Omit<JSX.TextareaHTMLAttributes<HTMLTextAreaElement>, "class"> {
class?: string;
}
export default function TextAreaField({ class: extra, ...props }: TextAreaFieldProps) {
return <textarea class={twMerge(FIELD_CLASS, extra)} {...props} />;
}
+1
View File
@@ -29,6 +29,7 @@
"preact": "npm:preact@^10.29.1",
"@preact/signals": "npm:@preact/signals@^2.9.0",
"@fresh/plugin-vite": "jsr:@fresh/plugin-vite@^1.1.2",
"tailwind-merge": "npm:tailwind-merge@^3.7.0",
"vite": "npm:vite@^7.1.3",
"tailwindcss": "npm:tailwindcss@^4.1.10",
"@tailwindcss/vite": "npm:@tailwindcss/vite@^4.1.12"
Generated
+5
View File
@@ -51,6 +51,7 @@
"npm:preact@^10.28.2": "10.29.8_preact-render-to-string@6.7.0",
"npm:preact@^10.29.1": "10.29.8_preact-render-to-string@6.7.0",
"npm:rollup@^4.55.1": "4.63.3",
"npm:tailwind-merge@^3.7.0": "3.7.0",
"npm:tailwindcss@^4.1.10": "4.3.3",
"npm:vite@^7.1.3": "7.3.6",
"npm:vite@^7.1.4": "7.3.6"
@@ -1466,6 +1467,9 @@
"source-map-js@1.2.1": {
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="
},
"tailwind-merge@3.7.0": {
"integrity": "sha512-XPPUyAc+cvspz3lHTcR/QgPfW2A0lv/xQNIjX3HGhLR+Nq2lHaLq5MtTesHn8GUr3W3DguT2KT5x3NVgRtYwmA=="
},
"tailwindcss@4.3.3": {
"integrity": "sha512-gOhV3P7ufE62QDGg1zVaTgCR+EtPv92k2nIhVcVKcLmxT1sUBsQGhnZj175j+MqRt4zLF7ic+sCYjfhxMxj7YQ=="
},
@@ -1519,6 +1523,7 @@
"npm:@preact/signals@^2.9.0",
"npm:@tailwindcss/vite@^4.1.12",
"npm:preact@^10.29.1",
"npm:tailwind-merge@^3.7.0",
"npm:tailwindcss@^4.1.10",
"npm:vite@^7.1.3"
]
+8 -4
View File
@@ -1,5 +1,7 @@
import { Signal, useSignal, useSignalEffect } from "@preact/signals";
import Button from "@/components/Button.tsx";
import InputField from "@/components/InputField.tsx";
import Form from "@/islands/Form.tsx";
import { post_json } from "@/src/client.ts";
@@ -37,13 +39,15 @@ export default function AskCode({ page }: AskCodeProps) {
});
if (checking.value) {
return <p>Verifying code...</p>;
return <p class="text-center text-gray-800 dark:text-gray-400">Verifying code...</p>;
}
return (
<Form action="/api/verify_code" on_success={on_success}>
<input type="text" name="code" />
<button type="submit">Enter</button>
<Form class="mx-auto w-full max-w-md py-8" action="/api/verify_code" on_success={on_success}>
<div class="flex flex-col gap-4">
<InputField type="text" name="code" placeholder="Code" />
<Button type="submit" variant="primary">Enter</Button>
</div>
</Form>
);
}
+1 -1
View File
@@ -39,7 +39,7 @@ export default function Form<T = unknown>(props: FormProps<T>) {
return (
<form class={props.class} onSubmit={submit}>
<fieldset disabled={submitting.value}>{props.children}</fieldset>
{error.value && <p role="alert">{error.value}</p>}
{error.value && <p role="alert" class="mt-4 text-error-600 dark:text-error-400">{error.value}</p>}
</form>
);
}
+28 -18
View File
@@ -1,5 +1,8 @@
import { useComputed, useSignal } from "@preact/signals";
import Button from "@/components/Button.tsx";
import InputField from "@/components/InputField.tsx";
import TextAreaField from "@/components/TextAreaField.tsx";
import { post_json } from "@/src/client.ts";
import { save_master_key } from "@/src/key_store.ts";
import {
@@ -102,56 +105,63 @@ export default function KeysCreate(props: KeysCreateProps) {
if (step.value === "create") {
return (
<div>
<p>Your files are encrypted in this browser with a key the server never sees.</p>
<button type="button" onClick={create}>Create encryption key</button>
<div class="mx-auto flex max-w-md flex-col items-center py-8">
<p class="mb-6 text-center leading-normal text-gray-800 dark:text-gray-400">
Your files are encrypted in this browser with a key the server never sees.
</p>
<Button variant="primary" onClick={create}>Create encryption key</Button>
</div>
);
}
return (
<form onSubmit={finish}>
<fieldset disabled={step.value === "saving"}>
<p>Back up your key. If you lose it, your files can't be recovered, not even by the server.</p>
<form class="mx-auto max-w-md py-8" onSubmit={finish}>
<fieldset class="flex flex-col gap-4" disabled={step.value === "saving"}>
<p class="leading-normal text-gray-800 dark:text-gray-400">
Back up your key. If you lose it, your files can't be recovered, not even by the server.
</p>
<h2>Key file</h2>
<textarea readOnly value={key_text.value} />
<button type="button" onClick={download_key_file}>Download key file</button>
<label>
<h2 class="mt-4 text-lg font-bold">Key file</h2>
<TextAreaField class="h-24 font-mono text-sm break-all" readOnly value={key_text.value} />
<Button variant="link" class="self-start" onClick={download_key_file}>Download key file</Button>
<label class="flex cursor-pointer items-center gap-2 leading-normal">
<input
type="checkbox"
class="size-5 accent-primary-500"
checked={saved_file.value}
onChange={(event) => saved_file.value = event.currentTarget.checked}
/>
I saved my key file somewhere safe
</label>
<h2>Passphrase (optional)</h2>
<p>
<h2 class="mt-4 text-lg font-bold">Passphrase (optional)</h2>
<p class="text-sm leading-normal text-gray-700 dark:text-gray-400">
Stores a copy of your key on the server, locked with this passphrase, so you can unlock other
devices with it. The key file is the stronger backup.
</p>
<input
<InputField
type="password"
autoComplete="new-password"
placeholder="Passphrase"
value={passphrase.value}
onInput={(event) => passphrase.value = event.currentTarget.value}
/>
<input
<InputField
type="password"
autoComplete="new-password"
placeholder="Confirm passphrase"
value={passphrase_confirm.value}
onInput={(event) => passphrase_confirm.value = event.currentTarget.value}
/>
{passphrase_error.value && <p role="alert">{passphrase_error.value}</p>}
{passphrase_error.value && (
<p role="alert" class="text-error-600 dark:text-error-400">{passphrase_error.value}</p>
)}
<button type="submit" disabled={!can_continue.value}>
<Button type="submit" variant="primary" class="mt-4" disabled={!can_continue.value}>
{step.value === "saving" ? "Saving..." : "Continue"}
</button>
</Button>
</fieldset>
{error.value && <p role="alert">{error.value}</p>}
{error.value && <p role="alert" class="mt-4 text-error-600 dark:text-error-400">{error.value}</p>}
</form>
);
}
+3 -1
View File
@@ -54,7 +54,9 @@ export default function KeysNew(props: KeysNewProps) {
}
if (step.value === "loading" || !account.value) {
return load_error.value ? <p role="alert">{load_error.value}</p> : <p>Loading...</p>;
return load_error.value
? <p role="alert" class="text-center text-error-600 dark:text-error-400">{load_error.value}</p>
: <p class="text-center text-gray-800 dark:text-gray-400">Loading...</p>;
}
if (step.value === "create") {
+24 -15
View File
@@ -1,5 +1,8 @@
import { useSignal } from "@preact/signals";
import Button, { button_class } from "@/components/Button.tsx";
import InputField from "@/components/InputField.tsx";
import TextAreaField from "@/components/TextAreaField.tsx";
import { save_master_key } from "@/src/key_store.ts";
import { type GetKeyResponse, import_key_text, unwrap_with_passphrase, verify_key_check } from "@/src/keys.ts";
@@ -66,42 +69,48 @@ export default function KeysUnlock(props: KeysUnlockProps) {
}
return (
<div>
<p>This account already has an encryption key. Unlock it on this device with one of your backups.</p>
<div class="mx-auto max-w-md py-8">
<p class="leading-normal text-gray-800 dark:text-gray-400">
This account already has an encryption key. Unlock it on this device with one of your backups.
</p>
<fieldset disabled={working.value}>
<fieldset class="flex flex-col gap-4" disabled={working.value}>
{props.account.passphrase_backup && (
<form onSubmit={unlock_with_passphrase}>
<h2>Passphrase</h2>
<input
<form class="flex flex-col gap-4" onSubmit={unlock_with_passphrase}>
<h2 class="mt-6 text-lg font-bold">Passphrase</h2>
<InputField
type="password"
autoComplete="current-password"
placeholder="Passphrase"
value={passphrase.value}
onInput={(event) => passphrase.value = event.currentTarget.value}
/>
<button type="submit">Unlock</button>
<Button type="submit" variant="primary">Unlock</Button>
</form>
)}
<h2>Key file</h2>
<input type="file" accept=".txt,text/plain" onChange={unlock_with_key_file} />
<h2 class="mt-6 text-lg font-bold">Key file</h2>
<label class={button_class("link", "self-start")}>
<input type="file" accept=".txt,text/plain" class="sr-only" onChange={unlock_with_key_file} />
Choose key file
</label>
<form onSubmit={unlock_with_key_text}>
<p>Or paste the key:</p>
<textarea
<form class="flex flex-col gap-4" onSubmit={unlock_with_key_text}>
<p class="text-sm text-gray-700 dark:text-gray-400">Or paste the key:</p>
<TextAreaField
class="h-24 font-mono text-sm break-all"
autoComplete="off"
spellcheck={false}
placeholder="vces-key-v1:..."
value={key_text.value}
onInput={(event) => key_text.value = event.currentTarget.value}
/>
<button type="submit">Unlock</button>
<Button type="submit" variant="primary">Unlock</Button>
</form>
</fieldset>
{working.value && <p>Unlocking...</p>}
{error.value && <p role="alert">{error.value}</p>}
{working.value && <p class="mt-4 text-gray-800 dark:text-gray-400">Unlocking...</p>}
{error.value && <p role="alert" class="mt-4 text-error-600 dark:text-error-400">{error.value}</p>}
</div>
);
}
+9 -2
View File
@@ -8,8 +8,15 @@ export default define.page(function ({ Component }) {
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>vces</title>
</head>
<body>
<Component />
<body class="flex min-h-screen flex-col items-center bg-white font-sans text-gray-900 md:bg-gray-100 dark:bg-black dark:text-gray-100">
<header class="flex h-16 w-full flex-none flex-row items-center px-6 md:h-24 md:px-8">
<a href="/" class="text-2xl font-bold md:text-3xl">vces</a>
</header>
<main class="flex w-full max-w-5xl md:m-auto md:w-[calc(100%-3rem)] md:flex-1 md:items-center md:py-8">
<section class="w-full bg-white p-6 md:min-h-[42rem] md:rounded-xl md:p-8 md:shadow-big dark:bg-gray-900 md:dark:border md:dark:border-gray-800">
<Component />
</section>
</main>
</body>
</html>
);
+1 -5
View File
@@ -2,9 +2,5 @@ import { define } from "@/utils.ts";
import MainIsland from "@/islands/MainIsland.tsx";
export default define.page(function () {
return (
<div>
<MainIsland />
</div>
);
return <MainIsland />;
});
+10
View File
@@ -0,0 +1,10 @@
import { extendTailwindMerge } from "tailwind-merge";
// Custom shadows from assets/styles.css, otherwise they're read as shadow colors
export const twMerge = extendTailwindMerge({
extend: {
theme: {
shadow: ["light", "big"],
},
},
});