Prepare product layout and reusable Flutter theme

Relocate the existing Astro website and preserve its assets and hosting configuration. Add the consumer/backend scaffold and themed Flutter package with consumer tests. Related to #1.
This commit is contained in:
Stephan D committed 2026-09-11 15:36:58 +02:00
1 parent ef65a40213
commit d9318053e8
46 files changed
+703 -1

No files matched your search

@@ -0,0 +1,65 @@
import 'dart:convert';
import 'dart:io';
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:sxchnge_theme/sxchnge_theme.dart';
double contrast(Color a, Color b) {
final x = a.computeLuminance();
final y = b.computeLuminance();
return (math.max(x, y) + 0.05) / (math.min(x, y) + 0.05);
}
void main() {
test('website core colors stay aligned with the package snapshot', () {
final source = File('../../../website/design/tokens.json');
if (!source.existsSync())
return; // Also allow testing outside this monorepo.
final colors =
(jsonDecode(source.readAsStringSync()) as Map)['colors'] as Map;
for (final entry in {
'ink': SxchngeBrand.ink,
'mint': SxchngeBrand.mint,
'lime': SxchngeBrand.lime,
'paper': SxchngeBrand.paper,
'forest': SxchngeBrand.forest,
}.entries) {
expect(
entry.value.toARGB32(),
int.parse('ff${(colors[entry.key] as String).substring(1)}', radix: 16),
);
}
});
for (final dark in [false, true]) {
final theme = dark ? SxchngeTheme.dark() : SxchngeTheme.light();
test(
'${dark ? "dark" : "light"} foreground pairs meet normal text contrast',
() {
final c = theme.colorScheme;
for (final pair in [
(c.primary, c.onPrimary),
(c.primaryContainer, c.onPrimaryContainer),
(c.secondary, c.onSecondary),
(c.secondaryContainer, c.onSecondaryContainer),
(c.tertiary, c.onTertiary),
(c.tertiaryContainer, c.onTertiaryContainer),
(c.surface, c.onSurface),
(c.surface, c.onSurfaceVariant),
(c.error, c.onError),
(c.errorContainer, c.onErrorContainer),
]) {
expect(contrast(pair.$1, pair.$2), greaterThanOrEqualTo(4.5));
}
expect(
theme.textTheme.bodyMedium!.fontFamily,
'packages/sxchnge_theme/Onest',
);
},
);
}
}