summaryrefslogtreecommitdiffhomepage
path: root/src/features/tabs/tab-groups.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-10-21 20:32:41 +0900
committerAdam Malczewski <[email protected]>2026-10-21 20:32:41 +0900
commitbac1e1c39398ddcb0866db510c11bed75ac3a9a8 (patch)
tree5b2bde4e1db4683290ea0c1a42eb61c498a06402 /src/features/tabs/tab-groups.ts
parent564b2c1d03cf477d7cfc23414b60d1ec76904ecc (diff)
downloaddispatch-web-bac1e1c39398ddcb0866db510c11bed75ac3a9a8.tar.gz
dispatch-web-bac1e1c39398ddcb0866db510c11bed75ac3a9a8.zip
feat(tabs): rotate three theme colours per group nesting level
Diffstat (limited to 'src/features/tabs/tab-groups.ts')
-rw-r--r--src/features/tabs/tab-groups.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/features/tabs/tab-groups.ts b/src/features/tabs/tab-groups.ts
index 12870ee..c7406d8 100644
--- a/src/features/tabs/tab-groups.ts
+++ b/src/features/tabs/tab-groups.ts
@@ -153,6 +153,22 @@ export function lastRowIsGroup(children: readonly TabGroupNode[]): boolean {
}
/**
+ * The DaisyUI theme colour a group box at nesting `level` (1 = outermost) is
+ * tinted with. Three colours ROTATE by level, so a box always differs from
+ * the box around it AND from the one around that (with two colours a box
+ * would match its grandparent). `primary` is deliberately excluded — it marks
+ * the active tab, which must stay legible inside any box.
+ */
+export const GROUP_TONES = ["secondary", "success", "accent"] as const;
+export type GroupTone = (typeof GROUP_TONES)[number];
+
+export function groupTone(level: number): GroupTone {
+ const n = GROUP_TONES.length;
+ const i = (((Math.trunc(level) - 1) % n) + n) % n; // non-negative even for level < 1
+ return GROUP_TONES[i] ?? GROUP_TONES[0];
+}
+
+/**
* Horizontal bleed (px) of a group box at nesting `level` (1 = outermost)
* when the deepest box is `maxDepth`. A box bleeds OUTWARD by this much (a
* negative margin + equal padding), so the cards inside every box sit on