utils/design_system/lib/src/logo.dart
Krzysztof kuhy Rudnicki 7252ba0a76
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
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 <noreply@anthropic.com>
2026-11-21 05:58:11 +01:00

116 lines
3.1 KiB
Dart

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