From 9e10bc30314e18254d08a096c0d87c01d038d0c2 Mon Sep 17 00:00:00 2001 From: Guoliang Chen Date: Sat, 6 Jun 2026 14:15:19 -0700 Subject: [PATCH] Redesign UI to match Solis design system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace Pico CSS with a custom Solis-style design system — warm amber on cream, Outfit font, 260px sidebar (logged in) or sticky public header (logged out), soft amber-tinted shadows, cubic-bezier spring animations on toasts and modals. - Add static/css/style.css with the full design token system - Add base.html + content-block pattern; each page defines its own {{define "content"}} and base.html provides the chrome - pageData gains ActiveNav; adminPage(w, r, nav) sets it; handlers pass the right value for every admin route - Standalone pages (login, 404, embed) render without base.html - Templates use Solis-style data-table, card, stats-bar, tag-pill, alert, btn components - Remove vendored Pico CSS (83KB) and the old style.css (12KB) - Update AGENTS.md and CLAUDE.md to reflect the new design system Bug fixes during the redesign: - Preview dialog now only shows when [open] (UA default was being overridden by display:flex) - Preview dialog centered via explicit top/left/transform — the browser's default margin:auto centering fights with display:flex on - Add ?embed=1 route that renders paste content without base.html chrome, so the admin paste preview iframe shows only the body Tested: go build ./... clean, go vet ./... clean, binary boots. --- AGENTS.md | 30 +- CLAUDE.md | 30 +- internal/server/handlers.go | 33 +- internal/server/static/css/style.css | 1627 +++++++++++++++++ internal/server/static/pico.min.css | 4 - internal/server/static/style.css | 644 ------- internal/server/templates.go | 54 +- internal/server/templates/404.html | 43 +- internal/server/templates/admin.html | 349 ++-- internal/server/templates/admin_bin.html | 321 ++-- internal/server/templates/admin_bin_edit.html | 357 ++-- internal/server/templates/admin_edit.html | 95 +- internal/server/templates/admin_login.html | 67 +- internal/server/templates/admin_uploads.html | 346 ++-- internal/server/templates/base.html | 120 ++ internal/server/templates/bin_token.html | 69 +- internal/server/templates/bin_view.html | 96 +- internal/server/templates/bin_view_embed.html | 23 + internal/server/templates/index.html | 125 +- 19 files changed, 2790 insertions(+), 1643 deletions(-) create mode 100644 internal/server/static/css/style.css delete mode 100644 internal/server/static/pico.min.css delete mode 100644 internal/server/static/style.css create mode 100644 internal/server/templates/base.html create mode 100644 internal/server/templates/bin_view_embed.html diff --git a/AGENTS.md b/AGENTS.md index 8e0948c..a1145cc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -44,14 +44,18 @@ glimmer/ ├── middleware.go # Auth, CSRF, sessions, rate limiter ├── templates.go # embed.FS for templates + static; initTemplates() ├── static/ - │ ├── style.css # Custom styles on top of Pico CSS 2 + │ ├── css/ + │ │ └── style.css # Custom Solis-style design system (amber/cream, Outfit font) + │ ├── favicon.ico + │ ├── favicon.png │ └── upload.js # Shared client-side upload helper (window.GlimmerUpload) └── templates/ + ├── base.html # Layout wrapper: sidebar (logged in) or public header ├── index.html # Public: URL shortener form - ├── admin_login.html # Login (dark, centered) + ├── admin_login.html # Login (light, centered card) ├── admin.html # Dashboard: stats, tiles, links tables ├── admin_edit.html # Edit a single link - ├── admin_bin.html # Pastes list + ├── admin_bin.html # Pastes list (cards + preview dialog) ├── admin_bin_edit.html # Create / edit paste (uses /static/upload.js) ├── admin_uploads.html # Image + file upload management ├── bin_view.html # Public paste viewer @@ -89,7 +93,13 @@ Templates and static files are embedded into the binary via `//go:embed` in `tem All JavaScript is vanilla ES5-style (`var`, not `const`/`let`). Most JS is inline in templates; shared upload logic lives in `static/upload.js` and is exposed as `window.GlimmerUpload`. No build step, no npm, no bundler. ### CSS framework -[Pico CSS 2](https://picocss.com/) loaded from CDN. Custom overrides in `static/style.css`. Admin pages use `data-theme="dark"`. +**No CSS framework.** Glimmer uses a custom design system in `static/css/style.css` inspired by Solis's "Sunlight & Clarity" theme — warm amber (`#d97706`) on cream (`#fafaf9`) with Outfit font, sidebar + main-area layout, soft shadows with amber tint, cubic-bezier spring animations on toasts/modals. All templates are self-contained and offline-capable. **No external CDN dependencies.** + +### Layout +Admin pages share a `base.html` layout that renders a 260px fixed sidebar (when `.LoggedIn`) or a sticky public header (otherwise). Each page template defines its own `{{define "content"}}...{{end}}` block; `base.html` calls `{{template "content" .}}` to inject it. The active sidebar item is driven by the `ActiveNav` field in `pageData` (`"links"`, `"pastes"`, `"uploads"`, or `"shorten"`). Use `s.adminPage(w, r, "links")` to get a pre-populated `pageData` for an admin route. + +### Theme +Single light theme only — no `data-theme` switching. The design system is documented in the `:root` of `static/css/style.css`. --- @@ -125,14 +135,12 @@ Shared upload rules: Only PNG (`.png`) and JPEG (`.jpg`) are resizable. Resize uses a nearest-neighbour scale implemented in stdlib (`image`, `image/color`, `image/jpeg`, `image/png`) — no external image library. GIF and WebP are served and deletable but not resizable. ### Admin tabs -Every admin page (`admin.html`, `admin_bin.html`, `admin_bin_edit.html`, `admin_uploads.html`) must include the full three-tab nav. Add the `active` class to the correct tab: -```html - +Admin pages share a sidebar rendered by `base.html`. To highlight the current section, set `ActiveNav` on the `pageData`: +```go +d := s.adminPage(w, r, "pastes") // highlights the Pastes nav item +renderTemplate(w, "admin_bin.html", d) ``` +Valid values are `"links"`, `"pastes"`, `"uploads"`, `"shorten"`. New admin pages should follow the same `base.html` + `{{define "content"}}` pattern and live under `templates/`. ### Database migrations Migrations run automatically in `db.Open()`. New columns are added with `ALTER TABLE ... ADD COLUMN IF NOT EXISTS`. Never drop columns — the schema must remain backwards compatible with existing `data/urls.db` files on deployed instances. diff --git a/CLAUDE.md b/CLAUDE.md index d6b4647..7361713 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -44,14 +44,18 @@ glimmer/ ├── middleware.go # Auth, CSRF, sessions, rate limiter ├── templates.go # embed.FS for templates + static; initTemplates() ├── static/ - │ ├── style.css # Custom styles on top of Pico CSS 2 + │ ├── css/ + │ │ └── style.css # Custom Solis-style design system (amber/cream, Outfit font) + │ ├── favicon.ico + │ ├── favicon.png │ └── upload.js # Shared client-side upload helper (window.GlimmerUpload) └── templates/ + ├── base.html # Layout wrapper: sidebar (logged in) or public header ├── index.html # Public: URL shortener form - ├── admin_login.html # Login (dark, centered) + ├── admin_login.html # Login (light, centered card) ├── admin.html # Dashboard: stats, tiles, links tables ├── admin_edit.html # Edit a single link - ├── admin_bin.html # Pastes list + ├── admin_bin.html # Pastes list (cards + preview dialog) ├── admin_bin_edit.html # Create / edit paste (uses /static/upload.js) ├── admin_uploads.html # Image + file upload management ├── bin_view.html # Public paste viewer @@ -89,7 +93,13 @@ Templates and static files are embedded into the binary via `//go:embed` in `tem All JavaScript is vanilla ES5-style (`var`, not `const`/`let`). Most JS is inline in templates; shared upload logic lives in `static/upload.js` and is exposed as `window.GlimmerUpload`. No build step, no npm, no bundler. ### CSS framework -[Pico CSS 2](https://picocss.com/) is **vendored locally** at `static/pico.min.css` (served from `/static/pico.min.css`) so the app works fully offline with no external requests. Custom overrides in `static/style.css`. Admin pages use `data-theme="dark"`. Do not reintroduce CDN ``/` - - +{{end}} diff --git a/internal/server/templates/admin_bin.html b/internal/server/templates/admin_bin.html index 616bc1e..c5a437e 100644 --- a/internal/server/templates/admin_bin.html +++ b/internal/server/templates/admin_bin.html @@ -1,184 +1,163 @@ - - - - - - - Pastes — Admin - - - - - -
- Links - Pastes - Uploads -
-
- {{if .Error}} -
{{.Error}}
- {{end}} +{{define "title"}}Pastes — Admin{{end}} +{{define "content"}} -
-
-

