mirror of
https://github.com/traberph/short.git
synced 2026-11-22 22:55:12 +00:00
Remove the built-in "Colourful" palettes
Users import their own palettes from coolors.co, so the four built-in ones aren't needed. The usage hint moved to "Your palettes"; the palette mapping tests keep the four palettes as sample data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
A small self-hosted URL shortener and link-page tool for a handful of people, with login through Authentik (OIDC).
|
A small self-hosted URL shortener and link-page tool for a handful of people, with login through Authentik (OIDC).
|
||||||
|
|
||||||
- **Short links**: `/<code>` for admins, `/<username>/<code>` for everyone else. Codes can be custom or random, and both codes and destinations can be edited later.
|
- **Short links**: `/<code>` for admins, `/<username>/<code>` for everyone else. Codes can be custom or random, and both codes and destinations can be edited later.
|
||||||
- **Link pages**: a "link in bio" page with avatar, link buttons, Markdown text blocks and colour themes, including built-in and pasted [coolors.co](https://coolors.co) palettes. Blocks are reordered by drag and drop.
|
- **Link pages**: a "link in bio" page with avatar, link buttons, Markdown text blocks and colour themes, including palettes imported from [coolors.co](https://coolors.co). Blocks are reordered by drag and drop.
|
||||||
- **QR codes**: choose the error correction level and colours, then download as PNG or SVG.
|
- **QR codes**: choose the error correction level and colours, then download as PNG or SVG.
|
||||||
- **Privacy-friendly stats**: clicks per day, daily unique visitors, last visit. No raw IPs are stored, the visitor hash uses a salt that rotates daily, and individual clicks are deleted after 90 days.
|
- **Privacy-friendly stats**: clicks per day, daily unique visitors, last visit. No raw IPs are stored, the visitor hash uses a salt that rotates daily, and individual clicks are deleted after 90 days.
|
||||||
- **API with personal access tokens**: for scripts and iOS Shortcuts.
|
- **API with personal access tokens**: for scripts and iOS Shortcuts.
|
||||||
|
|||||||
@@ -2,19 +2,6 @@ import type { Theme } from "../../shared/validation.js";
|
|||||||
|
|
||||||
// Turning coolors.co palettes (5–10 colors) into a link page theme (4 roles).
|
// Turning coolors.co palettes (5–10 colors) into a link page theme (4 roles).
|
||||||
|
|
||||||
export interface Palette {
|
|
||||||
name: string;
|
|
||||||
colors: string[]; // "#rrggbb"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Snapshot of the top 4 on https://coolors.co/palettes/trending (October 2026).
|
|
||||||
export const TRENDING_PALETTES: Palette[] = [
|
|
||||||
{ name: "Fiery Ocean", colors: hexList("780000-c1121f-fdf0d5-003049-669bbc") },
|
|
||||||
{ name: "Olive Garden Feast", colors: hexList("606c38-283618-fefae0-dda15e-bc6c25") },
|
|
||||||
{ name: "Pastel Dreamland", colors: hexList("cdb4db-ffc8dd-ffafcc-bde0fe-a2d2ff") },
|
|
||||||
{ name: "Ocean Sunset", colors: hexList("001219-005f73-0a9396-94d2bd-e9d8a6-ee9b00-ca6702-bb3e03-ae2012-9b2226") },
|
|
||||||
];
|
|
||||||
|
|
||||||
function hexList(dashed: string): string[] {
|
function hexList(dashed: string): string[] {
|
||||||
return dashed.split("-").map((h) => `#${h.toLowerCase()}`);
|
return dashed.split("-").map((h) => `#${h.toLowerCase()}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { useConfirm } from "../../components/ui/dialog.js";
|
|||||||
import { ColorInput, Input } from "../../components/ui/form.js";
|
import { ColorInput, Input } from "../../components/ui/form.js";
|
||||||
import { useToast } from "../../components/ui/toast.js";
|
import { useToast } from "../../components/ui/toast.js";
|
||||||
import { cx } from "../../lib/cx.js";
|
import { cx } from "../../lib/cx.js";
|
||||||
import { parseCoolorsInput, themeFromPalette, TRENDING_PALETTES, type Variant } from "../../lib/palette.js";
|
import { parseCoolorsInput, themeFromPalette, type Variant } from "../../lib/palette.js";
|
||||||
|
|
||||||
export const COLOR_FIELDS: [keyof Theme, string][] = [
|
export const COLOR_FIELDS: [keyof Theme, string][] = [
|
||||||
["background", "Background"],
|
["background", "Background"],
|
||||||
@@ -237,7 +237,7 @@ type OpenMenu =
|
|||||||
| { kind: "variant"; colors: string[]; label: string; anchor: HTMLElement }
|
| { kind: "variant"; colors: string[]; label: string; anchor: HTMLElement }
|
||||||
| null;
|
| null;
|
||||||
|
|
||||||
// Theme picker: basic presets, trending and saved coolors.co palettes, and custom colors.
|
// Theme picker: basic presets, the user's saved coolors.co palettes, and custom colors.
|
||||||
export function ThemePicker({ theme, onChange }: { theme: Theme; onChange: (theme: Theme) => void }) {
|
export function ThemePicker({ theme, onChange }: { theme: Theme; onChange: (theme: Theme) => void }) {
|
||||||
const saved = useApi<SavedPalette[]>("/palettes");
|
const saved = useApi<SavedPalette[]>("/palettes");
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
@@ -326,25 +326,7 @@ export function ThemePicker({ theme, onChange }: { theme: Theme; onChange: (them
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<SectionLabel hint={pickHint}>
|
<SectionLabel hint={saved.data?.length ? pickHint : "Import palettes from coolors.co to use them on your pages."}>Your palettes</SectionLabel>
|
||||||
Colourful
|
|
||||||
</SectionLabel>
|
|
||||||
<div className="grid grid-cols-2 gap-3">
|
|
||||||
{TRENDING_PALETTES.map((p) => (
|
|
||||||
<PaletteCard
|
|
||||||
key={p.name}
|
|
||||||
label={p.name}
|
|
||||||
colors={p.colors}
|
|
||||||
selected={selectedVariant(p.colors)}
|
|
||||||
onOpenVariants={(anchor) => toggleMenu({ kind: "variant", colors: p.colors, label: p.name, anchor })}
|
|
||||||
onPickColor={(color, anchor) => toggleMenu({ kind: "color", color, anchor })}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<SectionLabel hint="Paste a coolors.co palette link to save it to your palettes.">Your palettes</SectionLabel>
|
|
||||||
<form
|
<form
|
||||||
className="flex gap-2"
|
className="flex gap-2"
|
||||||
onSubmit={(e) => {
|
onSubmit={(e) => {
|
||||||
|
|||||||
+11
-3
@@ -1,5 +1,13 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { contrast, parseCoolorsInput, themeFromPalette, TRENDING_PALETTES } from "../src/web/lib/palette.js";
|
import { contrast, parseCoolorsInput, themeFromPalette } from "../src/web/lib/palette.js";
|
||||||
|
|
||||||
|
// A mix of real coolors.co palettes: dark, light, pastel and a 10-color one.
|
||||||
|
const SAMPLE_PALETTES = [
|
||||||
|
"780000-c1121f-fdf0d5-003049-669bbc",
|
||||||
|
"606c38-283618-fefae0-dda15e-bc6c25",
|
||||||
|
"cdb4db-ffc8dd-ffafcc-bde0fe-a2d2ff",
|
||||||
|
"001219-005f73-0a9396-94d2bd-e9d8a6-ee9b00-ca6702-bb3e03-ae2012-9b2226",
|
||||||
|
].map((p) => parseCoolorsInput(p)!);
|
||||||
|
|
||||||
describe("coolors.co palettes", () => {
|
describe("coolors.co palettes", () => {
|
||||||
it("parses palette and generator links as well as bare color lists", () => {
|
it("parses palette and generator links as well as bare color lists", () => {
|
||||||
@@ -18,8 +26,8 @@ describe("coolors.co palettes", () => {
|
|||||||
expect(parseCoolorsInput("zzzzzz-2a9d8f")).toBeNull();
|
expect(parseCoolorsInput("zzzzzz-2a9d8f")).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("maps every trending palette to a readable theme in both variants", () => {
|
it("maps palettes to a readable theme in both variants", () => {
|
||||||
for (const { colors } of TRENDING_PALETTES) {
|
for (const colors of SAMPLE_PALETTES) {
|
||||||
for (const variant of ["dark", "light"] as const) {
|
for (const variant of ["dark", "light"] as const) {
|
||||||
const theme = themeFromPalette(colors, variant);
|
const theme = themeFromPalette(colors, variant);
|
||||||
expect(contrast(theme.text, theme.background)).toBeGreaterThanOrEqual(4.5);
|
expect(contrast(theme.text, theme.background)).toBeGreaterThanOrEqual(4.5);
|
||||||
|
|||||||
Reference in New Issue
Block a user