design_system 0.5.1: KLogo, fix asset key
Some checks are pending
design_system tests / test (push) Waiting to run
file length / file-length (push) Waiting to run
kuhy_credit drift / drift (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run

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 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-21 05:58:11 +01:00
parent 7c10ae734f
commit 7252ba0a76
6 changed files with 181 additions and 1 deletions

View File

@ -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

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
<rect id="field" width="512" height="512" fill="#211D1B"/>
<path fill="#B8862E" fill-rule="evenodd" d="M232.45 126.71L235.40 121.83L236.86 117.46L237.16 113.16L236.11 108.55L233.71 104.34L230.14 100.74L225.62 97.95L220.41 96.16L214.75 95.51L208.86 96.11L202.89 97.96L196.97 101.02L191.80 104.61L186.14 109.43L168.83 127.05L163.79 131.69L158.86 135.08L156.85 135.91L155.00 136.26L153.32 136.10L151.51 135.26L150.17 134.03L148.74 131.95L146.53 126.68L142.68 113.58L140.39 107.28L137.47 101.80L134.17 98.03L131.62 96.28L129.30 95.34L126.82 94.91L124.22 94.99L121.55 95.59L118.85 96.69L116.18 98.26L113.59 100.29L110.67 103.26L108.46 106.12L104.82 112.71L103.46 116.33L102.26 120.85L101.33 129.40L101.51 134.83L102.18 140.16L107.16 161.56L107.92 166.59L108.16 170.93L107.96 175.30L107.23 180.39L103.30 196.89L102.03 203.60L101.44 209.71L101.57 215.83L102.56 221.84L104.46 227.54L106.85 232.14L110.30 236.77L113.30 239.71L117.11 242.44L120.52 244.13L124.51 245.27L128.36 245.46L131.44 244.86L134.25 243.55L137.10 241.19L138.84 238.98L140.33 236.37L142.79 229.46L144.26 222.20L146.91 203.45L149.00 195.46L150.82 191.74L152.78 189.39L155.06 187.98L157.64 187.54L160.46 188.07L163.46 189.54L166.57 191.89L170.18 195.54L176.49 203.82L187.93 221.96L192.91 229.15L198.18 235.26L203.30 239.57L207.07 241.74L210.40 243.03L213.78 243.76L217.74 243.92L221.07 243.47L224.80 242.29L228.25 240.44L230.89 238.38L233.17 235.92L235.02 233.11L236.37 230.00L237.18 226.63L237.42 223.07L237.07 219.35L236.13 215.54L234.60 211.66L230.90 205.16L225.43 198.15L219.02 191.41L205.04 178.08L200.57 173.11L197.35 167.98L196.49 165.31L196.29 163.13L196.57 160.98L197.54 158.44L199.16 155.90L201.39 153.37L206.78 148.63L224.45 135.06L228.82 130.95ZM439.15 304.62L441.35 299.45L442.51 294.18L442.42 288.99L441.16 284.54L438.79 280.56L435.43 277.23L431.27 274.73L426.09 273.10L421.13 272.75L416.70 273.37L412.03 275.08L407.76 277.80L404.33 280.97L400.93 285.13L391.39 300.46L387.52 305.61L384.97 308.13L382.62 309.84L379.82 311.14L377.32 311.67L374.44 311.56L371.59 310.69L368.84 309.10L366.22 306.86L361.68 301.20L353.72 288.20L349.90 282.87L345.10 278.03L339.97 274.81L336.22 273.46L332.80 272.84L328.82 272.80L324.89 273.46L321.18 274.78L317.81 276.73L314.92 279.23L312.64 282.19L311.36 284.65L310.49 287.28L310.02 290.04L309.96 292.87L310.28 295.74L311.10 299.10L313.73 305.20L316.79 310.09L321.01 315.47L337.30 332.65L344.34 340.99L350.25 349.71L354.13 357.71L356.15 364.64L356.94 371.76L356.69 378.61L354.92 395.62L354.93 400.36L355.46 405.02L356.78 409.97L358.95 414.48L361.98 418.37L365.77 421.42L369.24 423.14L372.98 424.16L376.83 424.43L380.67 423.95L384.34 422.72L387.71 420.81L390.68 418.27L393.42 414.79L394.87 412.17L396.16 408.88L397.04 405.40L397.53 401.79L397.58 394.42L395.86 378.48L395.63 371.63L396.54 364.05L398.85 356.69L402.90 348.74L408.61 340.49L415.36 332.56L431.64 315.37L435.86 309.98Z"/>
<path fill="#ECEAE9" fill-rule="evenodd" d="M272.87 180.50L273.78 191.15L275.43 199.68L277.93 207.24L281.46 214.32L286.01 220.83L291.97 227.15L298.81 232.68L306.29 237.38L314.83 241.44L323.65 244.37L331.97 245.96L340.33 246.39L348.69 245.62L356.98 243.70L365.74 240.46L374.17 236.11L379.85 232.38L385.15 228.16L389.95 223.48L393.76 218.86L397.03 213.89L399.73 208.60L401.84 203.03L403.53 196.59L404.61 189.99L405.30 181.99L405.89 159.12L407.09 137.35L407.21 129.01L406.69 121.27L405.60 115.09L403.79 109.27L401.53 104.61L398.24 100.21L394.25 96.96L389.72 95.06L385.41 94.63L381.04 95.41L376.28 97.71L371.95 101.35L368.30 106.12L366.03 110.43L364.13 115.78L363.07 120.69L362.53 126.40L362.58 131.38L363.12 136.95L366.62 155.29L367.54 162.94L367.32 171.38L366.55 176.01L365.50 179.98L363.26 185.87L360.61 190.86L357.41 195.43L353.74 199.38L349.69 202.52L345.92 204.46L342.02 205.56L338.06 205.77L334.12 205.08L330.28 203.52L326.61 201.16L322.73 197.62L319.27 193.35L316.32 188.55L313.95 183.43L312.21 178.16L310.80 170.23L310.73 162.45L311.59 155.45L315.00 137.80L315.74 128.01L315.47 123.01L314.68 118.04L313.31 113.22L311.38 108.68L308.91 104.56L305.95 101.00L302.59 98.14L298.95 96.07L295.15 94.89L291.33 94.64L287.61 95.31L284.11 96.89L281.80 98.52L279.70 100.54L277.81 102.91L275.86 106.15L273.20 112.94L271.66 120.41L271.11 126.72L271.03 133.73L272.32 158.32ZM142.50 408.93L144.93 412.86L148.33 416.82L151.62 419.58L155.73 421.94L159.96 423.33L164.11 423.69L168.00 423.04L171.46 421.41L173.61 419.69L175.81 417.09L177.30 414.53L178.71 411.07L180.34 403.92L181.90 389.45L182.76 384.30L184.38 379.06L186.60 375.03L188.42 372.84L190.56 370.93L193.02 369.30L196.36 367.72L203.33 365.93L207.41 365.55L211.54 365.59L218.20 366.61L224.14 368.79L226.71 370.32L228.97 372.13L232.20 376.09L234.21 380.29L235.51 385.06L237.68 403.40L239.06 409.98L241.43 415.72L243.06 418.13L244.99 420.16L247.70 422.03L250.76 423.22L254.12 423.70L257.08 423.52L260.70 422.61L263.71 421.29L267.19 419.06L269.90 416.70L273.71 412.09L276.70 406.63L278.73 400.57L279.77 394.13L279.87 387.57L279.19 381.08L277.76 374.06L273.42 357.39L272.70 353.01L272.43 348.73L272.65 344.45L273.45 339.45L277.62 323.51L278.95 317.31L279.71 311.68L279.93 306.77L279.20 298.62L277.23 291.66L274.04 285.39L269.78 280.17L267.06 277.83L263.57 275.63L260.56 274.33L256.94 273.46L253.99 273.30L250.64 273.80L248.07 274.77L245.32 276.56L243.34 278.53L241.66 280.88L239.20 286.54L237.66 293.75L235.48 312.08L233.95 317.39L231.82 321.50L230.08 323.74L228.00 325.70L225.60 327.39L222.90 328.79L216.76 330.71L209.32 331.48L201.85 330.81L198.02 329.85L195.07 328.73L192.39 327.32L190.00 325.62L187.94 323.64L186.21 321.39L184.11 317.26L182.60 311.93L180.42 293.59L179.04 287.01L177.76 283.44L176.37 280.76L174.68 278.43L172.69 276.48L169.92 274.72L167.34 273.77L163.98 273.30L161.03 273.48L157.40 274.38L154.40 275.70L150.92 277.93L148.21 280.29L143.97 285.54L141.10 291.09L139.19 297.22L138.23 304.49L138.34 311.05L139.18 317.50L144.55 338.96L145.64 347.04L145.57 351.31L144.91 356.27L139.77 376.54L138.77 382.07L138.23 387.76L138.29 393.51L139.06 399.17L140.59 404.59Z"/>
</svg>

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -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';

View File

@ -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);
}

View File

@ -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

View File

@ -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<SvgPicture>(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<SvgPicture>(find.byType(SvgPicture)).colorFilter,
const ColorFilter.mode(Color(0xFFB8862E), BlendMode.srcIn),
);
await tester.pumpWidget(const Center(child: KLogo()));
expect(
tester.widget<SvgPicture>(find.byType(SvgPicture)).colorFilter,
isNull,
);
});
}