Pastes

-

{{len .Pastes}} pastes

-
- + New Paste -
+ - {{if .Pastes}} -
- {{range .Pastes}} -
- {{if .ThumbURL}} -
- -
- {{end}} -
-

{{if .Title}}{{.Title}}{{else}}{{.Name}}{{end}}

- {{if .Summary}}

{{.Summary}}

{{end}} -
- {{.Format}} - {{if .Token}}🔒{{else}}public{{end}} - {{if .Hidden}}hidden{{end}} - {{.UpdatedAt.Format "01-02 15:04"}} -
-
- - Edit - -
- - -
-
-
-
- {{end}} -
- {{else}} -
- 📄 -

No pastes yet.

- Create your first paste -
- {{end}} -
+{{if .Error}} +
{{.Error}}
+{{end}} - -
- Preview -
- Open ↗ - - -
-
- -
- -
-
- -

QR Code

-
-
-
+{{if .Pastes}} +
+ {{range .Pastes}} +
+ {{if .ThumbURL}} +
+ +
+ {{else}} +
+ {{.Format}} +
+ {{end}} +
+

{{if .Title}}{{.Title}}{{else}}{{.Name}}{{end}}

+ {{if .Summary}}

{{.Summary}}

{{end}} +
+ {{.Format}} + {{if .Token}} + 🔒 + {{else}} + public + {{end}} + {{if .Hidden}}hidden{{end}} + {{.UpdatedAt.Format "01-02 15:04"}} +
+
+
+ + Edit + +
+ + +
+
+
+ {{end}} +
+{{else}} +
+
+ 📄 +

