feat(garage_ui): PageHeading, a real extraBold, and a mono that chains

The weight helpers went through _StyledText, which merges a style naming
one property and lets everything else in scope stand. That works for a
colour and it doesnt work for a weight: google_fonts encodes the weight
in the family NAME, so merging w800 over an already resolved family
changes no font file and skia synthesises instead. Skia has one fake
bold, so w600, w700 and w800 all came out the same stroke and extraBold
was indistinguishable from bold. They re-resolve the family now, keeping
whichever face is in scope, so .mono().bold() and .bold().mono() both
land on the real mono bold.

PageHeading is lifted out of the hub, where it was drawn by hand above
every section. A&A's licence page wanted the same block and a lookalike
drifts from the original inside a day.

pageGutter and propertiesSectionGap are new density tokens. Both were
local magic numbers - `fontSize * 3` copied into every app that copied
the hub, and a flat gapLg that a dense editor pane full of sections
wears badly.

garage_auth takes an optional handoff code on signIn/beginSignIn and
sends it as _handoff, so a desktop build can hand its user to the web
one without a second sign in.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FkzfwZf59HNP6R8jXcC1NR
This commit is contained in:
ImBenji
2026-10-09 15:21:48 +01:00
co-authored by Claude Opus 5
parent b5e5ed5b75
commit 7aa5cb8f8b
7 changed files with 276 additions and 23 deletions
+78 -12
View File
@@ -70,23 +70,89 @@ extension TextStyleExtension on Widget {
style: (t) => TextStyle(fontSize: t.density.textLg),
);
Widget medium() => _StyledText(
child: this,
style: (t) => const TextStyle(fontWeight: FontWeight.w500),
);
Widget semiBold() => _StyledText(
child: this,
style: (t) => const TextStyle(fontWeight: FontWeight.w600),
);
Widget bold() => _StyledText(
child: this,
style: (t) => const TextStyle(fontWeight: FontWeight.w700),
);
// these DONT go through _StyledText. Merging `fontWeight: w800` over an
// already resolved google_fonts family changes nothing about which font
// FILE gets used - the file is the weight - so skia synthesises instead,
// and skia has exactly one fake bold. w600, w700 and w800 all came out the
// same stroke, which is how extraBold ended up looking identical to bold.
Widget medium() => _WeightText(child: this, weight: FontWeight.w500);
Widget semiBold() => _WeightText(child: this, weight: FontWeight.w600);
Widget bold() => _WeightText(child: this, weight: FontWeight.w700);
/// Top of the ladder. A display weight - for a figure or a name somebody is
/// meant to read across a desk, not for body copy.
Widget extraBold() => _WeightText(child: this, weight: FontWeight.w800);
Widget muted() => _StyledText(
child: this,
style: (t) => TextStyle(color: t.colorScheme.mutedForeground),
);
/// Geist Mono, keeping whatever size, weight and colour are already in
/// scope.
///
/// Chains in either order - `.mono().bold()` and `.bold().mono()` both land
/// on the real mono bold, because the weight helpers re-resolve whichever
/// family they find in scope rather than assuming sans.
///
/// Only w300 and w700 are in main.dart's `pendingFonts`. Any other weight
/// resolves fine and lands a frame or two late.
Widget mono() => _MonoText(child: this);
}
// mono cant ride on _StyledText the way the weights do. those merge a style
// naming ONE property and dont care what else is in scope, so they compose in
// any order. A family out of google_fonts isnt one property - the family name
// encodes the weight - so this one has to read the inherited style first and
// hand the whole thing over to be re-resolved.
// re-resolves the family for the weight it's setting, keeping whichever face
// is already in scope. sans unless somebody put mono there first.
class _WeightText extends StatelessWidget {
const _WeightText({required this.child, required this.weight});
final Widget child;
final FontWeight weight;
@override
Widget build(BuildContext context) {
final theme = GarageTheme.of(context);
final inherited = DefaultTextStyle.of(context).style;
final wanted = inherited.copyWith(fontWeight: weight);
// google_fonts names a family "<Family>_<weight>", so the bit before the
// underscore is the face. taken off typography.mono rather than spelled
// out, so renaming the font doesnt quietly turn every .bold() on a mono
// run back into sans.
String? face(String? family) => family?.split("_").first;
final isMono = face(inherited.fontFamily) == face(theme.typography.mono.fontFamily);
return DefaultTextStyle.merge(
style: isMono
? theme.typography.monoStyle(wanted)
: theme.typography.sansStyle(wanted),
child: child,
);
}
}
class _MonoText extends StatelessWidget {
const _MonoText({required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
final theme = GarageTheme.of(context);
// .of(context), not the theme: this is the point of the class. everything
// a caller stacked ABOVE this widget is already merged into here.
final inherited = DefaultTextStyle.of(context).style;
return DefaultTextStyle.merge(
style: theme.typography.monoStyle(inherited),
child: child,
);
}
}
typedef _StyleFromTheme = TextStyle Function(ThemeData theme);