mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-19 14:54:33 +01:00
unified-design-system/ froze the token layer as prose -- 1220 lines of README, tokens.md and annotated HTML, and zero importable code. Every Flutter repo transcribed the token table by hand, so the "shared" palette was enforced only by discipline, and had already drifted: 10 divergent theme.dart copies (todo and untools byte-identical, the other 8 each unique), ~318 raw color literals, 4 hand-rolled AppStatusColors extensions with inconsistent field sets, ~35 inlined AlertDialogs, ~38 raw SnackBar sites with no helper anywhere. This promotes the token layer into an importable component layer, so the design system is enforced by the compiler and the package manager instead. The components own the tokens: a consumer has nothing local left to edit. Scales are the six-repo consensus, which is also what tokens.md specifies; drifted repos get corrected to this rather than the reverse. Themes are built from explicit ColorSchemes, never fromSeed -- the palette is hand-picked for contrast, and secondary/tertiary are set explicitly so SegmentedButton cannot fall back to stock Material teal. Widgets are extracted only where two or more repos already had a structurally similar implementation; SectionHeader reconciles untools' trailing-action variant with billsplit's padded one as an opt-in union, so either caller can adopt it with no visual change. 63 tests, 102/102 lines covered, gated at 100% on pre-push. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XS1m7b1piBtAL22USLW6jL
137 lines
4.1 KiB
Dart
137 lines
4.1 KiB
Dart
/// The frozen design tokens, as importable Dart instead of a token table
|
|
/// every repo transcribes by hand.
|
|
///
|
|
/// Values are the six-repo consensus (todo, home_inventory, dufs-cloud,
|
|
/// habit_stack, workout_app, untools all shipped a byte-identical copy of
|
|
/// these scales), which is also exactly what `unified-design-system/tokens.md`
|
|
/// specifies. Repos that had drifted are corrected *to* this file, not the
|
|
/// other way round.
|
|
library;
|
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
/// The raw palette, as named constants.
|
|
///
|
|
/// Prefer reading colors off `Theme.of(context).colorScheme` (or
|
|
/// [AppStatusColors] for the status hues) — this class exists so the theme
|
|
/// builders and the very few places that genuinely need a literal have one
|
|
/// shared source, rather than 343 scattered `Color(0x…)` values.
|
|
abstract final class AppPalette {
|
|
/// Dark background. Same value as the shared launcher-icon charcoal.
|
|
static const Color ink = Color(0xFF211D1B);
|
|
|
|
/// Dark elevated surface, step 1.
|
|
static const Color inkRaised1 = Color(0xFF2B2624);
|
|
|
|
/// Dark elevated surface, step 2 (kept within 12% luma of the background).
|
|
static const Color inkRaised2 = Color(0xFF38312E);
|
|
|
|
/// Border on dark surfaces.
|
|
static const Color lineDark = Color(0xFF463E3A);
|
|
|
|
/// Primary text on dark. Near-white, deliberately not pure white.
|
|
static const Color textOnDark = Color(0xFFECEAE9);
|
|
|
|
/// Secondary/caption text on dark.
|
|
static const Color mutedOnDark = Color(0xFFAAA09A);
|
|
|
|
/// Light background.
|
|
static const Color paper = Color(0xFFF6F4F3);
|
|
|
|
/// Light elevated surface — lighter than the background, per rule 15.
|
|
static const Color paperRaised = Color(0xFFFCFBFB);
|
|
|
|
/// Border on light surfaces.
|
|
static const Color lineLight = Color(0xFFE0DAD7);
|
|
|
|
/// Primary text on light. Reuses [ink] — a deliberate symmetry.
|
|
static const Color textOnLight = ink;
|
|
|
|
/// Secondary/caption text on light.
|
|
static const Color mutedOnLight = Color(0xFF70625B);
|
|
|
|
/// The single accent hue. The palette has one accent, not a second
|
|
/// secondary hue.
|
|
static const Color accent = Color(0xFFB8862E);
|
|
|
|
/// Informational status — the accent, reused.
|
|
static const Color info = accent;
|
|
|
|
/// Success status.
|
|
static const Color success = Color(0xFF8A9A3C);
|
|
|
|
/// Warning status.
|
|
static const Color warning = Color(0xFFE0A63C);
|
|
|
|
/// Danger/error status.
|
|
static const Color danger = Color(0xFFE2585F);
|
|
|
|
/// Text drawn on top of a filled accent/status surface. Dark, not white:
|
|
/// the accent is light enough that white text fails contrast on it.
|
|
static const Color onFill = ink;
|
|
}
|
|
|
|
/// Shared spacing scale (4px base) — round any new value to one of these
|
|
/// instead of introducing an off-scale literal.
|
|
abstract final class AppSpacing {
|
|
/// 4px.
|
|
static const double xs = 4;
|
|
|
|
/// 8px.
|
|
static const double sm = 8;
|
|
|
|
/// 16px.
|
|
static const double md = 16;
|
|
|
|
/// 24px.
|
|
static const double lg = 24;
|
|
|
|
/// 32px.
|
|
static const double xl = 32;
|
|
|
|
/// 48px.
|
|
static const double xxl = 48;
|
|
}
|
|
|
|
/// Shared corner-radius scale. Nested radii should be `outer - gap`, not a
|
|
/// fixed constant — compute per instance per safe-design-rules rule 24.
|
|
abstract final class AppRadius {
|
|
/// Buttons, inputs, chips.
|
|
static const double sm = 8;
|
|
|
|
/// Cards.
|
|
static const double md = 12;
|
|
|
|
/// Sheets, dialogs.
|
|
static const double lg = 16;
|
|
}
|
|
|
|
/// Shared type scale (px). `body` is the floor for anything a user reads;
|
|
/// `label`/`caption` are for UI chrome only (timestamps, badges, tags).
|
|
abstract final class AppTextSize {
|
|
/// 12px — chrome only.
|
|
static const double caption = 12;
|
|
|
|
/// 14px — chrome only.
|
|
static const double label = 14;
|
|
|
|
/// 16px — the floor for actual reading content.
|
|
static const double body = 16;
|
|
|
|
/// 20px.
|
|
static const double subtitle = 20;
|
|
|
|
/// 24px.
|
|
static const double title = 24;
|
|
|
|
/// 32px.
|
|
static const double display = 32;
|
|
}
|
|
|
|
/// Prose/paragraph line-length cap (rule 21).
|
|
///
|
|
/// Desktop builds here are Chrome `--app` windows that can be arbitrarily
|
|
/// wide (potentially 4K), so rendered/edited body text needs an explicit
|
|
/// column width instead of filling the whole viewport.
|
|
const double kProseMaxWidth = 640;
|