No pastes yet.

+ Create your first paste +
+
+{{end}} + + + +
+ Preview +
+ Open ↗ + + +
+
+
+ - - +{{end}} diff --git a/internal/server/templates/admin_bin_edit.html b/internal/server/templates/admin_bin_edit.html index 3332a7b..ca9cbda 100644 --- a/internal/server/templates/admin_bin_edit.html +++ b/internal/server/templates/admin_bin_edit.html @@ -1,193 +1,194 @@ - - - - - - - {{if .Paste}}Edit Paste{{else}}New Paste{{end}} — Admin - - - - - -
- Links - Pastes - Uploads -
-
-
-
-

{{if .Paste}}Edit Paste{{else}}New Paste{{end}}

-
+{{define "title"}}{{if .Paste}}Edit Paste{{else}}New Paste{{end}} — Admin{{end}} +{{define "content"}} - {{if .Error}} -
{{.Error}}
- {{end}} + - {{if .Paste}} - {{with .Paste}} -
- {{else}}{{end}} - {{else}} - - {{end}} +{{if .Error}} +
{{.Error}}
+{{end}} - -
- - -
+
+ {{if .Paste}} + {{with .Paste}}{{else}}{{end}} + {{else}} + + {{end}} - + - -
- - - - - -
- {{if .Paste}} - {{with .Paste}}{{end}} - {{else}} - - {{end}} +
+
+ + {{if .Paste}} + {{with .Paste}}{{end}} + {{else}} + + {{end}} + Path: /bin/{{if .Paste}}{{with .Paste}}{{.Name}}{{end}}{{else}}...{{end}} +
-
- Access Token - {{if .Paste}} - {{with .Paste}} - {{if .Token}} -

Current token: {{.Token}} — URL: /bin/{{.Name}}/{{.Token}}

- - - - - {{else}} -

Token is currently disabled — paste is publicly accessible.

- - - - {{end}} - - - {{end}} - {{else}} - - - - - - {{end}} -
+
+ + {{if .Paste}} + {{with .Paste}}{{end}} + {{else}} + + {{end}} +
+
-
- - Cancel -
+
+ + +
+ +
+ +
+ + + + + +
+ {{if .Paste}} + {{with .Paste}}{{end}} + {{else}} + + {{end}} +
+ +
+ Access Token + {{if .Paste}} + {{with .Paste}} + {{if .Token}} +

+ Current token: {{.Token}} — URL: /bin/{{.Name}}/{{.Token}} +

+ + + + + {{else}} +

Token is currently disabled — paste is publicly accessible.

+ + + + {{end}} + + + {{end}} + {{else}} + + + + + + {{end}} +
+ +
+ + Cancel +
+ + {{if .Paste}}{{with .Paste}}{{end}}{{end}} +
- - {{if .Paste}}{{with .Paste}}{{end}}{{end}} -
-
- - +{{end}} diff --git a/internal/server/templates/admin_edit.html b/internal/server/templates/admin_edit.html index ab70b44..6c9ef97 100644 --- a/internal/server/templates/admin_edit.html +++ b/internal/server/templates/admin_edit.html @@ -1,52 +1,51 @@ - - - - - - - Edit Link — Glimmer - - - - - -
-
-
-

