Files
clide/app/lib/widgets/src/clide_text.dart
T
jpmschweitzerandClaude c1ad33f1b0 bundle Josefin Sans as the default UI face at weight 300
Vendor the JosefinSans variable font (upright + italic, weight range
100-700), OFL licensed. _AppRoot installs it as the ambient
DefaultTextStyle at weight w300 (Light); ClideText inherits rather
than re-specifying the family, so Alchemist's Ahem injection keeps
goldens deterministic per D-024 while production renders the
intended face.

typography.dart gains clideUiFamily + clideUiFamilyFallback
alongside the existing mono constants; .gitignore learns about
Alchemist's failures/ diff output dir so local re-runs don't leak
into `git status`.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-22 08:18:15 +02:00

57 lines
1.7 KiB
Dart

import 'package:clide_app/kernel/src/theme/controller.dart';
import 'package:clide_app/widgets/src/typography.dart';
import 'package:flutter/widgets.dart';
/// Theme-aware Text. Defaults pull from the global foreground token
/// and [clideUiDefaultWeight].
///
/// The UI font family is deliberately **not** set on this widget — it
/// inherits from the ambient `DefaultTextStyle` which `_AppRoot`
/// provides ([clideUiFamily] in real runs). Goldens rely on Alchemist
/// injecting Ahem for deterministic metrics; hard-coding a family here
/// would override that and break pixel determinism per D-024.
class ClideText extends StatelessWidget {
const ClideText(
this.data, {
super.key,
this.color,
this.fontSize = 13,
this.fontWeight,
this.muted = false,
this.maxLines,
this.overflow,
this.textAlign,
});
final String data;
final Color? color;
final double fontSize;
final FontWeight? fontWeight;
final bool muted;
final int? maxLines;
final TextOverflow? overflow;
final TextAlign? textAlign;
@override
Widget build(BuildContext context) {
final tokens = ClideTheme.of(context).surface;
final resolved =
color ?? (muted ? tokens.globalTextMuted : tokens.globalForeground);
return Text(
data,
maxLines: maxLines,
overflow: overflow,
textAlign: textAlign,
style: TextStyle(
color: resolved,
fontSize: fontSize,
// Null means inherit from the ambient DefaultTextStyle —
// _AppRoot installs clideUiDefaultWeight there; goldens get
// whatever Alchemist injects. Passing an explicit weight (e.g.
// FontWeight.bold) still wins.
fontWeight: fontWeight,
),
);
}
}