mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-11 13:07:46 +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
85 lines
2.6 KiB
Dart
85 lines
2.6 KiB
Dart
import 'package:design_system/design_system.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('AppSpacing', () {
|
|
test('is a 4px-based scale in ascending order', () {
|
|
const scale = [
|
|
AppSpacing.xs,
|
|
AppSpacing.sm,
|
|
AppSpacing.md,
|
|
AppSpacing.lg,
|
|
AppSpacing.xl,
|
|
AppSpacing.xxl,
|
|
];
|
|
expect(scale, [4.0, 8.0, 16.0, 24.0, 32.0, 48.0]);
|
|
for (final step in scale) {
|
|
expect(step % 4, 0, reason: '$step is off the 4px grid');
|
|
}
|
|
});
|
|
});
|
|
|
|
group('AppRadius', () {
|
|
test('matches the frozen scale', () {
|
|
expect([AppRadius.sm, AppRadius.md, AppRadius.lg], [8.0, 12.0, 16.0]);
|
|
});
|
|
});
|
|
|
|
group('AppTextSize', () {
|
|
test('matches the frozen scale', () {
|
|
expect(
|
|
[
|
|
AppTextSize.caption,
|
|
AppTextSize.label,
|
|
AppTextSize.body,
|
|
AppTextSize.subtitle,
|
|
AppTextSize.title,
|
|
AppTextSize.display,
|
|
],
|
|
[12.0, 14.0, 16.0, 20.0, 24.0, 32.0],
|
|
);
|
|
});
|
|
|
|
test('body is the reading floor', () {
|
|
expect(AppTextSize.caption, lessThan(AppTextSize.body));
|
|
expect(AppTextSize.label, lessThan(AppTextSize.body));
|
|
});
|
|
});
|
|
|
|
group('AppPalette', () {
|
|
test('matches the frozen token table', () {
|
|
expect(AppPalette.ink, const Color(0xFF211D1B));
|
|
expect(AppPalette.inkRaised1, const Color(0xFF2B2624));
|
|
expect(AppPalette.inkRaised2, const Color(0xFF38312E));
|
|
expect(AppPalette.lineDark, const Color(0xFF463E3A));
|
|
expect(AppPalette.textOnDark, const Color(0xFFECEAE9));
|
|
expect(AppPalette.mutedOnDark, const Color(0xFFAAA09A));
|
|
expect(AppPalette.paper, const Color(0xFFF6F4F3));
|
|
expect(AppPalette.paperRaised, const Color(0xFFFCFBFB));
|
|
expect(AppPalette.lineLight, const Color(0xFFE0DAD7));
|
|
expect(AppPalette.mutedOnLight, const Color(0xFF70625B));
|
|
expect(AppPalette.accent, const Color(0xFFB8862E));
|
|
expect(AppPalette.success, const Color(0xFF8A9A3C));
|
|
expect(AppPalette.warning, const Color(0xFFE0A63C));
|
|
expect(AppPalette.danger, const Color(0xFFE2585F));
|
|
});
|
|
|
|
test(
|
|
'reuses ink for text-on-light and on-fill, as the table specifies',
|
|
() {
|
|
expect(AppPalette.textOnLight, AppPalette.ink);
|
|
expect(AppPalette.onFill, AppPalette.ink);
|
|
},
|
|
);
|
|
|
|
test('has one accent hue: info mirrors it', () {
|
|
expect(AppPalette.info, AppPalette.accent);
|
|
});
|
|
});
|
|
|
|
test('kProseMaxWidth caps line length', () {
|
|
expect(kProseMaxWidth, 640.0);
|
|
});
|
|
}
|