Edit Link

-
+{{define "title"}}Edit Link — Glimmer{{end}} +{{define "content"}} - {{if .Error}} -
{{.Error}}
- {{end}} + - {{with .Link}} -
- - - +{{if .Error}} +
{{.Error}}
+{{end}} - - +{{with .Link}} +
+ + -
- - Cancel -
- - {{end}} -
-
- - +
+ + + The short path users will visit: /{{.Slug}} +
+ +
+ + +
+ +
+ +
+ + Cancel +
+ + + + +{{else}} +
Link not found.
+{{end}} +{{end}} diff --git a/internal/server/templates/admin_login.html b/internal/server/templates/admin_login.html index 0698007..6c552d4 100644 --- a/internal/server/templates/admin_login.html +++ b/internal/server/templates/admin_login.html @@ -1,44 +1,43 @@ - + + + + - - - Admin Login — Glimmer - - + Admin Login — Glimmer + - - -
- -
+
+ + +
+ + + + diff --git a/internal/server/templates/admin_uploads.html b/internal/server/templates/admin_uploads.html index 372a44b..61ce2a2 100644 --- a/internal/server/templates/admin_uploads.html +++ b/internal/server/templates/admin_uploads.html @@ -1,191 +1,179 @@ - - - - - - - Uploads — Admin - - - - - -
- Links - Pastes - Uploads -
-
- {{if .Error}} -
{{.Error}}
- {{end}} +{{define "title"}}Uploads — Admin{{end}} +{{define "content"}} -
-
-
-

Uploads

-

{{len .Uploads}} files

-
-
- - - - - -
-
-
- - - - - - - - - - - - - {{range .Uploads}} - - - - - - - - - {{else}} - - - - {{end}} - -
PreviewFileSizeDimensionsUploadedActions
- {{if .IsImage}} - {{else}}📄 - {{end}} - -
- {{.Ext}} - {{if .OriginalName}}{{.OriginalName}}{{end}} -
- {{.Filename}} -
{{.SizeHuman}}{{if .Width}}{{.Width}}×{{.Height}}{{else}}—{{end}}{{.ModTime.Format "2006-01-02 15:04"}} -
- - {{if .CanResize}}{{end}} -
- - -
-
-
-
- 📄 -

No uploads yet. Use the buttons above to upload an image or file.

-
-
-
-
-
+ - -
-
- -

Resize Image

-
-

- - -
- - -
-
-
+{{if .Error}} +
{{.Error}}
+{{end}} + +
+
+
+

All uploads

+

{{len .Uploads}} file{{if ne (len .Uploads) 1}}s{{end}} stored locally.

+
+
+ + + + + +
+
+
+ + + + + + + + + + + + + {{range .Uploads}} + + + + + + + + + {{else}} + + {{end}} + +
PreviewFileSizeDimensionsUploadedActions
+ {{if .IsImage}} + + + + {{else}} + 📄 + {{end}} + +
+ {{.Ext}} + {{if .OriginalName}}{{.OriginalName}}{{end}} +
+ {{.Filename}} +
{{.SizeHuman}}{{if .Width}}{{.Width}}×{{.Height}}{{else}}—{{end}}{{.ModTime.Format "2006-01-02 15:04"}} +
+ + {{if .CanResize}}{{end}} +
+ + +
+
+
+
+ 📄 +

No uploads yet. Use the buttons above to upload an image or file.

+
+
+
+
+ + +
+
+ +

Resize Image

+
+

+ + + +
+ + +
+
+
- - +{{end}} diff --git a/internal/server/templates/base.html b/internal/server/templates/base.html new file mode 100644 index 0000000..70fd764 --- /dev/null +++ b/internal/server/templates/base.html @@ -0,0 +1,120 @@ +{{define "base"}} + + + + + + + {{block "title" .}}Glimmer{{end}} + + + +
+ {{if .LoggedIn}} + + {{else}} +
+ + + Glimmer + +
+ {{if .LoggedIn}} + + + Admin + + {{else}} + + + Admin + + {{end}} +
+
+ {{end}} + +
+ {{template "content" .}} +
+
+ + +
+
+ +

QR Code

