From 7252ba0a7637f08dba09a79426817e423643c62f Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sat, 21 Nov 2026 05:58:11 +0100 Subject: [PATCH] design_system 0.5.1: KLogo, fix asset key The 0.5.0 tag passed 'packages/design_system/...' plus package:, so flutter_svg loaded a doubled key and the logo never rendered. Lands the logo on main (0.5.0 was tagged off-branch) with tests. Co-Authored-By: Claude Opus 5.5 --- design_system/README.md | 1 + design_system/assets/logo/kuhy.svg | 5 ++ design_system/lib/design_system.dart | 1 + design_system/lib/src/logo.dart | 115 +++++++++++++++++++++++++++ design_system/pubspec.yaml | 5 +- design_system/test/logo_test.dart | 55 +++++++++++++ 6 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 design_system/assets/logo/kuhy.svg create mode 100644 design_system/lib/src/logo.dart create mode 100644 design_system/test/logo_test.dart diff --git a/design_system/README.md b/design_system/README.md index 621a343..c6fe221 100644 --- a/design_system/README.md +++ b/design_system/README.md @@ -51,6 +51,7 @@ MaterialApp( | `showToast()` / `showError()` | ~38 raw `SnackBar` sites and zero helpers | | `EmptyState` | 4 variants, only one of them reusable | | `SectionHeader` | 3 near-identical private widgets | +| `KLogo` (+ `KLogoSmall`/`Medium`/`Large`/`XLarge`: 24/32/48/96 px) | per-app copies of the kuhy logo; the SVG ships as a package asset | ### Why the scales are what they are diff --git a/design_system/assets/logo/kuhy.svg b/design_system/assets/logo/kuhy.svg new file mode 100644 index 0000000..51ca959 --- /dev/null +++ b/design_system/assets/logo/kuhy.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/design_system/lib/design_system.dart b/design_system/lib/design_system.dart index b876944..707c381 100644 --- a/design_system/lib/design_system.dart +++ b/design_system/lib/design_system.dart @@ -15,6 +15,7 @@ export 'src/confirm.dart'; export 'src/empty_state.dart'; export 'src/feedback.dart'; export 'src/fit_grid.dart'; +export 'src/logo.dart'; export 'src/section_header.dart'; export 'src/status_colors.dart'; export 'src/theme.dart'; diff --git a/design_system/lib/src/logo.dart b/design_system/lib/src/logo.dart new file mode 100644 index 0000000..09cbc4a --- /dev/null +++ b/design_system/lib/src/logo.dart @@ -0,0 +1,115 @@ +/// The kuhy logo as a Flutter widget. +/// +/// Uses the canonical SVG from unified-design-system/logo/final/kuhy.svg +/// (charcoal #211D1B field, shared accent #B8862E + off-white #ECEAE9 glyphs). +library; + +import 'package:flutter/widgets.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +/// The kuhy logo widget. +/// +/// Renders the canonical kuhy logo at any size. The asset is bundled with +/// the design_system package so every app gets it from one source. +/// +/// Example: +/// ```dart +/// const KLogo(size: 48) +/// ``` +class KLogo extends StatelessWidget { + /// Creates the logo. + const KLogo({ + super.key, + this.size = 48, + this.color, + this.semanticLabel = 'kuhy logo', + }); + + /// The logo size in logical pixels (width = height). + final double size; + + /// Optional color filter — when null, uses the SVG's own colours. + final Color? color; + + /// Semantic label for accessibility. + final String semanticLabel; + + @override + Widget build(BuildContext context) => Semantics( + label: semanticLabel, + child: SvgPicture.asset( + // `package:` adds the packages/design_system/ prefix itself. + 'assets/logo/kuhy.svg', + package: 'design_system', + width: size, + height: size, + colorFilter: color == null + ? null + : ColorFilter.mode(color!, BlendMode.srcIn), + ), + ); +} + +/// Small kuhy logo — 24px, for inline use. +class KLogoSmall extends StatelessWidget { + /// Creates the small logo. + const KLogoSmall({super.key, this.color, this.semanticLabel = 'kuhy logo'}); + + /// Optional color filter. + final Color? color; + + /// Semantic label for accessibility. + final String semanticLabel; + + @override + Widget build(BuildContext context) => + KLogo(size: 24, color: color, semanticLabel: semanticLabel); +} + +/// Medium kuhy logo — 32px, for headers. +class KLogoMedium extends StatelessWidget { + /// Creates the medium logo. + const KLogoMedium({super.key, this.color, this.semanticLabel = 'kuhy logo'}); + + /// Optional color filter. + final Color? color; + + /// Semantic label for accessibility. + final String semanticLabel; + + @override + Widget build(BuildContext context) => + KLogo(size: 32, color: color, semanticLabel: semanticLabel); +} + +/// Large kuhy logo — 48px, for splash/about screens. +class KLogoLarge extends StatelessWidget { + /// Creates the large logo. + const KLogoLarge({super.key, this.color, this.semanticLabel = 'kuhy logo'}); + + /// Optional color filter. + final Color? color; + + /// Semantic label for accessibility. + final String semanticLabel; + + @override + Widget build(BuildContext context) => + KLogo(size: 48, color: color, semanticLabel: semanticLabel); +} + +/// Extra-large kuhy logo — 96px, for splash screens. +class KLogoXLarge extends StatelessWidget { + /// Creates the extra-large logo. + const KLogoXLarge({super.key, this.color, this.semanticLabel = 'kuhy logo'}); + + /// Optional color filter. + final Color? color; + + /// Semantic label for accessibility. + final String semanticLabel; + + @override + Widget build(BuildContext context) => + KLogo(size: 96, color: color, semanticLabel: semanticLabel); +} diff --git a/design_system/pubspec.yaml b/design_system/pubspec.yaml index eb1e048..e11e50f 100644 --- a/design_system/pubspec.yaml +++ b/design_system/pubspec.yaml @@ -5,7 +5,7 @@ description: >- helpers that were each reimplemented in three or more repos. Owns the tokens -- consumers import them rather than transcribing the token table by hand. publish_to: 'none' -version: 0.4.1 +version: 0.5.1 environment: sdk: ^3.12.2 @@ -13,6 +13,7 @@ environment: dependencies: flutter: sdk: flutter + flutter_svg: 2.5.0 material_ui: 1.11.1 dev_dependencies: @@ -21,3 +22,5 @@ dev_dependencies: very_good_analysis: ^11.0.0 flutter: + assets: + - assets/logo/kuhy.svg diff --git a/design_system/test/logo_test.dart b/design_system/test/logo_test.dart new file mode 100644 index 0000000..b06f7dd --- /dev/null +++ b/design_system/test/logo_test.dart @@ -0,0 +1,55 @@ +import 'package:design_system/design_system.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:material_ui/material_ui.dart'; + +/// The bundle key flutter_svg loads for [loader] (see SvgAssetLoader). +String _keyOf(SvgAssetLoader loader) => loader.packageName == null + ? loader.assetName + : 'packages/${loader.packageName}/${loader.assetName}'; + +void main() { + testWidgets('KLogo loads an asset that is in the bundle', (tester) async { + await tester.pumpWidget(const Center(child: KLogo())); + final picture = tester.widget(find.byType(SvgPicture)); + final key = _keyOf(picture.bytesLoader as SvgAssetLoader); + final data = await rootBundle.load(key); + expect(data.lengthInBytes, greaterThan(0)); + }); + + testWidgets('size presets are 24, 32, 48, 96', (tester) async { + final presets = <(Widget, double)>[ + (const KLogoSmall(), 24), + (const KLogoMedium(), 32), + (const KLogoLarge(), 48), + (const KLogoXLarge(), 96), + ]; + for (final (logo, side) in presets) { + await tester.pumpWidget(Center(child: logo)); + expect(tester.getSize(find.byType(SvgPicture)), Size.square(side)); + } + }); + + testWidgets('carries a semantics label', (tester) async { + await tester.pumpWidget(const MaterialApp(home: KLogo())); + expect(find.bySemanticsLabel('kuhy logo'), findsOneWidget); + }); + + testWidgets('a color tints the glyphs, none keeps the SVG colours', ( + tester, + ) async { + await tester.pumpWidget( + const Center(child: KLogo(color: Color(0xFFB8862E))), + ); + expect( + tester.widget(find.byType(SvgPicture)).colorFilter, + const ColorFilter.mode(Color(0xFFB8862E), BlendMode.srcIn), + ); + await tester.pumpWidget(const Center(child: KLogo())); + expect( + tester.widget(find.byType(SvgPicture)).colorFilter, + isNull, + ); + }); +}