From 3dd2346502163554fd3d77ae99850ae9b7350e05 Mon Sep 17 00:00:00 2001 From: whereareiam Date: Sat, 3 Oct 2026 13:30:51 +0200 Subject: [PATCH] Controls: Share the counter, switch, empty state and label Four small display pieces were written once per page: count pills on profile tabs, release assets, the diff filter and issue state tabs; the Releases/Tags switch on both of its pages; the bordered empty state on profile and release pages; and a hand-built outline label for package types beside Forgejo's native one. They move to components/common as theme-counter, theme-switch and theme-empty, and the package type uses the native ui basic label. The copies had drifted, so the shared versions take GitHub's values: the counter is 20px tall at weight 500 on the muted label background, and the switch is weight 500 on both pages. Organization empty-state overrides that a later profile rule always overrode are removed, along with the unused org-empty rules. Co-Authored-By: Claude Opus 5.5 --- CONTRIBUTING.md | 15 ++++- components/common/counter/counter.css | 13 +++++ components/common/counter/counter.test.ts | 29 ++++++++++ components/common/empty/empty.css | 40 +++++++++++++ components/common/switch/switch.css | 32 +++++++++++ public/assets/js/diff-file-tree.js | 2 +- public/assets/js/issue-list.js | 2 +- styles/components/diff_controls.ts | 4 -- styles/components/issues/issue_overview.ts | 7 --- styles/components/repo/release.ts | 66 ---------------------- styles/pages/organization.css | 17 +----- styles/pages/profile-subpages.css | 49 ---------------- styles/pages/user-profile.css | 10 ---- templates/base/component_assets.tmpl | 3 + templates/org/menu.tmpl | 10 ++-- templates/repo/release/list.tmpl | 6 +- templates/repo/tag/list.tmpl | 2 +- templates/user/overview/header.tmpl | 8 +-- templates/user/profile.tmpl | 2 +- templates/user/profile_empty.tmpl | 2 +- templates/user/profile_packages.tmpl | 4 +- 21 files changed, 149 insertions(+), 174 deletions(-) create mode 100644 components/common/counter/counter.css create mode 100644 components/common/counter/counter.test.ts create mode 100644 components/common/empty/empty.css create mode 100644 components/common/switch/switch.css diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 296a4014..402f499b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -204,9 +204,9 @@ For complex logic, it is recommended to extract it into functions under the `src ### Reuse shared page controls -Use `components/common/*/*.css` for sidebars, search fields, selects, and compact buttons, and -`components/common/dropdown/*` for dropdown variants. `templates/base/head_navbar.tmpl` loads the shared styles and -controllers for all pages. Keep page layout rules in the page stylesheet and pass the page's existing routes, +Use `components/common/*/*.css` for sidebars, search fields, selects, counters, switches, empty states, and compact +buttons, and `components/common/dropdown/*` for dropdown variants. `templates/base/head_navbar.tmpl` loads the shared +styles and controllers for all pages. Keep page layout rules in the page stylesheet and pass the page's existing routes, permissions, and form values into the shared controls. - **Sidebar:** add `theme-sidebar-layout` and a unique `data-theme-sidebar` storage key to the page, then use @@ -234,6 +234,15 @@ permissions, and form values into the shared controls. a page stylesheet, with `theme-control-wide` for the 16px padding GitHub uses on profile pages or `theme-control-small` for 28px controls. Use `theme-icon-button` only for icon-only controls. Keep native `primary`, `secondary`, and permission checks on actions, and leave page stylesheets to layout such as `flex` and `order`. +- **Counter:** add `theme-counter` to a count pill next to a tab, heading, or filter, including ones a script creates. + Keep only layout (`margin`, `flex`) under the page's own class. +- **Segmented switch:** use `