+ QR Code + + Download PNG +
+
+ + + +{{end}} diff --git a/internal/server/templates/bin_token.html b/internal/server/templates/bin_token.html index 810070c..eca9825 100644 --- a/internal/server/templates/bin_token.html +++ b/internal/server/templates/bin_token.html @@ -1,43 +1,34 @@ - - - - - - - Access Token Required — Glimmer - - - - - -
-

🔒

-

Access Token Required

-

This paste is protected. Enter the access token to view it.

+{{define "title"}}Access Token Required — Glimmer{{end}} +{{define "content"}} +
- {{if .Error}} -
{{.Error}}
- {{end}} +
+
🔒
+

Access Token Required

+

This paste is protected. Enter the access token to view it.

+ + {{if .Error}} +
{{.Error}}
+ {{end}} + +
+
+ + +
+ +
+
+ +
-
- - -
-
- - +{{end}} diff --git a/internal/server/templates/bin_view.html b/internal/server/templates/bin_view.html index 2638920..21fcf49 100644 --- a/internal/server/templates/bin_view.html +++ b/internal/server/templates/bin_view.html @@ -1,49 +1,51 @@ - - - - - - - {{with .Paste}}{{with .Title}}{{.}}{{else}}{{with $.Paste}}{{.Name}}{{end}}{{end}}{{end}} - - - - - -
- {{with .Paste}} -
-
-

{{if .Title}}{{.Title}}{{else}}{{.Name}}{{end}}

- - /bin/{{.Name}} -  ·  - {{.Format}} -  ·  - {{if .Token}}🔒 token protected{{else}}public{{end}} -  ·  - updated {{.UpdatedAt.Format "2006-01-02 15:04"}} - -
-
- Raw - -
-
-
- {{end}} +{{define "title"}}{{if .Paste}}{{with .Paste}}{{if .Title}}{{.Title}}{{else}}{{.Name}}{{end}}{{end}}{{else}}Paste{{end}} — Glimmer{{end}} +{{define "content"}} +{{with .Paste}} +
-
- {{.PasteBody}} -
+
+
+

{{if .Title}}{{.Title}}{{else}}{{.Name}}{{end}}

+
+ /bin/{{.Name}} + {{.Format}} + {{if .Token}} + 🔒 token protected + {{else}} + public + {{end}} + updated {{.UpdatedAt.Format "2006-01-02 15:04"}} +
+
+
+ Raw + +
+
- {{with .Paste}} - - {{end}} -
- - +
+
+ {{$.PasteBody}} +
+
+ + + + + + +{{else}} +
+

Paste not found

+

This paste may have been deleted or is hidden.

+
+{{end}} +{{end}} diff --git a/internal/server/templates/bin_view_embed.html b/internal/server/templates/bin_view_embed.html new file mode 100644 index 0000000..1c142e0 --- /dev/null +++ b/internal/server/templates/bin_view_embed.html @@ -0,0 +1,23 @@ + + + + + + {{with .Paste}}{{if .Title}}{{.Title}}{{else}}{{.Name}}{{end}} — Glimmer Paste{{end}} + + + + +
+ {{with .Paste}} +
+ {{$.PasteBody}} +
+ {{end}} +
+ + diff --git a/internal/server/templates/index.html b/internal/server/templates/index.html index 7b74b7e..2a37d84 100644 --- a/internal/server/templates/index.html +++ b/internal/server/templates/index.html @@ -1,64 +1,71 @@ - - - - - - - Glimmer - - - - - -
-
-

Shorten a URL

-

Paste a long URL and get a short link

-
+{{define "title"}}Glimmer{{end}} +{{define "content"}} +
- {{if .Error}} -
- {{.Error}} -
- {{end}} +
+
+ + Glimmer +
+

Shorten a URL

+

Paste a long URL and get a short link.

- {{if .ShortURL}} -
-

Your short link is ready:

-

{{.OriginalURL}}

-
- {{.ShortURL}} - -
- {{if .QRSVG}} -
{{.QRSVG}}
- {{end}} -
- {{end}} + {{if .Error}} +
{{.Error}}
+ {{end}} -
- - - + {{if .ShortURL}} +
+
+ Your short link is ready. +

{{.OriginalURL}}

+
+
+
+ {{.ShortURL}} + +
+ {{if .QRSVG}} +
{{.QRSVG}}
+ {{end}} + {{end}} - {{if .LoggedIn}} - - - {{end}} + + - -
- -
- - +
+ + +
+ + {{if .LoggedIn}} +
+ + + Leave blank to auto-generate a 3-character slug. +
+ {{end}} + + + + + + + + +{{end}}