From 50c784cc25ff28d98acffeb57742d405b47042f3 Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Wed, 15 Apr 2026 19:00:36 -0400 Subject: [PATCH 01/26] Pass release inputs through environment variables - Forward `change_message` and `release_title` via env vars - Avoid inline interpolation in the release workflow script --- .github/workflows/release-desktop.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml index 8f875d1e..9ffebc41 100644 --- a/.github/workflows/release-desktop.yml +++ b/.github/workflows/release-desktop.yml @@ -71,13 +71,16 @@ jobs: - name: Run Desktop Release Script shell: pwsh + env: + CHANGE_MESSAGE: ${{ inputs.change_message }} + RELEASE_TITLE: ${{ inputs.release_title }} run: | $args = @( "-ExecutionPolicy", "Bypass", "-File", "scripts/release_desktop.ps1", "-VersionBump", "${{ inputs.version_bump }}", "-Channel", "${{ inputs.channel }}", - "-ChangeMessage", "${{ inputs.change_message }}" + "-ChangeMessage", $env:CHANGE_MESSAGE ) if ("${{ inputs.publish_pages }}" -eq "true") { @@ -88,8 +91,8 @@ jobs: $args += "-Mandatory" } - if (-not [string]::IsNullOrWhiteSpace("${{ inputs.release_title }}")) { - $args += @("-ReleaseTitle", "${{ inputs.release_title }}") + if (-not [string]::IsNullOrWhiteSpace($env:RELEASE_TITLE)) { + $args += @("-ReleaseTitle", $env:RELEASE_TITLE) } & powershell @args From 6c0d04508b2ad18be1e6486c0842edf02c3b3d07 Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Tue, 21 Apr 2026 20:20:55 -0400 Subject: [PATCH 02/26] Persist drawing colors as ARGB integers - Migrate drawing elements and serializers from `Color` strings to `colorValue` - Preserve legacy JSON and Hive payloads during read - Add regression tests for JSON and Hive color persistence --- lib/const/drawing_element.dart | 71 ++++-- lib/const/drawing_element.g.dart | 5 +- lib/hive/hive_adapters.g.dart | 25 +- lib/hive/hive_adapters.g.yaml | 16 +- lib/providers/drawing_provider.dart | 36 +-- lib/providers/strategy_provider.dart | 6 +- test/color_persistence_test.dart | 335 +++++++++++++++++++++++++++ test/drawing_provider_test.dart | 10 + 8 files changed, 458 insertions(+), 46 deletions(-) create mode 100644 test/color_persistence_test.dart diff --git a/lib/const/drawing_element.dart b/lib/const/drawing_element.dart index 84b171da..11e3db9f 100644 --- a/lib/const/drawing_element.dart +++ b/lib/const/drawing_element.dart @@ -10,8 +10,12 @@ import 'package:json_annotation/json_annotation.dart'; part "drawing_element.g.dart"; abstract class DrawingElement { - @ColorConverter() - final Color color; + @JsonKey( + readValue: _readDrawingColorJsonValue, + fromJson: _drawingColorValueFromJson, + toJson: _drawingColorValueToJson, + ) + final int colorValue; @JsonKey(defaultValue: Settings.defaultStrokeThickness) final double thickness; final bool isDotted; @@ -19,8 +23,11 @@ abstract class DrawingElement { final String id; BoundingBox? boundingBox; + @JsonKey(includeFromJson: false, includeToJson: false) + Color get color => Color(colorValue); + DrawingElement({ - required this.color, + required this.colorValue, this.thickness = Settings.defaultStrokeThickness, this.boundingBox, required this.isDotted, @@ -35,6 +42,21 @@ abstract class DrawingElement { } } +Object? _readDrawingColorJsonValue(Map json, String key) { + return json[key] ?? json['color']; +} + +int _drawingColorValueFromJson(Object? json) { + if (json is int) return json; + if (json is num) return json.toInt(); + if (json is String) { + return const ColorConverter().fromJson(json).toARGB32(); + } + throw ArgumentError.value(json, 'json', 'Unsupported drawing color value'); +} + +int _drawingColorValueToJson(int colorValue) => colorValue; + class Line extends DrawingElement with HiveObjectMixin { final Offset lineStart; Offset lineEnd; @@ -44,7 +66,8 @@ class Line extends DrawingElement with HiveObjectMixin { Line({ required this.lineStart, required this.lineEnd, - required super.color, + Color? color, + int? colorValue, super.thickness = Settings.defaultStrokeThickness, super.boundingBox, required super.isDotted, @@ -52,7 +75,11 @@ class Line extends DrawingElement with HiveObjectMixin { required super.id, this.showTraversalTime = false, this.traversalSpeedProfile = TraversalSpeed.defaultProfile, - }); + }) : assert( + color != null || colorValue != null, + 'Either color or colorValue is required.', + ), + super(colorValue: colorValue ?? color!.toARGB32()); void updateEndPoint(Offset endPoint) { lineEnd = endPoint; @@ -62,6 +89,7 @@ class Line extends DrawingElement with HiveObjectMixin { Offset? lineStart, Offset? lineEnd, Color? color, + int? colorValue, double? thickness, BoundingBox? boundingBox, bool? isDotted, @@ -73,7 +101,7 @@ class Line extends DrawingElement with HiveObjectMixin { return Line( lineStart: lineStart ?? this.lineStart, lineEnd: lineEnd ?? this.lineEnd, - color: color ?? this.color, + colorValue: colorValue ?? color?.toARGB32() ?? this.colorValue, thickness: thickness ?? this.thickness, boundingBox: boundingBox ?? this.boundingBox, isDotted: isDotted ?? this.isDotted, @@ -93,13 +121,18 @@ class RectangleDrawing extends DrawingElement with HiveObjectMixin { RectangleDrawing({ required this.start, required this.end, - required super.color, + Color? color, + int? colorValue, super.thickness = Settings.defaultStrokeThickness, super.boundingBox, required super.isDotted, required super.hasArrow, required super.id, - }); + }) : assert( + color != null || colorValue != null, + 'Either color or colorValue is required.', + ), + super(colorValue: colorValue ?? color!.toARGB32()); void updateEndPoint(Offset endPoint) { end = endPoint; @@ -120,13 +153,18 @@ class EllipseDrawing extends DrawingElement with HiveObjectMixin { EllipseDrawing({ required this.start, required this.end, - required super.color, + Color? color, + int? colorValue, super.thickness = Settings.defaultStrokeThickness, super.boundingBox, required super.isDotted, required super.hasArrow, required super.id, - }); + }) : assert( + color != null || colorValue != null, + 'Either color or colorValue is required.', + ), + super(colorValue: colorValue ?? color!.toARGB32()); void updateEndPoint(Offset endPoint) { end = endPoint; @@ -145,7 +183,8 @@ class FreeDrawing extends DrawingElement with HiveObjectMixin { FreeDrawing({ List? listOfPoints, Path? path, - required super.color, + Color? color, + int? colorValue, super.thickness = Settings.defaultStrokeThickness, super.boundingBox, required super.isDotted, @@ -155,9 +194,14 @@ class FreeDrawing extends DrawingElement with HiveObjectMixin { this.traversalSpeedProfile = TraversalSpeed.defaultProfile, double? cachedPolylineLengthUnits, }) : listOfPoints = listOfPoints ?? [], + assert( + color != null || colorValue != null, + 'Either color or colorValue is required.', + ), _path = path ?? Path(), cachedPolylineLengthUnits = cachedPolylineLengthUnits ?? - _computePolylineLength(listOfPoints ?? []); + _computePolylineLength(listOfPoints ?? []), + super(colorValue: colorValue ?? color!.toARGB32()); @OffsetListConverter() List listOfPoints = []; @@ -263,6 +307,7 @@ class FreeDrawing extends DrawingElement with HiveObjectMixin { List? listOfPoints, Path? path, Color? color, + int? colorValue, double? thickness, BoundingBox? boundingBox, bool? isDotted, @@ -273,7 +318,7 @@ class FreeDrawing extends DrawingElement with HiveObjectMixin { double? cachedPolylineLengthUnits, }) { return FreeDrawing( - color: color ?? this.color, + colorValue: colorValue ?? color?.toARGB32() ?? this.colorValue, thickness: thickness ?? this.thickness, listOfPoints: listOfPoints ?? this.listOfPoints, path: path ?? _path, diff --git a/lib/const/drawing_element.g.dart b/lib/const/drawing_element.g.dart index c2bfba0d..c2046ac9 100644 --- a/lib/const/drawing_element.g.dart +++ b/lib/const/drawing_element.g.dart @@ -9,7 +9,8 @@ part of 'drawing_element.dart'; FreeDrawing _$FreeDrawingFromJson(Map json) => FreeDrawing( listOfPoints: _$JsonConverterFromJson, List>( json['listOfPoints'], const OffsetListConverter().fromJson), - color: const ColorConverter().fromJson(json['color'] as String), + colorValue: _drawingColorValueFromJson( + _readDrawingColorJsonValue(json, 'colorValue')), thickness: (json['thickness'] as num?)?.toDouble() ?? 5.0, boundingBox: json['boundingBox'] == null ? null @@ -25,7 +26,7 @@ FreeDrawing _$FreeDrawingFromJson(Map json) => FreeDrawing( Map _$FreeDrawingToJson(FreeDrawing instance) => { - 'color': const ColorConverter().toJson(instance.color), + 'colorValue': _drawingColorValueToJson(instance.colorValue), 'thickness': instance.thickness, 'isDotted': instance.isDotted, 'hasArrow': instance.hasArrow, diff --git a/lib/hive/hive_adapters.g.dart b/lib/hive/hive_adapters.g.dart index 1f0c3b8b..4f465e20 100644 --- a/lib/hive/hive_adapters.g.dart +++ b/lib/hive/hive_adapters.g.dart @@ -6,6 +6,15 @@ part of 'hive_adapters.dart'; // AdaptersGenerator // ************************************************************************** +int _readLegacyDrawingHiveColorValue(Object? value) { + return switch (value) { + final int colorValue => colorValue, + final num colorValue => colorValue.toInt(), + final Color color => color.toARGB32(), + _ => 0xFFFFFFFF, + }; +} + class StrategyDataAdapter extends TypeAdapter { @override final typeId = 0; @@ -641,7 +650,7 @@ class FreeDrawingAdapter extends TypeAdapter { }; return FreeDrawing( listOfPoints: (fields[0] as List?)?.cast(), - color: fields[2] as Color, + colorValue: _readLegacyDrawingHiveColorValue(fields[12] ?? fields[2]), thickness: fields[11] == null ? Settings.defaultStrokeThickness : (fields[11] as num).toDouble(), @@ -664,7 +673,7 @@ class FreeDrawingAdapter extends TypeAdapter { ..writeByte(0) ..write(obj.listOfPoints) ..writeByte(2) - ..write(obj.color) + ..write(obj.colorValue) ..writeByte(3) ..write(obj.isDotted) ..writeByte(4) @@ -707,7 +716,7 @@ class LineAdapter extends TypeAdapter { return Line( lineStart: fields[0] as Offset, lineEnd: fields[1] as Offset, - color: fields[2] as Color, + colorValue: _readLegacyDrawingHiveColorValue(fields[10] ?? fields[2]), thickness: fields[9] == null ? Settings.defaultStrokeThickness : (fields[9] as num).toDouble(), @@ -731,7 +740,7 @@ class LineAdapter extends TypeAdapter { ..writeByte(1) ..write(obj.lineEnd) ..writeByte(2) - ..write(obj.color) + ..write(obj.colorValue) ..writeByte(3) ..write(obj.isDotted) ..writeByte(4) @@ -1288,7 +1297,7 @@ class RectangleDrawingAdapter extends TypeAdapter { return RectangleDrawing( start: fields[0] as Offset, end: fields[1] as Offset, - color: fields[2] as Color, + colorValue: _readLegacyDrawingHiveColorValue(fields[8] ?? fields[2]), thickness: fields[7] == null ? Settings.defaultStrokeThickness : (fields[7] as num).toDouble(), @@ -1308,7 +1317,7 @@ class RectangleDrawingAdapter extends TypeAdapter { ..writeByte(1) ..write(obj.end) ..writeByte(2) - ..write(obj.color) + ..write(obj.colorValue) ..writeByte(3) ..write(obj.isDotted) ..writeByte(4) @@ -1631,7 +1640,7 @@ class EllipseDrawingAdapter extends TypeAdapter { return EllipseDrawing( start: fields[0] as Offset, end: fields[1] as Offset, - color: fields[2] as Color, + colorValue: _readLegacyDrawingHiveColorValue(fields[8] ?? fields[2]), thickness: fields[3] == null ? Settings.defaultStrokeThickness : (fields[3] as num).toDouble(), @@ -1651,7 +1660,7 @@ class EllipseDrawingAdapter extends TypeAdapter { ..writeByte(1) ..write(obj.end) ..writeByte(2) - ..write(obj.color) + ..write(obj.colorValue) ..writeByte(3) ..write(obj.thickness) ..writeByte(4) diff --git a/lib/hive/hive_adapters.g.yaml b/lib/hive/hive_adapters.g.yaml index ad40594a..3cc4cbb3 100644 --- a/lib/hive/hive_adapters.g.yaml +++ b/lib/hive/hive_adapters.g.yaml @@ -237,7 +237,7 @@ types: index: 1 FreeDrawing: typeId: 11 - nextIndex: 12 + nextIndex: 13 fields: listOfPoints: index: 0 @@ -259,9 +259,11 @@ types: index: 10 thickness: index: 11 + colorValue: + index: 12 Line: typeId: 12 - nextIndex: 10 + nextIndex: 11 fields: lineStart: index: 0 @@ -283,6 +285,8 @@ types: index: 8 thickness: index: 9 + colorValue: + index: 10 BoundingBox: typeId: 13 nextIndex: 2 @@ -449,7 +453,7 @@ types: index: 1 RectangleDrawing: typeId: 24 - nextIndex: 8 + nextIndex: 9 fields: start: index: 0 @@ -467,6 +471,8 @@ types: index: 6 thickness: index: 7 + colorValue: + index: 8 TraversalSpeedProfile: typeId: 25 nextIndex: 4 @@ -559,7 +565,7 @@ types: index: 8 EllipseDrawing: typeId: 31 - nextIndex: 8 + nextIndex: 9 fields: start: index: 0 @@ -577,6 +583,8 @@ types: index: 6 boundingBox: index: 7 + colorValue: + index: 8 AbilityVisualState: typeId: 32 nextIndex: 6 diff --git a/lib/providers/drawing_provider.dart b/lib/providers/drawing_provider.dart index 93e0b90b..336dd86e 100644 --- a/lib/providers/drawing_provider.dart +++ b/lib/providers/drawing_provider.dart @@ -178,11 +178,10 @@ class DrawingProvider extends Notifier { } if (element is Line) { - const colorConverter = ColorConverter(); const offsetConverter = OffsetConverter(); return { 'type': 'lineDrawing', - 'color': colorConverter.toJson(element.color), + 'colorValue': element.colorValue, 'thickness': element.thickness, 'isDotted': element.isDotted, 'hasArrow': element.hasArrow, @@ -196,11 +195,10 @@ class DrawingProvider extends Notifier { } if (element is RectangleDrawing) { - const colorConverter = ColorConverter(); const offsetConverter = OffsetConverter(); return { 'type': 'rectangleDrawing', - 'color': colorConverter.toJson(element.color), + 'colorValue': element.colorValue, 'thickness': element.thickness, 'isDotted': element.isDotted, 'hasArrow': element.hasArrow, @@ -212,11 +210,10 @@ class DrawingProvider extends Notifier { } if (element is EllipseDrawing) { - const colorConverter = ColorConverter(); const offsetConverter = OffsetConverter(); return { 'type': 'ellipseDrawing', - 'color': colorConverter.toJson(element.color), + 'colorValue': element.colorValue, 'thickness': element.thickness, 'isDotted': element.isDotted, 'hasArrow': element.hasArrow, @@ -249,7 +246,6 @@ class DrawingProvider extends Notifier { (type == null && json.containsKey('lineStart') && json.containsKey('lineEnd'))) { - const colorConverter = ColorConverter(); const offsetConverter = OffsetConverter(); final lineStart = offsetConverter @@ -269,7 +265,7 @@ class DrawingProvider extends Notifier { return Line( lineStart: lineStart, lineEnd: lineEnd, - color: colorConverter.fromJson(json['color'] as String), + colorValue: _readDrawingColorValue(json), thickness: (json['thickness'] as num?)?.toDouble() ?? Settings.defaultStrokeThickness, isDotted: json['isDotted'] as bool? ?? false, @@ -289,7 +285,6 @@ class DrawingProvider extends Notifier { (type == null && json.containsKey('start') && json.containsKey('end'))) { - const colorConverter = ColorConverter(); const offsetConverter = OffsetConverter(); final start = offsetConverter @@ -312,7 +307,7 @@ class DrawingProvider extends Notifier { return RectangleDrawing( start: start, end: end, - color: colorConverter.fromJson(json['color'] as String), + colorValue: _readDrawingColorValue(json), thickness: (json['thickness'] as num?)?.toDouble() ?? Settings.defaultStrokeThickness, isDotted: json['isDotted'] as bool? ?? false, @@ -323,7 +318,6 @@ class DrawingProvider extends Notifier { } if (type == 'ellipseDrawing') { - const colorConverter = ColorConverter(); const offsetConverter = OffsetConverter(); final start = offsetConverter @@ -347,7 +341,7 @@ class DrawingProvider extends Notifier { return EllipseDrawing( start: start, end: end, - color: colorConverter.fromJson(json['color'] as String), + colorValue: _readDrawingColorValue(json), thickness: (json['thickness'] as num?)?.toDouble() ?? Settings.defaultStrokeThickness, isDotted: json['isDotted'] as bool? ?? false, @@ -572,7 +566,7 @@ class DrawingProvider extends Notifier { FreeDrawing freeDrawing = FreeDrawing( hasArrow: hasArrow, isDotted: isDotted, - color: activeColor, + colorValue: activeColor.toARGB32(), thickness: thickness, boundingBox: BoundingBox(min: normalizedStart, max: normalizedStart), id: id, @@ -664,7 +658,7 @@ class DrawingProvider extends Notifier { final rectangle = RectangleDrawing( start: normalizedStart, end: normalizedStart, - color: activeColor, + colorValue: activeColor.toARGB32(), thickness: thickness, isDotted: isDotted, hasArrow: false, @@ -742,7 +736,7 @@ class DrawingProvider extends Notifier { final ellipse = EllipseDrawing( start: normalizedStart, end: normalizedStart, - color: activeColor, + colorValue: activeColor.toARGB32(), thickness: thickness, isDotted: isDotted, hasArrow: false, @@ -831,7 +825,7 @@ class DrawingProvider extends Notifier { final line = Line( lineStart: normalizedStart, lineEnd: normalizedStart, - color: activeColor, + colorValue: activeColor.toARGB32(), thickness: thickness, boundingBox: BoundingBox(min: normalizedStart, max: normalizedStart), isDotted: isDotted, @@ -921,6 +915,16 @@ class DrawingProvider extends Notifier { } } +int _readDrawingColorValue(Map json) { + final value = json['colorValue'] ?? json['color']; + if (value is int) return value; + if (value is num) return value.toInt(); + if (value is String) { + return const ColorConverter().fromJson(value).toARGB32(); + } + throw UnsupportedError('Unsupported drawing color payload: $value'); +} + BoundingBox _boundingBoxForPoints(Offset a, Offset b) { return BoundingBox( min: Offset(min(a.dx, b.dx), min(a.dy, b.dy)), diff --git a/lib/providers/strategy_provider.dart b/lib/providers/strategy_provider.dart index b397548e..a9e553fe 100644 --- a/lib/providers/strategy_provider.dart +++ b/lib/providers/strategy_provider.dart @@ -800,7 +800,7 @@ class StrategyProvider extends Notifier { return Line( lineStart: shift(element.lineStart), lineEnd: shift(element.lineEnd), - color: element.color, + colorValue: element.colorValue, thickness: element.thickness, boundingBox: shiftBoundingBox(element.boundingBox), isDotted: element.isDotted, @@ -816,7 +816,7 @@ class StrategyProvider extends Notifier { return FreeDrawing( listOfPoints: shiftedPoints, - color: element.color, + colorValue: element.colorValue, thickness: element.thickness, boundingBox: shiftBoundingBox(element.boundingBox), isDotted: element.isDotted, @@ -830,7 +830,7 @@ class StrategyProvider extends Notifier { return RectangleDrawing( start: shift(element.start), end: shift(element.end), - color: element.color, + colorValue: element.colorValue, thickness: element.thickness, boundingBox: shiftBoundingBox(element.boundingBox), isDotted: element.isDotted, diff --git a/test/color_persistence_test.dart b/test/color_persistence_test.dart new file mode 100644 index 00000000..15796728 --- /dev/null +++ b/test/color_persistence_test.dart @@ -0,0 +1,335 @@ +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:hive_ce/hive.dart'; +import 'package:hive_ce/src/binary/binary_reader_impl.dart'; +import 'package:hive_ce/src/binary/binary_writer_impl.dart'; +import 'package:icarus/const/agents.dart'; +import 'package:icarus/const/bounding_box.dart'; +import 'package:icarus/const/drawing_element.dart'; +import 'package:icarus/const/placed_classes.dart'; +import 'package:icarus/const/traversal_speed.dart'; +import 'package:icarus/const/utilities.dart'; +import 'package:icarus/hive/hive_adapters.dart'; +import 'package:icarus/hive/hive_registration.dart'; +import 'package:icarus/providers/drawing_provider.dart'; +import 'package:icarus/providers/strategy_page.dart'; +import 'package:icarus/providers/strategy_settings_provider.dart'; + +const int _testColorAdapterTypeId = 220; + +class _TestColorAdapter extends TypeAdapter { + @override + final typeId = _testColorAdapterTypeId; + + @override + Color read(BinaryReader reader) { + return Color((reader.read() as num).toInt()); + } + + @override + void write(BinaryWriter writer, Color obj) { + writer.write(obj.toARGB32()); + } +} + +void _ensureAdaptersRegistered() { + if (!Hive.isAdapterRegistered(20)) { + registerIcarusAdapters(Hive); + } + if (!Hive.isAdapterRegistered(_testColorAdapterTypeId)) { + Hive.registerAdapter(_TestColorAdapter()); + } +} + +Map _readAdapterFields( + void Function(BinaryWriterImpl writer) writeObject, +) { + _ensureAdaptersRegistered(); + final writer = BinaryWriterImpl(Hive); + writeObject(writer); + final reader = BinaryReaderImpl(Uint8List.fromList(writer.toBytes()), Hive); + final numOfFields = reader.readByte(); + return { + for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), + }; +} + +BinaryReaderImpl _legacyFieldReader(Map fields) { + _ensureAdaptersRegistered(); + final writer = BinaryWriterImpl(Hive)..writeByte(fields.length); + for (final entry in fields.entries) { + writer + ..writeByte(entry.key) + ..write(entry.value); + } + return BinaryReaderImpl(Uint8List.fromList(writer.toBytes()), Hive); +} + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('JSON color persistence', () { + test('strategy page exports user-editable colors as ints', () { + final page = StrategyPage( + id: 'page-1', + name: 'Page 1', + drawingData: [ + Line( + id: 'line-1', + lineStart: const Offset(1, 2), + lineEnd: const Offset(3, 4), + color: const Color(0xFFAA5500), + boundingBox: BoundingBox( + min: const Offset(1, 2), + max: const Offset(3, 4), + ), + isDotted: false, + hasArrow: true, + ), + ], + agentData: const [], + abilityData: const [], + textData: [ + PlacedText( + id: 'text-1', + position: const Offset(5, 6), + tagColorValue: 0xFF22C55E, + )..text = 'Tagged text', + ], + imageData: [ + PlacedImage( + id: 'image-1', + position: const Offset(7, 8), + aspectRatio: 1.5, + scale: 200, + fileExtension: '.png', + tagColorValue: 0xFF3B82F6, + ), + ], + utilityData: [ + PlacedUtility( + id: 'utility-1', + position: const Offset(9, 10), + type: UtilityType.customCircle, + customDiameter: 12, + customColorValue: 0xFFEF4444, + customOpacityPercent: 35, + ), + ], + sortIndex: 0, + isAttack: true, + settings: StrategySettings(), + ); + + final payload = page.toJson('strategy-1'); + final drawingJson = (payload['drawingData'] as List).single + as Map; + final textJson = + (payload['textData'] as List).single as Map; + final imageJson = (payload['imageData'] as List).single + as Map; + final utilityJson = (payload['utilityData'] as List).single + as Map; + + expect(drawingJson['colorValue'], 0xFFAA5500); + expect(drawingJson.containsKey('color'), isFalse); + expect(textJson['tagColorValue'], 0xFF22C55E); + expect(imageJson['tagColorValue'], 0xFF3B82F6); + expect(utilityJson['customColorValue'], 0xFFEF4444); + }); + + test('legacy drawing color strings still deserialize', () { + final decoded = DrawingProvider.fromJson(jsonEncode([ + { + 'type': 'lineDrawing', + 'id': 'line-legacy', + 'color': '#FF22C55E', + 'isDotted': false, + 'hasArrow': false, + 'lineStart': {'dx': 1.0, 'dy': 2.0}, + 'lineEnd': {'dx': 3.0, 'dy': 4.0}, + }, + { + 'type': 'freeDrawing', + 'id': 'free-legacy', + 'color': '#FFEF4444', + 'isDotted': false, + 'hasArrow': false, + 'listOfPoints': [ + {'dx': 5.0, 'dy': 6.0}, + {'dx': 7.0, 'dy': 8.0}, + ], + }, + ])); + + expect((decoded[0] as Line).colorValue, 0xFF22C55E); + expect((decoded[1] as FreeDrawing).colorValue, 0xFFEF4444); + }); + }); + + group('Hive color persistence', () { + test('drawing adapters write integer color fields', () { + final freeDrawingFields = _readAdapterFields( + (writer) => FreeDrawingAdapter().write( + writer, + FreeDrawing( + id: 'free-1', + listOfPoints: const [Offset(1, 2), Offset(3, 4)], + color: const Color(0xFF22C55E), + isDotted: false, + hasArrow: false, + ), + ), + ); + final lineFields = _readAdapterFields( + (writer) => LineAdapter().write( + writer, + Line( + id: 'line-1', + lineStart: const Offset(1, 2), + lineEnd: const Offset(3, 4), + color: const Color(0xFF3B82F6), + boundingBox: BoundingBox( + min: const Offset(1, 2), + max: const Offset(3, 4), + ), + isDotted: false, + hasArrow: true, + ), + ), + ); + final rectangleFields = _readAdapterFields( + (writer) => RectangleDrawingAdapter().write( + writer, + RectangleDrawing( + id: 'rect-1', + start: const Offset(1, 2), + end: const Offset(3, 4), + color: const Color(0xFFF59E0B), + boundingBox: BoundingBox( + min: const Offset(1, 2), + max: const Offset(3, 4), + ), + isDotted: true, + hasArrow: false, + ), + ), + ); + final ellipseFields = _readAdapterFields( + (writer) => EllipseDrawingAdapter().write( + writer, + EllipseDrawing( + id: 'ellipse-1', + start: const Offset(1, 2), + end: const Offset(3, 4), + color: const Color(0xFFA855F7), + boundingBox: BoundingBox( + min: const Offset(1, 2), + max: const Offset(3, 4), + ), + isDotted: true, + hasArrow: false, + ), + ), + ); + + expect(freeDrawingFields[2], 0xFF22C55E); + expect(lineFields[2], 0xFF3B82F6); + expect(rectangleFields[2], 0xFFF59E0B); + expect(ellipseFields[2], 0xFFA855F7); + + expect(freeDrawingFields.values.whereType(), isEmpty); + expect(lineFields.values.whereType(), isEmpty); + expect(rectangleFields.values.whereType(), isEmpty); + expect(ellipseFields.values.whereType(), isEmpty); + }); + + test('drawing adapters still read legacy Hive Color payloads', () { + final restoredLine = LineAdapter().read( + _legacyFieldReader({ + 0: const Offset(1, 2), + 1: const Offset(3, 4), + 2: const Color(0xFFEF4444), + 3: true, + 4: false, + 5: 'legacy-line', + 6: BoundingBox( + min: const Offset(1, 2), + max: const Offset(3, 4), + ), + 7: false, + 8: TraversalSpeedProfile.walking, + 9: 5.0, + }), + ); + + expect(restoredLine.colorValue, 0xFFEF4444); + expect(restoredLine.color, const Color(0xFFEF4444)); + }); + + test('placed model adapters continue writing integer color fields', () { + final textFields = _readAdapterFields( + (writer) => PlacedTextAdapter().write( + writer, + PlacedText( + id: 'text-1', + position: const Offset(1, 2), + tagColorValue: 0xFF22C55E, + )..text = 'hello', + ), + ); + final imageFields = _readAdapterFields( + (writer) => PlacedImageAdapter().write( + writer, + PlacedImage( + id: 'image-1', + position: const Offset(3, 4), + aspectRatio: 1.5, + scale: 200, + fileExtension: '.png', + tagColorValue: 0xFF3B82F6, + ), + ), + ); + final utilityFields = _readAdapterFields( + (writer) => PlacedUtilityAdapter().write( + writer, + PlacedUtility( + id: 'utility-1', + position: const Offset(5, 6), + type: UtilityType.customRectangle, + customWidth: 4, + customLength: 8, + customColorValue: 0xFFF59E0B, + customOpacityPercent: 45, + ), + ), + ); + final circleAgentFields = _readAdapterFields( + (writer) => PlacedCircleAgentAdapter().write( + writer, + PlacedCircleAgent( + id: 'circle-agent-1', + type: AgentType.jett, + position: const Offset(7, 8), + diameterMeters: 12, + colorValue: 0xFFA855F7, + opacityPercent: 60, + ), + ), + ); + + expect(textFields[5], 0xFF22C55E); + expect(imageFields[9], 0xFF3B82F6); + expect(utilityFields[11], 0xFFF59E0B); + expect(circleAgentFields[1], 0xFFA855F7); + expect(textFields.values.whereType(), isEmpty); + expect(imageFields.values.whereType(), isEmpty); + expect(utilityFields.values.whereType(), isEmpty); + expect(circleAgentFields.values.whereType(), isEmpty); + }); + }); +} diff --git a/test/drawing_provider_test.dart b/test/drawing_provider_test.dart index 7cc09efb..02acc1e4 100644 --- a/test/drawing_provider_test.dart +++ b/test/drawing_provider_test.dart @@ -66,6 +66,10 @@ void main() { final decodedJson = jsonDecode(encoded) as List; expect(decodedJson.single, containsPair('type', 'lineDrawing')); + expect( + decodedJson.single, + containsPair('colorValue', Colors.red.toARGB32()), + ); expect(decodedJson.single, containsPair('isDotted', true)); expect(decodedJson.single, containsPair('hasArrow', true)); expect(decodedJson.single, containsPair('showTraversalTime', true)); @@ -77,6 +81,7 @@ void main() { final decoded = DrawingProvider.fromJson(encoded).single as Line; expect(decoded.lineStart, const Offset(10, 20)); expect(decoded.lineEnd, const Offset(30, 40)); + expect(decoded.colorValue, Colors.red.toARGB32()); expect(decoded.boundingBox!.min, const Offset(10, 20)); expect(decoded.boundingBox!.max, const Offset(30, 40)); expect(decoded.isDotted, isTrue); @@ -103,6 +108,10 @@ void main() { final decodedJson = jsonDecode(encoded) as List; expect(decodedJson.single, containsPair('type', 'ellipseDrawing')); + expect( + decodedJson.single, + containsPair('colorValue', Colors.purple.toARGB32()), + ); expect(decodedJson.single, containsPair('isDotted', true)); expect(decodedJson.single, containsPair('hasArrow', false)); @@ -110,6 +119,7 @@ void main() { DrawingProvider.fromJson(encoded).single as EllipseDrawing; expect(decoded.start, const Offset(10, 20)); expect(decoded.end, const Offset(40, 70)); + expect(decoded.colorValue, Colors.purple.toARGB32()); expect(decoded.boundingBox!.min, const Offset(10, 20)); expect(decoded.boundingBox!.max, const Offset(40, 70)); expect(decoded.isDotted, isTrue); From c06d6f49b7e932b8d5535f9658639f8d2bc61a99 Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Tue, 21 Apr 2026 20:38:19 -0400 Subject: [PATCH 03/26] Persist drawing colors with custom Hive adapters - Register source-owned adapters for free, line, rectangle, and ellipse drawings - Preserve legacy color fields while writing the current colorValue field - Update generated Hive metadata and registrar outputs --- AGENTS.md | 1 + lib/hive/hive_adapters.dart | 250 ++++++++++++++++++++++++++++++- lib/hive/hive_adapters.g.dart | 253 -------------------------------- lib/hive/hive_adapters.g.yaml | 96 ------------ lib/hive/hive_registrar.g.dart | 8 - lib/hive/hive_registration.dart | 24 +++ 6 files changed, 271 insertions(+), 361 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 0c8ff483..cccc495c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -16,6 +16,7 @@ A Flutter desktop app for creating interactive Valorant game strategies. See `RE - **`xdg-user-dirs` must be initialized.** The `path_provider` plugin needs XDG user directories. Run `sudo apt-get install -y xdg-user-dirs && xdg-user-dirs-update` if the app crashes with `MissingPlatformDirectoryException`. - **Linux build deps.** `clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-14-dev` must be installed for Linux desktop builds. - **Code generation.** After changing Hive models, Riverpod providers, or JSON-serializable classes, regenerate with: `fvm flutter pub run build_runner build --delete-conflicting-outputs`. +- **Generated files are outputs, not edit targets.** Never manually edit generated files like `*.g.dart`, `*.g.yaml`, or registrar outputs. Make changes in the source files that drive generation, or replace generated behavior with explicit source-owned code such as a custom adapter, then regenerate. - **No automated tests exist** in this codebase. `flutter test` will find nothing. - **Lint.** `fvm flutter analyze` — expect ~70 pre-existing warnings/infos (unused imports, deprecated APIs). No errors. - **Build.** `fvm flutter build linux --debug` produces the binary at `build/linux/x64/debug/bundle/icarus`. diff --git a/lib/hive/hive_adapters.dart b/lib/hive/hive_adapters.dart index 5f45e44c..8759dd07 100644 --- a/lib/hive/hive_adapters.dart +++ b/lib/hive/hive_adapters.dart @@ -31,8 +31,6 @@ import 'package:icarus/providers/strategy_settings_provider.dart'; AdapterSpec(), AdapterSpec(), AdapterSpec(), - AdapterSpec(), - AdapterSpec(), AdapterSpec(), AdapterSpec(), AdapterSpec(), @@ -45,8 +43,6 @@ import 'package:icarus/providers/strategy_settings_provider.dart'; AdapterSpec(), AdapterSpec(), AdapterSpec(), - AdapterSpec(), - AdapterSpec(), AdapterSpec(), AdapterSpec(), AdapterSpec(), @@ -56,6 +52,252 @@ import 'package:icarus/providers/strategy_settings_provider.dart'; ]) part 'hive_adapters.g.dart'; +const int freeDrawingAdapterTypeId = 11; +const int lineAdapterTypeId = 12; +const int rectangleDrawingAdapterTypeId = 24; +const int ellipseDrawingAdapterTypeId = 31; + +int _readDrawingHiveColorValue( + Map fields, { + required int colorFieldIndex, + int? legacyColorValueFieldIndex, +}) { + final value = legacyColorValueFieldIndex == null + ? fields[colorFieldIndex] + : fields[legacyColorValueFieldIndex] ?? fields[colorFieldIndex]; + + return switch (value) { + final int colorValue => colorValue, + final num colorValue => colorValue.toInt(), + final Color color => color.toARGB32(), + _ => 0xFFFFFFFF, + }; +} + +class FreeDrawingAdapter extends TypeAdapter { + @override + final typeId = freeDrawingAdapterTypeId; + + @override + FreeDrawing read(BinaryReader reader) { + final numOfFields = reader.readByte(); + final fields = { + for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), + }; + + return FreeDrawing( + listOfPoints: (fields[0] as List?)?.cast(), + colorValue: _readDrawingHiveColorValue( + fields, + colorFieldIndex: 2, + legacyColorValueFieldIndex: 12, + ), + thickness: fields[11] == null + ? Settings.defaultStrokeThickness + : (fields[11] as num).toDouble(), + boundingBox: fields[6] as BoundingBox?, + isDotted: fields[3] as bool, + hasArrow: fields[4] as bool, + id: fields[5] as String, + showTraversalTime: fields[8] == null ? false : fields[8] as bool, + traversalSpeedProfile: fields[9] == null + ? TraversalSpeed.defaultProfile + : fields[9] as TraversalSpeedProfile, + cachedPolylineLengthUnits: (fields[10] as num?)?.toDouble(), + ); + } + + @override + void write(BinaryWriter writer, FreeDrawing obj) { + writer + ..writeByte(10) + ..writeByte(0) + ..write(obj.listOfPoints) + ..writeByte(2) + ..write(obj.colorValue) + ..writeByte(3) + ..write(obj.isDotted) + ..writeByte(4) + ..write(obj.hasArrow) + ..writeByte(5) + ..write(obj.id) + ..writeByte(6) + ..write(obj.boundingBox) + ..writeByte(8) + ..write(obj.showTraversalTime) + ..writeByte(9) + ..write(obj.traversalSpeedProfile) + ..writeByte(10) + ..write(obj.cachedPolylineLengthUnits) + ..writeByte(11) + ..write(obj.thickness); + } +} + +class LineAdapter extends TypeAdapter { + @override + final typeId = lineAdapterTypeId; + + @override + Line read(BinaryReader reader) { + final numOfFields = reader.readByte(); + final fields = { + for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), + }; + + return Line( + lineStart: fields[0] as Offset, + lineEnd: fields[1] as Offset, + colorValue: _readDrawingHiveColorValue( + fields, + colorFieldIndex: 2, + legacyColorValueFieldIndex: 10, + ), + thickness: fields[9] == null + ? Settings.defaultStrokeThickness + : (fields[9] as num).toDouble(), + boundingBox: fields[6] as BoundingBox?, + isDotted: fields[3] as bool, + hasArrow: fields[4] as bool, + id: fields[5] as String, + showTraversalTime: fields[7] == null ? false : fields[7] as bool, + traversalSpeedProfile: fields[8] == null + ? TraversalSpeed.defaultProfile + : fields[8] as TraversalSpeedProfile, + ); + } + + @override + void write(BinaryWriter writer, Line obj) { + writer + ..writeByte(10) + ..writeByte(0) + ..write(obj.lineStart) + ..writeByte(1) + ..write(obj.lineEnd) + ..writeByte(2) + ..write(obj.colorValue) + ..writeByte(3) + ..write(obj.isDotted) + ..writeByte(4) + ..write(obj.hasArrow) + ..writeByte(5) + ..write(obj.id) + ..writeByte(6) + ..write(obj.boundingBox) + ..writeByte(7) + ..write(obj.showTraversalTime) + ..writeByte(8) + ..write(obj.traversalSpeedProfile) + ..writeByte(9) + ..write(obj.thickness); + } +} + +class RectangleDrawingAdapter extends TypeAdapter { + @override + final typeId = rectangleDrawingAdapterTypeId; + + @override + RectangleDrawing read(BinaryReader reader) { + final numOfFields = reader.readByte(); + final fields = { + for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), + }; + + return RectangleDrawing( + start: fields[0] as Offset, + end: fields[1] as Offset, + colorValue: _readDrawingHiveColorValue( + fields, + colorFieldIndex: 2, + legacyColorValueFieldIndex: 8, + ), + thickness: fields[7] == null + ? Settings.defaultStrokeThickness + : (fields[7] as num).toDouble(), + boundingBox: fields[6] as BoundingBox?, + isDotted: fields[3] as bool, + hasArrow: fields[4] as bool, + id: fields[5] as String, + ); + } + + @override + void write(BinaryWriter writer, RectangleDrawing obj) { + writer + ..writeByte(8) + ..writeByte(0) + ..write(obj.start) + ..writeByte(1) + ..write(obj.end) + ..writeByte(2) + ..write(obj.colorValue) + ..writeByte(3) + ..write(obj.isDotted) + ..writeByte(4) + ..write(obj.hasArrow) + ..writeByte(5) + ..write(obj.id) + ..writeByte(6) + ..write(obj.boundingBox) + ..writeByte(7) + ..write(obj.thickness); + } +} + +class EllipseDrawingAdapter extends TypeAdapter { + @override + final typeId = ellipseDrawingAdapterTypeId; + + @override + EllipseDrawing read(BinaryReader reader) { + final numOfFields = reader.readByte(); + final fields = { + for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), + }; + + return EllipseDrawing( + start: fields[0] as Offset, + end: fields[1] as Offset, + colorValue: _readDrawingHiveColorValue( + fields, + colorFieldIndex: 2, + legacyColorValueFieldIndex: 8, + ), + thickness: fields[3] == null + ? Settings.defaultStrokeThickness + : (fields[3] as num).toDouble(), + boundingBox: fields[7] as BoundingBox?, + isDotted: fields[4] as bool, + hasArrow: fields[5] as bool, + id: fields[6] as String, + ); + } + + @override + void write(BinaryWriter writer, EllipseDrawing obj) { + writer + ..writeByte(8) + ..writeByte(0) + ..write(obj.start) + ..writeByte(1) + ..write(obj.end) + ..writeByte(2) + ..write(obj.colorValue) + ..writeByte(3) + ..write(obj.thickness) + ..writeByte(4) + ..write(obj.isDotted) + ..writeByte(5) + ..write(obj.hasArrow) + ..writeByte(6) + ..write(obj.id) + ..writeByte(7) + ..write(obj.boundingBox); + } +} + class FolderAdapter extends TypeAdapter { @override final typeId = 17; diff --git a/lib/hive/hive_adapters.g.dart b/lib/hive/hive_adapters.g.dart index 4f465e20..2316e209 100644 --- a/lib/hive/hive_adapters.g.dart +++ b/lib/hive/hive_adapters.g.dart @@ -6,15 +6,6 @@ part of 'hive_adapters.dart'; // AdaptersGenerator // ************************************************************************** -int _readLegacyDrawingHiveColorValue(Object? value) { - return switch (value) { - final int colorValue => colorValue, - final num colorValue => colorValue.toInt(), - final Color color => color.toARGB32(), - _ => 0xFFFFFFFF, - }; -} - class StrategyDataAdapter extends TypeAdapter { @override final typeId = 0; @@ -638,136 +629,6 @@ class OffsetAdapter extends TypeAdapter { typeId == other.typeId; } -class FreeDrawingAdapter extends TypeAdapter { - @override - final typeId = 11; - - @override - FreeDrawing read(BinaryReader reader) { - final numOfFields = reader.readByte(); - final fields = { - for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), - }; - return FreeDrawing( - listOfPoints: (fields[0] as List?)?.cast(), - colorValue: _readLegacyDrawingHiveColorValue(fields[12] ?? fields[2]), - thickness: fields[11] == null - ? Settings.defaultStrokeThickness - : (fields[11] as num).toDouble(), - boundingBox: fields[6] as BoundingBox?, - isDotted: fields[3] as bool, - hasArrow: fields[4] as bool, - id: fields[5] as String, - showTraversalTime: fields[8] == null ? false : fields[8] as bool, - traversalSpeedProfile: fields[9] == null - ? TraversalSpeed.defaultProfile - : fields[9] as TraversalSpeedProfile, - cachedPolylineLengthUnits: (fields[10] as num?)?.toDouble(), - ); - } - - @override - void write(BinaryWriter writer, FreeDrawing obj) { - writer - ..writeByte(10) - ..writeByte(0) - ..write(obj.listOfPoints) - ..writeByte(2) - ..write(obj.colorValue) - ..writeByte(3) - ..write(obj.isDotted) - ..writeByte(4) - ..write(obj.hasArrow) - ..writeByte(5) - ..write(obj.id) - ..writeByte(6) - ..write(obj.boundingBox) - ..writeByte(8) - ..write(obj.showTraversalTime) - ..writeByte(9) - ..write(obj.traversalSpeedProfile) - ..writeByte(10) - ..write(obj.cachedPolylineLengthUnits) - ..writeByte(11) - ..write(obj.thickness); - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is FreeDrawingAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} - -class LineAdapter extends TypeAdapter { - @override - final typeId = 12; - - @override - Line read(BinaryReader reader) { - final numOfFields = reader.readByte(); - final fields = { - for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), - }; - return Line( - lineStart: fields[0] as Offset, - lineEnd: fields[1] as Offset, - colorValue: _readLegacyDrawingHiveColorValue(fields[10] ?? fields[2]), - thickness: fields[9] == null - ? Settings.defaultStrokeThickness - : (fields[9] as num).toDouble(), - boundingBox: fields[6] as BoundingBox?, - isDotted: fields[3] as bool, - hasArrow: fields[4] as bool, - id: fields[5] as String, - showTraversalTime: fields[7] == null ? false : fields[7] as bool, - traversalSpeedProfile: fields[8] == null - ? TraversalSpeed.defaultProfile - : fields[8] as TraversalSpeedProfile, - ); - } - - @override - void write(BinaryWriter writer, Line obj) { - writer - ..writeByte(10) - ..writeByte(0) - ..write(obj.lineStart) - ..writeByte(1) - ..write(obj.lineEnd) - ..writeByte(2) - ..write(obj.colorValue) - ..writeByte(3) - ..write(obj.isDotted) - ..writeByte(4) - ..write(obj.hasArrow) - ..writeByte(5) - ..write(obj.id) - ..writeByte(6) - ..write(obj.boundingBox) - ..writeByte(7) - ..write(obj.showTraversalTime) - ..writeByte(8) - ..write(obj.traversalSpeedProfile) - ..writeByte(9) - ..write(obj.thickness); - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is LineAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} - class BoundingBoxAdapter extends TypeAdapter { @override final typeId = 13; @@ -1284,63 +1145,6 @@ class AgentStateAdapter extends TypeAdapter { typeId == other.typeId; } -class RectangleDrawingAdapter extends TypeAdapter { - @override - final typeId = 24; - - @override - RectangleDrawing read(BinaryReader reader) { - final numOfFields = reader.readByte(); - final fields = { - for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), - }; - return RectangleDrawing( - start: fields[0] as Offset, - end: fields[1] as Offset, - colorValue: _readLegacyDrawingHiveColorValue(fields[8] ?? fields[2]), - thickness: fields[7] == null - ? Settings.defaultStrokeThickness - : (fields[7] as num).toDouble(), - boundingBox: fields[6] as BoundingBox?, - isDotted: fields[3] as bool, - hasArrow: fields[4] as bool, - id: fields[5] as String, - ); - } - - @override - void write(BinaryWriter writer, RectangleDrawing obj) { - writer - ..writeByte(8) - ..writeByte(0) - ..write(obj.start) - ..writeByte(1) - ..write(obj.end) - ..writeByte(2) - ..write(obj.colorValue) - ..writeByte(3) - ..write(obj.isDotted) - ..writeByte(4) - ..write(obj.hasArrow) - ..writeByte(5) - ..write(obj.id) - ..writeByte(6) - ..write(obj.boundingBox) - ..writeByte(7) - ..write(obj.thickness); - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is RectangleDrawingAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} - class TraversalSpeedProfileAdapter extends TypeAdapter { @override final typeId = 25; @@ -1627,63 +1431,6 @@ class PlacedCircleAgentAdapter extends TypeAdapter { typeId == other.typeId; } -class EllipseDrawingAdapter extends TypeAdapter { - @override - final typeId = 31; - - @override - EllipseDrawing read(BinaryReader reader) { - final numOfFields = reader.readByte(); - final fields = { - for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), - }; - return EllipseDrawing( - start: fields[0] as Offset, - end: fields[1] as Offset, - colorValue: _readLegacyDrawingHiveColorValue(fields[8] ?? fields[2]), - thickness: fields[3] == null - ? Settings.defaultStrokeThickness - : (fields[3] as num).toDouble(), - boundingBox: fields[7] as BoundingBox?, - isDotted: fields[4] as bool, - hasArrow: fields[5] as bool, - id: fields[6] as String, - ); - } - - @override - void write(BinaryWriter writer, EllipseDrawing obj) { - writer - ..writeByte(8) - ..writeByte(0) - ..write(obj.start) - ..writeByte(1) - ..write(obj.end) - ..writeByte(2) - ..write(obj.colorValue) - ..writeByte(3) - ..write(obj.thickness) - ..writeByte(4) - ..write(obj.isDotted) - ..writeByte(5) - ..write(obj.hasArrow) - ..writeByte(6) - ..write(obj.id) - ..writeByte(7) - ..write(obj.boundingBox); - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is EllipseDrawingAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} - class AbilityVisualStateAdapter extends TypeAdapter { @override final typeId = 32; diff --git a/lib/hive/hive_adapters.g.yaml b/lib/hive/hive_adapters.g.yaml index 3cc4cbb3..5b834f65 100644 --- a/lib/hive/hive_adapters.g.yaml +++ b/lib/hive/hive_adapters.g.yaml @@ -235,58 +235,6 @@ types: index: 0 dy: index: 1 - FreeDrawing: - typeId: 11 - nextIndex: 13 - fields: - listOfPoints: - index: 0 - color: - index: 2 - isDotted: - index: 3 - hasArrow: - index: 4 - id: - index: 5 - boundingBox: - index: 6 - showTraversalTime: - index: 8 - traversalSpeedProfile: - index: 9 - cachedPolylineLengthUnits: - index: 10 - thickness: - index: 11 - colorValue: - index: 12 - Line: - typeId: 12 - nextIndex: 11 - fields: - lineStart: - index: 0 - lineEnd: - index: 1 - color: - index: 2 - isDotted: - index: 3 - hasArrow: - index: 4 - id: - index: 5 - boundingBox: - index: 6 - showTraversalTime: - index: 7 - traversalSpeedProfile: - index: 8 - thickness: - index: 9 - colorValue: - index: 10 BoundingBox: typeId: 13 nextIndex: 2 @@ -451,28 +399,6 @@ types: index: 0 none: index: 1 - RectangleDrawing: - typeId: 24 - nextIndex: 9 - fields: - start: - index: 0 - end: - index: 1 - color: - index: 2 - isDotted: - index: 3 - hasArrow: - index: 4 - id: - index: 5 - boundingBox: - index: 6 - thickness: - index: 7 - colorValue: - index: 8 TraversalSpeedProfile: typeId: 25 nextIndex: 4 @@ -563,28 +489,6 @@ types: index: 7 position: index: 8 - EllipseDrawing: - typeId: 31 - nextIndex: 9 - fields: - start: - index: 0 - end: - index: 1 - color: - index: 2 - thickness: - index: 3 - isDotted: - index: 4 - hasArrow: - index: 5 - id: - index: 6 - boundingBox: - index: 7 - colorValue: - index: 8 AbilityVisualState: typeId: 32 nextIndex: 6 diff --git a/lib/hive/hive_registrar.g.dart b/lib/hive/hive_registrar.g.dart index a09987f5..bb55d7f4 100644 --- a/lib/hive/hive_registrar.g.dart +++ b/lib/hive/hive_registrar.g.dart @@ -14,11 +14,8 @@ extension HiveRegistrar on HiveInterface { registerAdapter(AgentTypeAdapter()); registerAdapter(AppPreferencesAdapter()); registerAdapter(BoundingBoxAdapter()); - registerAdapter(EllipseDrawingAdapter()); registerAdapter(FolderColorAdapter()); - registerAdapter(FreeDrawingAdapter()); registerAdapter(IconDataAdapter()); - registerAdapter(LineAdapter()); registerAdapter(LineUpAdapter()); registerAdapter(LineUpGroupAdapter()); registerAdapter(LineUpItemAdapter()); @@ -34,7 +31,6 @@ extension HiveRegistrar on HiveInterface { registerAdapter(PlacedUtilityAdapter()); registerAdapter(PlacedViewConeAgentAdapter()); registerAdapter(PlacedWidgetAdapter()); - registerAdapter(RectangleDrawingAdapter()); registerAdapter(SimpleImageDataAdapter()); registerAdapter(StrategyDataAdapter()); registerAdapter(StrategyPageAdapter()); @@ -52,11 +48,8 @@ extension IsolatedHiveRegistrar on IsolatedHiveInterface { registerAdapter(AgentTypeAdapter()); registerAdapter(AppPreferencesAdapter()); registerAdapter(BoundingBoxAdapter()); - registerAdapter(EllipseDrawingAdapter()); registerAdapter(FolderColorAdapter()); - registerAdapter(FreeDrawingAdapter()); registerAdapter(IconDataAdapter()); - registerAdapter(LineAdapter()); registerAdapter(LineUpAdapter()); registerAdapter(LineUpGroupAdapter()); registerAdapter(LineUpItemAdapter()); @@ -72,7 +65,6 @@ extension IsolatedHiveRegistrar on IsolatedHiveInterface { registerAdapter(PlacedUtilityAdapter()); registerAdapter(PlacedViewConeAgentAdapter()); registerAdapter(PlacedWidgetAdapter()); - registerAdapter(RectangleDrawingAdapter()); registerAdapter(SimpleImageDataAdapter()); registerAdapter(StrategyDataAdapter()); registerAdapter(StrategyPageAdapter()); diff --git a/lib/hive/hive_registration.dart b/lib/hive/hive_registration.dart index ec038957..9e9348b9 100644 --- a/lib/hive/hive_registration.dart +++ b/lib/hive/hive_registration.dart @@ -6,6 +6,18 @@ const int _folderAdapterTypeId = 17; void registerIcarusAdapters(HiveInterface hive) { hive.registerAdapters(); + if (!hive.isAdapterRegistered(freeDrawingAdapterTypeId)) { + hive.registerAdapter(FreeDrawingAdapter()); + } + if (!hive.isAdapterRegistered(lineAdapterTypeId)) { + hive.registerAdapter(LineAdapter()); + } + if (!hive.isAdapterRegistered(rectangleDrawingAdapterTypeId)) { + hive.registerAdapter(RectangleDrawingAdapter()); + } + if (!hive.isAdapterRegistered(ellipseDrawingAdapterTypeId)) { + hive.registerAdapter(EllipseDrawingAdapter()); + } if (!hive.isAdapterRegistered(_folderAdapterTypeId)) { hive.registerAdapter(FolderAdapter()); } @@ -13,6 +25,18 @@ void registerIcarusAdapters(HiveInterface hive) { void registerIcarusIsolatedAdapters(IsolatedHiveInterface hive) { hive.registerAdapters(); + if (!hive.isAdapterRegistered(freeDrawingAdapterTypeId)) { + hive.registerAdapter(FreeDrawingAdapter()); + } + if (!hive.isAdapterRegistered(lineAdapterTypeId)) { + hive.registerAdapter(LineAdapter()); + } + if (!hive.isAdapterRegistered(rectangleDrawingAdapterTypeId)) { + hive.registerAdapter(RectangleDrawingAdapter()); + } + if (!hive.isAdapterRegistered(ellipseDrawingAdapterTypeId)) { + hive.registerAdapter(EllipseDrawingAdapter()); + } if (!hive.isAdapterRegistered(_folderAdapterTypeId)) { hive.registerAdapter(FolderAdapter()); } From 1868a547f4118294163aa05ad6470d9f5442bc03 Mon Sep 17 00:00:00 2001 From: Dara Adedeji Date: Sat, 25 Apr 2026 15:47:16 -0400 Subject: [PATCH 04/26] Add customizable color picker styling - Introduce a reusable BetterColorPicker style and palette - Update color picker consumers to use the new custom styling --- lib/widgets/better_color_picker.dart | 2000 +++++++++++++++++++ lib/widgets/folder_edit_dialog.dart | 25 +- lib/widgets/icarus_color_picker_style.dart | 33 + lib/widgets/map_theme_settings_section.dart | 18 +- pubspec.lock | 16 +- pubspec.yaml | 1 - 6 files changed, 2066 insertions(+), 27 deletions(-) create mode 100644 lib/widgets/better_color_picker.dart create mode 100644 lib/widgets/icarus_color_picker_style.dart diff --git a/lib/widgets/better_color_picker.dart b/lib/widgets/better_color_picker.dart new file mode 100644 index 00000000..a4726d68 --- /dev/null +++ b/lib/widgets/better_color_picker.dart @@ -0,0 +1,2000 @@ +import 'dart:math' as math; +import 'dart:ui' show FontFeature; + +import 'package:flutter/material.dart' as material; +import 'package:flutter/services.dart'; +import 'package:shadcn_ui/shadcn_ui.dart'; + +enum BetterColorPickerMode { rgb, hsl, hsv, hex } + +class BetterColorPickerPalette { + const BetterColorPickerPalette({ + required this.surface, + required this.foreground, + required this.mutedForeground, + required this.inputBorder, + required this.fieldFill, + }); + + final material.Color surface; + final material.Color foreground; + final material.Color mutedForeground; + final material.Color inputBorder; + final material.Color fieldFill; + + static const lightZinc = BetterColorPickerPalette( + surface: material.Color(0xFFFFFFFF), + foreground: material.Color(0xFF09090B), + mutedForeground: material.Color(0xFF71717A), + inputBorder: material.Color(0xFFE4E4E7), + fieldFill: material.Color(0x4DE4E4E7), + ); + + static const darkZinc = BetterColorPickerPalette( + surface: material.Color(0xFF09090B), + foreground: material.Color(0xFFFAFAFA), + mutedForeground: material.Color(0xFFA1A1AA), + inputBorder: material.Color(0xFF27272A), + fieldFill: material.Color(0x4D27272A), + ); +} + +class BetterColorPickerStyle { + const BetterColorPickerStyle({ + this.lightPalette = BetterColorPickerPalette.lightZinc, + this.darkPalette = BetterColorPickerPalette.darkZinc, + this.textStyle, + this.monospaceTextStyle, + this.mainSliderRadius = 8, + this.channelSliderRadius = 4, + this.fieldRadius = 8, + this.swatchRadius = 8, + this.fieldHeight = 36, + this.dialogWidth = 420, + this.mainSliderMinExtent = 150, + }); + + final BetterColorPickerPalette lightPalette; + final BetterColorPickerPalette darkPalette; + final material.TextStyle? textStyle; + final material.TextStyle? monospaceTextStyle; + final double mainSliderRadius; + final double channelSliderRadius; + final double fieldRadius; + final double swatchRadius; + final double fieldHeight; + final double dialogWidth; + final double mainSliderMinExtent; + + BetterColorPickerPalette paletteFor(material.Brightness brightness) { + return brightness == material.Brightness.dark ? darkPalette : lightPalette; + } +} + +class BetterColorPicker extends material.StatefulWidget { + const BetterColorPicker({ + super.key, + required this.value, + this.onChanged, + this.onChanging, + this.initialMode = BetterColorPickerMode.rgb, + this.onModeChanged, + this.showAlpha = false, + this.orientation = material.Axis.vertical, + this.spacing, + this.controlSpacing, + this.sliderSize, + this.style = const BetterColorPickerStyle(), + }); + + final material.Color value; + final material.ValueChanged? onChanged; + final material.ValueChanged? onChanging; + final BetterColorPickerMode initialMode; + final material.ValueChanged? onModeChanged; + final bool showAlpha; + final material.Axis orientation; + final double? spacing; + final double? controlSpacing; + final double? sliderSize; + final BetterColorPickerStyle style; + + @override + material.State createState() => _BetterColorPickerState(); +} + +class _BetterColorPickerState extends material.State { + late BetterColorPickerMode _mode; + _PickerValue? _draftValue; + + @override + void initState() { + super.initState(); + _mode = widget.initialMode; + } + + @override + void didUpdateWidget(covariant BetterColorPicker oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.initialMode != widget.initialMode) { + _mode = widget.initialMode; + } + if (oldWidget.value != widget.value) { + final draftValue = _draftValue; + if (draftValue == null || draftValue.color != widget.value) { + _draftValue = null; + } + } + } + + _PickerValue get _effectiveValue => + _draftValue ?? _PickerValue.fromColor(widget.value); + + @override + material.Widget build(material.BuildContext context) { + final pickerWidth = _rgbPickerControlsWidth(showAlpha: widget.showAlpha); + final pickerScale = _pickerScaleFactor(pickerWidth: pickerWidth); + final spacing = (widget.spacing ?? 12.0) * pickerScale; + final controlSpacing = (widget.controlSpacing ?? 8.0) * pickerScale; + final sliderSize = (widget.sliderSize ?? 24.0) * pickerScale; + final mainSliderRadius = widget.style.mainSliderRadius * pickerScale; + final channelSliderRadius = widget.style.channelSliderRadius * pickerScale; + final sliderHandleSize = 16.0 * pickerScale; + final sliderHandleBorderWidth = math.max(1.0, 2.0 * pickerScale); + final alphaCheckboardSize = 8.0 * pickerScale; + final body = widget.orientation == material.Axis.horizontal + ? material.Column( + mainAxisSize: material.MainAxisSize.min, + crossAxisAlignment: material.CrossAxisAlignment.stretch, + children: [ + material.IntrinsicHeight( + child: material.Row( + mainAxisSize: material.MainAxisSize.min, + crossAxisAlignment: material.CrossAxisAlignment.stretch, + children: [ + material.Flexible( + child: _buildMainSlider( + sliderRadius: mainSliderRadius, + sliderHandleSize: sliderHandleSize, + sliderHandleBorderWidth: sliderHandleBorderWidth, + ), + ), + material.SizedBox(width: spacing), + ..._buildChannelSliders( + isHorizontalLayout: true, + sliderSize: sliderSize, + spacing: controlSpacing, + sliderRadius: channelSliderRadius, + sliderHandleSize: sliderHandleSize, + sliderHandleBorderWidth: sliderHandleBorderWidth, + alphaCheckboardSize: alphaCheckboardSize, + ), + ], + ), + ), + material.SizedBox(height: spacing), + material.SizedBox( + width: pickerWidth, + child: _PickerControls( + value: _effectiveValue, + mode: _mode, + showAlpha: widget.showAlpha, + fieldHeight: widget.style.fieldHeight, + fieldRadius: widget.style.fieldRadius, + style: widget.style, + targetWidth: pickerWidth, + onModeChanged: (mode) { + setState(() { + _mode = mode; + }); + widget.onModeChanged?.call(mode); + }, + onChanged: _handleCommittedChange, + ), + ), + ], + ) + : material.Column( + mainAxisSize: material.MainAxisSize.min, + crossAxisAlignment: material.CrossAxisAlignment.stretch, + children: [ + material.SizedBox( + width: pickerWidth, + child: _buildMainSlider( + sliderRadius: mainSliderRadius, + sliderHandleSize: sliderHandleSize, + sliderHandleBorderWidth: sliderHandleBorderWidth, + ), + ), + material.SizedBox(height: spacing), + ..._buildChannelSliders( + isHorizontalLayout: false, + sliderSize: sliderSize, + spacing: controlSpacing, + mainAxisExtent: pickerWidth, + sliderRadius: channelSliderRadius, + sliderHandleSize: sliderHandleSize, + sliderHandleBorderWidth: sliderHandleBorderWidth, + alphaCheckboardSize: alphaCheckboardSize, + ), + material.SizedBox(height: controlSpacing), + material.SizedBox( + width: pickerWidth, + child: _PickerControls( + value: _effectiveValue, + mode: _mode, + showAlpha: widget.showAlpha, + fieldHeight: widget.style.fieldHeight, + fieldRadius: widget.style.fieldRadius, + style: widget.style, + targetWidth: pickerWidth, + onModeChanged: (mode) { + setState(() { + _mode = mode; + }); + widget.onModeChanged?.call(mode); + }, + onChanged: _handleCommittedChange, + ), + ), + ], + ); + + return material.RepaintBoundary( + child: material.SizedBox(width: pickerWidth, child: body), + ); + } + + material.Widget _buildMainSlider({ + required double sliderRadius, + required double sliderHandleSize, + required double sliderHandleBorderWidth, + }) { + return material.AspectRatio( + aspectRatio: 1, + child: material.ConstrainedBox( + constraints: material.BoxConstraints( + minWidth: widget.style.mainSliderMinExtent, + minHeight: widget.style.mainSliderMinExtent, + ), + child: _mode == BetterColorPickerMode.hsl + ? _HSLColorSlider( + color: _effectiveValue.hsl, + radius: material.Radius.circular(sliderRadius), + cursorDiameter: sliderHandleSize, + cursorBorderWidth: sliderHandleBorderWidth, + onChanging: (value) { + _handleChangingChange( + _effectiveValue + .changeToHSLSaturation(value.saturation) + .changeToHSLLightness(value.lightness), + ); + }, + onChanged: (value) { + _handleCommittedChange( + _effectiveValue + .changeToHSLSaturation(value.saturation) + .changeToHSLLightness(value.lightness), + ); + }, + ) + : _HSVColorSlider( + value: _effectiveValue.hsv, + sliderType: _HSVSliderType.satVal, + radius: material.Radius.circular(sliderRadius), + cursorDiameter: sliderHandleSize, + cursorBorderWidth: sliderHandleBorderWidth, + onChanging: (value) { + _handleChangingChange( + _effectiveValue + .changeToHSVSaturation(value.saturation) + .changeToHSVValue(value.value), + ); + }, + onChanged: (value) { + _handleCommittedChange( + _effectiveValue + .changeToHSVSaturation(value.saturation) + .changeToHSVValue(value.value), + ); + }, + ), + ), + ); + } + + List _buildChannelSliders({ + required bool isHorizontalLayout, + required double sliderSize, + required double spacing, + required double sliderRadius, + required double sliderHandleSize, + required double sliderHandleBorderWidth, + required double alphaCheckboardSize, + double? mainAxisExtent, + }) { + final widgets = [ + material.SizedBox( + width: isHorizontalLayout ? sliderSize : mainAxisExtent, + height: isHorizontalLayout ? null : sliderSize, + child: _HSVColorSlider( + value: _effectiveValue.hsv.withSaturation(1).withValue(1), + sliderType: _HSVSliderType.hue, + reverse: !isHorizontalLayout, + radius: material.Radius.circular(sliderRadius), + cursorDiameter: sliderHandleSize, + cursorBorderWidth: sliderHandleBorderWidth, + onChanging: (value) { + _handleChangingChange(_effectiveValue.changeToHSVHue(value.hue)); + }, + onChanged: (value) { + _handleCommittedChange(_effectiveValue.changeToHSVHue(value.hue)); + }, + ), + ), + ]; + + if (widget.showAlpha) { + widgets.add( + material.SizedBox( + width: isHorizontalLayout ? sliderSize : mainAxisExtent, + height: isHorizontalLayout ? null : sliderSize, + child: _HSVColorSlider( + value: _effectiveValue.hsv, + sliderType: _HSVSliderType.alpha, + reverse: !isHorizontalLayout, + radius: material.Radius.circular(sliderRadius), + cursorDiameter: sliderHandleSize, + cursorBorderWidth: sliderHandleBorderWidth, + alphaCheckboardSize: alphaCheckboardSize, + onChanging: (value) { + _handleChangingChange( + _effectiveValue.changeToOpacity(value.alpha), + ); + }, + onChanged: (value) { + _handleCommittedChange( + _effectiveValue.changeToOpacity(value.alpha), + ); + }, + ), + ), + ); + } + + final wrapped = []; + for (var i = 0; i < widgets.length; i++) { + wrapped.add(widgets[i]); + if (i < widgets.length - 1) { + wrapped.add( + isHorizontalLayout + ? material.SizedBox(width: spacing) + : material.SizedBox(height: spacing), + ); + } + } + return wrapped; + } + + void _handleChangingChange(_PickerValue value) { + setState(() { + _draftValue = value; + }); + widget.onChanging?.call(value.color); + } + + void _handleCommittedChange(_PickerValue value) { + setState(() { + _draftValue = value; + }); + widget.onChanged?.call(value.color); + } +} + +class BetterColorPickerField extends material.StatelessWidget { + const BetterColorPickerField({ + super.key, + required this.value, + required this.onChanged, + this.onChanging, + this.initialMode = BetterColorPickerMode.rgb, + this.showAlpha = false, + this.orientation = material.Axis.vertical, + this.label, + this.enabled = true, + this.dialogTitle = 'Select color', + this.style = const BetterColorPickerStyle(), + }); + + final material.Color value; + final material.ValueChanged onChanged; + final material.ValueChanged? onChanging; + final BetterColorPickerMode initialMode; + final bool showAlpha; + final material.Axis orientation; + final String? label; + final bool enabled; + final String dialogTitle; + final BetterColorPickerStyle style; + + @override + material.Widget build(material.BuildContext context) { + final theme = material.Theme.of(context); + final borderColor = theme.colorScheme.outlineVariant; + final foregroundColor = enabled + ? theme.colorScheme.onSurface + : theme.colorScheme.onSurface.withValues(alpha: 0.38); + return material.InkWell( + onTap: enabled + ? () async { + final result = await showBetterColorPickerDialog( + context, + initialColor: value, + title: dialogTitle, + initialMode: initialMode, + showAlpha: showAlpha, + orientation: orientation, + onChanging: onChanging, + style: style, + ); + if (result != null && context.mounted) { + onChanged(result); + } + } + : null, + borderRadius: material.BorderRadius.circular(12), + child: material.Container( + padding: const material.EdgeInsets.symmetric( + horizontal: 14, + vertical: 12, + ), + decoration: material.BoxDecoration( + border: material.Border.all(color: borderColor), + borderRadius: material.BorderRadius.circular(12), + color: enabled ? theme.colorScheme.surface : theme.disabledColor, + ), + child: material.Row( + mainAxisSize: material.MainAxisSize.min, + children: [ + material.Expanded( + child: material.Column( + crossAxisAlignment: material.CrossAxisAlignment.start, + mainAxisSize: material.MainAxisSize.min, + children: [ + if (label != null) + material.Padding( + padding: const material.EdgeInsets.only(bottom: 4), + child: material.Text( + label!, + style: theme.textTheme.labelSmall?.copyWith( + color: theme.colorScheme.onSurfaceVariant, + ), + ), + ), + material.Text( + _colorToHex(value, showAlpha: showAlpha), + style: _monoTextStyle( + context, + style, + ).copyWith(color: foregroundColor), + ), + ], + ), + ), + const material.SizedBox(width: 12), + _ColorSwatch(color: value, size: 28, radius: style.swatchRadius), + ], + ), + ), + ); + } +} + +Future showBetterColorPickerDialog( + material.BuildContext context, { + required material.Color initialColor, + String title = 'Select color', + BetterColorPickerMode initialMode = BetterColorPickerMode.rgb, + bool showAlpha = false, + material.Axis orientation = material.Axis.vertical, + material.ValueChanged? onChanging, + BetterColorPickerStyle style = const BetterColorPickerStyle(), +}) { + return material.showDialog( + context: context, + builder: (context) { + return _BetterColorPickerDialog( + initialColor: initialColor, + title: title, + initialMode: initialMode, + showAlpha: showAlpha, + orientation: orientation, + onChanging: onChanging, + style: style, + ); + }, + ); +} + +class _BetterColorPickerDialog extends material.StatefulWidget { + const _BetterColorPickerDialog({ + required this.initialColor, + required this.title, + required this.initialMode, + required this.showAlpha, + required this.orientation, + required this.style, + this.onChanging, + }); + + final material.Color initialColor; + final String title; + final BetterColorPickerMode initialMode; + final bool showAlpha; + final material.Axis orientation; + final BetterColorPickerStyle style; + final material.ValueChanged? onChanging; + + @override + material.State<_BetterColorPickerDialog> createState() => + _BetterColorPickerDialogState(); +} + +class _BetterColorPickerDialogState + extends material.State<_BetterColorPickerDialog> { + late material.Color _value; + late final material.ValueNotifier _previewColor; + + @override + void initState() { + super.initState(); + _value = widget.initialColor; + _previewColor = material.ValueNotifier(widget.initialColor); + } + + @override + void dispose() { + _previewColor.dispose(); + super.dispose(); + } + + @override + material.Widget build(material.BuildContext context) { + final theme = material.Theme.of(context); + return material.AlertDialog( + title: material.Text(widget.title), + contentPadding: const material.EdgeInsets.fromLTRB(24, 20, 24, 0), + content: material.SizedBox( + width: widget.style.dialogWidth, + child: material.Column( + mainAxisSize: material.MainAxisSize.min, + crossAxisAlignment: material.CrossAxisAlignment.stretch, + children: [ + material.ValueListenableBuilder( + valueListenable: _previewColor, + builder: (context, previewColor, child) { + return material.Row( + children: [ + _ColorSwatch( + color: previewColor, + size: 44, + radius: widget.style.swatchRadius, + ), + const material.SizedBox(width: 12), + material.Expanded( + child: material.Text( + _colorToHex(previewColor, showAlpha: widget.showAlpha), + style: _monoTextStyle( + context, + widget.style, + ).merge(theme.textTheme.titleMedium), + ), + ), + ], + ); + }, + ), + const material.SizedBox(height: 20), + BetterColorPicker( + value: _value, + initialMode: widget.initialMode, + showAlpha: widget.showAlpha, + orientation: widget.orientation, + style: widget.style, + onChanging: (value) { + if (_previewColor.value != value) { + _previewColor.value = value; + } + widget.onChanging?.call(value); + }, + onChanged: (value) { + _value = value; + if (_previewColor.value != value) { + _previewColor.value = value; + } + }, + ), + ], + ), + ), + actions: [ + material.TextButton( + onPressed: () => material.Navigator.of(context).pop(), + child: const material.Text('Cancel'), + ), + material.FilledButton( + onPressed: () => material.Navigator.of(context).pop(_value), + child: const material.Text('Apply'), + ), + ], + ); + } +} + +class _PickerControls extends material.StatelessWidget { + const _PickerControls({ + required this.value, + required this.mode, + required this.showAlpha, + required this.fieldHeight, + required this.fieldRadius, + required this.style, + this.targetWidth, + required this.onModeChanged, + required this.onChanged, + }); + + final _PickerValue value; + final BetterColorPickerMode mode; + final bool showAlpha; + final double fieldHeight; + final double fieldRadius; + final BetterColorPickerStyle style; + final double? targetWidth; + final material.ValueChanged onModeChanged; + final material.ValueChanged<_PickerValue> onChanged; + + @override + material.Widget build(material.BuildContext context) { + final palette = style.paletteFor(material.Theme.of(context).brightness); + final fields = <_GroupedFieldData>[ + _GroupedFieldData( + width: 96, + builder: (scaledWidth, index, length) => _ModeField( + value: mode, + width: scaledWidth, + fieldHeight: fieldHeight, + fieldRadius: fieldRadius, + style: style, + palette: palette, + groupIndex: index, + groupLength: length, + onChanged: onModeChanged, + ), + ), + ...switch (mode) { + BetterColorPickerMode.rgb => _buildRgbFields(), + BetterColorPickerMode.hsl => _buildHslFields(), + BetterColorPickerMode.hsv => _buildHsvFields(), + BetterColorPickerMode.hex => _buildHexFields(), + }, + ]; + final preferredWidth = + targetWidth ?? _pickerControlsWidth(mode: mode, showAlpha: showAlpha); + + return material.LayoutBuilder( + builder: (context, constraints) { + final resolvedTargetWidth = constraints.hasBoundedWidth + ? math.max(preferredWidth, constraints.maxWidth) + : preferredWidth; + final scaledWidths = _scaleGroupedFieldWidths( + widths: [for (final field in fields) field.width], + targetWidth: resolvedTargetWidth, + ); + + return material.SizedBox( + width: resolvedTargetWidth, + child: material.SingleChildScrollView( + scrollDirection: material.Axis.horizontal, + child: material.Row( + mainAxisSize: material.MainAxisSize.min, + children: [ + for (var i = 0; i < fields.length; i++) + fields[i].builder(scaledWidths[i], i, fields.length), + ], + ), + ), + ); + }, + ); + } + + List<_GroupedFieldData> _buildRgbFields() { + return [ + _numberField( + width: 64, + value: value.red.toString(), + placeholder: 'Red', + min: 0, + max: 255, + onChanged: (next) => onChanged(value.changeToColorRed(next.toDouble())), + ), + _numberField( + width: 64, + value: value.green.toString(), + placeholder: 'Green', + min: 0, + max: 255, + onChanged: (next) => + onChanged(value.changeToColorGreen(next.toDouble())), + ), + _numberField( + width: 64, + value: value.blue.toString(), + placeholder: 'Blue', + min: 0, + max: 255, + onChanged: (next) => + onChanged(value.changeToColorBlue(next.toDouble())), + ), + if (showAlpha) + _numberField( + width: 64, + value: (value.opacity * 255).round().toString(), + placeholder: 'Alpha', + min: 0, + max: 255, + onChanged: (next) => onChanged(value.changeToOpacity(next / 255)), + ), + ]; + } + + List<_GroupedFieldData> _buildHslFields() { + return [ + _numberField( + width: 64, + value: value.hslHue.round().toString(), + placeholder: 'Hue', + min: 0, + max: 360, + onChanged: (next) => onChanged(value.changeToHSLHue(next.toDouble())), + ), + _numberField( + width: 64, + value: (value.hslSat * 100).round().toString(), + placeholder: 'Sat', + min: 0, + max: 100, + onChanged: (next) => onChanged(value.changeToHSLSaturation(next / 100)), + ), + _numberField( + width: 64, + value: (value.hslLightness * 100).round().toString(), + placeholder: 'Lum', + min: 0, + max: 100, + onChanged: (next) => onChanged(value.changeToHSLLightness(next / 100)), + ), + if (showAlpha) + _numberField( + width: 64, + value: (value.opacity * 100).round().toString(), + placeholder: 'Alpha', + min: 0, + max: 100, + onChanged: (next) => onChanged(value.changeToOpacity(next / 100)), + ), + ]; + } + + List<_GroupedFieldData> _buildHsvFields() { + return [ + _numberField( + width: 64, + value: value.hsvHue.round().toString(), + placeholder: 'Hue', + min: 0, + max: 360, + onChanged: (next) => onChanged(value.changeToHSVHue(next.toDouble())), + ), + _numberField( + width: 64, + value: (value.hsvSat * 100).round().toString(), + placeholder: 'Sat', + min: 0, + max: 100, + onChanged: (next) => onChanged(value.changeToHSVSaturation(next / 100)), + ), + _numberField( + width: 64, + value: (value.hsvValue * 100).round().toString(), + placeholder: 'Val', + min: 0, + max: 100, + onChanged: (next) => onChanged(value.changeToHSVValue(next / 100)), + ), + if (showAlpha) + _numberField( + width: 64, + value: (value.opacity * 100).round().toString(), + placeholder: 'Alpha', + min: 0, + max: 100, + onChanged: (next) => onChanged(value.changeToOpacity(next / 100)), + ), + ]; + } + + List<_GroupedFieldData> _buildHexFields() { + return [ + _GroupedFieldData( + width: 104, + builder: (scaledWidth, index, length) => _PickerFieldFrame( + width: scaledWidth, + height: fieldHeight, + fieldRadius: fieldRadius, + style: style, + groupIndex: index, + groupLength: length, + child: _ValueField( + value: _colorToHex(value.color, showAlpha: false), + placeholder: 'HEX', + style: style, + keyboardType: material.TextInputType.text, + inputFormatters: const [_HexTextFormatter()], + onChanged: (raw) { + final parsed = _tryParseHex(raw); + if (parsed != null) { + onChanged( + value + .changeToColorRed(_red(parsed).toDouble()) + .changeToColorGreen(_green(parsed).toDouble()) + .changeToColorBlue(_blue(parsed).toDouble()), + ); + } + }, + ), + ), + ), + if (showAlpha) + _numberField( + width: 64, + value: (value.opacity * 100).round().toString(), + placeholder: 'Alpha', + min: 0, + max: 100, + onChanged: (next) => onChanged(value.changeToOpacity(next / 100)), + ), + ]; + } + + _GroupedFieldData _numberField({ + required double width, + required String value, + required String placeholder, + required int min, + required int max, + required material.ValueChanged onChanged, + }) { + return _GroupedFieldData( + width: width, + builder: (scaledWidth, index, length) => _PickerFieldFrame( + width: scaledWidth, + height: fieldHeight, + fieldRadius: fieldRadius, + style: style, + groupIndex: index, + groupLength: length, + child: _ValueField( + value: value, + placeholder: placeholder, + style: style, + keyboardType: material.TextInputType.number, + inputFormatters: [_IntegerRangeFormatter(min: min, max: max)], + onChanged: (raw) { + final parsed = int.tryParse(raw); + if (parsed != null) { + onChanged(parsed.clamp(min, max)); + } + }, + ), + ), + ); + } +} + +class _GroupedFieldData { + const _GroupedFieldData({required this.width, required this.builder}); + + final double width; + final material.Widget Function(double width, int index, int length) builder; +} + +double _pickerControlsWidth({ + required BetterColorPickerMode mode, + required bool showAlpha, +}) { + final widths = [ + 96, + ...switch (mode) { + BetterColorPickerMode.rgb => [64, 64, 64, if (showAlpha) 64], + BetterColorPickerMode.hsl => [64, 64, 64, if (showAlpha) 64], + BetterColorPickerMode.hsv => [64, 64, 64, if (showAlpha) 64], + BetterColorPickerMode.hex => [104, if (showAlpha) 64], + }, + ]; + + // Grouped fields overlap borders by 1px to avoid double-width separators. + return widths.reduce((sum, width) => sum + width) - (widths.length - 1); +} + +double _rgbPickerControlsWidth({required bool showAlpha}) { + return _pickerControlsWidth( + mode: BetterColorPickerMode.rgb, + showAlpha: showAlpha, + ); +} + +List _scaleGroupedFieldWidths({ + required List widths, + required double targetWidth, +}) { + if (widths.isEmpty) { + return const []; + } + + final overlapCount = widths.length - 1; + final totalBaseWidth = widths.reduce((sum, width) => sum + width); + final scale = (targetWidth + overlapCount) / totalBaseWidth; + + return [for (final width in widths) width * scale]; +} + +double _pickerScaleFactor({required double pickerWidth}) { + return pickerWidth / _rgbPickerControlsWidth(showAlpha: false); +} + +class _ModeField extends material.StatelessWidget { + const _ModeField({ + required this.value, + required this.width, + required this.fieldHeight, + required this.fieldRadius, + required this.style, + required this.palette, + required this.groupIndex, + required this.groupLength, + required this.onChanged, + }); + + final BetterColorPickerMode value; + final double width; + final double fieldHeight; + final double fieldRadius; + final BetterColorPickerStyle style; + final BetterColorPickerPalette palette; + final int groupIndex; + final int groupLength; + final material.ValueChanged onChanged; + + @override + material.Widget build(material.BuildContext context) { + return _PickerFieldFrame( + width: width, + height: fieldHeight, + fieldRadius: fieldRadius, + style: style, + groupIndex: groupIndex, + groupLength: groupLength, + child: ShadSelect( + initialValue: value, + minWidth: width, + maxWidth: width, + maxHeight: 180, + padding: const material.EdgeInsets.symmetric(horizontal: 12), + optionsPadding: const material.EdgeInsets.all(4), + decoration: ShadDecoration.none, + selectedOptionBuilder: (context, mode) { + return material.Text( + _modeLabel(mode), + style: _textStyle(context, style).copyWith( + color: palette.foreground, + ), + ); + }, + trailing: material.Icon( + material.Icons.unfold_more, + size: 16, + color: palette.mutedForeground, + ), + options: [ + for (final mode in BetterColorPickerMode.values) + ShadOption( + value: mode, + child: material.Text(_modeLabel(mode)), + ), + ], + onChanged: (mode) { + if (mode != null) { + onChanged(mode); + } + }, + ), + ); + } +} + +class _PickerFieldFrame extends material.StatelessWidget { + const _PickerFieldFrame({ + required this.width, + required this.height, + required this.fieldRadius, + required this.style, + required this.groupIndex, + required this.groupLength, + required this.child, + }); + + final double width; + final double height; + final double fieldRadius; + final BetterColorPickerStyle style; + final int groupIndex; + final int groupLength; + final material.Widget child; + + @override + material.Widget build(material.BuildContext context) { + final palette = style.paletteFor(material.Theme.of(context).brightness); + final field = material.Container( + width: width, + height: height, + decoration: material.BoxDecoration( + color: palette.fieldFill, + borderRadius: _groupRadius(), + border: material.Border.all(color: palette.inputBorder), + ), + child: child, + ); + if (groupIndex == 0) { + return field; + } + return material.Transform.translate( + offset: material.Offset(-groupIndex.toDouble(), 0), + child: field, + ); + } + + material.BorderRadius _groupRadius() { + final radius = material.Radius.circular(fieldRadius); + if (groupLength == 1) { + return material.BorderRadius.all(radius); + } + if (groupIndex == 0) { + return material.BorderRadius.horizontal(left: radius); + } + if (groupIndex == groupLength - 1) { + return material.BorderRadius.horizontal(right: radius); + } + return material.BorderRadius.zero; + } +} + +class _ValueField extends material.StatefulWidget { + const _ValueField({ + required this.value, + required this.placeholder, + required this.style, + this.onChanged, + this.inputFormatters, + this.keyboardType, + }); + + final String value; + final String placeholder; + final BetterColorPickerStyle style; + final material.ValueChanged? onChanged; + final List? inputFormatters; + final material.TextInputType? keyboardType; + + @override + material.State<_ValueField> createState() => _ValueFieldState(); +} + +class _ValueFieldState extends material.State<_ValueField> { + late final material.TextEditingController _controller; + bool _focused = false; + + @override + void initState() { + super.initState(); + _controller = material.TextEditingController(text: widget.value); + } + + @override + void didUpdateWidget(covariant _ValueField oldWidget) { + super.didUpdateWidget(oldWidget); + if (!_focused && oldWidget.value != widget.value) { + _controller.text = widget.value; + } + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + material.Widget build(material.BuildContext context) { + final palette = widget.style.paletteFor( + material.Theme.of(context).brightness, + ); + return material.Focus( + onFocusChange: (focused) { + setState(() { + _focused = focused; + }); + }, + child: material.TextField( + controller: _controller, + onChanged: widget.onChanged == null + ? null + : (value) { + if (_focused) { + widget.onChanged!(value); + } + }, + keyboardType: widget.keyboardType, + inputFormatters: widget.inputFormatters, + maxLines: 1, + textAlignVertical: material.TextAlignVertical.center, + style: _monoTextStyle( + context, + widget.style, + ).copyWith(color: palette.foreground), + decoration: material.InputDecoration( + isDense: true, + border: material.InputBorder.none, + contentPadding: const material.EdgeInsets.symmetric( + horizontal: 12, + vertical: 10, + ), + hintText: widget.placeholder, + hintStyle: _textStyle( + context, + widget.style, + ).copyWith(color: palette.mutedForeground), + ), + ), + ); + } +} + +class _PickerValue { + const _PickerValue._({ + required this.color, + required this.hsv, + required this.hsl, + }); + + factory _PickerValue.fromColor(material.Color color) { + return _PickerValue._( + color: color, + hsv: material.HSVColor.fromColor(color), + hsl: material.HSLColor.fromColor(color), + ); + } + + factory _PickerValue.fromHSV(material.HSVColor hsv) { + final color = hsv.toColor(); + return _PickerValue._( + color: color, + hsv: hsv, + hsl: material.HSLColor.fromColor(color), + ); + } + + factory _PickerValue.fromHSL(material.HSLColor hsl) { + final color = hsl.toColor(); + return _PickerValue._( + color: color, + hsv: material.HSVColor.fromColor(color), + hsl: hsl, + ); + } + + final material.Color color; + final material.HSVColor hsv; + final material.HSLColor hsl; + + int get red => _red(color); + int get green => _green(color); + int get blue => _blue(color); + double get opacity => color.a.clamp(0, 1); + double get hsvHue => hsv.hue; + double get hsvSat => hsv.saturation; + double get hsvValue => hsv.value; + double get hslHue => hsl.hue; + double get hslSat => hsl.saturation; + double get hslLightness => hsl.lightness; + + _PickerValue changeToColorRed(double value) { + return _PickerValue.fromColor( + material.Color.fromARGB( + _alpha(color), + value.round().clamp(0, 255), + green, + blue, + ), + ); + } + + _PickerValue changeToColorGreen(double value) { + return _PickerValue.fromColor( + material.Color.fromARGB( + _alpha(color), + red, + value.round().clamp(0, 255), + blue, + ), + ); + } + + _PickerValue changeToColorBlue(double value) { + return _PickerValue.fromColor( + material.Color.fromARGB( + _alpha(color), + red, + green, + value.round().clamp(0, 255), + ), + ); + } + + _PickerValue changeToOpacity(double value) { + return _PickerValue.fromHSV(hsv.withAlpha(value.clamp(0, 1))); + } + + _PickerValue changeToHSVHue(double value) { + return _PickerValue.fromHSV(hsv.withHue(value)); + } + + _PickerValue changeToHSVSaturation(double value) { + return _PickerValue.fromHSV(hsv.withSaturation(value.clamp(0, 1))); + } + + _PickerValue changeToHSVValue(double value) { + return _PickerValue.fromHSV(hsv.withValue(value.clamp(0, 1))); + } + + _PickerValue changeToHSLHue(double value) { + return _PickerValue.fromHSL(hsl.withHue(value)); + } + + _PickerValue changeToHSLSaturation(double value) { + return _PickerValue.fromHSL(hsl.withSaturation(value.clamp(0, 1))); + } + + _PickerValue changeToHSLLightness(double value) { + return _PickerValue.fromHSL(hsl.withLightness(value.clamp(0, 1))); + } +} + +enum _HSVSliderType { hue, satVal, alpha } + +class _HSVColorSlider extends material.StatefulWidget { + const _HSVColorSlider({ + required this.value, + required this.sliderType, + required this.radius, + this.cursorDiameter = 16, + this.cursorBorderWidth = 2, + this.alphaCheckboardSize = 8, + this.onChanging, + this.onChanged, + this.reverse = false, + }); + + final material.HSVColor value; + final _HSVSliderType sliderType; + final material.Radius radius; + final double cursorDiameter; + final double cursorBorderWidth; + final double alphaCheckboardSize; + final material.ValueChanged? onChanging; + final material.ValueChanged? onChanged; + final bool reverse; + + @override + material.State<_HSVColorSlider> createState() => _HSVColorSliderState(); +} + +class _HSVColorSliderState extends material.State<_HSVColorSlider> { + late double _currentHorizontal; + late double _currentVertical; + late double _hue; + late double _saturation; + late double _value; + late double _alpha; + + @override + void initState() { + super.initState(); + _syncFromWidget(); + } + + @override + void didUpdateWidget(covariant _HSVColorSlider oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.value != widget.value) { + _syncFromWidget(); + } + } + + void _syncFromWidget() { + final hsv = widget.value; + _hue = hsv.hue; + _saturation = hsv.saturation; + _value = hsv.value; + _alpha = hsv.alpha; + _currentHorizontal = horizontal; + _currentVertical = vertical; + } + + @override + material.Widget build(material.BuildContext context) { + final cursorDiameter = widget.cursorDiameter; + final radiusDivisor = + widget.sliderType == _HSVSliderType.satVal ? 2.0 : 4.0; + return material.GestureDetector( + onTapDown: (details) { + _updateColor(details.localPosition, context.size!); + widget.onChanged?.call(_currentColor); + }, + onPanUpdate: (details) { + setState(() { + _updateColor(details.localPosition, context.size!); + }); + }, + onPanEnd: (_) => widget.onChanged?.call(_currentColor), + child: material.Stack( + clipBehavior: material.Clip.none, + children: [ + if (widget.sliderType == _HSVSliderType.alpha) + material.Positioned.fill( + child: material.RepaintBoundary( + child: material.ClipRRect( + borderRadius: material.BorderRadius.all(widget.radius), + child: material.CustomPaint( + painter: _AlphaPainter( + checkboardSize: widget.alphaCheckboardSize, + ), + ), + ), + ), + ), + material.Positioned.fill( + child: material.RepaintBoundary( + child: material.ClipRRect( + borderRadius: material.BorderRadius.all(widget.radius), + child: material.CustomPaint( + painter: _HSVColorSliderPainter( + sliderType: widget.sliderType, + color: _currentColor, + reverse: widget.reverse, + ), + ), + ), + ), + ), + material.Positioned( + left: -cursorDiameter / radiusDivisor, + right: -cursorDiameter / radiusDivisor, + top: -cursorDiameter / radiusDivisor, + bottom: -cursorDiameter / radiusDivisor, + child: widget.sliderType == _HSVSliderType.satVal + ? material.Align( + alignment: material.Alignment( + (_currentHorizontal.clamp(0, 1) * 2) - 1, + (_currentVertical.clamp(0, 1) * 2) - 1, + ), + child: material.Container( + width: cursorDiameter, + height: cursorDiameter, + decoration: material.BoxDecoration( + shape: material.BoxShape.circle, + color: _currentColor.toColor(), + border: material.Border.all( + color: material.Colors.white, + width: widget.cursorBorderWidth, + ), + ), + ), + ) + : _SingleAxisCursor( + reverse: widget.reverse, + horizontal: _currentHorizontal, + vertical: _currentVertical, + radius: widget.radius, + thickness: cursorDiameter, + borderWidth: widget.cursorBorderWidth, + color: _currentColor.toColor(), + ), + ), + ], + ), + ); + } + + material.HSVColor get _currentColor { + return material.HSVColor.fromAHSV( + _alpha.clamp(0, 1), + _hue.clamp(0, 360), + _saturation.clamp(0, 1), + _value.clamp(0, 1), + ); + } + + void _updateColor(material.Offset localPosition, material.Size size) { + _currentHorizontal = (localPosition.dx / size.width).clamp(0, 1); + _currentVertical = (localPosition.dy / size.height).clamp(0, 1); + switch (widget.sliderType) { + case _HSVSliderType.hue: + _hue = (widget.reverse ? _currentHorizontal : _currentVertical) * 360; + break; + case _HSVSliderType.alpha: + _alpha = widget.reverse ? _currentHorizontal : _currentVertical; + break; + case _HSVSliderType.satVal: + if (widget.reverse) { + _saturation = _currentHorizontal; + _value = _currentVertical; + } else { + _saturation = _currentVertical; + _value = _currentHorizontal; + } + break; + } + widget.onChanging?.call(_currentColor); + } + + double get vertical { + switch (widget.sliderType) { + case _HSVSliderType.hue: + return widget.value.hue / 360; + case _HSVSliderType.alpha: + return widget.value.alpha; + case _HSVSliderType.satVal: + return widget.reverse ? widget.value.value : widget.value.saturation; + } + } + + double get horizontal { + switch (widget.sliderType) { + case _HSVSliderType.hue: + return widget.value.hue / 360; + case _HSVSliderType.alpha: + return widget.value.alpha; + case _HSVSliderType.satVal: + return widget.reverse ? widget.value.saturation : widget.value.value; + } + } +} + +class _HSLColorSlider extends material.StatefulWidget { + const _HSLColorSlider({ + required this.color, + required this.radius, + this.cursorDiameter = 16, + this.cursorBorderWidth = 2, + this.onChanging, + this.onChanged, + }); + + final material.HSLColor color; + final material.Radius radius; + final double cursorDiameter; + final double cursorBorderWidth; + final material.ValueChanged? onChanging; + final material.ValueChanged? onChanged; + + @override + material.State<_HSLColorSlider> createState() => _HSLColorSliderState(); +} + +class _HSLColorSliderState extends material.State<_HSLColorSlider> { + late double _currentHorizontal; + late double _currentVertical; + late double _hue; + late double _saturation; + late double _lightness; + late double _alpha; + + @override + void initState() { + super.initState(); + _syncFromWidget(); + } + + @override + void didUpdateWidget(covariant _HSLColorSlider oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.color != widget.color) { + _syncFromWidget(); + } + } + + void _syncFromWidget() { + final hsl = widget.color; + _hue = hsl.hue; + _saturation = hsl.saturation; + _lightness = hsl.lightness; + _alpha = hsl.alpha; + _currentHorizontal = horizontal; + _currentVertical = vertical; + } + + @override + material.Widget build(material.BuildContext context) { + final cursorDiameter = widget.cursorDiameter; + return material.GestureDetector( + onTapDown: (details) { + _updateColor(details.localPosition, context.size!); + widget.onChanged?.call(_currentColor); + }, + onPanUpdate: (details) { + setState(() { + _updateColor(details.localPosition, context.size!); + }); + }, + onPanEnd: (_) => widget.onChanged?.call(_currentColor), + child: material.Stack( + clipBehavior: material.Clip.none, + children: [ + material.Positioned.fill( + child: material.RepaintBoundary( + child: material.ClipRRect( + borderRadius: material.BorderRadius.all(widget.radius), + child: material.CustomPaint( + painter: _HSLColorSliderPainter(color: _currentColor), + ), + ), + ), + ), + material.Positioned( + left: -cursorDiameter / 2, + right: -cursorDiameter / 2, + top: -cursorDiameter / 2, + bottom: -cursorDiameter / 2, + child: material.Align( + alignment: material.Alignment( + (_currentHorizontal.clamp(0, 1) * 2) - 1, + (_currentVertical.clamp(0, 1) * 2) - 1, + ), + child: material.Container( + width: cursorDiameter, + height: cursorDiameter, + decoration: material.BoxDecoration( + shape: material.BoxShape.circle, + color: _currentColor.toColor(), + border: material.Border.all( + color: material.Colors.white, + width: widget.cursorBorderWidth, + ), + ), + ), + ), + ), + ], + ), + ); + } + + material.HSLColor get _currentColor { + return material.HSLColor.fromAHSL( + _alpha.clamp(0, 1), + _hue.clamp(0, 360), + _saturation.clamp(0, 1), + _lightness.clamp(0, 1), + ); + } + + void _updateColor(material.Offset localPosition, material.Size size) { + _currentHorizontal = (localPosition.dx / size.width).clamp(0, 1); + _currentVertical = (localPosition.dy / size.height).clamp(0, 1); + _saturation = _currentVertical; + _lightness = _currentHorizontal; + widget.onChanging?.call(_currentColor); + } + + double get vertical => widget.color.saturation; + + double get horizontal => widget.color.lightness; +} + +class _SingleAxisCursor extends material.StatelessWidget { + const _SingleAxisCursor({ + required this.reverse, + required this.horizontal, + required this.vertical, + required this.radius, + required this.thickness, + required this.borderWidth, + required this.color, + }); + + final bool reverse; + final double horizontal; + final double vertical; + final material.Radius radius; + final double thickness; + final double borderWidth; + final material.Color color; + + @override + material.Widget build(material.BuildContext context) { + final alignment = material.Alignment( + (horizontal.clamp(0, 1) * 2) - 1, + (vertical.clamp(0, 1) * 2) - 1, + ); + final handleCornerRadius = + radius.x < thickness / 4 ? radius.x : thickness / 4; + final handleRadius = material.Radius.circular(handleCornerRadius); + if (reverse) { + return material.Align( + alignment: alignment, + child: material.Container( + width: thickness, + height: double.infinity, + decoration: material.BoxDecoration( + color: color, + border: material.Border.all( + color: material.Colors.white, + width: borderWidth, + ), + borderRadius: material.BorderRadius.all(handleRadius), + ), + ), + ); + } + return material.Align( + alignment: alignment, + child: material.Container( + width: double.infinity, + height: thickness, + decoration: material.BoxDecoration( + color: color, + border: material.Border.all( + color: material.Colors.white, + width: borderWidth, + ), + borderRadius: material.BorderRadius.all(handleRadius), + ), + ), + ); + } +} + +class _AlphaPainter extends material.CustomPainter { + const _AlphaPainter({required this.checkboardSize}); + + static const checkboardPrimary = material.Color(0xFFE0E0E0); + static const checkboardSecondary = material.Color(0xFFB0B0B0); + final double checkboardSize; + + @override + void paint(material.Canvas canvas, material.Size size) { + final paint = material.Paint() + ..style = material.PaintingStyle.fill + ..color = checkboardPrimary; + canvas.drawRect(material.Offset.zero & size, paint); + paint.color = checkboardSecondary; + for (var x = 0.0; x < size.width; x += checkboardSize) { + for (var y = 0.0; y < size.height; y += checkboardSize) { + final isEvenColumn = (x / checkboardSize).floor().isEven; + final isEvenRow = (y / checkboardSize).floor().isEven; + if (isEvenColumn == isEvenRow) { + canvas.drawRect( + material.Rect.fromLTWH(x, y, checkboardSize, checkboardSize), + paint, + ); + } + } + } + } + + @override + bool shouldRepaint(covariant _AlphaPainter oldDelegate) { + return oldDelegate.checkboardSize != checkboardSize; + } +} + +class _HSVColorSliderPainter extends material.CustomPainter { + _HSVColorSliderPainter({ + required this.sliderType, + required this.color, + required this.reverse, + }); + + final _HSVSliderType sliderType; + final material.HSVColor color; + final bool reverse; + + @override + void paint(material.Canvas canvas, material.Size size) { + final paint = material.Paint() + ..isAntiAlias = false + ..style = material.PaintingStyle.fill; + + switch (sliderType) { + case _HSVSliderType.satVal: + final width = size.width / 100; + final height = size.height / 100; + for (var i = 0; i < 100; i++) { + for (var j = 0; j < 100; j++) { + paint.color = material.HSVColor.fromAHSV( + 1, + color.hue, + reverse ? i / 100 : j / 100, + reverse ? j / 100 : i / 100, + ).toColor(); + canvas.drawRect( + material.Rect.fromLTWH(i * width, j * height, width, height), + paint, + ); + } + } + break; + case _HSVSliderType.hue: + if (reverse) { + final width = size.width / 360; + for (var i = 0; i < 360; i++) { + paint.color = material.HSVColor.fromAHSV( + 1, + i.toDouble(), + color.saturation, + color.value, + ).toColor(); + canvas.drawRect( + material.Rect.fromLTWH(i * width, 0, width, size.height), + paint, + ); + } + } else { + final height = size.height / 360; + for (var i = 0; i < 360; i++) { + paint.color = material.HSVColor.fromAHSV( + 1, + i.toDouble(), + color.saturation, + color.value, + ).toColor(); + canvas.drawRect( + material.Rect.fromLTWH(0, i * height, size.width, height), + paint, + ); + } + } + break; + case _HSVSliderType.alpha: + final opaque = material.Color.fromARGB( + 255, + _red(color.toColor()), + _green(color.toColor()), + _blue(color.toColor()), + ); + paint.shader = material.LinearGradient( + begin: reverse + ? material.Alignment.centerLeft + : material.Alignment.topCenter, + end: reverse + ? material.Alignment.centerRight + : material.Alignment.bottomCenter, + colors: [opaque.withValues(alpha: 0), opaque], + ).createShader(material.Offset.zero & size); + canvas.drawRect(material.Offset.zero & size, paint); + paint.shader = null; + break; + } + } + + @override + bool shouldRepaint(covariant _HSVColorSliderPainter oldDelegate) { + if (oldDelegate.sliderType != sliderType || + oldDelegate.reverse != reverse) { + return true; + } + switch (sliderType) { + case _HSVSliderType.satVal: + return oldDelegate.color.hue != color.hue; + case _HSVSliderType.hue: + return oldDelegate.color.saturation != color.saturation || + oldDelegate.color.value != color.value; + case _HSVSliderType.alpha: + return oldDelegate.color.hue != color.hue || + oldDelegate.color.saturation != color.saturation || + oldDelegate.color.value != color.value; + } + } +} + +class _HSLColorSliderPainter extends material.CustomPainter { + _HSLColorSliderPainter({required this.color}); + + final material.HSLColor color; + + @override + void paint(material.Canvas canvas, material.Size size) { + final paint = material.Paint() + ..isAntiAlias = false + ..style = material.PaintingStyle.fill; + final width = size.width / 100; + final height = size.height / 100; + for (var i = 0; i < 100; i++) { + for (var j = 0; j < 100; j++) { + paint.color = material.HSLColor.fromAHSL( + 1, + color.hue, + j / 100, + i / 100, + ).toColor(); + canvas.drawRect( + material.Rect.fromLTWH(i * width, j * height, width, height), + paint, + ); + } + } + } + + @override + bool shouldRepaint(covariant _HSLColorSliderPainter oldDelegate) { + return oldDelegate.color.hue != color.hue; + } +} + +class _IntegerRangeFormatter extends TextInputFormatter { + _IntegerRangeFormatter({required this.min, required this.max}); + + final int min; + final int max; + + @override + TextEditingValue formatEditUpdate( + TextEditingValue oldValue, + TextEditingValue newValue, + ) { + final text = newValue.text; + if (text.isEmpty) { + return newValue; + } + if (!RegExp(r'^\d+$').hasMatch(text)) { + return oldValue; + } + final parsed = int.tryParse(text); + if (parsed == null || parsed < min || parsed > max) { + return oldValue; + } + return newValue; + } +} + +class _HexTextFormatter extends TextInputFormatter { + const _HexTextFormatter(); + + @override + TextEditingValue formatEditUpdate( + TextEditingValue oldValue, + TextEditingValue newValue, + ) { + var text = newValue.text.toUpperCase().replaceAll( + RegExp(r'[^0-9A-F#]'), + '', + ); + if (text.isEmpty) { + return newValue.copyWith(text: ''); + } + if (!text.startsWith('#')) { + text = '#$text'; + } + if (text.length > 7) { + text = text.substring(0, 7); + } + return newValue.copyWith( + text: text, + selection: material.TextSelection.collapsed(offset: text.length), + ); + } +} + +class _ColorSwatch extends material.StatelessWidget { + const _ColorSwatch({ + required this.color, + required this.size, + required this.radius, + }); + + final material.Color color; + final double size; + final double radius; + + @override + material.Widget build(material.BuildContext context) { + return material.Container( + width: size, + height: size, + decoration: material.BoxDecoration( + color: color, + borderRadius: material.BorderRadius.circular(radius), + border: material.Border.all( + color: material.Theme.of(context).colorScheme.outlineVariant, + ), + ), + ); + } +} + +material.TextStyle _textStyle( + material.BuildContext context, + BetterColorPickerStyle style, +) { + return style.textStyle ?? material.Theme.of(context).textTheme.bodyMedium!; +} + +material.TextStyle _monoTextStyle( + material.BuildContext context, + BetterColorPickerStyle style, +) { + return style.monospaceTextStyle ?? + _textStyle( + context, + style, + ).copyWith(fontFeatures: const [FontFeature.tabularFigures()]); +} + +material.Color? _tryParseHex(String value) { + var hex = value.trim().toUpperCase(); + if (hex.startsWith('#')) { + hex = hex.substring(1); + } + if (hex.length != 6) { + return null; + } + final parsed = int.tryParse(hex, radix: 16); + if (parsed == null) { + return null; + } + return material.Color(0xFF000000 | parsed); +} + +String _modeLabel(BetterColorPickerMode mode) { + switch (mode) { + case BetterColorPickerMode.rgb: + return 'RGB'; + case BetterColorPickerMode.hsl: + return 'HSL'; + case BetterColorPickerMode.hsv: + return 'HSV'; + case BetterColorPickerMode.hex: + return 'HEX'; + } +} + +String _colorToHex(material.Color color, {required bool showAlpha}) { + final red = _red(color).toRadixString(16).padLeft(2, '0'); + final green = _green(color).toRadixString(16).padLeft(2, '0'); + final blue = _blue(color).toRadixString(16).padLeft(2, '0'); + if (!showAlpha) { + return '#$red$green$blue'.toUpperCase(); + } + final alpha = _alpha(color).toRadixString(16).padLeft(2, '0'); + return '#$alpha$red$green$blue'.toUpperCase(); +} + +int _red(material.Color color) => (color.r * 255).round().clamp(0, 255); + +int _green(material.Color color) => (color.g * 255).round().clamp(0, 255); + +int _blue(material.Color color) => (color.b * 255).round().clamp(0, 255); + +int _alpha(material.Color color) => (color.a * 255).round().clamp(0, 255); diff --git a/lib/widgets/folder_edit_dialog.dart b/lib/widgets/folder_edit_dialog.dart index e982e8e2..c994407c 100644 --- a/lib/widgets/folder_edit_dialog.dart +++ b/lib/widgets/folder_edit_dialog.dart @@ -1,12 +1,13 @@ import 'package:flutter/material.dart'; -import 'package:flutter_colorpicker/flutter_colorpicker.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:icarus/const/settings.dart'; import 'package:icarus/providers/folder_provider.dart'; +import 'package:icarus/widgets/better_color_picker.dart'; import 'package:icarus/widgets/color_picker_button.dart'; import 'package:icarus/widgets/custom_text_field.dart'; import 'package:icarus/widgets/dot_painter.dart'; import 'package:icarus/widgets/folder_pill.dart'; +import 'package:icarus/widgets/icarus_color_picker_style.dart'; import 'package:icarus/widgets/sidebar_widgets/color_buttons.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; @@ -185,20 +186,28 @@ class _FolderEditDialogState extends ConsumerState { ), ], child: Material( + color: Colors.transparent, child: SizedBox( width: 300, - child: ColorPicker( - portraitOnly: true, - pickerColor: - Folder.folderColorMap[_selectedColor] ?? - _customColor!, - onColorChanged: (color) { + child: BetterColorPicker( + value: Folder + .folderColorMap[_selectedColor] ?? + _customColor ?? + Folder.folderColorMap[FolderColor.red]!, + initialMode: BetterColorPickerMode.hsv, + style: icarusColorPickerStyle, + onChanging: (color) { + setState(() { + _selectedColor = FolderColor.custom; + _customColor = color; + }); + }, + onChanged: (color) { setState(() { _selectedColor = FolderColor.custom; _customColor = color; }); }, - pickerAreaHeightPercent: 0.8, ), ), ), diff --git a/lib/widgets/icarus_color_picker_style.dart b/lib/widgets/icarus_color_picker_style.dart new file mode 100644 index 00000000..d6367854 --- /dev/null +++ b/lib/widgets/icarus_color_picker_style.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; +import 'package:icarus/widgets/better_color_picker.dart'; + +const icarusColorPickerStyle = BetterColorPickerStyle( + darkPalette: BetterColorPickerPalette( + surface: Color(0xff18181b), + foreground: Color(0xfffafafa), + mutedForeground: Color(0xffa1a1aa), + inputBorder: Color(0xff27272a), + fieldFill: Color(0xff27272a), + ), + lightPalette: BetterColorPickerPalette( + surface: Color(0xff18181b), + foreground: Color(0xfffafafa), + mutedForeground: Color(0xffa1a1aa), + inputBorder: Color(0xff27272a), + fieldFill: Color(0xff27272a), + ), + textStyle: TextStyle( + color: Color(0xfffafafa), + fontSize: 13, + ), + monospaceTextStyle: TextStyle( + color: Color(0xfffafafa), + fontSize: 13, + fontFeatures: [FontFeature.tabularFigures()], + ), + mainSliderRadius: 6, + channelSliderRadius: 4, + fieldRadius: 6, + swatchRadius: 6, + dialogWidth: 320, +); diff --git a/lib/widgets/map_theme_settings_section.dart b/lib/widgets/map_theme_settings_section.dart index ad143650..9d2eb4f0 100644 --- a/lib/widgets/map_theme_settings_section.dart +++ b/lib/widgets/map_theme_settings_section.dart @@ -1,10 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:flutter_colorpicker/flutter_colorpicker.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:icarus/widgets/better_color_picker.dart'; import 'package:icarus/const/settings.dart'; import 'package:icarus/providers/map_theme_provider.dart'; import 'package:icarus/providers/strategy_provider.dart'; import 'package:icarus/widgets/custom_text_field.dart'; +import 'package:icarus/widgets/icarus_color_picker_style.dart'; import 'package:icarus/widgets/settings_scope_card.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; @@ -777,15 +778,20 @@ Future _showColorPickerDialog({ color: Colors.transparent, child: SizedBox( width: 320, - child: ColorPicker( - portraitOnly: true, - pickerColor: workingColor, - onColorChanged: (color) { + child: BetterColorPicker( + value: workingColor, + initialMode: BetterColorPickerMode.hsv, + style: icarusColorPickerStyle, + onChanging: (color) { + setState(() { + workingColor = color; + }); + }, + onChanged: (color) { setState(() { workingColor = color; }); }, - pickerAreaHeightPercent: 0.8, ), ), ), diff --git a/pubspec.lock b/pubspec.lock index b6fb56e7..67941faf 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -374,14 +374,6 @@ packages: url: "https://pub.dev" source: hosted version: "4.5.2" - flutter_colorpicker: - dependency: "direct main" - description: - name: flutter_colorpicker - sha256: "969de5f6f9e2a570ac660fb7b501551451ea2a1ab9e2097e89475f60e07816ea" - url: "https://pub.dev" - source: hosted - version: "1.1.0" flutter_inappwebview: dependency: "direct main" description: @@ -721,10 +713,10 @@ packages: dependency: transitive description: name: matcher - sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6" + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 url: "https://pub.dev" source: hosted - version: "0.12.18" + version: "0.12.19" material_color_utilities: dependency: transitive description: @@ -1086,10 +1078,10 @@ packages: dependency: transitive description: name: test_api - sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636" + sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a" url: "https://pub.dev" source: hosted - version: "0.7.9" + version: "0.7.10" theme_extensions_builder_annotation: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 0ac374b7..b353e75b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,7 +30,6 @@ dependencies: image: ^4.5.4 http: ^1.6.0 screenshot: ^3.0.0 - flutter_colorpicker: ^1.1.0 archive: ^4.0.7 flutter_portal: ^1.1.4 shadcn_ui: ^0.40.3 From 58c5047f7aa68c48ebdfe0c056d1b56c7eb3a6cf Mon Sep 17 00:00:00 2001 From: Dara Adedeji Date: Sat, 25 Apr 2026 16:14:44 -0400 Subject: [PATCH 05/26] Add customizable color library - Persist custom swatch colors in app preferences - Replace hardcoded color pickers with shared color library UI - Allow adding, editing, and deleting custom colors --- lib/hive/hive_adapters.g.dart | 7 +- lib/hive/hive_adapters.g.yaml | 4 +- lib/providers/color_library_provider.dart | 81 ++++++ lib/providers/map_theme_provider.dart | 17 +- lib/widgets/dialogs/upload_image_dialog.dart | 42 +-- .../image/placed_image_builder.dart | 64 ++--- .../sidebar_widgets/color_library.dart | 250 ++++++++++++++++++ .../sidebar_widgets/custom_shape_tools.dart | 33 +-- .../sidebar_widgets/drawing_tools.dart | 32 +-- lib/widgets/sidebar_widgets/text_tools.dart | 41 +-- 10 files changed, 414 insertions(+), 157 deletions(-) create mode 100644 lib/providers/color_library_provider.dart create mode 100644 lib/widgets/sidebar_widgets/color_library.dart diff --git a/lib/hive/hive_adapters.g.dart b/lib/hive/hive_adapters.g.dart index 2316e209..725ba4ec 100644 --- a/lib/hive/hive_adapters.g.dart +++ b/lib/hive/hive_adapters.g.dart @@ -1291,19 +1291,22 @@ class AppPreferencesAdapter extends TypeAdapter { autosaveEnabled: fields[1] == null ? true : fields[1] as bool, pagesBarExpandedHeight: fields[2] == null ? 310.0 : (fields[2] as num).toDouble(), + customColorValues: (fields[3] as List?)?.cast(), ); } @override void write(BinaryWriter writer, AppPreferences obj) { writer - ..writeByte(3) + ..writeByte(4) ..writeByte(0) ..write(obj.defaultThemeProfileIdForNewStrategies) ..writeByte(1) ..write(obj.autosaveEnabled) ..writeByte(2) - ..write(obj.pagesBarExpandedHeight); + ..write(obj.pagesBarExpandedHeight) + ..writeByte(3) + ..write(obj.customColorValues); } @override diff --git a/lib/hive/hive_adapters.g.yaml b/lib/hive/hive_adapters.g.yaml index 5b834f65..473a874c 100644 --- a/lib/hive/hive_adapters.g.yaml +++ b/lib/hive/hive_adapters.g.yaml @@ -437,7 +437,7 @@ types: index: 4 AppPreferences: typeId: 28 - nextIndex: 3 + nextIndex: 4 fields: defaultThemeProfileIdForNewStrategies: index: 0 @@ -445,6 +445,8 @@ types: index: 1 pagesBarExpandedHeight: index: 2 + customColorValues: + index: 3 PlacedViewConeAgent: typeId: 29 nextIndex: 9 diff --git a/lib/providers/color_library_provider.dart b/lib/providers/color_library_provider.dart new file mode 100644 index 00000000..abcd1c2f --- /dev/null +++ b/lib/providers/color_library_provider.dart @@ -0,0 +1,81 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:icarus/providers/map_theme_provider.dart'; + +class ColorLibraryEntry { + const ColorLibraryEntry({ + required this.color, + required this.isCustom, + this.customIndex, + }); + + final Color color; + final bool isCustom; + final int? customIndex; +} + +final defaultColorLibraryProvider = Provider>((ref) { + return const [ + Colors.white, + Colors.red, + Colors.blue, + Colors.yellow, + Colors.green, + ]; +}); + +final customColorLibraryProvider = Provider>((ref) { + final prefs = ref.watch(appPreferencesProvider); + return prefs.customColorValues.map(Color.new).toList(growable: false); +}); + +final colorLibraryProvider = Provider>((ref) { + final defaults = ref.watch(defaultColorLibraryProvider); + final customColors = ref.watch(customColorLibraryProvider); + return [ + for (final color in defaults) + ColorLibraryEntry(color: color, isCustom: false), + for (final (index, color) in customColors.indexed) + ColorLibraryEntry(color: color, isCustom: true, customIndex: index), + ]; +}); + +class ColorLibraryController extends Notifier> { + static const int customColorLimit = 15; + + @override + List build() { + return ref.watch(appPreferencesProvider).customColorValues; + } + + bool get canAddColor => state.length < customColorLimit; + + Future addColor(Color color) async { + if (!canAddColor) return; + await _save([...state, color.toARGB32()]); + } + + Future updateColor(int customIndex, Color color) async { + if (customIndex < 0 || customIndex >= state.length) return; + final next = [...state]; + next[customIndex] = color.toARGB32(); + await _save(next); + } + + Future deleteColor(int customIndex) async { + if (customIndex < 0 || customIndex >= state.length) return; + final next = [...state]..removeAt(customIndex); + await _save(next); + } + + Future _save(List colorValues) async { + await ref + .read(appPreferencesProvider.notifier) + .setCustomColorValues(colorValues); + } +} + +final colorLibraryControllerProvider = + NotifierProvider>( + ColorLibraryController.new, +); diff --git a/lib/providers/map_theme_provider.dart b/lib/providers/map_theme_provider.dart index 4fb80928..62a463b8 100644 --- a/lib/providers/map_theme_provider.dart +++ b/lib/providers/map_theme_provider.dart @@ -112,17 +112,20 @@ class AppPreferences extends HiveObject { final String defaultThemeProfileIdForNewStrategies; final bool autosaveEnabled; final double pagesBarExpandedHeight; + final List customColorValues; AppPreferences({ required this.defaultThemeProfileIdForNewStrategies, this.autosaveEnabled = true, this.pagesBarExpandedHeight = 310.0, - }); + List? customColorValues, + }) : customColorValues = List.unmodifiable(customColorValues ?? const []); AppPreferences copyWith({ String? defaultThemeProfileIdForNewStrategies, bool? autosaveEnabled, double? pagesBarExpandedHeight, + List? customColorValues, }) { return AppPreferences( defaultThemeProfileIdForNewStrategies: @@ -131,6 +134,7 @@ class AppPreferences extends HiveObject { autosaveEnabled: autosaveEnabled ?? this.autosaveEnabled, pagesBarExpandedHeight: pagesBarExpandedHeight ?? this.pagesBarExpandedHeight, + customColorValues: customColorValues ?? this.customColorValues, ); } } @@ -502,6 +506,17 @@ class AppPreferencesNotifier extends Notifier { state = updated; } + Future setCustomColorValues(List colorValues) async { + final updated = _readFromHive().copyWith( + customColorValues: colorValues.take(15).toList(growable: false), + ); + await Hive.box(HiveBoxNames.appPreferencesBox).put( + MapThemeProfilesProvider.appPreferencesSingletonKey, + updated, + ); + state = updated; + } + AppPreferences _readFromHive() { return Hive.box(HiveBoxNames.appPreferencesBox).get( MapThemeProfilesProvider.appPreferencesSingletonKey, diff --git a/lib/widgets/dialogs/upload_image_dialog.dart b/lib/widgets/dialogs/upload_image_dialog.dart index 7169a66c..0a68bed5 100644 --- a/lib/widgets/dialogs/upload_image_dialog.dart +++ b/lib/widgets/dialogs/upload_image_dialog.dart @@ -8,7 +8,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:icarus/const/settings.dart'; import 'package:icarus/providers/image_provider.dart'; import 'package:icarus/services/clipboard_service.dart'; -import 'package:icarus/widgets/sidebar_widgets/color_buttons.dart'; +import 'package:icarus/widgets/sidebar_widgets/color_library.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; @@ -36,13 +36,6 @@ class _UploadImageDialogState extends ConsumerState { Uint8List? _selectedBytes; String? _selectedName; int? _selectedTagColorValue; - static const List _colorOptions = [ - Color(0xFF22C55E), - Color(0xFF3B82F6), - Color(0xFFF59E0B), - Color(0xFFEF4444), - Color(0xFFA855F7), - ]; @override void initState() { @@ -215,33 +208,12 @@ class _UploadImageDialogState extends ConsumerState { const SizedBox(height: 12), const Text('Tag color'), const SizedBox(height: 6), - Wrap( - children: [ - Padding( - padding: const EdgeInsets.all(4.0), - child: ColorButtons( - height: 24, - width: 24, - color: const Color(0xFFC5C5C5), - isSelected: _selectedTagColorValue == null, - onTap: () => - setState(() => _selectedTagColorValue = null), - ), - ), - for (final color in _colorOptions) - Padding( - padding: const EdgeInsets.all(4.0), - child: ColorButtons( - height: 24, - width: 24, - color: color, - isSelected: - _selectedTagColorValue == color.toARGB32(), - onTap: () => setState( - () => _selectedTagColorValue = color.toARGB32()), - ), - ), - ], + ColorLibrary( + includeEmpty: true, + selectedColorValue: _selectedTagColorValue, + onSelected: (colorValue) => setState( + () => _selectedTagColorValue = colorValue, + ), ), ], ), diff --git a/lib/widgets/draggable_widgets/image/placed_image_builder.dart b/lib/widgets/draggable_widgets/image/placed_image_builder.dart index be3dd8b7..a433390a 100644 --- a/lib/widgets/draggable_widgets/image/placed_image_builder.dart +++ b/lib/widgets/draggable_widgets/image/placed_image_builder.dart @@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:icarus/const/coordinate_system.dart'; import 'package:icarus/const/image_scale_policy.dart'; import 'package:icarus/const/placed_classes.dart'; +import 'package:icarus/providers/color_library_provider.dart'; import 'package:icarus/providers/hovered_delete_target_provider.dart'; import 'package:icarus/providers/image_provider.dart'; @@ -32,13 +33,6 @@ class _PlacedImageBuilderState extends State { double? localScale; // Make localScale nullable to check if it's initialized bool isPanning = false; bool isDragging = false; - static const List _tagPalette = [ - Color(0xFF22C55E), - Color(0xFF3B82F6), - Color(0xFFF59E0B), - Color(0xFFEF4444), - Color(0xFFA855F7), - ]; @override void initState() { @@ -58,8 +52,8 @@ class _PlacedImageBuilderState extends State { if (ref.watch(placedImageProvider).images[index].scale != localScale && !isPanning) { - localScale = - ImageScalePolicy.clamp(ref.read(placedImageProvider).images[index].scale); + localScale = ImageScalePolicy.clamp( + ref.read(placedImageProvider).images[index].scale); } return ImageScaleController( @@ -156,40 +150,32 @@ class _PlacedImageBuilderState extends State { .updateTagColor(widget.placedImage.id, null); }, ), - ..._tagPalette.map( - (color) => ShadContextMenuItem( - leading: Container( - width: 12, - height: 12, - decoration: BoxDecoration( - color: color, - shape: BoxShape.circle, + ...ref.watch(colorLibraryProvider).map( + (entry) => ShadContextMenuItem( + leading: Container( + width: 12, + height: 12, + decoration: BoxDecoration( + color: entry.color, + shape: BoxShape.circle, + ), + ), + child: Text(_labelForColor(entry)), + onPressed: () { + ref.read(placedImageProvider.notifier).updateTagColor( + widget.placedImage.id, entry.color.toARGB32()); + }, ), ), - child: Text(_labelForColor(color)), - onPressed: () { - ref - .read(placedImageProvider.notifier) - .updateTagColor(widget.placedImage.id, color.toARGB32()); - }, - ), - ), ]; } - String _labelForColor(Color color) { - if (color.toARGB32() == const Color(0xFF22C55E).toARGB32()) { - return 'Green tag'; - } - if (color.toARGB32() == const Color(0xFF3B82F6).toARGB32()) { - return 'Blue tag'; - } - if (color.toARGB32() == const Color(0xFFF59E0B).toARGB32()) { - return 'Amber tag'; - } - if (color.toARGB32() == const Color(0xFFEF4444).toARGB32()) { - return 'Red tag'; - } - return 'Purple tag'; + String _labelForColor(ColorLibraryEntry entry) { + final kind = entry.isCustom ? 'custom' : 'default'; + final hex = (entry.color.toARGB32() & 0x00FFFFFF) + .toRadixString(16) + .padLeft(6, '0') + .toUpperCase(); + return '#$hex $kind tag'; } } diff --git a/lib/widgets/sidebar_widgets/color_library.dart b/lib/widgets/sidebar_widgets/color_library.dart new file mode 100644 index 00000000..e952de07 --- /dev/null +++ b/lib/widgets/sidebar_widgets/color_library.dart @@ -0,0 +1,250 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:icarus/const/settings.dart'; +import 'package:icarus/providers/color_library_provider.dart'; +import 'package:icarus/widgets/better_color_picker.dart'; +import 'package:icarus/widgets/icarus_color_picker_style.dart'; +import 'package:icarus/widgets/sidebar_widgets/color_buttons.dart'; +import 'package:shadcn_ui/shadcn_ui.dart'; + +class ColorLibrary extends ConsumerWidget { + const ColorLibrary({ + super.key, + required this.selectedColorValue, + required this.onSelected, + this.includeEmpty = false, + this.emptyColor = const Color(0xFFC5C5C5), + }); + + final int? selectedColorValue; + final ValueChanged onSelected; + final bool includeEmpty; + final Color emptyColor; + + @override + Widget build(BuildContext context, WidgetRef ref) { + final entries = ref.watch(colorLibraryProvider); + final canAdd = ref.watch( + colorLibraryControllerProvider.select( + (colors) => colors.length < ColorLibraryController.customColorLimit, + ), + ); + + return Wrap( + children: [ + if (includeEmpty) + _SwatchPadding( + child: ColorButtons( + height: 26, + width: 26, + color: emptyColor, + isSelected: selectedColorValue == null, + onTap: () => onSelected(null), + ), + ), + for (final entry in entries) + _SwatchPadding( + child: entry.isCustom + ? ShadContextMenuRegion( + items: [ + ShadContextMenuItem( + leading: const Icon(LucideIcons.pencil, size: 14), + child: const Text('Edit'), + onPressed: () => _editColor(context, ref, entry), + ), + ShadContextMenuItem( + leading: Icon( + LucideIcons.trash2, + size: 14, + color: Settings.tacticalVioletTheme.destructive, + ), + child: Text( + 'Delete', + style: TextStyle( + color: Settings.tacticalVioletTheme.destructive, + ), + ), + onPressed: () => ref + .read(colorLibraryControllerProvider.notifier) + .deleteColor(entry.customIndex!), + ), + ], + child: ColorButtons( + height: 26, + width: 26, + color: entry.color, + isSelected: selectedColorValue == entry.color.toARGB32(), + onTap: () => onSelected(entry.color.toARGB32()), + ), + ) + : ColorButtons( + height: 26, + width: 26, + color: entry.color, + isSelected: selectedColorValue == entry.color.toARGB32(), + onTap: () => onSelected(entry.color.toARGB32()), + ), + ), + if (canAdd) + _SwatchPadding( + child: ColorPickerButton( + onTap: () => _addColor(context, ref), + ), + ), + ], + ); + } + + Future _addColor(BuildContext context, WidgetRef ref) async { + final picked = await _showColorLibraryDialog( + context: context, + initialColor: Colors.white, + title: 'Add color', + ); + if (picked == null) return; + await ref.read(colorLibraryControllerProvider.notifier).addColor(picked); + onSelected(picked.toARGB32()); + } + + Future _editColor( + BuildContext context, + WidgetRef ref, + ColorLibraryEntry entry, + ) async { + final picked = await _showColorLibraryDialog( + context: context, + initialColor: entry.color, + title: 'Edit color', + ); + if (picked == null) return; + await ref + .read(colorLibraryControllerProvider.notifier) + .updateColor(entry.customIndex!, picked); + onSelected(picked.toARGB32()); + } +} + +Future _showColorLibraryDialog({ + required BuildContext context, + required Color initialColor, + required String title, +}) async { + var workingColor = initialColor; + return showShadDialog( + context: context, + builder: (context) { + return StatefulBuilder( + builder: (context, setState) { + return ShadDialog( + title: Text(title), + actions: [ + ShadButton.secondary( + onPressed: () => Navigator.of(context).pop(), + child: const Text('Cancel'), + ), + ShadButton( + onPressed: () => Navigator.of(context).pop(workingColor), + child: const Text('Apply'), + ), + ], + child: Material( + color: Colors.transparent, + child: SizedBox( + width: 320, + child: BetterColorPicker( + value: workingColor, + initialMode: BetterColorPickerMode.hsv, + style: icarusColorPickerStyle, + onChanging: (color) { + setState(() { + workingColor = color; + }); + }, + onChanged: (color) { + setState(() { + workingColor = color; + }); + }, + ), + ), + ), + ); + }, + ); + }, + ); +} + +class _SwatchPadding extends StatelessWidget { + const _SwatchPadding({required this.child}); + + final Widget child; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(4), + child: child, + ); + } +} + +class ColorPickerButton extends StatefulWidget { + const ColorPickerButton({ + super.key, + required this.onTap, + }); + + final VoidCallback onTap; + + @override + State createState() => _ColorPickerButtonState(); +} + +class _ColorPickerButtonState extends State { + Color _borderColor = Colors.transparent; + + @override + Widget build(BuildContext context) { + return AnimatedContainer( + duration: const Duration(milliseconds: 200), + height: 26, + width: 26, + decoration: BoxDecoration( + borderRadius: const BorderRadius.all(Radius.circular(4)), + border: Border.all( + color: _borderColor, + width: 3, + strokeAlign: BorderSide.strokeAlignCenter, + ), + ), + child: MouseRegion( + cursor: SystemMouseCursors.click, + onEnter: (_) => setState(() => _borderColor = Colors.white), + onExit: (_) => setState(() => _borderColor = Colors.transparent), + child: GestureDetector( + onTap: widget.onTap, + child: Center( + child: Container( + height: 24, + width: 24, + decoration: BoxDecoration( + borderRadius: const BorderRadius.all(Radius.circular(4)), + border: Border.all( + color: const Color(0xFF272727), + width: 1, + strokeAlign: BorderSide.strokeAlignCenter, + ), + ), + child: Icon( + LucideIcons.plus, + size: 16, + color: Settings.tacticalVioletTheme.foreground, + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/sidebar_widgets/custom_shape_tools.dart b/lib/widgets/sidebar_widgets/custom_shape_tools.dart index c2c87b14..abac7181 100644 --- a/lib/widgets/sidebar_widgets/custom_shape_tools.dart +++ b/lib/widgets/sidebar_widgets/custom_shape_tools.dart @@ -14,7 +14,7 @@ import 'package:icarus/providers/utility_provider.dart'; import 'package:icarus/widgets/draggable_widgets/utilities/custom_circle_utility_widget.dart'; import 'package:icarus/widgets/numeric_drag_input.dart'; import 'package:icarus/widgets/selectable_icon_button.dart'; -import 'package:icarus/widgets/sidebar_widgets/color_buttons.dart'; +import 'package:icarus/widgets/sidebar_widgets/color_library.dart'; import 'package:icarus/widgets/draggable_widgets/utilities/custom_rectangle_utility_widget.dart'; import 'package:icarus/widgets/draggable_widgets/zoom_transform.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; @@ -36,14 +36,6 @@ class _CustomShapeToolsState extends ConsumerState { static const int _defaultOpacityPercent = 30; static const int _defaultColorValue = 0xFF22C55E; - static const List _colorOptions = [ - Color(0xFF22C55E), - Color(0xFF3B82F6), - Color(0xFFF59E0B), - Color(0xFFEF4444), - Color(0xFFA855F7), - ]; - _CustomShapeKind _shape = _CustomShapeKind.circle; double _diameterMeters = _defaultCircleDiameterMeters; double _rectWidthMeters = _defaultRectangleWidthMeters; @@ -53,7 +45,8 @@ class _CustomShapeToolsState extends ConsumerState { @override Widget build(BuildContext context) { - final currentMap = ref.watch(mapProvider.select((state) => state.currentMap)); + final currentMap = + ref.watch(mapProvider.select((state) => state.currentMap)); final mapScale = Maps.mapScale[currentMap] ?? 1.0; final draggableData = _buildToolData(mapScale); @@ -233,20 +226,12 @@ class _CustomShapeToolsState extends ConsumerState { } Widget _buildColorPicker() { - return Row( - children: [ - for (final color in _colorOptions) - Padding( - padding: const EdgeInsets.all(4.0), - child: ColorButtons( - height: 26, - width: 26, - color: color, - isSelected: _selectedColor == color, - onTap: () => setState(() => _selectedColor = color), - ), - ), - ], + return ColorLibrary( + selectedColorValue: _selectedColor.toARGB32(), + onSelected: (colorValue) { + if (colorValue == null) return; + setState(() => _selectedColor = Color(colorValue)); + }, ); } diff --git a/lib/widgets/sidebar_widgets/drawing_tools.dart b/lib/widgets/sidebar_widgets/drawing_tools.dart index b52f09ae..9c047bb3 100644 --- a/lib/widgets/sidebar_widgets/drawing_tools.dart +++ b/lib/widgets/sidebar_widgets/drawing_tools.dart @@ -6,7 +6,7 @@ import 'package:icarus/const/traversal_speed.dart'; import 'package:icarus/providers/pen_provider.dart'; import 'package:icarus/widgets/custom_segmented_tabs.dart'; import 'package:icarus/widgets/selectable_icon_button.dart'; -import 'package:icarus/widgets/sidebar_widgets/color_buttons.dart'; +import 'package:icarus/widgets/sidebar_widgets/color_library.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; class DrawingTools extends ConsumerWidget { @@ -30,26 +30,16 @@ class DrawingTools extends ConsumerWidget { children: [ const Text("Color"), // const SizedBox(height: 10), - Row( - children: [ - for (final (index, colorOption) in ref - .watch(penProvider.select( - (state) => state.listOfColors, - )) - .indexed) - Padding( - padding: const EdgeInsets.all(4.0), - child: ColorButtons( - height: 26, - width: 26, - color: colorOption.color, - isSelected: colorOption.isSelected, - onTap: () { - ref.read(penProvider.notifier).setColor(index); - }, - ), - ), - ], + ColorLibrary( + selectedColorValue: ref.watch( + penProvider.select((state) => state.color.toARGB32()), + ), + onSelected: (colorValue) async { + if (colorValue == null) return; + final notifier = ref.read(penProvider.notifier); + notifier.updateValue(color: Color(colorValue)); + await notifier.buildCursors(); + }, ), const SizedBox(height: 4), Row( diff --git a/lib/widgets/sidebar_widgets/text_tools.dart b/lib/widgets/sidebar_widgets/text_tools.dart index afb05fe2..3aa2efde 100644 --- a/lib/widgets/sidebar_widgets/text_tools.dart +++ b/lib/widgets/sidebar_widgets/text_tools.dart @@ -10,7 +10,7 @@ import 'package:icarus/providers/screen_zoom_provider.dart'; import 'package:icarus/providers/text_provider.dart'; import 'package:icarus/widgets/draggable_widgets/text/text_widget.dart'; import 'package:icarus/widgets/draggable_widgets/zoom_transform.dart'; -import 'package:icarus/widgets/sidebar_widgets/color_buttons.dart'; +import 'package:icarus/widgets/sidebar_widgets/color_library.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; import 'package:uuid/uuid.dart'; @@ -22,14 +22,6 @@ class TextTools extends ConsumerStatefulWidget { } class _TextToolsState extends ConsumerState { - static const List _colorOptions = [ - Color(0xFF22C55E), - Color(0xFF3B82F6), - Color(0xFFF59E0B), - Color(0xFFEF4444), - Color(0xFFA855F7), - ]; - int? _selectedTagColorValue; @override @@ -104,31 +96,12 @@ class _TextToolsState extends ConsumerState { } Widget _buildColorPicker() { - return Wrap( - children: [ - Padding( - padding: const EdgeInsets.all(4.0), - child: ColorButtons( - height: 26, - width: 26, - color: const Color(0xFFC5C5C5), - isSelected: _selectedTagColorValue == null, - onTap: () => setState(() => _selectedTagColorValue = null), - ), - ), - for (final color in _colorOptions) - Padding( - padding: const EdgeInsets.all(4.0), - child: ColorButtons( - height: 26, - width: 26, - color: color, - isSelected: _selectedTagColorValue == color.toARGB32(), - onTap: () => - setState(() => _selectedTagColorValue = color.toARGB32()), - ), - ), - ], + return ColorLibrary( + includeEmpty: true, + selectedColorValue: _selectedTagColorValue, + onSelected: (colorValue) => setState( + () => _selectedTagColorValue = colorValue, + ), ); } From b72a33d3b5488c068544c30a568c3878008a1efc Mon Sep 17 00:00:00 2001 From: Dara Adedeji Date: Thu, 30 Apr 2026 23:37:39 -0400 Subject: [PATCH 06/26] Add neutral team color settings - Persist neutral team colors in strategy settings and app defaults - Apply neutral marker styling across strategy pages and agent widgets - Add coverage for strategy settings JSON and shade conversion --- lib/const/settings.dart | 4 + lib/hive/hive_adapters.g.dart | 25 ++- lib/hive/hive_adapters.g.yaml | 12 +- lib/providers/map_theme_provider.dart | 48 +++++ lib/providers/strategy_provider.dart | 41 +++- lib/providers/strategy_settings_provider.dart | 8 + .../strategy_settings_provider.g.dart | 2 + .../agents/agent_feedback_widget.dart | 17 +- .../agents/agent_widget.dart | 15 +- .../shared/framed_ability_icon_shell.dart | 11 +- lib/widgets/settings_tab.dart | 188 +++++++++++++++--- test/strategy_settings_provider_test.dart | 35 ++++ 12 files changed, 355 insertions(+), 51 deletions(-) create mode 100644 test/strategy_settings_provider_test.dart diff --git a/lib/const/settings.dart b/lib/const/settings.dart index 5c3ddf9d..31c672e2 100644 --- a/lib/const/settings.dart +++ b/lib/const/settings.dart @@ -79,6 +79,10 @@ class Settings { static const Color enemyOutlineColor = Color.fromARGB(139, 255, 82, 82); static const Color allyOutlineColor = Color.fromARGB(106, 105, 240, 175); + static Color neutralTeamShade(Color color) { + return HSLColor.fromColor(color).withSaturation(0).toColor(); + } + static final Uri dicordLink = Uri.parse("https://discord.gg/PN2uKwCqYB"); static const Duration autoSaveOffset = Duration(seconds: 15); diff --git a/lib/hive/hive_adapters.g.dart b/lib/hive/hive_adapters.g.dart index 725ba4ec..467b9615 100644 --- a/lib/hive/hive_adapters.g.dart +++ b/lib/hive/hive_adapters.g.dart @@ -683,17 +683,20 @@ class StrategySettingsAdapter extends TypeAdapter { abilitySize: fields[1] == null ? Settings.abilitySize : (fields[1] as num).toDouble(), + useNeutralTeamColors: fields[2] == null ? false : fields[2] as bool, ); } @override void write(BinaryWriter writer, StrategySettings obj) { writer - ..writeByte(2) + ..writeByte(3) ..writeByte(0) ..write(obj.agentSize) ..writeByte(1) - ..write(obj.abilitySize); + ..write(obj.abilitySize) + ..writeByte(2) + ..write(obj.useNeutralTeamColors); } @override @@ -1289,6 +1292,14 @@ class AppPreferencesAdapter extends TypeAdapter { return AppPreferences( defaultThemeProfileIdForNewStrategies: fields[0] as String, autosaveEnabled: fields[1] == null ? true : fields[1] as bool, + defaultAgentSizeForNewStrategies: fields[5] == null + ? Settings.agentSize + : (fields[5] as num).toDouble(), + defaultAbilitySizeForNewStrategies: fields[6] == null + ? Settings.abilitySize + : (fields[6] as num).toDouble(), + defaultNeutralTeamColorsForNewStrategies: + fields[4] == null ? false : fields[4] as bool, pagesBarExpandedHeight: fields[2] == null ? 310.0 : (fields[2] as num).toDouble(), customColorValues: (fields[3] as List?)?.cast(), @@ -1298,7 +1309,7 @@ class AppPreferencesAdapter extends TypeAdapter { @override void write(BinaryWriter writer, AppPreferences obj) { writer - ..writeByte(4) + ..writeByte(7) ..writeByte(0) ..write(obj.defaultThemeProfileIdForNewStrategies) ..writeByte(1) @@ -1306,7 +1317,13 @@ class AppPreferencesAdapter extends TypeAdapter { ..writeByte(2) ..write(obj.pagesBarExpandedHeight) ..writeByte(3) - ..write(obj.customColorValues); + ..write(obj.customColorValues) + ..writeByte(4) + ..write(obj.defaultNeutralTeamColorsForNewStrategies) + ..writeByte(5) + ..write(obj.defaultAgentSizeForNewStrategies) + ..writeByte(6) + ..write(obj.defaultAbilitySizeForNewStrategies); } @override diff --git a/lib/hive/hive_adapters.g.yaml b/lib/hive/hive_adapters.g.yaml index 473a874c..539c32c9 100644 --- a/lib/hive/hive_adapters.g.yaml +++ b/lib/hive/hive_adapters.g.yaml @@ -245,12 +245,14 @@ types: index: 1 StrategySettings: typeId: 14 - nextIndex: 2 + nextIndex: 3 fields: agentSize: index: 0 abilitySize: index: 1 + useNeutralTeamColors: + index: 2 PlacedUtility: typeId: 15 nextIndex: 15 @@ -437,7 +439,7 @@ types: index: 4 AppPreferences: typeId: 28 - nextIndex: 4 + nextIndex: 7 fields: defaultThemeProfileIdForNewStrategies: index: 0 @@ -447,6 +449,12 @@ types: index: 2 customColorValues: index: 3 + defaultNeutralTeamColorsForNewStrategies: + index: 4 + defaultAgentSizeForNewStrategies: + index: 5 + defaultAbilitySizeForNewStrategies: + index: 6 PlacedViewConeAgent: typeId: 29 nextIndex: 9 diff --git a/lib/providers/map_theme_provider.dart b/lib/providers/map_theme_provider.dart index 62a463b8..cf8fa1b6 100644 --- a/lib/providers/map_theme_provider.dart +++ b/lib/providers/map_theme_provider.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:hive_ce_flutter/hive_flutter.dart'; import 'package:icarus/const/hive_boxes.dart'; +import 'package:icarus/const/settings.dart'; import 'package:uuid/uuid.dart'; class MapThemePalette extends HiveObject { @@ -111,12 +112,18 @@ class MapThemeProfile extends HiveObject { class AppPreferences extends HiveObject { final String defaultThemeProfileIdForNewStrategies; final bool autosaveEnabled; + final double defaultAgentSizeForNewStrategies; + final double defaultAbilitySizeForNewStrategies; + final bool defaultNeutralTeamColorsForNewStrategies; final double pagesBarExpandedHeight; final List customColorValues; AppPreferences({ required this.defaultThemeProfileIdForNewStrategies, this.autosaveEnabled = true, + this.defaultAgentSizeForNewStrategies = Settings.agentSize, + this.defaultAbilitySizeForNewStrategies = Settings.abilitySize, + this.defaultNeutralTeamColorsForNewStrategies = false, this.pagesBarExpandedHeight = 310.0, List? customColorValues, }) : customColorValues = List.unmodifiable(customColorValues ?? const []); @@ -124,6 +131,9 @@ class AppPreferences extends HiveObject { AppPreferences copyWith({ String? defaultThemeProfileIdForNewStrategies, bool? autosaveEnabled, + double? defaultAgentSizeForNewStrategies, + double? defaultAbilitySizeForNewStrategies, + bool? defaultNeutralTeamColorsForNewStrategies, double? pagesBarExpandedHeight, List? customColorValues, }) { @@ -132,6 +142,13 @@ class AppPreferences extends HiveObject { defaultThemeProfileIdForNewStrategies ?? this.defaultThemeProfileIdForNewStrategies, autosaveEnabled: autosaveEnabled ?? this.autosaveEnabled, + defaultAgentSizeForNewStrategies: defaultAgentSizeForNewStrategies ?? + this.defaultAgentSizeForNewStrategies, + defaultAbilitySizeForNewStrategies: defaultAbilitySizeForNewStrategies ?? + this.defaultAbilitySizeForNewStrategies, + defaultNeutralTeamColorsForNewStrategies: + defaultNeutralTeamColorsForNewStrategies ?? + this.defaultNeutralTeamColorsForNewStrategies, pagesBarExpandedHeight: pagesBarExpandedHeight ?? this.pagesBarExpandedHeight, customColorValues: customColorValues ?? this.customColorValues, @@ -497,6 +514,37 @@ class AppPreferencesNotifier extends Notifier { state = updated; } + Future setDefaultNeutralTeamColorsForNewStrategies(bool enabled) async { + final updated = _readFromHive().copyWith( + defaultNeutralTeamColorsForNewStrategies: enabled, + ); + await Hive.box(HiveBoxNames.appPreferencesBox).put( + MapThemeProfilesProvider.appPreferencesSingletonKey, + updated, + ); + state = updated; + } + + Future setDefaultAgentSizeForNewStrategies(double size) async { + final updated = + _readFromHive().copyWith(defaultAgentSizeForNewStrategies: size); + await Hive.box(HiveBoxNames.appPreferencesBox).put( + MapThemeProfilesProvider.appPreferencesSingletonKey, + updated, + ); + state = updated; + } + + Future setDefaultAbilitySizeForNewStrategies(double size) async { + final updated = + _readFromHive().copyWith(defaultAbilitySizeForNewStrategies: size); + await Hive.box(HiveBoxNames.appPreferencesBox).put( + MapThemeProfilesProvider.appPreferencesSingletonKey, + updated, + ); + state = updated; + } + Future setPagesBarExpandedHeight(double height) async { final updated = _readFromHive().copyWith(pagesBarExpandedHeight: height); await Hive.box(HiveBoxNames.appPreferencesBox).put( diff --git a/lib/providers/strategy_provider.dart b/lib/providers/strategy_provider.dart index a9e553fe..85154513 100644 --- a/lib/providers/strategy_provider.dart +++ b/lib/providers/strategy_provider.dart @@ -3025,6 +3025,13 @@ class StrategyProvider extends Notifier { final pageID = const Uuid().v4(); final defaultThemeProfileId = ref.read(mapThemeProfilesProvider).defaultProfileIdForNewStrategies; + final appPreferences = ref.read(appPreferencesProvider); + final defaultSettings = StrategySettings( + agentSize: appPreferences.defaultAgentSizeForNewStrategies, + abilitySize: appPreferences.defaultAbilitySizeForNewStrategies, + useNeutralTeamColors: + appPreferences.defaultNeutralTeamColorsForNewStrategies, + ); final newStrategy = StrategyData( mapData: MapValue.ascent, versionNumber: Settings.versionNumber, @@ -3043,13 +3050,13 @@ class StrategyProvider extends Notifier { lineUpGroups: [], sortIndex: 0, isAttack: true, - settings: StrategySettings(), + settings: defaultSettings, ) ], lastEdited: DateTime.now(), // ignore: deprecated_member_use_from_same_package - strategySettings: StrategySettings(), + strategySettings: defaultSettings, folderID: ref.read(folderProvider), themeProfileId: defaultThemeProfileId, ); @@ -3665,6 +3672,36 @@ class StrategyProvider extends Notifier { setUnsaved(); } + Future applyNeutralTeamColorsToAllPages(bool value) async { + if (state.stratName == null) return; + + await _syncCurrentPageToHive(); + + final box = Hive.box(HiveBoxNames.strategiesBox); + final strat = box.get(state.id); + if (strat == null || strat.pages.isEmpty) return; + + final newPages = [ + for (final page in strat.pages) + page.copyWith( + settings: page.settings.copyWith(useNeutralTeamColors: value), + ), + ]; + + final strategyTheme = ref.read(strategyThemeProvider); + final updated = strat.copyWith( + pages: newPages, + mapData: ref.read(mapProvider).currentMap, + themeProfileId: strategyTheme.profileId, + clearThemeProfileId: strategyTheme.profileId == null, + themeOverridePalette: strategyTheme.overridePalette, + clearThemeOverridePalette: strategyTheme.overridePalette == null, + lastEdited: DateTime.now(), + ); + await box.put(updated.id, updated); + setUnsaved(); + } + void moveToFolder({required String strategyID, required String? parentID}) { final strategyBox = Hive.box(HiveBoxNames.strategiesBox); final strategy = strategyBox.get(strategyID); diff --git a/lib/providers/strategy_settings_provider.dart b/lib/providers/strategy_settings_provider.dart index f06e2710..89ac5910 100644 --- a/lib/providers/strategy_settings_provider.dart +++ b/lib/providers/strategy_settings_provider.dart @@ -10,20 +10,24 @@ part "strategy_settings_provider.g.dart"; class StrategySettings extends HiveObject { final double agentSize; final double abilitySize; + final bool useNeutralTeamColors; StrategySettings({ this.agentSize = Settings.agentSize, this.abilitySize = Settings.abilitySize, + this.useNeutralTeamColors = false, }); StrategySettings copyWith({ double? agentSize, double? abilitySize, + bool? useNeutralTeamColors, bool? isOpen, }) { return StrategySettings( agentSize: agentSize ?? this.agentSize, abilitySize: abilitySize ?? this.abilitySize, + useNeutralTeamColors: useNeutralTeamColors ?? this.useNeutralTeamColors, ); } @@ -76,4 +80,8 @@ class StrategySettingsProvider extends Notifier { void updateAbilitySize(double size) { state = state.copyWith(abilitySize: size); } + + void updateNeutralTeamColors(bool value) { + state = state.copyWith(useNeutralTeamColors: value); + } } diff --git a/lib/providers/strategy_settings_provider.g.dart b/lib/providers/strategy_settings_provider.g.dart index 5745091a..0fd36553 100644 --- a/lib/providers/strategy_settings_provider.g.dart +++ b/lib/providers/strategy_settings_provider.g.dart @@ -11,10 +11,12 @@ StrategySettings _$StrategySettingsFromJson(Map json) => agentSize: (json['agentSize'] as num?)?.toDouble() ?? Settings.agentSize, abilitySize: (json['abilitySize'] as num?)?.toDouble() ?? Settings.abilitySize, + useNeutralTeamColors: json['useNeutralTeamColors'] as bool? ?? false, ); Map _$StrategySettingsToJson(StrategySettings instance) => { 'agentSize': instance.agentSize, 'abilitySize': instance.abilitySize, + 'useNeutralTeamColors': instance.useNeutralTeamColors, }; diff --git a/lib/widgets/draggable_widgets/agents/agent_feedback_widget.dart b/lib/widgets/draggable_widgets/agents/agent_feedback_widget.dart index 82dfa336..c11c1328 100644 --- a/lib/widgets/draggable_widgets/agents/agent_feedback_widget.dart +++ b/lib/widgets/draggable_widgets/agents/agent_feedback_widget.dart @@ -5,6 +5,7 @@ import 'package:icarus/const/coordinate_system.dart'; import 'package:icarus/const/settings.dart'; import 'package:icarus/providers/strategy_settings_provider.dart'; import 'package:icarus/providers/team_provider.dart'; +import 'package:shadcn_ui/shadcn_ui.dart'; class AgentFeedback extends ConsumerWidget { const AgentFeedback({ @@ -15,16 +16,24 @@ class AgentFeedback extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final coordinateSystem = CoordinateSystem.instance; - final agentSize = ref.watch(strategySettingsProvider).agentSize; + final strategySettings = ref.watch(strategySettingsProvider); + final agentSize = strategySettings.agentSize; final bool isAlly = ref.watch(teamProvider); + final backgroundColor = + isAlly ? Settings.allyBGColor : Settings.enemyBGColor; + final outlineColor = + isAlly ? Settings.allyOutlineColor : Settings.enemyOutlineColor; return ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(3.0)), child: Container( decoration: BoxDecoration( - color: isAlly ? Settings.allyBGColor : Settings.enemyBGColor, + color: strategySettings.useNeutralTeamColors + ? ShadTheme.of(context).colorScheme.secondary + : backgroundColor, border: Border.all( - color: - isAlly ? Settings.allyOutlineColor : Settings.enemyOutlineColor, + color: strategySettings.useNeutralTeamColors + ? Settings.neutralTeamShade(outlineColor) + : outlineColor, ), borderRadius: const BorderRadius.all( Radius.circular(3), diff --git a/lib/widgets/draggable_widgets/agents/agent_widget.dart b/lib/widgets/draggable_widgets/agents/agent_widget.dart index 8a230a29..6e838ad7 100644 --- a/lib/widgets/draggable_widgets/agents/agent_widget.dart +++ b/lib/widgets/draggable_widgets/agents/agent_widget.dart @@ -93,6 +93,8 @@ class AgentWidget extends ConsumerWidget { final coordinateSystem = CoordinateSystem.instance; final agentSize = forcedAgentSize ?? ref.watch(strategySettingsProvider).agentSize; + final useNeutralTeamColors = + ref.watch(strategySettingsProvider).useNeutralTeamColors; final isScreenshot = ref.watch(screenshotProvider); final deadProgress = (deadStateProgress ?? (state == AgentState.dead ? 1.0 : 0.0)) @@ -105,9 +107,9 @@ class AgentWidget extends ConsumerWidget { final agentImage = RepaintBoundary(child: Image.asset(agent.iconPath)); // Determine background color - Color bgColor = Settings.enemyBGColor; - if (isAlly) { - bgColor = Settings.allyBGColor; + Color bgColor = isAlly ? Settings.allyBGColor : Settings.enemyBGColor; + if (useNeutralTeamColors) { + bgColor = ShadTheme.of(context).colorScheme.secondary; } final deadBgColor = isAlly ? _mutedAllyBGColor : _mutedEnemyBGColor; @@ -118,9 +120,10 @@ class AgentWidget extends ConsumerWidget { } // Determine outline color - Color outlineColor = Settings.enemyOutlineColor; - if (isAlly) { - outlineColor = Settings.allyOutlineColor; + Color outlineColor = + isAlly ? Settings.allyOutlineColor : Settings.enemyOutlineColor; + if (useNeutralTeamColors) { + outlineColor = Settings.neutralTeamShade(outlineColor); } final deadOutlineColor = diff --git a/lib/widgets/draggable_widgets/shared/framed_ability_icon_shell.dart b/lib/widgets/draggable_widgets/shared/framed_ability_icon_shell.dart index 66f0a6a2..a3d143c8 100644 --- a/lib/widgets/draggable_widgets/shared/framed_ability_icon_shell.dart +++ b/lib/widgets/draggable_widgets/shared/framed_ability_icon_shell.dart @@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:icarus/const/coordinate_system.dart'; import 'package:icarus/const/line_provider.dart'; import 'package:icarus/const/settings.dart'; +import 'package:icarus/providers/strategy_settings_provider.dart'; class FramedAbilityIconShell extends ConsumerWidget { const FramedAbilityIconShell({ @@ -27,6 +28,10 @@ class FramedAbilityIconShell extends ConsumerWidget { final isLineUpHovered = lineUpId != null && lineUpItemId != null && (hoverTarget?.matchesAbility(lineUpId!, lineUpItemId!) ?? false); + final useNeutralTeamColors = + ref.watch(strategySettingsProvider).useNeutralTeamColors; + final outlineColor = + isAlly ? Settings.allyOutlineColor : Settings.enemyOutlineColor; return Container( width: coordinateSystem.scale(size), @@ -38,9 +43,9 @@ class FramedAbilityIconShell extends ConsumerWidget { border: Border.all( color: isLineUpHovered ? Colors.deepPurpleAccent - : isAlly - ? Settings.allyOutlineColor - : Settings.enemyOutlineColor, + : useNeutralTeamColors + ? Settings.neutralTeamShade(outlineColor) + : outlineColor, ), ), child: ClipRRect( diff --git a/lib/widgets/settings_tab.dart b/lib/widgets/settings_tab.dart index ac86558f..77e9d25e 100644 --- a/lib/widgets/settings_tab.dart +++ b/lib/widgets/settings_tab.dart @@ -8,15 +8,30 @@ import 'package:icarus/providers/map_theme_provider.dart'; import 'package:icarus/providers/marker_sizes_sync.dart'; import 'package:icarus/providers/strategy_provider.dart'; import 'package:icarus/providers/strategy_settings_provider.dart'; +import 'package:icarus/widgets/custom_segmented_tabs.dart'; import 'package:icarus/widgets/map_theme_settings_section.dart'; import 'package:icarus/widgets/settings_scope_card.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; -class SettingsTab extends ConsumerWidget { +enum _SettingsMode { + strategy, + global, +} + +class SettingsTab extends ConsumerStatefulWidget { const SettingsTab({super.key}); + static const double _settingsPanelContentWidth = 490; + + @override + ConsumerState createState() => _SettingsTabState(); +} + +class _SettingsTabState extends ConsumerState { + _SettingsMode _mode = _SettingsMode.strategy; + @override - Widget build(BuildContext context, WidgetRef ref) { + Widget build(BuildContext context) { final activeStrategyName = ref.watch(strategyProvider).stratName; final strategySettings = ref.watch(strategySettingsProvider); final mapState = ref.watch(mapProvider); @@ -27,43 +42,39 @@ class SettingsTab extends ConsumerWidget { // match the sidebar panel (content + ShadDialog's default horizontal padding). return ShadSheet( constraints: const BoxConstraints( - maxWidth: Settings.sideBarPanelWidth + 48, + maxWidth: SettingsTab._settingsPanelContentWidth + 48, ), // Avoid nested scroll views; the outer ShadDialog scroll shows a desktop bar. scrollable: false, title: Row( children: [ - Icon( - LucideIcons.pencil, - size: 18, - color: Settings.tacticalVioletTheme.primary, + Expanded( + child: Text("Settings", style: ShadTheme.of(context).textTheme.h3), + ), + _SettingsModeSwitcher( + mode: _mode, + onChanged: (mode) => setState(() => _mode = mode), ), - const SizedBox(width: 8), - Text("Settings", style: ShadTheme.of(context).textTheme.h3), ], ), - description: const Text( - "Adjust strategy sizing and workspace visibility from one place.", - ), - child: Padding( - padding: const EdgeInsets.all(8), - child: SizedBox( - width: Settings.sideBarContentWidth, - child: Material( - color: Colors.transparent, - child: ScrollConfiguration( - behavior: - ScrollConfiguration.of(context).copyWith(scrollbars: false), - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ + child: SizedBox( + width: SettingsTab._settingsPanelContentWidth, + child: Material( + color: Colors.transparent, + child: ScrollConfiguration( + behavior: + ScrollConfiguration.of(context).copyWith(scrollbars: false), + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (_mode == _SettingsMode.strategy) ...[ SettingsScopeCard( scope: SettingsScope.strategy, - title: "Page object sizing", + title: "Strategy object styling", description: activeStrategyName == null - ? "Resize placed objects for the current strategy page." - : "Resize placed objects for \"$activeStrategyName\".", + ? "Customize placed objects for the current strategy." + : "Customize placed objects for \"$activeStrategyName\".", child: Column( children: [ _SettingsSliderTile( @@ -99,10 +110,94 @@ class SettingsTab extends ConsumerWidget { .updateAbilitySize(value); }, ), + const _SettingsItemDivider(), + _SettingsToggleTile( + icon: Icons.contrast_outlined, + title: "Neutral team marker colors", + description: + "Render ally and enemy marker accents as matching-brightness greys.", + value: strategySettings.useNeutralTeamColors, + onChanged: (value) { + WidgetsBinding.instance.addPostFrameCallback((_) { + if (!context.mounted) return; + ref + .read(strategySettingsProvider.notifier) + .updateNeutralTeamColors(value); + ref + .read(strategyProvider.notifier) + .applyNeutralTeamColorsToAllPages(value); + }); + }, + ), const _PageMarkerSizesSyncBanner(), ], ), ), + ] else ...[ + SettingsScopeCard( + scope: SettingsScope.workspace, + title: "Strategy defaults", + description: + "Set the starting values used when creating new strategies.", + child: Column( + children: [ + _SettingsSliderTile( + icon: Icons.person_pin_circle_outlined, + title: "Default agent markers", + description: + "Default size for agent markers in new strategies.", + value: + appPreferences.defaultAgentSizeForNewStrategies, + min: Settings.agentSizeMin, + max: Settings.agentSizeMax, + divisions: 15, + accentColor: Settings.tacticalVioletTheme.primary, + onChanged: (value) { + ref + .read(appPreferencesProvider.notifier) + .setDefaultAgentSizeForNewStrategies(value); + }, + ), + const _SettingsItemDivider(), + _SettingsSliderTile( + icon: Icons.auto_awesome_outlined, + title: "Default ability markers", + description: + "Default size for ability markers in new strategies.", + value: appPreferences + .defaultAbilitySizeForNewStrategies, + min: Settings.abilitySizeMin, + max: Settings.abilitySizeMax, + divisions: 15, + accentColor: Settings.tacticalVioletTheme.primary, + onChanged: (value) { + ref + .read(appPreferencesProvider.notifier) + .setDefaultAbilitySizeForNewStrategies(value); + }, + ), + const _SettingsItemDivider(), + _SettingsToggleTile( + icon: Icons.contrast_outlined, + title: "Neutral marker colors by default", + description: + "Use grey ally and enemy accents for new strategies.", + value: appPreferences + .defaultNeutralTeamColorsForNewStrategies, + onChanged: (value) { + WidgetsBinding.instance.addPostFrameCallback((_) { + if (!context.mounted) return; + ref + .read(appPreferencesProvider.notifier) + .setDefaultNeutralTeamColorsForNewStrategies( + value, + ); + }); + }, + ), + ], + ), + ), const SizedBox(height: 20), const _SectionDivider(), const SizedBox(height: 20), @@ -186,9 +281,9 @@ class SettingsTab extends ConsumerWidget { const _SectionDivider(), const SizedBox(height: 20), const MapThemeSettingsSection(), - const SizedBox(height: 4), ], - ), + const SizedBox(height: 4), + ], ), ), ), @@ -198,6 +293,39 @@ class SettingsTab extends ConsumerWidget { } } +class _SettingsModeSwitcher extends StatelessWidget { + const _SettingsModeSwitcher({ + required this.mode, + required this.onChanged, + }); + + final _SettingsMode mode; + final ValueChanged<_SettingsMode> onChanged; + + @override + Widget build(BuildContext context) { + return SizedBox( + width: 210, + child: CustomSegmentedTabs<_SettingsMode>( + value: mode, + onChanged: onChanged, + compactness: 0.8, + indicatorBehavior: SegmentedIndicatorBehavior.staticFill, + items: const [ + SegmentedTabItem<_SettingsMode>( + value: _SettingsMode.strategy, + child: Text('Strategy'), + ), + SegmentedTabItem<_SettingsMode>( + value: _SettingsMode.global, + child: Text('Global'), + ), + ], + ), + ); + } +} + class _SettingsSliderTile extends StatelessWidget { const _SettingsSliderTile({ required this.icon, diff --git a/test/strategy_settings_provider_test.dart b/test/strategy_settings_provider_test.dart new file mode 100644 index 00000000..6583c386 --- /dev/null +++ b/test/strategy_settings_provider_test.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:icarus/const/settings.dart'; +import 'package:icarus/providers/strategy_settings_provider.dart'; + +void main() { + test('strategy settings json defaults neutral team colors off', () { + final settings = StrategySettings.fromJson(const { + 'agentSize': 35, + 'abilitySize': 25, + }); + + expect(settings.useNeutralTeamColors, isFalse); + }); + + test('strategy settings json persists neutral team colors', () { + final settings = StrategySettings(useNeutralTeamColors: true); + + expect(settings.toJson()['useNeutralTeamColors'], isTrue); + expect( + StrategySettings.fromJson(settings.toJson()).useNeutralTeamColors, + isTrue, + ); + }); + + test('neutral team shade keeps lightness and removes saturation', () { + final original = HSLColor.fromColor(Settings.allyBGColor); + final neutral = HSLColor.fromColor( + Settings.neutralTeamShade(Settings.allyBGColor), + ); + + expect(neutral.saturation, 0); + expect(neutral.lightness, closeTo(original.lightness, 0.001)); + }); +} From ebd9e6af25a98e8a2c36a55be936e9b491d06aca Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Fri, 1 May 2026 00:15:40 -0400 Subject: [PATCH 07/26] Refine settings spacing and add hot reload watcher - Tighten sidebar and segmented tab corner radii - Adjust settings dialog padding and simplify mode switcher - Add a PowerShell watcher script for Flutter hot reload --- lib/sidebar.dart | 2 +- lib/widgets/custom_segmented_tabs.dart | 21 +++-- lib/widgets/settings_tab.dart | 57 ++++++------- pubspec.lock | 8 +- scripts/watch_flutter_hot_reload.ps1 | 111 +++++++++++++++++++++++++ 5 files changed, 155 insertions(+), 44 deletions(-) create mode 100644 scripts/watch_flutter_hot_reload.ps1 diff --git a/lib/sidebar.dart b/lib/sidebar.dart index 6c0450dc..f0b0e753 100644 --- a/lib/sidebar.dart +++ b/lib/sidebar.dart @@ -21,7 +21,7 @@ class SideBarUI extends ConsumerStatefulWidget { class _SideBarUIState extends ConsumerState { static const BorderRadius _panelBorderRadius = BorderRadius.all( - Radius.circular(20), + Radius.circular(12), ); ScrollController gridScrollController = ScrollController(); diff --git a/lib/widgets/custom_segmented_tabs.dart b/lib/widgets/custom_segmented_tabs.dart index 0426bd10..db0d7d67 100644 --- a/lib/widgets/custom_segmented_tabs.dart +++ b/lib/widgets/custom_segmented_tabs.dart @@ -68,6 +68,9 @@ class CustomSegmentedTabs extends StatefulWidget { } class _CustomSegmentedTabsState extends State> { + static const double _containerRadius = 6; + static const double _segmentRadius = 5; + final GlobalKey _stackKey = GlobalKey(); late List _tabKeys; late List _segmentLefts; @@ -179,7 +182,7 @@ class _CustomSegmentedTabsState extends State> { padding: widget.padding, decoration: BoxDecoration( color: Settings.tacticalVioletTheme.secondary, - borderRadius: BorderRadius.circular(10), + borderRadius: BorderRadius.circular(_containerRadius), border: Border.all( color: Settings.tacticalVioletTheme.border, width: 1, @@ -205,15 +208,8 @@ class _CustomSegmentedTabsState extends State> { bottom: 0, child: DecoratedBox( decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(100), - blurRadius: 2, - offset: const Offset(0, 2), - ), - ], color: Settings.tacticalVioletTheme.primary, - borderRadius: BorderRadius.circular(8), + borderRadius: BorderRadius.circular(_segmentRadius), ), ), ), @@ -231,6 +227,7 @@ class _CustomSegmentedTabsState extends State> { animationCurve: widget.animationCurve, horizontalPadding: itemHorizontalPadding, verticalPadding: itemVerticalPadding, + borderRadius: _segmentRadius, ), if (index < widget.items.length - 1) SizedBox(width: itemGap), ], @@ -263,6 +260,7 @@ class _TabButton extends StatelessWidget { required this.animationCurve, required this.horizontalPadding, required this.verticalPadding, + required this.borderRadius, }); final SegmentedTabItem item; @@ -273,6 +271,7 @@ class _TabButton extends StatelessWidget { final Curve animationCurve; final double horizontalPadding; final double verticalPadding; + final double borderRadius; @override Widget build(BuildContext context) { @@ -287,7 +286,7 @@ class _TabButton extends StatelessWidget { color: Colors.transparent, child: InkWell( mouseCursor: SystemMouseCursors.click, - borderRadius: BorderRadius.circular(8), + borderRadius: BorderRadius.circular(borderRadius), onTap: onTap, child: AnimatedContainer( duration: animationDuration, @@ -298,7 +297,7 @@ class _TabButton extends StatelessWidget { vertical: verticalPadding, ), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), + borderRadius: BorderRadius.circular(borderRadius), color: showStaticFill && isSelected ? Settings.tacticalVioletTheme.primary : Colors.transparent, diff --git a/lib/widgets/settings_tab.dart b/lib/widgets/settings_tab.dart index 77e9d25e..8b41a1b7 100644 --- a/lib/widgets/settings_tab.dart +++ b/lib/widgets/settings_tab.dart @@ -44,18 +44,23 @@ class _SettingsTabState extends ConsumerState { constraints: const BoxConstraints( maxWidth: SettingsTab._settingsPanelContentWidth + 48, ), + padding: const EdgeInsets.fromLTRB(24, 24, 24, 0), // Avoid nested scroll views; the outer ShadDialog scroll shows a desktop bar. scrollable: false, - title: Row( - children: [ - Expanded( - child: Text("Settings", style: ShadTheme.of(context).textTheme.h3), - ), - _SettingsModeSwitcher( - mode: _mode, - onChanged: (mode) => setState(() => _mode = mode), - ), - ], + title: Padding( + padding: const EdgeInsets.only(top: 4), + child: Row( + children: [ + Expanded( + child: + Text("Settings", style: ShadTheme.of(context).textTheme.h3), + ), + _SettingsModeSwitcher( + mode: _mode, + onChanged: (mode) => setState(() => _mode = mode), + ), + ], + ), ), child: SizedBox( width: SettingsTab._settingsPanelContentWidth, @@ -304,24 +309,20 @@ class _SettingsModeSwitcher extends StatelessWidget { @override Widget build(BuildContext context) { - return SizedBox( - width: 210, - child: CustomSegmentedTabs<_SettingsMode>( - value: mode, - onChanged: onChanged, - compactness: 0.8, - indicatorBehavior: SegmentedIndicatorBehavior.staticFill, - items: const [ - SegmentedTabItem<_SettingsMode>( - value: _SettingsMode.strategy, - child: Text('Strategy'), - ), - SegmentedTabItem<_SettingsMode>( - value: _SettingsMode.global, - child: Text('Global'), - ), - ], - ), + return CustomSegmentedTabs<_SettingsMode>( + value: mode, + onChanged: onChanged, + compactness: 0.8, + items: const [ + SegmentedTabItem<_SettingsMode>( + value: _SettingsMode.strategy, + child: Text('Strategy'), + ), + SegmentedTabItem<_SettingsMode>( + value: _SettingsMode.global, + child: Text('Global'), + ), + ], ); } } diff --git a/pubspec.lock b/pubspec.lock index 67941faf..6988a16e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -713,10 +713,10 @@ packages: dependency: transitive description: name: matcher - sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 + sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6" url: "https://pub.dev" source: hosted - version: "0.12.19" + version: "0.12.18" material_color_utilities: dependency: transitive description: @@ -1078,10 +1078,10 @@ packages: dependency: transitive description: name: test_api - sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a" + sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636" url: "https://pub.dev" source: hosted - version: "0.7.10" + version: "0.7.9" theme_extensions_builder_annotation: dependency: transitive description: diff --git a/scripts/watch_flutter_hot_reload.ps1 b/scripts/watch_flutter_hot_reload.ps1 new file mode 100644 index 00000000..e98167ea --- /dev/null +++ b/scripts/watch_flutter_hot_reload.ps1 @@ -0,0 +1,111 @@ +param( + [string]$Device = "windows", + [string[]]$WatchPath = @("lib", "assets", "pubspec.yaml"), + [int]$DebounceMs = 750 +) + +$ErrorActionPreference = "Stop" +$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..") + +function New-RepoWatcher { + param( + [Parameter(Mandatory = $true)] + [string]$Path + ) + + $resolved = Resolve-Path (Join-Path $repoRoot $Path) + $item = Get-Item -LiteralPath $resolved + $watcher = [System.IO.FileSystemWatcher]::new() + + if ($item.PSIsContainer) { + $watcher.Path = $item.FullName + $watcher.IncludeSubdirectories = $true + $watcher.Filter = "*.*" + } + else { + $watcher.Path = $item.DirectoryName + $watcher.IncludeSubdirectories = $false + $watcher.Filter = $item.Name + } + + $watcher.NotifyFilter = [System.IO.NotifyFilters]'FileName, DirectoryName, LastWrite, Size' + $watcher.EnableRaisingEvents = $true + return $watcher +} + +$process = [System.Diagnostics.Process]::new() +$process.StartInfo.FileName = "cmd.exe" +$process.StartInfo.Arguments = "/c fvm flutter run -d $Device" +$process.StartInfo.WorkingDirectory = $repoRoot +$process.StartInfo.UseShellExecute = $false +$process.StartInfo.RedirectStandardInput = $true + +Write-Host "Starting: fvm flutter run -d $Device" +[void]$process.Start() + +$lastReload = [DateTime]::MinValue +$syncRoot = [object]::new() + +$action = { + $path = $Event.SourceEventArgs.FullPath + $name = [System.IO.Path]::GetFileName($path) + + if ($name -like "*.tmp" -or + $name -like "*.swp" -or + $name -like "*.lock" -or + $path -match "\\\.dart_tool\\" -or + $path -match "\\build\\") { + return + } + + [System.Threading.Monitor]::Enter($syncRoot) + try { + $now = [DateTime]::UtcNow + if (($now - $script:lastReload).TotalMilliseconds -lt $DebounceMs) { + return + } + + $script:lastReload = $now + if (-not $process.HasExited) { + Write-Host "Hot reload: $path" + $process.StandardInput.WriteLine("r") + } + } + finally { + [System.Threading.Monitor]::Exit($syncRoot) + } +} + +$watchers = @() +$subscriptions = @() + +foreach ($path in $WatchPath) { + $watcher = New-RepoWatcher -Path $path + $watchers += $watcher + + foreach ($eventName in @("Changed", "Created", "Deleted", "Renamed")) { + $subscriptions += Register-ObjectEvent -InputObject $watcher -EventName $eventName -Action $action + } + + Write-Host "Watching: $path" +} + +try { + while (-not $process.HasExited) { + Start-Sleep -Milliseconds 250 + } +} +finally { + foreach ($subscription in $subscriptions) { + Unregister-Event -SubscriptionId $subscription.Id -ErrorAction SilentlyContinue + } + + foreach ($watcher in $watchers) { + $watcher.Dispose() + } + + if (-not $process.HasExited) { + $process.StandardInput.WriteLine("q") + $process.WaitForExit(5000) + } +} From d37900da732e0b91df6a578936da9d86a5dac7cf Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Fri, 1 May 2026 00:27:37 -0400 Subject: [PATCH 08/26] Add page name to screenshot exports - Render the active page name in the lower-left corner - Pass page names through the save/load screenshot flow - Add a widget test covering the new label --- lib/screenshot/screenshot_view.dart | 29 ++++++++++++++++++++++++++- lib/widgets/save_and_load_button.dart | 1 + test/screenshot_view_test.dart | 22 ++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/lib/screenshot/screenshot_view.dart b/lib/screenshot/screenshot_view.dart index 7fb8e1ce..ab7acfcc 100644 --- a/lib/screenshot/screenshot_view.dart +++ b/lib/screenshot/screenshot_view.dart @@ -60,6 +60,7 @@ class ScreenshotView extends ConsumerWidget { required this.strategySettings, required this.isAttack, required this.strategyState, + this.pageName, List lineUpGroups = const [], @Deprecated('Use lineUpGroups instead') List lineUps = const [], required this.themeProfileId, @@ -80,6 +81,7 @@ class ScreenshotView extends ConsumerWidget { final List utilities; final StrategySettings strategySettings; final bool isAttack; + final String? pageName; final List lineUpGroups; final String? themeProfileId; final MapThemePalette? themeOverridePalette; @@ -219,7 +221,32 @@ class ScreenshotView extends ConsumerWidget { ), ), ), - // Add any other widgets you want to include in the screenshot + if (pageName?.trim().isNotEmpty ?? false) + Positioned( + left: 28, + bottom: 22, + child: SizedBox( + width: CoordinateSystem.screenShotSize.width - 56, + child: Text( + pageName!.trim(), + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: Color(0xffb8b8c2), + decoration: TextDecoration.none, + fontSize: 28, + fontWeight: FontWeight.w600, + shadows: [ + Shadow( + color: Color(0xaa000000), + offset: Offset(0, 1), + blurRadius: 4, + ), + ], + ), + ), + ), + ), ], ), ); diff --git a/lib/widgets/save_and_load_button.dart b/lib/widgets/save_and_load_button.dart index 0405bc1d..967283cc 100644 --- a/lib/widgets/save_and_load_button.dart +++ b/lib/widgets/save_and_load_button.dart @@ -149,6 +149,7 @@ class _SaveAndLoadButtonState extends ConsumerState { utilities: activePage.utilityData, strategySettings: activePage.settings, strategyState: ref.read(strategyProvider), + pageName: activePage.name, lineUpGroups: activePage.lineUpGroups, themeProfileId: newStrat.themeProfileId, themeOverridePalette: diff --git a/test/screenshot_view_test.dart b/test/screenshot_view_test.dart index bae34e7d..ad35ed98 100644 --- a/test/screenshot_view_test.dart +++ b/test/screenshot_view_test.dart @@ -168,6 +168,7 @@ void main() { bool showSpawnBarrier = false, bool showRegionNames = false, bool showUltOrbs = false, + String? pageName, }) { final strategyState = StrategyState( isSaved: true, @@ -217,6 +218,7 @@ void main() { strategySettings: StrategySettings(), isAttack: isAttack, strategyState: strategyState, + pageName: pageName, lineUps: const [], themeProfileId: null, themeOverridePalette: null, @@ -348,4 +350,24 @@ void main() { expect(ultOrbTransform.transform.storage[0], -1); expect(ultOrbTransform.transform.storage[5], -1); }); + + testWidgets('page name is shown in the lower-left screenshot corner', + (tester) async { + await tester.pumpWidget( + buildHarness( + isAttack: true, + pageName: 'A Execute', + ), + ); + await tester.pumpAndSettle(); + + final labelFinder = find.text('A Execute'); + + expect(labelFinder, findsOneWidget); + expect(tester.getBottomLeft(labelFinder).dx, 28); + expect( + tester.getBottomLeft(labelFinder).dy, + lessThan(CoordinateSystem.screenShotSize.height), + ); + }); } From 01553332fb5146c3dccb08f431eff12699d97eff Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Fri, 1 May 2026 01:22:26 -0400 Subject: [PATCH 09/26] Tighten page bar and row styling - Reduce bar and row corner radii for a cleaner fit - Adjust expanded panel spacing and resize handle height - Refresh row action buttons with compact icon spacing --- lib/widgets/pages_bar.dart | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/widgets/pages_bar.dart b/lib/widgets/pages_bar.dart index 341cb49f..0b769810 100644 --- a/lib/widgets/pages_bar.dart +++ b/lib/widgets/pages_bar.dart @@ -19,7 +19,9 @@ class PagesBar extends ConsumerStatefulWidget { class _PagesBarState extends ConsumerState { static const double _defaultExpandedHeight = 310; - static final double _minExpandedHeight = _ExpandedPanel.minHeightForVisibleRows( + static const double _barRadius = 12; + static final double _minExpandedHeight = + _ExpandedPanel.minHeightForVisibleRows( 2, ); static const double _maxExpandedHeight = 520; @@ -225,7 +227,7 @@ class _PagesBarState extends ConsumerState { return Container( decoration: BoxDecoration( color: Settings.tacticalVioletTheme.card, - borderRadius: BorderRadius.circular(16), + borderRadius: BorderRadius.circular(_barRadius), border: Border.all( color: Settings.tacticalVioletTheme.border, width: 2, @@ -344,9 +346,9 @@ class _ExpandedPanel extends ConsumerWidget { static const double _rowHeight = 40; // each page tile height static const double _verticalSpacing = 10; // separator height - static const double _resizeHandleHeight = 6; + static const double _resizeHandleHeight = 8; static const double _headerFooterHeight = 48 + 1; // bottom bar + divider - static const double _topPadding = 6; // handle + gap should match side inset + static const double _topPadding = 0; // handle + gap should match side inset static const double _bottomPadding = 0; // list bottom padding inside Expanded static double minHeightForVisibleRows(int visibleRows) { @@ -601,6 +603,7 @@ class _PageRow extends StatelessWidget { final bool disableDelete; static const double _rowHeight = 40; + static const double _rowRadius = 6; @override Widget build(BuildContext context) { @@ -611,15 +614,15 @@ class _PageRow extends StatelessWidget { return Material( // color: bg, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), + borderRadius: BorderRadius.circular(_rowRadius), ), child: InkWell( mouseCursor: SystemMouseCursors.click, - borderRadius: BorderRadius.circular(14), + borderRadius: BorderRadius.circular(_rowRadius), onTap: () => onSelect(page.id), child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), + borderRadius: BorderRadius.circular(_rowRadius), border: Border.all( color: Settings.tacticalVioletTheme.border, width: 1, @@ -660,27 +663,32 @@ class _PageRow extends StatelessWidget { ShadTooltip( builder: (context) => const Text("Rename"), child: ShadIconButton.ghost( + width: 24, hoverBackgroundColor: Colors.transparent, foregroundColor: Colors.white, - icon: const Icon(Icons.edit, size: 18, color: Colors.white), + icon: const Icon(LucideIcons.pen, + size: 18, color: Colors.white), onPressed: () => onRename(page), ), ), + const SizedBox(width: 2), ShadTooltip( builder: (context) => const Text("Delete"), child: ShadIconButton.ghost( + width: 24, hoverForegroundColor: Settings.tacticalVioletTheme.destructive, hoverBackgroundColor: Colors.transparent, foregroundColor: disableDelete ? Colors.white24 : Colors.white, icon: const Icon( - Icons.delete, + LucideIcons.trash, size: 18, ), onPressed: disableDelete ? null : () => onDelete(page), ), ), + const SizedBox(width: 4), ], ), ), From 111a592c2cb2addb6881094cff1af65007f0a7e2 Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Fri, 1 May 2026 01:47:19 -0400 Subject: [PATCH 10/26] Add resizable pages bar width persistence - Store pages bar width in app preferences - Add horizontal resize handle and clamp width - Keep existing height resize behavior intact --- lib/hive/hive_adapters.g.dart | 7 +- lib/hive/hive_adapters.g.yaml | 4 +- lib/providers/map_theme_provider.dart | 13 ++ lib/widgets/pages_bar.dart | 228 +++++++++++++++++++------- 4 files changed, 192 insertions(+), 60 deletions(-) diff --git a/lib/hive/hive_adapters.g.dart b/lib/hive/hive_adapters.g.dart index 467b9615..de80c681 100644 --- a/lib/hive/hive_adapters.g.dart +++ b/lib/hive/hive_adapters.g.dart @@ -1302,6 +1302,7 @@ class AppPreferencesAdapter extends TypeAdapter { fields[4] == null ? false : fields[4] as bool, pagesBarExpandedHeight: fields[2] == null ? 310.0 : (fields[2] as num).toDouble(), + pagesBarWidth: fields[7] == null ? 224.0 : (fields[7] as num).toDouble(), customColorValues: (fields[3] as List?)?.cast(), ); } @@ -1309,7 +1310,7 @@ class AppPreferencesAdapter extends TypeAdapter { @override void write(BinaryWriter writer, AppPreferences obj) { writer - ..writeByte(7) + ..writeByte(8) ..writeByte(0) ..write(obj.defaultThemeProfileIdForNewStrategies) ..writeByte(1) @@ -1323,7 +1324,9 @@ class AppPreferencesAdapter extends TypeAdapter { ..writeByte(5) ..write(obj.defaultAgentSizeForNewStrategies) ..writeByte(6) - ..write(obj.defaultAbilitySizeForNewStrategies); + ..write(obj.defaultAbilitySizeForNewStrategies) + ..writeByte(7) + ..write(obj.pagesBarWidth); } @override diff --git a/lib/hive/hive_adapters.g.yaml b/lib/hive/hive_adapters.g.yaml index 539c32c9..8be03752 100644 --- a/lib/hive/hive_adapters.g.yaml +++ b/lib/hive/hive_adapters.g.yaml @@ -439,7 +439,7 @@ types: index: 4 AppPreferences: typeId: 28 - nextIndex: 7 + nextIndex: 8 fields: defaultThemeProfileIdForNewStrategies: index: 0 @@ -455,6 +455,8 @@ types: index: 5 defaultAbilitySizeForNewStrategies: index: 6 + pagesBarWidth: + index: 7 PlacedViewConeAgent: typeId: 29 nextIndex: 9 diff --git a/lib/providers/map_theme_provider.dart b/lib/providers/map_theme_provider.dart index cf8fa1b6..26ea89f7 100644 --- a/lib/providers/map_theme_provider.dart +++ b/lib/providers/map_theme_provider.dart @@ -116,6 +116,7 @@ class AppPreferences extends HiveObject { final double defaultAbilitySizeForNewStrategies; final bool defaultNeutralTeamColorsForNewStrategies; final double pagesBarExpandedHeight; + final double pagesBarWidth; final List customColorValues; AppPreferences({ @@ -125,6 +126,7 @@ class AppPreferences extends HiveObject { this.defaultAbilitySizeForNewStrategies = Settings.abilitySize, this.defaultNeutralTeamColorsForNewStrategies = false, this.pagesBarExpandedHeight = 310.0, + this.pagesBarWidth = 224.0, List? customColorValues, }) : customColorValues = List.unmodifiable(customColorValues ?? const []); @@ -135,6 +137,7 @@ class AppPreferences extends HiveObject { double? defaultAbilitySizeForNewStrategies, bool? defaultNeutralTeamColorsForNewStrategies, double? pagesBarExpandedHeight, + double? pagesBarWidth, List? customColorValues, }) { return AppPreferences( @@ -151,6 +154,7 @@ class AppPreferences extends HiveObject { this.defaultNeutralTeamColorsForNewStrategies, pagesBarExpandedHeight: pagesBarExpandedHeight ?? this.pagesBarExpandedHeight, + pagesBarWidth: pagesBarWidth ?? this.pagesBarWidth, customColorValues: customColorValues ?? this.customColorValues, ); } @@ -554,6 +558,15 @@ class AppPreferencesNotifier extends Notifier { state = updated; } + Future setPagesBarWidth(double width) async { + final updated = _readFromHive().copyWith(pagesBarWidth: width); + await Hive.box(HiveBoxNames.appPreferencesBox).put( + MapThemeProfilesProvider.appPreferencesSingletonKey, + updated, + ); + state = updated; + } + Future setCustomColorValues(List colorValues) async { final updated = _readFromHive().copyWith( customColorValues: colorValues.take(15).toList(growable: false), diff --git a/lib/widgets/pages_bar.dart b/lib/widgets/pages_bar.dart index 0b769810..8f9baffa 100644 --- a/lib/widgets/pages_bar.dart +++ b/lib/widgets/pages_bar.dart @@ -19,6 +19,10 @@ class PagesBar extends ConsumerStatefulWidget { class _PagesBarState extends ConsumerState { static const double _defaultExpandedHeight = 310; + static const double _defaultWidth = 224; + static const double _minWidth = 224; + static const double _maxWidth = 420; + static const double _widthResizeHandleWidth = 8; static const double _barRadius = 12; static final double _minExpandedHeight = _ExpandedPanel.minHeightForVisibleRows( @@ -27,10 +31,14 @@ class _PagesBarState extends ConsumerState { static const double _maxExpandedHeight = 520; bool _expanded = false; - bool _isResizing = false; + bool _isHeightResizing = false; + bool _isWidthResizing = false; double? _liveExpandedHeight; + double? _liveWidth; double? _persistedExpandedHeightCache; + double? _persistedWidthCache; final GlobalKey _expandedPanelKey = GlobalKey(); + final GlobalKey _barKey = GlobalKey(); StrategyData? _strategy(Box box, String id) => box.get(id); @@ -38,14 +46,24 @@ class _PagesBarState extends ConsumerState { return height.clamp(_minExpandedHeight, _maxExpandedHeight).toDouble(); } + double _clampWidth(double width) { + return width.clamp(_minWidth, _maxWidth).toDouble(); + } + double _effectiveExpandedHeight(double persistedHeight) { final baseHeight = _persistedExpandedHeightCache ?? persistedHeight; return _clampExpandedHeight( - _isResizing ? (_liveExpandedHeight ?? baseHeight) : baseHeight, + _isHeightResizing ? (_liveExpandedHeight ?? baseHeight) : baseHeight, ); } - void _startResize() { + double _effectiveWidth(double persistedWidth) { + final baseWidth = _persistedWidthCache ?? persistedWidth; + return _clampWidth( + _isWidthResizing ? (_liveWidth ?? baseWidth) : baseWidth); + } + + void _startHeightResize() { final context = _expandedPanelKey.currentContext; final renderBox = context?.findRenderObject() as RenderBox?; final renderedHeight = renderBox != null && renderBox.hasSize @@ -53,12 +71,12 @@ class _PagesBarState extends ConsumerState { : (_persistedExpandedHeightCache ?? _defaultExpandedHeight); setState(() { - _isResizing = true; + _isHeightResizing = true; _liveExpandedHeight = _clampExpandedHeight(renderedHeight); }); } - void _updateResize(Offset globalPosition) { + void _updateHeightResize(Offset globalPosition) { final context = _expandedPanelKey.currentContext; if (context == null) return; @@ -78,8 +96,8 @@ class _PagesBarState extends ConsumerState { }); } - Future _endResize() async { - if (!_isResizing) return; + Future _endHeightResize() async { + if (!_isHeightResizing) return; final height = _clampExpandedHeight( _liveExpandedHeight ?? @@ -88,7 +106,7 @@ class _PagesBarState extends ConsumerState { ); setState(() { - _isResizing = false; + _isHeightResizing = false; _liveExpandedHeight = null; _persistedExpandedHeightCache = height; }); @@ -103,9 +121,64 @@ class _PagesBarState extends ConsumerState { }); } + void _startWidthResize() { + final context = _barKey.currentContext; + final renderBox = context?.findRenderObject() as RenderBox?; + final renderedWidth = renderBox != null && renderBox.hasSize + ? renderBox.size.width + : (_persistedWidthCache ?? _defaultWidth); + + setState(() { + _isWidthResizing = true; + _liveWidth = _clampWidth(renderedWidth); + }); + } + + void _updateWidthResize(Offset globalPosition) { + final context = _barKey.currentContext; + if (context == null) return; + + final renderBox = context.findRenderObject() as RenderBox?; + if (renderBox == null || !renderBox.hasSize) return; + + final localPosition = renderBox.globalToLocal(globalPosition); + final nextWidth = _clampWidth(localPosition.dx); + final currentWidth = _liveWidth; + if (currentWidth != null && (nextWidth - currentWidth).abs() < 0.5) { + return; + } + + setState(() { + _liveWidth = nextWidth; + }); + } + + Future _endWidthResize() async { + if (!_isWidthResizing) return; + + final width = + _clampWidth(_liveWidth ?? _persistedWidthCache ?? _defaultWidth); + + setState(() { + _isWidthResizing = false; + _liveWidth = null; + _persistedWidthCache = width; + }); + + await ref.read(appPreferencesProvider.notifier).setPagesBarWidth(width); + + if (!mounted) return; + setState(() { + _persistedWidthCache = null; + }); + } + Future _collapsePanel() async { - if (_isResizing) { - await _endResize(); + if (_isHeightResizing) { + await _endHeightResize(); + } + if (_isWidthResizing) { + await _endWidthResize(); } if (!mounted) return; setState(() => _expanded = false); @@ -205,6 +278,9 @@ class _PagesBarState extends ConsumerState { final persistedExpandedHeight = ref.watch( appPreferencesProvider.select((prefs) => prefs.pagesBarExpandedHeight), ); + final persistedWidth = ref.watch( + appPreferencesProvider.select((prefs) => prefs.pagesBarWidth), + ); final box = Hive.box(HiveBoxNames.strategiesBox); return ValueListenableBuilder( @@ -224,38 +300,63 @@ class _PagesBarState extends ConsumerState { ) .name; - return Container( - decoration: BoxDecoration( - color: Settings.tacticalVioletTheme.card, - borderRadius: BorderRadius.circular(_barRadius), - border: Border.all( - color: Settings.tacticalVioletTheme.border, - width: 2, - ), - ), - width: 224, - padding: EdgeInsets.zero, - child: _expanded - ? _ExpandedPanel( - pages: pages, - activePageId: activePageId, - height: _effectiveExpandedHeight(persistedExpandedHeight), - panelKey: _expandedPanelKey, - onSelect: _selectPage, - onRename: (p) => _renamePage(strat, p), - onDelete: (p) => _deletePage(strat, p), - onAdd: _addPage, - onCollapse: _collapsePanel, - onResizeStart: _startResize, - onResizeUpdate: _updateResize, - onResizeEnd: _endResize, - isResizeActive: _isResizing, - ) - : _CollapsedPill( - activeName: activeName, - onAdd: _addPage, - onToggle: () => setState(() => _expanded = true), + final width = _effectiveWidth(persistedWidth); + + return Stack( + clipBehavior: Clip.none, + children: [ + Container( + key: _barKey, + decoration: BoxDecoration( + color: Settings.tacticalVioletTheme.card, + borderRadius: BorderRadius.circular(_barRadius), + border: Border.all( + color: Settings.tacticalVioletTheme.border, + width: 2, ), + ), + width: width, + padding: EdgeInsets.zero, + child: Padding( + padding: const EdgeInsets.only(right: _widthResizeHandleWidth), + child: _expanded + ? _ExpandedPanel( + pages: pages, + activePageId: activePageId, + height: + _effectiveExpandedHeight(persistedExpandedHeight), + panelKey: _expandedPanelKey, + onSelect: _selectPage, + onRename: (p) => _renamePage(strat, p), + onDelete: (p) => _deletePage(strat, p), + onAdd: _addPage, + onCollapse: _collapsePanel, + onResizeStart: _startHeightResize, + onResizeUpdate: _updateHeightResize, + onResizeEnd: _endHeightResize, + isResizeActive: _isHeightResizing, + ) + : _CollapsedPill( + activeName: activeName, + onAdd: _addPage, + onToggle: () => setState(() => _expanded = true), + ), + ), + ), + Positioned( + top: 0, + right: 2, + bottom: 0, + child: _ResizeHandle( + width: _widthResizeHandleWidth, + axis: Axis.horizontal, + onResizeStart: _startWidthResize, + onResizeUpdate: _updateWidthResize, + onResizeEnd: _endWidthResize, + isActive: _isWidthResizing, + ), + ), + ], ); }, ); @@ -394,6 +495,7 @@ class _ExpandedPanel extends ConsumerWidget { children: [ _ResizeHandle( height: _resizeHandleHeight, + axis: Axis.vertical, onResizeStart: onResizeStart, onResizeUpdate: onResizeUpdate, onResizeEnd: onResizeEnd, @@ -408,7 +510,7 @@ class _ExpandedPanel extends ConsumerWidget { .read(strategyProvider.notifier) .reorderPage(oldIndex, newIndex); }, - padding: const EdgeInsets.fromLTRB(8, 0, 8, 8), + padding: const EdgeInsets.fromLTRB(8, 0, 0, 8), shrinkWrap: false, physics: needsScroll ? null : const NeverScrollableScrollPhysics(), @@ -492,14 +594,18 @@ class _ExpandedPanel extends ConsumerWidget { class _ResizeHandle extends StatelessWidget { const _ResizeHandle({ - required this.height, + this.height, + this.width, + required this.axis, required this.onResizeStart, required this.onResizeUpdate, required this.onResizeEnd, required this.isActive, }); - final double height; + final double? height; + final double? width; + final Axis axis; final VoidCallback onResizeStart; final ValueChanged onResizeUpdate; final Future Function() onResizeEnd; @@ -509,6 +615,8 @@ class _ResizeHandle extends StatelessWidget { Widget build(BuildContext context) { return _ResizeHandleStateful( height: height, + width: width, + axis: axis, onResizeStart: onResizeStart, onResizeUpdate: onResizeUpdate, onResizeEnd: onResizeEnd, @@ -519,14 +627,18 @@ class _ResizeHandle extends StatelessWidget { class _ResizeHandleStateful extends StatefulWidget { const _ResizeHandleStateful({ - required this.height, + this.height, + this.width, + required this.axis, required this.onResizeStart, required this.onResizeUpdate, required this.onResizeEnd, required this.isActive, }); - final double height; + final double? height; + final double? width; + final Axis axis; final VoidCallback onResizeStart; final ValueChanged onResizeUpdate; final Future Function() onResizeEnd; @@ -544,31 +656,33 @@ class _ResizeHandleStatefulState extends State<_ResizeHandleStateful> { final isHighlighted = widget.isActive || _isHovered; final handleColor = isHighlighted ? Settings.tacticalVioletTheme.primary - : Settings.tacticalVioletTheme.mutedForeground.withValues(alpha: 0.5); + : Colors.transparent; + final isHorizontalResize = widget.axis == Axis.horizontal; return MouseRegion( - cursor: SystemMouseCursors.resizeUpDown, + cursor: isHorizontalResize + ? SystemMouseCursors.resizeLeftRight + : SystemMouseCursors.resizeUpDown, onEnter: (_) => setState(() => _isHovered = true), onExit: (_) => setState(() => _isHovered = false), child: GestureDetector( behavior: HitTestBehavior.opaque, - onVerticalDragStart: (_) => widget.onResizeStart(), - onVerticalDragUpdate: (details) => - widget.onResizeUpdate(details.globalPosition), - onVerticalDragEnd: (_) { + onPanStart: (_) => widget.onResizeStart(), + onPanUpdate: (details) => widget.onResizeUpdate(details.globalPosition), + onPanEnd: (_) { widget.onResizeEnd(); }, - onVerticalDragCancel: () { + onPanCancel: () { widget.onResizeEnd(); }, child: SizedBox( - height: widget.height, - width: double.infinity, + height: widget.height ?? double.infinity, + width: widget.width ?? double.infinity, child: Center( child: AnimatedContainer( duration: const Duration(milliseconds: 120), - width: 36, - height: 2, + width: isHorizontalResize ? 2 : 36, + height: isHorizontalResize ? 36 : 2, decoration: BoxDecoration( color: handleColor, borderRadius: BorderRadius.circular(999), From 88f0b25cd885d199c6c09181b20249ebd01d2e92 Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Fri, 1 May 2026 01:56:09 -0400 Subject: [PATCH 11/26] Animate page row fills during transitions - Track source and target page IDs through transition state - Ease the overlay progress curve and drive row fill indicators - Clear transition page IDs when the animation completes --- lib/providers/strategy_provider.dart | 8 +- lib/providers/transition_provider.dart | 26 +++- lib/widgets/page_transition_overlay.dart | 4 +- lib/widgets/pages_bar.dart | 168 ++++++++++++++--------- 4 files changed, 137 insertions(+), 69 deletions(-) diff --git a/lib/providers/strategy_provider.dart b/lib/providers/strategy_provider.dart index 85154513..4e2deeef 100644 --- a/lib/providers/strategy_provider.dart +++ b/lib/providers/strategy_provider.dart @@ -1045,13 +1045,17 @@ class StrategyProvider extends Notifier { ..sort((a, b) => a.sortIndex.compareTo(b.sortIndex)); final resolvedDirection = direction ?? _resolveDirectionForPage(pageID, orderedPages); + final sourcePageId = activePageID; + final targetPageId = pageID; final startSettings = ref.read(strategySettingsProvider); final prev = _snapshotAllPlaced(); transitionNotifier.prepare(prev.values.toList(), direction: resolvedDirection, startAgentSize: startSettings.agentSize, - startAbilitySize: startSettings.abilitySize); + startAbilitySize: startSettings.abilitySize, + sourcePageId: sourcePageId, + targetPageId: targetPageId); // Load target page (hydrates providers) await setActivePage(pageID); @@ -1070,6 +1074,8 @@ class StrategyProvider extends Notifier { endAgentSize: endSettings.agentSize, startAbilitySize: startSettings.abilitySize, endAbilitySize: endSettings.abilitySize, + sourcePageId: sourcePageId, + targetPageId: targetPageId, ); } else { transitionNotifier.complete(); diff --git a/lib/providers/transition_provider.dart b/lib/providers/transition_provider.dart index a7d2c07b..9bbf1df3 100644 --- a/lib/providers/transition_provider.dart +++ b/lib/providers/transition_provider.dart @@ -21,6 +21,8 @@ class PageTransitionState { required this.endAgentSize, required this.startAbilitySize, required this.endAbilitySize, + this.sourcePageId, + this.targetPageId, }); final bool hideView; final bool active; @@ -35,6 +37,8 @@ class PageTransitionState { final double endAgentSize; final double startAbilitySize; final double endAbilitySize; + final String? sourcePageId; + final String? targetPageId; PageTransitionState copyWith({ bool? active, @@ -50,6 +54,9 @@ class PageTransitionState { double? endAgentSize, double? startAbilitySize, double? endAbilitySize, + String? sourcePageId, + String? targetPageId, + bool clearPageIds = false, }) => PageTransitionState( hideView: hideView ?? this.hideView, @@ -65,6 +72,8 @@ class PageTransitionState { endAgentSize: endAgentSize ?? this.endAgentSize, startAbilitySize: startAbilitySize ?? this.startAbilitySize, endAbilitySize: endAbilitySize ?? this.endAbilitySize, + sourcePageId: clearPageIds ? null : (sourcePageId ?? this.sourcePageId), + targetPageId: clearPageIds ? null : (targetPageId ?? this.targetPageId), ); static const idle = PageTransitionState( @@ -80,7 +89,9 @@ class PageTransitionState { startAgentSize: 0, endAgentSize: 0, startAbilitySize: 0, - endAbilitySize: 0); + endAbilitySize: 0, + sourcePageId: null, + targetPageId: null); } final transitionProvider = @@ -103,7 +114,9 @@ class TransitionProvider extends Notifier { void prepare(List widgets, {PageTransitionDirection direction = PageTransitionDirection.forward, required double startAgentSize, - required double startAbilitySize}) { + required double startAbilitySize, + String? sourcePageId, + String? targetPageId}) { state = state.copyWith( allWidgets: widgets, hideView: true, @@ -116,6 +129,8 @@ class TransitionProvider extends Notifier { endAgentSize: startAgentSize, startAbilitySize: startAbilitySize, endAbilitySize: startAbilitySize, + sourcePageId: sourcePageId, + targetPageId: targetPageId, ); } @@ -125,7 +140,9 @@ class TransitionProvider extends Notifier { required double startAgentSize, required double endAgentSize, required double startAbilitySize, - required double endAbilitySize}) { + required double endAbilitySize, + String? sourcePageId, + String? targetPageId}) { state = state.copyWith( hideView: true, active: true, @@ -139,6 +156,8 @@ class TransitionProvider extends Notifier { endAgentSize: endAgentSize, startAbilitySize: startAbilitySize, endAbilitySize: endAbilitySize, + sourcePageId: sourcePageId, + targetPageId: targetPageId, ); } @@ -158,6 +177,7 @@ class TransitionProvider extends Notifier { entries: const [], allWidgets: const [], phase: PageTransitionPhase.idle, + clearPageIds: true, ); } } diff --git a/lib/widgets/page_transition_overlay.dart b/lib/widgets/page_transition_overlay.dart index b18277cd..2594a42e 100644 --- a/lib/widgets/page_transition_overlay.dart +++ b/lib/widgets/page_transition_overlay.dart @@ -69,7 +69,9 @@ class _PageTransitionOverlayState extends ConsumerState if (_controller == null) { _controller = AnimationController(vsync: this, duration: duration) ..addListener(() { - // ref.read(transitionProvider.notifier).setProgress(_controller!.value); + ref.read(transitionProvider.notifier).setProgress( + Curves.easeInOutCubic.transform(_controller!.value), + ); setState(() {}); }) ..addStatusListener((status) { diff --git a/lib/widgets/pages_bar.dart b/lib/widgets/pages_bar.dart index 8f9baffa..89894f8a 100644 --- a/lib/widgets/pages_bar.dart +++ b/lib/widgets/pages_bar.dart @@ -6,6 +6,7 @@ import 'package:icarus/const/settings.dart'; import 'package:icarus/providers/map_theme_provider.dart'; import 'package:icarus/providers/strategy_provider.dart'; import 'package:icarus/providers/strategy_page.dart'; +import 'package:icarus/providers/transition_provider.dart'; import 'package:icarus/widgets/custom_text_field.dart'; import 'package:icarus/widgets/dialogs/confirm_alert_dialog.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; @@ -477,6 +478,7 @@ class _ExpandedPanel extends ConsumerWidget { final activeIndex = activePageId == null ? -1 : pages.indexWhere((p) => p.id == activePageId); + final transitionState = ref.watch(transitionProvider); int? backwardIndex; int? forwardIndex; @@ -551,6 +553,8 @@ class _ExpandedPanel extends ConsumerWidget { active: p.id == activePageId, showBackwardIndicator: showBackwardIndicator, showForwardIndicator: showForwardIndicator, + transitionProgress: + _rowTransitionProgress(transitionState, p.id), onSelect: onSelect, onRename: onRename, onDelete: onDelete, @@ -590,6 +594,16 @@ class _ExpandedPanel extends ConsumerWidget { ), ); } + + double? _rowTransitionProgress(PageTransitionState state, String pageId) { + if (state.phase != PageTransitionPhase.preparing && + state.phase != PageTransitionPhase.animating) { + return null; + } + if (state.sourcePageId == pageId) return 1 - state.progress; + if (state.targetPageId == pageId) return state.progress; + return null; + } } class _ResizeHandle extends StatelessWidget { @@ -701,6 +715,7 @@ class _PageRow extends StatelessWidget { required this.active, required this.showBackwardIndicator, required this.showForwardIndicator, + required this.transitionProgress, required this.onSelect, required this.onRename, required this.onDelete, @@ -711,6 +726,7 @@ class _PageRow extends StatelessWidget { final bool active; final bool showBackwardIndicator; final bool showForwardIndicator; + final double? transitionProgress; final ValueChanged onSelect; final ValueChanged onRename; final ValueChanged onDelete; @@ -722,7 +738,8 @@ class _PageRow extends StatelessWidget { @override Widget build(BuildContext context) { final theme = Theme.of(context); - final bg = active + final fillProgress = transitionProgress?.clamp(0.0, 1.0); + final bg = active && fillProgress == null ? Settings.tacticalVioletTheme.primary : Settings.tacticalVioletTheme.card; return Material( @@ -734,75 +751,98 @@ class _PageRow extends StatelessWidget { mouseCursor: SystemMouseCursors.click, borderRadius: BorderRadius.circular(_rowRadius), onTap: () => onSelect(page.id), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(_rowRadius), - border: Border.all( - color: Settings.tacticalVioletTheme.border, - width: 1, + child: ClipRRect( + borderRadius: BorderRadius.circular(_rowRadius), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(_rowRadius), + border: Border.all( + color: Settings.tacticalVioletTheme.border, + width: 1, + ), + boxShadow: [ + BoxShadow( + color: Settings.tacticalVioletTheme.card + .withValues(alpha: 0.2), + blurRadius: 12, + offset: const Offset(0, 4)) + ], + color: bg, ), - boxShadow: [ - BoxShadow( - color: - Settings.tacticalVioletTheme.card.withValues(alpha: 0.2), - blurRadius: 12, - offset: const Offset(0, 4)) - ], - color: bg, - ), - height: _rowHeight, - child: Padding( - padding: const EdgeInsets.only(left: 12), - child: Row( + height: _rowHeight, + child: Stack( children: [ - Expanded( - child: Text( - page.name, - overflow: TextOverflow.ellipsis, - style: theme.textTheme.titleMedium?.copyWith( - color: Colors.white, - fontWeight: active ? FontWeight.w600 : FontWeight.w500, - fontSize: 14, + if (fillProgress != null) + Positioned.fill( + child: FractionallySizedBox( + widthFactor: fillProgress, + alignment: Alignment.centerLeft, + child: DecoratedBox( + decoration: BoxDecoration( + color: Settings.tacticalVioletTheme.primary, + ), + ), ), ), - ), - if (showBackwardIndicator || showForwardIndicator) ...[ - const SizedBox(width: 6), - if (showBackwardIndicator) const _KeybindBadge(label: "A"), - if (showBackwardIndicator && showForwardIndicator) - const SizedBox(width: 4), - if (showForwardIndicator) const _KeybindBadge(label: "D"), - const SizedBox(width: 2), - ], - ShadTooltip( - builder: (context) => const Text("Rename"), - child: ShadIconButton.ghost( - width: 24, - hoverBackgroundColor: Colors.transparent, - foregroundColor: Colors.white, - icon: const Icon(LucideIcons.pen, - size: 18, color: Colors.white), - onPressed: () => onRename(page), - ), - ), - const SizedBox(width: 2), - ShadTooltip( - builder: (context) => const Text("Delete"), - child: ShadIconButton.ghost( - width: 24, - hoverForegroundColor: - Settings.tacticalVioletTheme.destructive, - hoverBackgroundColor: Colors.transparent, - foregroundColor: - disableDelete ? Colors.white24 : Colors.white, - icon: const Icon( - LucideIcons.trash, - size: 18, - ), - onPressed: disableDelete ? null : () => onDelete(page), + Padding( + padding: const EdgeInsets.only(left: 12), + child: Row( + children: [ + Expanded( + child: Text( + page.name, + overflow: TextOverflow.ellipsis, + style: theme.textTheme.titleMedium?.copyWith( + color: Colors.white, + fontWeight: + active ? FontWeight.w600 : FontWeight.w500, + fontSize: 14, + ), + ), + ), + if (showBackwardIndicator || showForwardIndicator) ...[ + const SizedBox(width: 6), + if (showBackwardIndicator) + const _KeybindBadge(label: "A"), + if (showBackwardIndicator && showForwardIndicator) + const SizedBox(width: 4), + if (showForwardIndicator) + const _KeybindBadge(label: "D"), + const SizedBox(width: 2), + ], + ShadTooltip( + builder: (context) => const Text("Rename"), + child: ShadIconButton.ghost( + width: 24, + hoverBackgroundColor: Colors.transparent, + foregroundColor: Colors.white, + icon: const Icon(LucideIcons.pen, + size: 18, color: Colors.white), + onPressed: () => onRename(page), + ), + ), + const SizedBox(width: 2), + ShadTooltip( + builder: (context) => const Text("Delete"), + child: ShadIconButton.ghost( + width: 24, + hoverForegroundColor: + Settings.tacticalVioletTheme.destructive, + hoverBackgroundColor: Colors.transparent, + foregroundColor: + disableDelete ? Colors.white24 : Colors.white, + icon: const Icon( + LucideIcons.trash, + size: 18, + ), + onPressed: + disableDelete ? null : () => onDelete(page), + ), + ), + const SizedBox(width: 4), + ], ), ), - const SizedBox(width: 4), ], ), ), From cece40b3fdcc71d209fd5f3f579c2e0245714f9b Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Fri, 1 May 2026 02:04:26 -0400 Subject: [PATCH 12/26] Unify lineup overlay rendering during transitions - Extract lineup visuals into a reusable overlay - Show lineup overlay while page transitions hide the map - Use a consistent easing curve for transition progress --- lib/interactive_map.dart | 10 +++++- .../placed_widget_builder.dart | 33 ++++++++++++------- lib/widgets/page_transition_overlay.dart | 6 ++-- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/lib/interactive_map.dart b/lib/interactive_map.dart index bd6bf9cc..ba07f50e 100644 --- a/lib/interactive_map.dart +++ b/lib/interactive_map.dart @@ -169,7 +169,8 @@ class _InteractiveMapState extends ConsumerState { (constraints.maxWidth - Settings.sideBarReservedWidth) .clamp(0.0, constraints.maxWidth); final viewportSize = Size(viewportWidth, height); - if (_lastViewportSize != viewportSize || _lastPlayAreaSize != playAreaSize) { + if (_lastViewportSize != viewportSize || + _lastPlayAreaSize != playAreaSize) { final double currentScale = controller.value.getMaxScaleOnAxis(); final double safeScale = currentScale == 0 ? 1.0 : currentScale; final double centeredOffsetX = @@ -339,6 +340,13 @@ class _InteractiveMapState extends ConsumerState { child: PlacedWidgetBuilder(), ), ), + Positioned.fill( + child: ref.watch(transitionProvider).hideView + ? IgnorePointer( + child: LineUpOverlay(), + ) + : SizedBox.shrink(), + ), Positioned.fill( child: ref.watch(transitionProvider).active ? PageTransitionOverlay() diff --git a/lib/widgets/draggable_widgets/placed_widget_builder.dart b/lib/widgets/draggable_widgets/placed_widget_builder.dart index 8e559976..697af7fd 100644 --- a/lib/widgets/draggable_widgets/placed_widget_builder.dart +++ b/lib/widgets/draggable_widgets/placed_widget_builder.dart @@ -151,16 +151,7 @@ class _PlacedWidgetBuilderState extends ConsumerState { abilitySize: abilitySize, mapScale: mapScale, ), - const Positioned.fill( - child: LineUpLinePainter(), - ), - Stack( - clipBehavior: Clip.none, - children: [ - _LineUpAgents(), - _LineUpAbilities(), - ], - ), + const LineUpOverlay(), ], ), ), @@ -200,7 +191,9 @@ class _PlacedWidgetBuilderState extends ConsumerState { if (ref.read(interactionStateProvider) == InteractionState.lineUpPlacing) { - ref.read(lineUpProvider.notifier).setCurrentAbility(placedAbility); + ref + .read(lineUpProvider.notifier) + .setCurrentAbility(placedAbility); return; } @@ -885,6 +878,24 @@ class _CustomShapeUtilityList extends ConsumerWidget { } } +class LineUpOverlay extends StatelessWidget { + const LineUpOverlay({super.key}); + + @override + Widget build(BuildContext context) { + return Stack( + clipBehavior: Clip.none, + children: const [ + Positioned.fill( + child: LineUpLinePainter(), + ), + _LineUpAgents(), + _LineUpAbilities(), + ], + ); + } +} + class _LineUpAgents extends ConsumerWidget { const _LineUpAgents(); diff --git a/lib/widgets/page_transition_overlay.dart b/lib/widgets/page_transition_overlay.dart index 2594a42e..6319ab72 100644 --- a/lib/widgets/page_transition_overlay.dart +++ b/lib/widgets/page_transition_overlay.dart @@ -16,6 +16,8 @@ import 'package:icarus/widgets/draggable_widgets/agents/placed_view_cone_agent_w import 'package:icarus/widgets/draggable_widgets/image/image_widget.dart'; import 'package:icarus/widgets/draggable_widgets/text/text_widget.dart'; +const Curve _pageTransitionCurve = Curves.easeOutCubic; + Offset _overlayScreenPosition({ required PlacedWidget widget, required CoordinateSystem coordinateSystem, @@ -70,7 +72,7 @@ class _PageTransitionOverlayState extends ConsumerState _controller = AnimationController(vsync: this, duration: duration) ..addListener(() { ref.read(transitionProvider.notifier).setProgress( - Curves.easeInOutCubic.transform(_controller!.value), + _pageTransitionCurve.transform(_controller!.value), ); setState(() {}); }) @@ -263,7 +265,7 @@ class _PageTransitionOverlayState extends ConsumerState return const SizedBox.shrink(); } - final t = Curves.easeInOutCubic.transform(_controller!.value); + final t = _pageTransitionCurve.transform(_controller!.value); final agentSize = _lerpRequired(state.startAgentSize, state.endAgentSize, t); final abilitySize = From 22ad064b2b10dc289329b9bf01be7bc9c03cd598 Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Fri, 1 May 2026 14:44:03 -0400 Subject: [PATCH 13/26] Refresh lineup overlay on canvas resize - Watch canvas resize changes in persistent lineup widgets - Add regression test for overlay repositioning and rescaling --- .../placed_widget_builder.dart | 3 ++ test/lineup_add_item_interaction_test.dart | 54 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/lib/widgets/draggable_widgets/placed_widget_builder.dart b/lib/widgets/draggable_widgets/placed_widget_builder.dart index 697af7fd..e65ff6fb 100644 --- a/lib/widgets/draggable_widgets/placed_widget_builder.dart +++ b/lib/widgets/draggable_widgets/placed_widget_builder.dart @@ -13,6 +13,7 @@ import 'package:icarus/providers/action_provider.dart'; import 'package:icarus/providers/ability_bar_provider.dart'; import 'package:icarus/providers/ability_provider.dart'; import 'package:icarus/providers/agent_provider.dart'; +import 'package:icarus/providers/canvas_resize_provider.dart'; import 'package:icarus/providers/duplicate_drag_modifier_provider.dart'; import 'package:icarus/providers/hovered_delete_target_provider.dart'; import 'package:icarus/providers/image_provider.dart'; @@ -901,6 +902,7 @@ class _LineUpAgents extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + ref.watch(canvasResizeProvider); final groups = ref.watch(lineUpProvider).groups; return Stack( @@ -917,6 +919,7 @@ class _LineUpAbilities extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + ref.watch(canvasResizeProvider); final groups = ref.watch(lineUpProvider).groups; return Stack( diff --git a/test/lineup_add_item_interaction_test.dart b/test/lineup_add_item_interaction_test.dart index 5ad3cbd9..42fafa84 100644 --- a/test/lineup_add_item_interaction_test.dart +++ b/test/lineup_add_item_interaction_test.dart @@ -13,6 +13,7 @@ import 'package:icarus/providers/canvas_resize_provider.dart'; import 'package:icarus/providers/interaction_state_provider.dart'; import 'package:icarus/providers/map_provider.dart'; import 'package:icarus/widgets/draggable_widgets/ability/placed_ability_widget.dart'; +import 'package:icarus/widgets/draggable_widgets/placed_widget_builder.dart'; import 'package:icarus/widgets/draggable_widgets/agents/agent_widget.dart'; import 'package:icarus/widgets/line_up_placer.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; @@ -321,6 +322,59 @@ void main() { expect(resizedAgentTopLeft.dy, closeTo(expectedAgentTopLeft.dy, 0.001)); }); + testWidgets('persistent lineup overlay repositions and rescales on resize', + (tester) async { + final container = _createContainer(); + final group = _breachGroup(); + container.read(lineUpProvider.notifier).addGroup(group); + + CoordinateSystem(playAreaSize: const Size(900, 600)); + await _pumpHarness( + tester, + container: container, + child: const SizedBox( + width: 900, + height: 600, + child: LineUpOverlay(), + ), + ); + + final agentFinder = find.byType(AgentWidget); + final initialAgentTopLeft = tester.getTopLeft(agentFinder); + final initialAgentSize = tester.getSize(agentFinder); + final initialAbilityTopLeft = tester + .getTopLeft(find.byKey(const ValueKey('lineup-ability-breach-item'))); + final initialAbilitySize = tester + .getSize(find.byKey(const ValueKey('lineup-ability-breach-item'))); + + CoordinateSystem(playAreaSize: const Size(1200, 800)); + container.read(canvasResizeProvider.notifier).increment(); + await tester.pump(); + + final resizedAgentTopLeft = tester.getTopLeft(agentFinder); + final resizedAgentSize = tester.getSize(agentFinder); + final resizedAbilityTopLeft = tester + .getTopLeft(find.byKey(const ValueKey('lineup-ability-breach-item'))); + final resizedAbilitySize = tester + .getSize(find.byKey(const ValueKey('lineup-ability-breach-item'))); + + expect(resizedAgentTopLeft, isNot(initialAgentTopLeft)); + expect(resizedAbilityTopLeft, isNot(initialAbilityTopLeft)); + expect(resizedAgentSize, isNot(initialAgentSize)); + expect(resizedAbilitySize, isNot(initialAbilitySize)); + + final coordinateSystem = CoordinateSystem.instance; + final expectedAgentTopLeft = + coordinateSystem.coordinateToScreen(group.agent.position); + final expectedAbilityTopLeft = coordinateSystem + .coordinateToScreen(group.items.single.ability.position); + + expect(resizedAgentTopLeft.dx, closeTo(expectedAgentTopLeft.dx, 0.001)); + expect(resizedAgentTopLeft.dy, closeTo(expectedAgentTopLeft.dy, 0.001)); + expect(resizedAbilityTopLeft.dx, closeTo(expectedAbilityTopLeft.dx, 0.001)); + expect(resizedAbilityTopLeft.dy, closeTo(expectedAbilityTopLeft.dy, 0.001)); + }); + testWidgets('locked add-item mode rejects dragging a different agent', (tester) async { final container = _createContainer(); From 867059a0fbe2719fbc5d6b0af5b07f5f953f6284 Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Fri, 1 May 2026 15:08:01 -0400 Subject: [PATCH 14/26] Refine pages bar hover and spacing behavior - Remove extra button spacing in the collapsed and expanded bars - Hide row actions until hover or active state - Disable outer scrollbars for the reorder list - Centralize pages bar corner radii constants --- lib/widgets/pages_bar.dart | 337 ++++++++++++++++++++----------------- 1 file changed, 181 insertions(+), 156 deletions(-) diff --git a/lib/widgets/pages_bar.dart b/lib/widgets/pages_bar.dart index 89894f8a..65b578db 100644 --- a/lib/widgets/pages_bar.dart +++ b/lib/widgets/pages_bar.dart @@ -11,6 +11,9 @@ import 'package:icarus/widgets/custom_text_field.dart'; import 'package:icarus/widgets/dialogs/confirm_alert_dialog.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; +const double _pagesBarCornerRadius = 12; +const double _pagesBarInnerButtonRadius = 6; + class PagesBar extends ConsumerStatefulWidget { const PagesBar({super.key}); @@ -24,7 +27,6 @@ class _PagesBarState extends ConsumerState { static const double _minWidth = 224; static const double _maxWidth = 420; static const double _widthResizeHandleWidth = 8; - static const double _barRadius = 12; static final double _minExpandedHeight = _ExpandedPanel.minHeightForVisibleRows( 2, @@ -310,7 +312,7 @@ class _PagesBarState extends ConsumerState { key: _barKey, decoration: BoxDecoration( color: Settings.tacticalVioletTheme.card, - borderRadius: BorderRadius.circular(_barRadius), + borderRadius: BorderRadius.circular(_pagesBarCornerRadius), border: Border.all( color: Settings.tacticalVioletTheme.border, width: 2, @@ -407,7 +409,6 @@ class _CollapsedPill extends StatelessWidget { onPressed: onToggle, icon: const Icon(Icons.keyboard_arrow_down, color: Colors.white), ), - const SizedBox(width: 4), ], ), ); @@ -506,63 +507,67 @@ class _ExpandedPanel extends ConsumerWidget { Expanded( child: Padding( padding: const EdgeInsets.only(top: _topPadding), - child: ReorderableListView.builder( - onReorder: (oldIndex, newIndex) { - ref - .read(strategyProvider.notifier) - .reorderPage(oldIndex, newIndex); - }, - padding: const EdgeInsets.fromLTRB(8, 0, 0, 8), - shrinkWrap: false, - physics: - needsScroll ? null : const NeverScrollableScrollPhysics(), - itemCount: pages.length, - buildDefaultDragHandles: false, - proxyDecorator: proxyDecorator, - itemBuilder: (ctx, i) { - bool showForwardIndicator = false; - bool showBackwardIndicator = false; - final p = pages[i]; - - if (pages.length != 1) { - if (pages.length == 2) { - if (activeIndex == 0 && activeIndex != i) { - showForwardIndicator = true; - } else if (activeIndex == 1 && activeIndex != i) { - showBackwardIndicator = true; - } - } else { - if (forwardIndex != null && i == forwardIndex) { - showForwardIndicator = true; - } - if (backwardIndex != null && - i == backwardIndex && - forwardIndex != backwardIndex) { - showBackwardIndicator = true; + child: ScrollConfiguration( + behavior: + ScrollConfiguration.of(context).copyWith(scrollbars: false), + child: ReorderableListView.builder( + onReorder: (oldIndex, newIndex) { + ref + .read(strategyProvider.notifier) + .reorderPage(oldIndex, newIndex); + }, + padding: const EdgeInsets.fromLTRB(8, 0, 0, 8), + shrinkWrap: false, + physics: + needsScroll ? null : const NeverScrollableScrollPhysics(), + itemCount: pages.length, + buildDefaultDragHandles: false, + proxyDecorator: proxyDecorator, + itemBuilder: (ctx, i) { + bool showForwardIndicator = false; + bool showBackwardIndicator = false; + final p = pages[i]; + + if (pages.length != 1) { + if (pages.length == 2) { + if (activeIndex == 0 && activeIndex != i) { + showForwardIndicator = true; + } else if (activeIndex == 1 && activeIndex != i) { + showBackwardIndicator = true; + } + } else { + if (forwardIndex != null && i == forwardIndex) { + showForwardIndicator = true; + } + if (backwardIndex != null && + i == backwardIndex && + forwardIndex != backwardIndex) { + showBackwardIndicator = true; + } } } - } - return ReorderableDragStartListener( - key: ValueKey(p.id), - index: i, - child: Padding( - padding: const EdgeInsets.only(bottom: 8), - child: _PageRow( - page: p, - active: p.id == activePageId, - showBackwardIndicator: showBackwardIndicator, - showForwardIndicator: showForwardIndicator, - transitionProgress: - _rowTransitionProgress(transitionState, p.id), - onSelect: onSelect, - onRename: onRename, - onDelete: onDelete, - disableDelete: pages.length == 1, + return ReorderableDragStartListener( + key: ValueKey(p.id), + index: i, + child: Padding( + padding: const EdgeInsets.only(bottom: 8), + child: _PageRow( + page: p, + active: p.id == activePageId, + showBackwardIndicator: showBackwardIndicator, + showForwardIndicator: showForwardIndicator, + transitionProgress: + _rowTransitionProgress(transitionState, p.id), + onSelect: onSelect, + onRename: onRename, + onDelete: onDelete, + disableDelete: pages.length == 1, + ), ), - ), - ); - }, + ); + }, + ), ), ), ), @@ -586,7 +591,6 @@ class _ExpandedPanel extends ConsumerWidget { icon: const Icon(Icons.keyboard_arrow_up, color: Colors.white), ), - const SizedBox(width: 4), ], ), ), @@ -709,7 +713,7 @@ class _ResizeHandleStatefulState extends State<_ResizeHandleStateful> { } } -class _PageRow extends StatelessWidget { +class _PageRow extends StatefulWidget { const _PageRow({ required this.page, required this.active, @@ -735,115 +739,136 @@ class _PageRow extends StatelessWidget { static const double _rowHeight = 40; static const double _rowRadius = 6; + @override + State<_PageRow> createState() => _PageRowState(); +} + +class _PageRowState extends State<_PageRow> { + bool _hovered = false; + @override Widget build(BuildContext context) { final theme = Theme.of(context); - final fillProgress = transitionProgress?.clamp(0.0, 1.0); - final bg = active && fillProgress == null + final fillProgress = widget.transitionProgress?.clamp(0.0, 1.0); + final showActions = + _hovered || widget.active || widget.transitionProgress != null; + final bg = widget.active && fillProgress == null ? Settings.tacticalVioletTheme.primary : Settings.tacticalVioletTheme.card; - return Material( - // color: bg, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(_rowRadius), - ), - child: InkWell( - mouseCursor: SystemMouseCursors.click, - borderRadius: BorderRadius.circular(_rowRadius), - onTap: () => onSelect(page.id), - child: ClipRRect( - borderRadius: BorderRadius.circular(_rowRadius), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(_rowRadius), - border: Border.all( - color: Settings.tacticalVioletTheme.border, - width: 1, + return MouseRegion( + onEnter: (_) => setState(() => _hovered = true), + onExit: (_) => setState(() => _hovered = false), + child: Material( + // color: bg, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(_PageRow._rowRadius), + ), + child: InkWell( + mouseCursor: SystemMouseCursors.click, + borderRadius: BorderRadius.circular(_PageRow._rowRadius), + onTap: () => widget.onSelect(widget.page.id), + child: ClipRRect( + borderRadius: BorderRadius.circular(_PageRow._rowRadius), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(_PageRow._rowRadius), + border: Border.all( + color: Settings.tacticalVioletTheme.border, + width: 1, + ), + boxShadow: [ + BoxShadow( + color: Settings.tacticalVioletTheme.card + .withValues(alpha: 0.2), + blurRadius: 12, + offset: const Offset(0, 4)) + ], + color: bg, ), - boxShadow: [ - BoxShadow( - color: Settings.tacticalVioletTheme.card - .withValues(alpha: 0.2), - blurRadius: 12, - offset: const Offset(0, 4)) - ], - color: bg, - ), - height: _rowHeight, - child: Stack( - children: [ - if (fillProgress != null) - Positioned.fill( - child: FractionallySizedBox( - widthFactor: fillProgress, - alignment: Alignment.centerLeft, - child: DecoratedBox( - decoration: BoxDecoration( - color: Settings.tacticalVioletTheme.primary, - ), - ), - ), - ), - Padding( - padding: const EdgeInsets.only(left: 12), - child: Row( - children: [ - Expanded( - child: Text( - page.name, - overflow: TextOverflow.ellipsis, - style: theme.textTheme.titleMedium?.copyWith( - color: Colors.white, - fontWeight: - active ? FontWeight.w600 : FontWeight.w500, - fontSize: 14, + height: _PageRow._rowHeight, + child: Stack( + children: [ + if (fillProgress != null) + Positioned.fill( + child: FractionallySizedBox( + widthFactor: fillProgress, + alignment: Alignment.centerLeft, + child: DecoratedBox( + decoration: BoxDecoration( + color: Settings.tacticalVioletTheme.primary, ), ), ), - if (showBackwardIndicator || showForwardIndicator) ...[ - const SizedBox(width: 6), - if (showBackwardIndicator) - const _KeybindBadge(label: "A"), - if (showBackwardIndicator && showForwardIndicator) - const SizedBox(width: 4), - if (showForwardIndicator) - const _KeybindBadge(label: "D"), - const SizedBox(width: 2), - ], - ShadTooltip( - builder: (context) => const Text("Rename"), - child: ShadIconButton.ghost( - width: 24, - hoverBackgroundColor: Colors.transparent, - foregroundColor: Colors.white, - icon: const Icon(LucideIcons.pen, - size: 18, color: Colors.white), - onPressed: () => onRename(page), - ), - ), - const SizedBox(width: 2), - ShadTooltip( - builder: (context) => const Text("Delete"), - child: ShadIconButton.ghost( - width: 24, - hoverForegroundColor: - Settings.tacticalVioletTheme.destructive, - hoverBackgroundColor: Colors.transparent, - foregroundColor: - disableDelete ? Colors.white24 : Colors.white, - icon: const Icon( - LucideIcons.trash, - size: 18, + ), + Positioned.fill( + child: Padding( + padding: const EdgeInsets.only(left: 12, right: 8), + child: Row( + children: [ + Expanded( + child: Text( + widget.page.name, + overflow: TextOverflow.ellipsis, + style: theme.textTheme.titleMedium?.copyWith( + color: Colors.white, + fontWeight: widget.active + ? FontWeight.w600 + : FontWeight.w500, + fontSize: 14, + ), + ), ), - onPressed: - disableDelete ? null : () => onDelete(page), - ), + if (widget.showBackwardIndicator || + widget.showForwardIndicator) ...[ + const SizedBox(width: 6), + if (widget.showBackwardIndicator) + const _KeybindBadge(label: "A"), + if (widget.showBackwardIndicator && + widget.showForwardIndicator) + const SizedBox(width: 4), + if (widget.showForwardIndicator) + const _KeybindBadge(label: "D"), + const SizedBox(width: 2), + ], + if (showActions) ...[ + ShadTooltip( + builder: (context) => const Text("Rename"), + child: ShadIconButton.ghost( + width: 24, + hoverBackgroundColor: Colors.transparent, + foregroundColor: Colors.white, + icon: const Icon(LucideIcons.pen, + size: 18, color: Colors.white), + onPressed: () => widget.onRename(widget.page), + ), + ), + const SizedBox(width: 2), + ShadTooltip( + builder: (context) => const Text("Delete"), + child: ShadIconButton.ghost( + width: 24, + hoverForegroundColor: + Settings.tacticalVioletTheme.destructive, + hoverBackgroundColor: Colors.transparent, + foregroundColor: widget.disableDelete + ? Colors.white24 + : Colors.white, + icon: const Icon( + LucideIcons.trash, + size: 18, + ), + onPressed: widget.disableDelete + ? null + : () => widget.onDelete(widget.page), + ), + ), + ], + ], ), - const SizedBox(width: 4), - ], + ), ), - ), - ], + ], + ), ), ), ), @@ -915,7 +940,7 @@ class _SquareIconButton extends StatelessWidget { onPressed: onTap, decoration: ShadDecoration( border: ShadBorder( - radius: BorderRadius.circular(12), + radius: BorderRadius.circular(_pagesBarInnerButtonRadius), ), ), ), From fbfdca97e2cc6f39e98592b4b0db77c18900a1d1 Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Fri, 1 May 2026 15:24:54 -0400 Subject: [PATCH 15/26] Route custom colors through the controller state - Read custom color library entries from `ColorLibraryController` - Stop watching preferences directly in the controller build - Keep controller state in sync before persisting preference updates --- lib/providers/color_library_provider.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/providers/color_library_provider.dart b/lib/providers/color_library_provider.dart index abcd1c2f..e4123d33 100644 --- a/lib/providers/color_library_provider.dart +++ b/lib/providers/color_library_provider.dart @@ -25,8 +25,8 @@ final defaultColorLibraryProvider = Provider>((ref) { }); final customColorLibraryProvider = Provider>((ref) { - final prefs = ref.watch(appPreferencesProvider); - return prefs.customColorValues.map(Color.new).toList(growable: false); + final colorValues = ref.watch(colorLibraryControllerProvider); + return colorValues.map(Color.new).toList(growable: false); }); final colorLibraryProvider = Provider>((ref) { @@ -45,7 +45,7 @@ class ColorLibraryController extends Notifier> { @override List build() { - return ref.watch(appPreferencesProvider).customColorValues; + return ref.read(appPreferencesProvider).customColorValues; } bool get canAddColor => state.length < customColorLimit; @@ -69,6 +69,7 @@ class ColorLibraryController extends Notifier> { } Future _save(List colorValues) async { + state = colorValues; await ref .read(appPreferencesProvider.notifier) .setCustomColorValues(colorValues); From 74e012d54d7c63c55589447d60c8ff54f745df31 Mon Sep 17 00:00:00 2001 From: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Date: Fri, 1 May 2026 15:32:54 -0400 Subject: [PATCH 16/26] Support duplicate-drag ability moves - Duplicate abilities on modifier-assisted drag - Track dragged IDs through drop handlers - Update ability widget tests for the new callback signature --- lib/providers/ability_provider.dart | 30 ++++++++++++++ .../ability/placed_ability_widget.dart | 40 +++++++++++++++++-- .../placed_deadlock_barrier_mesh_widget.dart | 17 +++++++- .../placed_widget_builder.dart | 6 +-- lib/widgets/line_up_placer.dart | 2 +- test/ability_visibility_widgets_test.dart | 14 +++---- test/resizable_square_ability_test.dart | 2 +- test/sector_circle_ability_test.dart | 3 +- 8 files changed, 94 insertions(+), 20 deletions(-) diff --git a/lib/providers/ability_provider.dart b/lib/providers/ability_provider.dart index 824875ad..a863aa64 100644 --- a/lib/providers/ability_provider.dart +++ b/lib/providers/ability_provider.dart @@ -9,6 +9,7 @@ import 'package:icarus/const/placed_classes.dart'; import 'package:icarus/providers/action_provider.dart'; import 'package:icarus/providers/map_provider.dart'; import 'package:icarus/providers/strategy_settings_provider.dart'; +import 'package:uuid/uuid.dart'; final abilityProvider = NotifierProvider>(AbilityProvider.new); @@ -33,6 +34,8 @@ class AbilitySnapshot { class AbilityProvider extends Notifier> { List poppedAbility = []; List snapshots = []; + static const _uuid = Uuid(); + @override List build() { return []; @@ -98,6 +101,33 @@ class AbilityProvider extends Notifier> { state = [...newState, temp]; } + String? duplicateAbilityAt({ + required String sourceId, + required Offset position, + }) { + final sourceIndex = PlacedWidget.getIndexByID(sourceId, state); + if (sourceIndex < 0) return null; + + final sourceAbility = state[sourceIndex]; + final coordinateSystem = CoordinateSystem.instance; + final mapState = ref.read(mapProvider); + final mapScale = Maps.mapScale[mapState.currentMap] ?? 1.0; + final abilitySize = ref.read(strategySettingsProvider).abilitySize; + final centerOffset = sourceAbility.data.abilityData! + .getAnchorPoint(mapScale: mapScale, abilitySize: abilitySize); + final centerPosition = + Offset(position.dx + centerOffset.dx, position.dy + centerOffset.dy); + + if (coordinateSystem.isOutOfBounds(centerPosition)) return null; + + final duplicatedAbility = sourceAbility.copyWith( + id: _uuid.v4(), + position: position, + ); + addAbility(duplicatedAbility); + return duplicatedAbility.id; + } + void switchSides() { if (state.isEmpty && poppedAbility.isEmpty) return; diff --git a/lib/widgets/draggable_widgets/ability/placed_ability_widget.dart b/lib/widgets/draggable_widgets/ability/placed_ability_widget.dart index 1d23db46..32bc3ac0 100644 --- a/lib/widgets/draggable_widgets/ability/placed_ability_widget.dart +++ b/lib/widgets/draggable_widgets/ability/placed_ability_widget.dart @@ -8,6 +8,7 @@ import 'package:icarus/const/placed_classes.dart'; import 'package:icarus/const/settings.dart'; import 'package:icarus/const/transition_data.dart'; import 'package:icarus/providers/ability_provider.dart'; +import 'package:icarus/providers/duplicate_drag_modifier_provider.dart'; import 'package:icarus/providers/map_provider.dart'; import 'package:icarus/providers/screen_zoom_provider.dart'; import 'package:icarus/providers/strategy_settings_provider.dart'; @@ -43,7 +44,7 @@ bool _shouldShowRotatableHandle( class PlacedAbilityWidget extends ConsumerStatefulWidget { final PlacedAbility ability; - final Function(DraggableDetails details) onDragEnd; + final void Function(DraggableDetails details, String draggedId) onDragEnd; final String id; final PlacedWidget data; final double rotation; @@ -74,6 +75,7 @@ class _PlacedAbilityWidgetState extends ConsumerState { double? localRotation; double? localLength; bool isDragging = false; + String? _activeDragId; double _resolvedLengthFor(PlacedAbility ability, double rawLength) { final abilityData = ability.data.abilityData; @@ -174,7 +176,7 @@ class _PlacedAbilityWidgetState extends ConsumerState { ), ), childWhenDragging: const SizedBox.shrink(), - onDragEnd: widget.onDragEnd, + onDragEnd: (details) => widget.onDragEnd(details, widget.id), child: widget.ability.data.abilityData!.createWidget( id: widget.id, isAlly: isAlly, @@ -342,15 +344,26 @@ class _PlacedAbilityWidgetState extends ConsumerState { ), childWhenDragging: const SizedBox.shrink(), onDragStarted: () { + final shouldDuplicate = + !widget.isLineUp && ref.read(duplicateDragModifierProvider); + final duplicateId = shouldDuplicate + ? ref.read(abilityProvider.notifier).duplicateAbilityAt( + sourceId: abilityRef.id, + position: abilityRef.position, + ) + : null; setState(() { isDragging = true; + _activeDragId = duplicateId ?? abilityRef.id; }); }, onDragEnd: (DraggableDetails details) { + final dragId = _activeDragId ?? abilityRef.id; setState(() { isDragging = false; + _activeDragId = null; }); - widget.onDragEnd(details); + widget.onDragEnd(details, dragId); }, // dragAnchorStrategy: pointDragAnchorStrategy, child: abilityData.createWidget( @@ -392,7 +405,26 @@ class _PlacedAbilityWidgetState extends ConsumerState { )), ), childWhenDragging: const SizedBox.shrink(), - onDragEnd: widget.onDragEnd, + onDragStarted: () { + final shouldDuplicate = + !widget.isLineUp && ref.read(duplicateDragModifierProvider); + final duplicateId = shouldDuplicate + ? ref.read(abilityProvider.notifier).duplicateAbilityAt( + sourceId: abilityRef.id, + position: abilityRef.position, + ) + : null; + setState(() { + _activeDragId = duplicateId ?? abilityRef.id; + }); + }, + onDragEnd: (details) { + final dragId = _activeDragId ?? abilityRef.id; + setState(() { + _activeDragId = null; + }); + widget.onDragEnd(details, dragId); + }, child: widget.ability.data.abilityData!.createWidget( id: widget.id, isAlly: isAlly, diff --git a/lib/widgets/draggable_widgets/ability/placed_deadlock_barrier_mesh_widget.dart b/lib/widgets/draggable_widgets/ability/placed_deadlock_barrier_mesh_widget.dart index f159fc71..ea1e8b48 100644 --- a/lib/widgets/draggable_widgets/ability/placed_deadlock_barrier_mesh_widget.dart +++ b/lib/widgets/draggable_widgets/ability/placed_deadlock_barrier_mesh_widget.dart @@ -12,6 +12,7 @@ import 'package:icarus/const/placed_classes.dart'; import 'package:icarus/const/settings.dart'; import 'package:icarus/const/transition_data.dart'; import 'package:icarus/providers/ability_provider.dart'; +import 'package:icarus/providers/duplicate_drag_modifier_provider.dart'; import 'package:icarus/providers/map_provider.dart'; import 'package:icarus/providers/screen_zoom_provider.dart'; import 'package:icarus/providers/screenshot_provider.dart'; @@ -33,7 +34,7 @@ class PlacedDeadlockBarrierMeshWidget extends ConsumerStatefulWidget { }); final PlacedAbility ability; - final void Function(DraggableDetails details) onDragEnd; + final void Function(DraggableDetails details, String draggedId) onDragEnd; final String id; final PlacedWidget data; final bool isLineUp; @@ -56,6 +57,7 @@ class _PlacedDeadlockBarrierMeshWidgetState bool _isDragging = false; bool _isRotating = false; bool _isRotationHandleHovered = false; + String? _activeDragId; Offset _rotationOriginGlobal = Offset.zero; late final AnimationController _animationController; late final Animation _scaleAnimation; @@ -206,14 +208,25 @@ class _PlacedDeadlockBarrierMeshWidgetState ), childWhenDragging: const SizedBox.shrink(), onDragStarted: () { + final shouldDuplicate = + !widget.isLineUp && ref.read(duplicateDragModifierProvider); + final duplicateId = shouldDuplicate + ? ref.read(abilityProvider.notifier).duplicateAbilityAt( + sourceId: abilityRef.id, + position: abilityRef.position, + ) + : null; setState(() { _isDragging = true; + _activeDragId = duplicateId ?? abilityRef.id; }); }, onDragEnd: (details) { - widget.onDragEnd(details); + final dragId = _activeDragId ?? abilityRef.id; + widget.onDragEnd(details, dragId); setState(() { _isDragging = false; + _activeDragId = null; }); }, child: AbilityWidget( diff --git a/lib/widgets/draggable_widgets/placed_widget_builder.dart b/lib/widgets/draggable_widgets/placed_widget_builder.dart index e65ff6fb..9ab97fa3 100644 --- a/lib/widgets/draggable_widgets/placed_widget_builder.dart +++ b/lib/widgets/draggable_widgets/placed_widget_builder.dart @@ -369,7 +369,7 @@ class _AbilityList extends ConsumerWidget { ability: ability, id: ability.id, length: ability.length, - onDragEnd: (details) { + onDragEnd: (details, draggedId) { final renderBox = context.findRenderObject() as RenderBox; final localOffset = renderBox.globalToLocal(details.offset); final virtualOffset = @@ -381,13 +381,13 @@ class _AbilityList extends ConsumerWidget { virtualOffset.translate(safeArea.dx, safeArea.dy))) { ref .read(abilityProvider.notifier) - .removeAbilityAsAction(ability.id); + .removeAbilityAsAction(draggedId); return; } ref .read(abilityProvider.notifier) - .updatePosition(virtualOffset, ability.id); + .updatePosition(virtualOffset, draggedId); }, ), ], diff --git a/lib/widgets/line_up_placer.dart b/lib/widgets/line_up_placer.dart index 21af8ea9..e88803b7 100644 --- a/lib/widgets/line_up_placer.dart +++ b/lib/widgets/line_up_placer.dart @@ -75,7 +75,7 @@ class _LineupPositionWidgetState extends ConsumerState { id: lineUp.currentAbility!.id, length: lineUp.currentAbility!.length, isLineUp: true, - onDragEnd: (details) { + onDragEnd: (details, _) { RenderBox renderBox = context.findRenderObject() as RenderBox; Offset localOffset = diff --git a/test/ability_visibility_widgets_test.dart b/test/ability_visibility_widgets_test.dart index d7ef3c56..b8a52a3b 100644 --- a/test/ability_visibility_widgets_test.dart +++ b/test/ability_visibility_widgets_test.dart @@ -82,7 +82,7 @@ void main() { children: [ PlacedAbilityWidget( ability: ability, - onDragEnd: (_) {}, + onDragEnd: (_, __) {}, id: ability.id, data: ability, rotation: ability.rotation, @@ -237,7 +237,7 @@ void main() { children: [ PlacedAbilityWidget( ability: ability, - onDragEnd: (_) {}, + onDragEnd: (_, __) {}, id: ability.id, data: ability, rotation: ability.rotation, @@ -292,7 +292,7 @@ void main() { children: [ PlacedAbilityWidget( ability: ability, - onDragEnd: (_) {}, + onDragEnd: (_, __) {}, id: ability.id, data: ability, rotation: ability.rotation, @@ -420,7 +420,7 @@ void main() { children: [ PlacedAbilityWidget( ability: sectorAbility, - onDragEnd: (_) {}, + onDragEnd: (_, __) {}, id: sectorAbility.id, data: sectorAbility, rotation: sectorAbility.rotation, @@ -1163,7 +1163,7 @@ Future _pumpPlacedAbility( children: [ PlacedAbilityWidget( ability: ability, - onDragEnd: (_) {}, + onDragEnd: (_, __) {}, id: ability.id, data: ability, rotation: ability.rotation, @@ -1194,6 +1194,8 @@ ProviderContainer _createLineUpContainer() { ); } + + Future _pumpLineUpAbilities( WidgetTester tester, { required ProviderContainer container, @@ -1280,5 +1282,3 @@ AbilityInfo _sectorAbilityInfo() { ), ); } - - diff --git a/test/resizable_square_ability_test.dart b/test/resizable_square_ability_test.dart index 62e0961e..c2515192 100644 --- a/test/resizable_square_ability_test.dart +++ b/test/resizable_square_ability_test.dart @@ -198,7 +198,7 @@ void main() { children: [ PlacedAbilityWidget( ability: placedAbility, - onDragEnd: (_) {}, + onDragEnd: (_, __) {}, id: placedAbility.id, data: placedAbility, rotation: placedAbility.rotation, diff --git a/test/sector_circle_ability_test.dart b/test/sector_circle_ability_test.dart index 286229b6..07fc4005 100644 --- a/test/sector_circle_ability_test.dart +++ b/test/sector_circle_ability_test.dart @@ -555,7 +555,7 @@ class _PlacedSectorAbilityHarness extends ConsumerWidget { children: [ PlacedAbilityWidget( ability: ability, - onDragEnd: (_) {}, + onDragEnd: (_, __) {}, id: ability.id, data: ability, rotation: ability.rotation, @@ -627,4 +627,3 @@ SectorCirclePainter _sectorPainter(WidgetTester tester) { return customPaint.painter! as SectorCirclePainter; } - From 66699bb9e6e38a9d6d6fbe4fc2c1f092179a59c3 Mon Sep 17 00:00:00 2001 From: Dara Adedeji Date: Mon, 4 May 2026 20:11:25 -0400 Subject: [PATCH 17/26] Add impeccable design skill scaffolding - Add the impeccable skill docs, commands, and references - Update map theme and settings UI to match the new design flow - Refresh strategy folder import test expectations --- .agents/skills/impeccable/SKILL.md | 176 + .agents/skills/impeccable/agents/openai.yaml | 4 + .agents/skills/impeccable/reference/adapt.md | 190 + .../skills/impeccable/reference/animate.md | 175 + .agents/skills/impeccable/reference/audit.md | 133 + .agents/skills/impeccable/reference/bolder.md | 113 + .agents/skills/impeccable/reference/brand.md | 114 + .../skills/impeccable/reference/clarify.md | 174 + .../impeccable/reference/cognitive-load.md | 106 + .../reference/color-and-contrast.md | 105 + .../skills/impeccable/reference/colorize.md | 154 + .agents/skills/impeccable/reference/craft.md | 193 + .../skills/impeccable/reference/critique.md | 213 + .../skills/impeccable/reference/delight.md | 302 + .../skills/impeccable/reference/distill.md | 111 + .../skills/impeccable/reference/document.md | 427 ++ .../skills/impeccable/reference/extract.md | 69 + .agents/skills/impeccable/reference/harden.md | 347 ++ .../reference/heuristics-scoring.md | 234 + .../reference/interaction-design.md | 195 + .agents/skills/impeccable/reference/layout.md | 141 + .agents/skills/impeccable/reference/live.md | 622 +++ .../impeccable/reference/motion-design.md | 109 + .../skills/impeccable/reference/onboard.md | 234 + .../skills/impeccable/reference/optimize.md | 258 + .../skills/impeccable/reference/overdrive.md | 130 + .../skills/impeccable/reference/personas.md | 179 + .agents/skills/impeccable/reference/polish.md | 233 + .../skills/impeccable/reference/product.md | 62 + .../skills/impeccable/reference/quieter.md | 99 + .../impeccable/reference/responsive-design.md | 114 + .agents/skills/impeccable/reference/shape.md | 151 + .../impeccable/reference/spatial-design.md | 100 + .agents/skills/impeccable/reference/teach.md | 156 + .../skills/impeccable/reference/typeset.md | 124 + .../skills/impeccable/reference/typography.md | 159 + .../skills/impeccable/reference/ux-writing.md | 107 + .../impeccable/scripts/cleanup-deprecated.mjs | 284 + .../impeccable/scripts/command-metadata.json | 94 + .../impeccable/scripts/design-parser.mjs | 820 +++ .../skills/impeccable/scripts/detect-csp.mjs | 198 + .../impeccable/scripts/impeccable-paths.mjs | 105 + .../impeccable/scripts/is-generated.mjs | 69 + .../skills/impeccable/scripts/live-accept.mjs | 595 ++ .../scripts/live-browser-session.js | 123 + .../skills/impeccable/scripts/live-browser.js | 4860 +++++++++++++++++ .../impeccable/scripts/live-complete.mjs | 75 + .../impeccable/scripts/live-completion.mjs | 18 + .../skills/impeccable/scripts/live-inject.mjs | 446 ++ .../skills/impeccable/scripts/live-poll.mjs | 200 + .../skills/impeccable/scripts/live-resume.mjs | 48 + .../skills/impeccable/scripts/live-server.mjs | 836 +++ .../impeccable/scripts/live-session-store.mjs | 254 + .../skills/impeccable/scripts/live-status.mjs | 47 + .../skills/impeccable/scripts/live-wrap.mjs | 632 +++ .agents/skills/impeccable/scripts/live.mjs | 247 + .../impeccable/scripts/load-context.mjs | 141 + .../scripts/modern-screenshot.umd.js | 14 + .agents/skills/impeccable/scripts/pin.mjs | 214 + .impeccable/design.json | 245 + DESIGN.md | 278 + PRODUCT.md | 41 + lib/providers/map_theme_provider.dart | 8 +- lib/widgets/map_theme_settings_section.dart | 266 +- lib/widgets/save_and_load_button.dart | 3 +- lib/widgets/settings_scope_card.dart | 18 +- lib/widgets/settings_tab.dart | 868 ++- skills-lock.json | 11 + test/strategy_folder_import_test.dart | 26 +- 69 files changed, 18223 insertions(+), 374 deletions(-) create mode 100644 .agents/skills/impeccable/SKILL.md create mode 100644 .agents/skills/impeccable/agents/openai.yaml create mode 100644 .agents/skills/impeccable/reference/adapt.md create mode 100644 .agents/skills/impeccable/reference/animate.md create mode 100644 .agents/skills/impeccable/reference/audit.md create mode 100644 .agents/skills/impeccable/reference/bolder.md create mode 100644 .agents/skills/impeccable/reference/brand.md create mode 100644 .agents/skills/impeccable/reference/clarify.md create mode 100644 .agents/skills/impeccable/reference/cognitive-load.md create mode 100644 .agents/skills/impeccable/reference/color-and-contrast.md create mode 100644 .agents/skills/impeccable/reference/colorize.md create mode 100644 .agents/skills/impeccable/reference/craft.md create mode 100644 .agents/skills/impeccable/reference/critique.md create mode 100644 .agents/skills/impeccable/reference/delight.md create mode 100644 .agents/skills/impeccable/reference/distill.md create mode 100644 .agents/skills/impeccable/reference/document.md create mode 100644 .agents/skills/impeccable/reference/extract.md create mode 100644 .agents/skills/impeccable/reference/harden.md create mode 100644 .agents/skills/impeccable/reference/heuristics-scoring.md create mode 100644 .agents/skills/impeccable/reference/interaction-design.md create mode 100644 .agents/skills/impeccable/reference/layout.md create mode 100644 .agents/skills/impeccable/reference/live.md create mode 100644 .agents/skills/impeccable/reference/motion-design.md create mode 100644 .agents/skills/impeccable/reference/onboard.md create mode 100644 .agents/skills/impeccable/reference/optimize.md create mode 100644 .agents/skills/impeccable/reference/overdrive.md create mode 100644 .agents/skills/impeccable/reference/personas.md create mode 100644 .agents/skills/impeccable/reference/polish.md create mode 100644 .agents/skills/impeccable/reference/product.md create mode 100644 .agents/skills/impeccable/reference/quieter.md create mode 100644 .agents/skills/impeccable/reference/responsive-design.md create mode 100644 .agents/skills/impeccable/reference/shape.md create mode 100644 .agents/skills/impeccable/reference/spatial-design.md create mode 100644 .agents/skills/impeccable/reference/teach.md create mode 100644 .agents/skills/impeccable/reference/typeset.md create mode 100644 .agents/skills/impeccable/reference/typography.md create mode 100644 .agents/skills/impeccable/reference/ux-writing.md create mode 100644 .agents/skills/impeccable/scripts/cleanup-deprecated.mjs create mode 100644 .agents/skills/impeccable/scripts/command-metadata.json create mode 100644 .agents/skills/impeccable/scripts/design-parser.mjs create mode 100644 .agents/skills/impeccable/scripts/detect-csp.mjs create mode 100644 .agents/skills/impeccable/scripts/impeccable-paths.mjs create mode 100644 .agents/skills/impeccable/scripts/is-generated.mjs create mode 100644 .agents/skills/impeccable/scripts/live-accept.mjs create mode 100644 .agents/skills/impeccable/scripts/live-browser-session.js create mode 100644 .agents/skills/impeccable/scripts/live-browser.js create mode 100644 .agents/skills/impeccable/scripts/live-complete.mjs create mode 100644 .agents/skills/impeccable/scripts/live-completion.mjs create mode 100644 .agents/skills/impeccable/scripts/live-inject.mjs create mode 100644 .agents/skills/impeccable/scripts/live-poll.mjs create mode 100644 .agents/skills/impeccable/scripts/live-resume.mjs create mode 100644 .agents/skills/impeccable/scripts/live-server.mjs create mode 100644 .agents/skills/impeccable/scripts/live-session-store.mjs create mode 100644 .agents/skills/impeccable/scripts/live-status.mjs create mode 100644 .agents/skills/impeccable/scripts/live-wrap.mjs create mode 100644 .agents/skills/impeccable/scripts/live.mjs create mode 100644 .agents/skills/impeccable/scripts/load-context.mjs create mode 100644 .agents/skills/impeccable/scripts/modern-screenshot.umd.js create mode 100644 .agents/skills/impeccable/scripts/pin.mjs create mode 100644 .impeccable/design.json create mode 100644 DESIGN.md create mode 100644 PRODUCT.md create mode 100644 skills-lock.json diff --git a/.agents/skills/impeccable/SKILL.md b/.agents/skills/impeccable/SKILL.md new file mode 100644 index 00000000..25044b37 --- /dev/null +++ b/.agents/skills/impeccable/SKILL.md @@ -0,0 +1,176 @@ +--- +name: impeccable +description: Use when the user wants to design, redesign, shape, critique, audit, polish, clarify, distill, harden, optimize, adapt, animate, colorize, extract, or otherwise improve a frontend interface. Covers websites, landing pages, dashboards, product UI, app shells, components, forms, settings, onboarding, and empty states. Handles UX review, visual hierarchy, information architecture, cognitive load, accessibility, performance, responsive behavior, theming, anti-patterns, typography, fonts, spacing, layout, alignment, color, motion, micro-interactions, UX copy, error states, edge cases, i18n, and reusable design systems or tokens. Also use for bland designs that need to become bolder or more delightful, loud designs that should become quieter, live browser iteration on UI elements, or ambitious visual effects that should feel technically extraordinary. Not for backend-only or non-UI tasks. +--- + +Designs and iterates production-grade frontend interfaces. Real working code, committed design choices, exceptional craft. + +## Setup (non-optional) + +Before any design work or file edits, pass these gates. Skipping them produces generic output that ignores the project. + +| Gate | Required check | If fail | +|---|---|---| +| Context | The PRODUCT.md / DESIGN.md loader result is known from `node .agents/skills/impeccable/scripts/load-context.mjs`. | Run the loader before continuing. | +| Product | PRODUCT.md exists and is not empty or placeholder (`[TODO]` markers, <200 chars). | Run `$impeccable teach`, refresh context, then resume. Never synthesize PRODUCT.md from the user's original prompt alone. | +| Command | The matching command reference is loaded when a sub-command is used. | Load the reference before continuing. | +| Craft | `$impeccable craft` has a user-confirmed shape brief for this task. `teach` / PRODUCT.md never counts as shape. | Run `$impeccable shape` and wait for explicit brief confirmation. | +| Image | Required visual probes / mocks are generated or skipped with a reason. | Resolve the image-generation gate in `shape.md` or `craft.md` before code. | +| Mutation | All active gates above pass. | Do not edit project files yet. | + +Codex-style agents must state this before editing files: + +```text +IMPECCABLE_PREFLIGHT: context=pass product=pass command_reference=pass shape=pass|not_required image_gate=pass|skipped: mutation=open +``` + +For `$impeccable craft`, `shape=pass` is only valid after a separate user response approving the shape design brief, or when the user provided an already-confirmed brief in the request. Do not mark `shape=pass` after writing PRODUCT.md, summarizing assumptions, or drafting an unconfirmed brief yourself. + +Other harnesses should follow the same checklist when they can expose this state. + +### 1. Context gathering + +Two files, case-insensitive. The loader looks at the project root by default and falls back to `.agents/context/` and `docs/` if the root is clean. Override with `IMPECCABLE_CONTEXT_DIR=path/to/dir` (absolute or relative to cwd). + +- **PRODUCT.md**: required. Users, brand, tone, anti-references, strategic principles. +- **DESIGN.md**: optional, strongly recommended. Colors, typography, elevation, components. + +Load both in one call: + +```bash +node .agents/skills/impeccable/scripts/load-context.mjs +``` + +Consume the full JSON output. Never pipe through `head`, `tail`, `grep`, or `jq`. The output's `contextDir` field tells you where the files were resolved from. + +If the output is already in this session's conversation history, don't re-run. Exceptions requiring a fresh load: you just ran `$impeccable teach` or `$impeccable document` (they rewrite the files), or the user manually edited one. + +`$impeccable live` already warms context via `live.mjs`. If you've run `live.mjs`, don't also run `load-context.mjs` this session. + +If PRODUCT.md is missing, empty, or placeholder (`[TODO]` markers, <200 chars): run `$impeccable teach`, then resume the user's original task with the fresh context. If the original task was `$impeccable craft`, resume into `$impeccable shape` before any implementation work. + +If DESIGN.md is missing: nudge once per session (*"Run `$impeccable document` for more on-brand output"*), then proceed. + +### 2. Register + +Every design task is **brand** (marketing, landing, campaign, long-form content, portfolio: design IS the product) or **product** (app UI, admin, dashboard, tool: design SERVES the product). + +Identify before designing. Priority: (1) cue in the task itself ("landing page" vs "dashboard"); (2) the surface in focus (the page, file, or route being worked on); (3) `register` field in PRODUCT.md. First match wins. + +If PRODUCT.md lacks the `register` field (legacy), infer it once from its "Users" and "Product Purpose" sections, then cache the inferred value for the session. Suggest the user run `$impeccable teach` to add the field explicitly. + +Load the matching reference: [reference/brand.md](reference/brand.md) or [reference/product.md](reference/product.md). The shared design laws below apply to both. + +## Shared design laws + +Apply to every design, both registers. Match implementation complexity to the aesthetic vision: maximalism needs elaborate code, minimalism needs precision. Interpret creatively. Vary across projects; never converge on the same choices. GPT is capable of extraordinary work. Don't hold back. + +### Color + +- Use OKLCH. Reduce chroma as lightness approaches 0 or 100; high chroma at extremes looks garish. +- Never use `#000` or `#fff`. Tint every neutral toward the brand hue (chroma 0.005–0.01 is enough). +- Pick a **color strategy** before picking colors. Four steps on the commitment axis: + - **Restrained**: tinted neutrals + one accent ≤10%. Product default; brand minimalism. + - **Committed**: one saturated color carries 30–60% of the surface. Brand default for identity-driven pages. + - **Full palette**: 3–4 named roles, each used deliberately. Brand campaigns; product data viz. + - **Drenched**: the surface IS the color. Brand heroes, campaign pages. +- The "one accent ≤10%" rule is Restrained only. Committed / Full palette / Drenched exceed it on purpose. Don't collapse every design to Restrained by reflex. + +### Theme + +Dark vs. light is never a default. Not dark "because tools look cool dark." Not light "to be safe." + +Before choosing, write one sentence of physical scene: who uses this, where, under what ambient light, in what mood. If the sentence doesn't force the answer, it's not concrete enough. Add detail until it does. + +"Observability dashboard" does not force an answer. "SRE glancing at incident severity on a 27-inch monitor at 2am in a dim room" does. Run the sentence, not the category. + +### Typography + +- Cap body line length at 65–75ch. +- Hierarchy through scale + weight contrast (≥1.25 ratio between steps). Avoid flat scales. + +### Layout + +- Vary spacing for rhythm. Same padding everywhere is monotony. +- Cards are the lazy answer. Use them only when they're truly the best affordance. Nested cards are always wrong. +- Don't wrap everything in a container. Most things don't need one. + +### Motion + +- Don't animate CSS layout properties. +- Ease out with exponential curves (ease-out-quart / quint / expo). No bounce, no elastic. + +### Absolute bans + +Match-and-refuse. If you're about to write any of these, rewrite the element with different structure. + +- **Side-stripe borders.** `border-left` or `border-right` greater than 1px as a colored accent on cards, list items, callouts, or alerts. Never intentional. Rewrite with full borders, background tints, leading numbers/icons, or nothing. +- **Gradient text.** `background-clip: text` combined with a gradient background. Decorative, never meaningful. Use a single solid color. Emphasis via weight or size. +- **Glassmorphism as default.** Blurs and glass cards used decoratively. Rare and purposeful, or nothing. +- **The hero-metric template.** Big number, small label, supporting stats, gradient accent. SaaS cliché. +- **Identical card grids.** Same-sized cards with icon + heading + text, repeated endlessly. +- **Modal as first thought.** Modals are usually laziness. Exhaust inline / progressive alternatives first. + +### Copy + +- Every word earns its place. No restated headings, no intros that repeat the title. +- **No em dashes.** Use commas, colons, semicolons, periods, or parentheses. Also not `--`. + +### The AI slop test + +If someone could look at this interface and say "AI made that" without doubt, it's failed. Cross-register failures are the absolute bans above. Register-specific failures live in each reference. + +**Category-reflex check.** Run at two altitudes; the second one catches what the first one misses. + +- **First-order:** if someone could guess the theme + palette from the category alone ("observability → dark blue", "healthcare → white + teal", "finance → navy + gold", "crypto → neon on black"), it's the first training-data reflex. Rework the scene sentence and color strategy until the answer isn't obvious from the domain. +- **Second-order:** if someone could guess the aesthetic family from category-plus-anti-references ("AI workflow tool that's not SaaS-cream → editorial-typographic", "fintech that's not navy-and-gold → terminal-native dark mode"), it's the trap one tier deeper. The first reflex was avoided; the second wasn't. Rework until both answers are not obvious. The brand register's [reflex-reject aesthetic lanes](reference/brand.md) list catches the currently-saturated families. + +## Commands + +| Command | Category | Description | Reference | +|---|---|---|---| +| `craft [feature]` | Build | Shape, then build a feature end-to-end | [reference/craft.md](reference/craft.md) | +| `shape [feature]` | Build | Plan UX/UI before writing code | [reference/shape.md](reference/shape.md) | +| `teach` | Build | Set up PRODUCT.md and DESIGN.md context | [reference/teach.md](reference/teach.md) | +| `document` | Build | Generate DESIGN.md from existing project code | [reference/document.md](reference/document.md) | +| `extract [target]` | Build | Pull reusable tokens and components into design system | [reference/extract.md](reference/extract.md) | +| `critique [target]` | Evaluate | UX design review with heuristic scoring | [reference/critique.md](reference/critique.md) | +| `audit [target]` | Evaluate | Technical quality checks (a11y, perf, responsive) | [reference/audit.md](reference/audit.md) | +| `polish [target]` | Refine | Final quality pass before shipping | [reference/polish.md](reference/polish.md) | +| `bolder [target]` | Refine | Amplify safe or bland designs | [reference/bolder.md](reference/bolder.md) | +| `quieter [target]` | Refine | Tone down aggressive or overstimulating designs | [reference/quieter.md](reference/quieter.md) | +| `distill [target]` | Refine | Strip to essence, remove complexity | [reference/distill.md](reference/distill.md) | +| `harden [target]` | Refine | Production-ready: errors, i18n, edge cases | [reference/harden.md](reference/harden.md) | +| `onboard [target]` | Refine | Design first-run flows, empty states, activation | [reference/onboard.md](reference/onboard.md) | +| `animate [target]` | Enhance | Add purposeful animations and motion | [reference/animate.md](reference/animate.md) | +| `colorize [target]` | Enhance | Add strategic color to monochromatic UIs | [reference/colorize.md](reference/colorize.md) | +| `typeset [target]` | Enhance | Improve typography hierarchy and fonts | [reference/typeset.md](reference/typeset.md) | +| `layout [target]` | Enhance | Fix spacing, rhythm, and visual hierarchy | [reference/layout.md](reference/layout.md) | +| `delight [target]` | Enhance | Add personality and memorable touches | [reference/delight.md](reference/delight.md) | +| `overdrive [target]` | Enhance | Push past conventional limits | [reference/overdrive.md](reference/overdrive.md) | +| `clarify [target]` | Fix | Improve UX copy, labels, and error messages | [reference/clarify.md](reference/clarify.md) | +| `adapt [target]` | Fix | Adapt for different devices and screen sizes | [reference/adapt.md](reference/adapt.md) | +| `optimize [target]` | Fix | Diagnose and fix UI performance | [reference/optimize.md](reference/optimize.md) | +| `live` | Iterate | Visual variant mode: pick elements in the browser, generate alternatives | [reference/live.md](reference/live.md) | + +Plus two management commands: `pin ` and `unpin `, detailed below. + +### Routing rules + +1. **No argument**: render the table above as the user-facing command menu, grouped by category. Ask what they'd like to do. +2. **First word matches a command**: load its reference file and follow its instructions. Everything after the command name is the target. +3. **First word doesn't match**: general design invocation. Apply the setup steps, shared design laws, and the loaded register reference, using the full argument as context. + +Setup (context gathering, register) is already loaded by then; sub-commands don't re-invoke `$impeccable`. + +If the first word is `craft`, setup still runs first, but [reference/craft.md](reference/craft.md) owns the rest of the flow. If setup invokes `teach` as a blocker, finish teach, refresh context, then resume the original command and target. + +## Pin / Unpin + +**Pin** creates a standalone shortcut so `$` invokes `$impeccable ` directly. **Unpin** removes it. The script writes to every harness directory present in the project. + +```bash +node .agents/skills/impeccable/scripts/pin.mjs +``` + +Valid `` is any command from the table above. Report the script's result concisely. Confirm the new shortcut on success, relay stderr verbatim on error. \ No newline at end of file diff --git a/.agents/skills/impeccable/agents/openai.yaml b/.agents/skills/impeccable/agents/openai.yaml new file mode 100644 index 00000000..ee6cae77 --- /dev/null +++ b/.agents/skills/impeccable/agents/openai.yaml @@ -0,0 +1,4 @@ +interface: + display_name: Impeccable + short_description: Use when the user wants to design, redesign, shape, critique, audit, polish, clarify,... + default_prompt: Use Impeccable to redesign, critique, audit, or polish this frontend. \ No newline at end of file diff --git a/.agents/skills/impeccable/reference/adapt.md b/.agents/skills/impeccable/reference/adapt.md new file mode 100644 index 00000000..21bb0255 --- /dev/null +++ b/.agents/skills/impeccable/reference/adapt.md @@ -0,0 +1,190 @@ +> **Additional context needed**: target platforms/devices and usage contexts. + +Adapt an existing design to a different context: another screen size, device, platform, or use case. The trap is treating adaptation as scaling. The job is rethinking the experience for the new context. + + +--- + +## Assess Adaptation Challenge + +Understand what needs adaptation and why: + +1. **Identify the source context**: + - What was it designed for originally? (Desktop web? Mobile app?) + - What assumptions were made? (Large screen? Mouse input? Fast connection?) + - What works well in current context? + +2. **Understand target context**: + - **Device**: Mobile, tablet, desktop, TV, watch, print? + - **Input method**: Touch, mouse, keyboard, voice, gamepad? + - **Screen constraints**: Size, resolution, orientation? + - **Connection**: Fast wifi, slow 3G, offline? + - **Usage context**: On-the-go vs desk, quick glance vs focused reading? + - **User expectations**: What do users expect on this platform? + +3. **Identify adaptation challenges**: + - What won't fit? (Content, navigation, features) + - What won't work? (Hover states on touch, tiny touch targets) + - What's inappropriate? (Desktop patterns on mobile, mobile patterns on desktop) + +**CRITICAL**: Adaptation is rethinking the experience for the new context, not scaling pixels. + +## Plan Adaptation Strategy + +Create context-appropriate strategy: + +### Mobile Adaptation (Desktop → Mobile) + +**Layout Strategy**: +- Single column instead of multi-column +- Vertical stacking instead of side-by-side +- Full-width components instead of fixed widths +- Bottom navigation instead of top/side navigation + +**Interaction Strategy**: +- Touch targets 44x44px minimum (not hover-dependent) +- Swipe gestures where appropriate (lists, carousels) +- Bottom sheets instead of dropdowns +- Thumbs-first design (controls within thumb reach) +- Larger tap areas with more spacing + +**Content Strategy**: +- Progressive disclosure (don't show everything at once) +- Prioritize primary content (secondary content in tabs/accordions) +- Shorter text (more concise) +- Larger text (16px minimum) + +**Navigation Strategy**: +- Hamburger menu or bottom navigation +- Reduce navigation complexity +- Sticky headers for context +- Back button in navigation flow + +### Tablet Adaptation (Hybrid Approach) + +**Layout Strategy**: +- Two-column layouts (not single or three-column) +- Side panels for secondary content +- Master-detail views (list + detail) +- Adaptive based on orientation (portrait vs landscape) + +**Interaction Strategy**: +- Support both touch and pointer +- Touch targets 44x44px but allow denser layouts than phone +- Side navigation drawers +- Multi-column forms where appropriate + +### Desktop Adaptation (Mobile → Desktop) + +**Layout Strategy**: +- Multi-column layouts (use horizontal space) +- Side navigation always visible +- Multiple information panels simultaneously +- Fixed widths with max-width constraints (don't stretch to 4K) + +**Interaction Strategy**: +- Hover states for additional information +- Keyboard shortcuts +- Right-click context menus +- Drag and drop where helpful +- Multi-select with Shift/Cmd + +**Content Strategy**: +- Show more information upfront (less progressive disclosure) +- Data tables with many columns +- Richer visualizations +- More detailed descriptions + +### Print Adaptation (Screen → Print) + +**Layout Strategy**: +- Page breaks at logical points +- Remove navigation, footer, interactive elements +- Black and white (or limited color) +- Proper margins for binding + +**Content Strategy**: +- Expand shortened content (show full URLs, hidden sections) +- Add page numbers, headers, footers +- Include metadata (print date, page title) +- Convert charts to print-friendly versions + +### Email Adaptation (Web → Email) + +**Layout Strategy**: +- Narrow width (600px max) +- Single column only +- Inline CSS (no external stylesheets) +- Table-based layouts (for email client compatibility) + +**Interaction Strategy**: +- Large, obvious CTAs (buttons not text links) +- No hover states (not reliable) +- Deep links to web app for complex interactions + +## Implement Adaptations + +Apply changes systematically: + +### Responsive Breakpoints + +Choose appropriate breakpoints: +- Mobile: 320px-767px +- Tablet: 768px-1023px +- Desktop: 1024px+ +- Or content-driven breakpoints (where design breaks) + +### Layout Adaptation Techniques + +- **CSS Grid/Flexbox**: Reflow layouts automatically +- **Container Queries**: Adapt based on container, not viewport +- **`clamp()`**: Fluid sizing between min and max +- **Media queries**: Different styles for different contexts +- **Display properties**: Show/hide elements per context + +### Touch Adaptation + +- Increase touch target sizes (44x44px minimum) +- Add more spacing between interactive elements +- Remove hover-dependent interactions +- Add touch feedback (ripples, highlights) +- Consider thumb zones (easier to reach bottom than top) + +### Content Adaptation + +- Use `display: none` sparingly (still downloads) +- Progressive enhancement (core content first, enhancements on larger screens) +- Lazy loading for off-screen content +- Responsive images (`srcset`, `picture` element) + +### Navigation Adaptation + +- Transform complex nav to hamburger/drawer on mobile +- Bottom nav bar for mobile apps +- Persistent side navigation on desktop +- Breadcrumbs on smaller screens for context + +**IMPORTANT**: Test on real devices. Device emulation in DevTools is helpful but not perfect. + +**NEVER**: +- Hide core functionality on mobile (if it matters, make it work) +- Assume desktop = powerful device (consider accessibility, older machines) +- Use different information architecture across contexts (confusing) +- Break user expectations for platform (mobile users expect mobile patterns) +- Forget landscape orientation on mobile/tablet +- Use generic breakpoints blindly (use content-driven breakpoints) +- Ignore touch on desktop (many desktop devices have touch) + +## Verify Adaptations + +Test thoroughly across contexts: + +- **Real devices**: Test on actual phones, tablets, desktops +- **Different orientations**: Portrait and landscape +- **Different browsers**: Safari, Chrome, Firefox, Edge +- **Different OS**: iOS, Android, Windows, macOS +- **Different input methods**: Touch, mouse, keyboard +- **Edge cases**: Very small screens (320px), very large screens (4K) +- **Slow connections**: Test on throttled network + +When the adaptation feels native to each context, hand off to `$impeccable polish` for the final pass. diff --git a/.agents/skills/impeccable/reference/animate.md b/.agents/skills/impeccable/reference/animate.md new file mode 100644 index 00000000..48b5e268 --- /dev/null +++ b/.agents/skills/impeccable/reference/animate.md @@ -0,0 +1,175 @@ +> **Additional context needed**: performance constraints. + +Add motion that conveys state, gives feedback, and clarifies hierarchy. Cut motion that exists only for decoration. Animation fatigue is a real cost; spend the budget on the moments that need it. + +--- + +## Register + +Brand: orchestrated page-load sequences, staggered reveals, scroll-driven animation. Motion is part of the voice; one well-rehearsed entrance beats scattered micro-interactions. + +Product: 150–250 ms on most transitions. Motion conveys state: feedback, reveal, loading, transitions between views. No page-load choreography; users are in a task and won't wait for it. + +--- + +## Assess Animation Opportunities + +Analyze where motion would improve the experience: + +1. **Identify static areas**: + - **Missing feedback**: Actions without visual acknowledgment (button clicks, form submission, etc.) + - **Jarring transitions**: Instant state changes that feel abrupt (show/hide, page loads, route changes) + - **Unclear relationships**: Spatial or hierarchical relationships that aren't obvious + - **Lack of delight**: Functional but joyless interactions + - **Missed guidance**: Opportunities to direct attention or explain behavior + +2. **Understand the context**: + - What's the personality? (Playful vs serious, energetic vs calm) + - What's the performance budget? (Mobile-first? Complex page?) + - Who's the audience? (Motion-sensitive users? Power users who want speed?) + - What matters most? (One hero animation vs many micro-interactions?) + +If any of these are unclear from the codebase, STOP and use Codex's structured user-input/question tool when available; if unavailable, ask directly in chat to clarify what you cannot infer. + +**CRITICAL**: Respect `prefers-reduced-motion`. Always provide non-animated alternatives for users who need them. + +## Plan Animation Strategy + +Create a purposeful animation plan: + +- **Hero moment**: What's the ONE signature animation? (Page load? Hero section? Key interaction?) +- **Feedback layer**: Which interactions need acknowledgment? +- **Transition layer**: Which state changes need smoothing? +- **Delight layer**: Where can we surprise and delight? + +**IMPORTANT**: One well-orchestrated experience beats scattered animations everywhere. Focus on high-impact moments. + +## Implement Animations + +Add motion systematically across these categories: + +### Entrance Animations +- **Page load choreography**: Stagger element reveals (100-150ms delays), fade + slide combinations +- **Hero section**: Dramatic entrance for primary content (scale, parallax, or creative effects) +- **Content reveals**: Scroll-triggered animations using intersection observer +- **Modal/drawer entry**: Smooth slide + fade, backdrop fade, focus management + +### Micro-interactions +- **Button feedback**: + - Hover: Subtle scale (1.02-1.05), color shift, shadow increase + - Click: Quick scale down then up (0.95 → 1), ripple effect + - Loading: Spinner or pulse state +- **Form interactions**: + - Input focus: Border color transition, slight scale or glow + - Validation: Shake on error, check mark on success, smooth color transitions +- **Toggle switches**: Smooth slide + color transition (200-300ms) +- **Checkboxes/radio**: Check mark animation, ripple effect +- **Like/favorite**: Scale + rotation, particle effects, color transition + +### State Transitions +- **Show/hide**: Fade + slide (not instant), appropriate timing (200-300ms) +- **Expand/collapse**: Height transition with overflow handling, icon rotation +- **Loading states**: Skeleton screen fades, spinner animations, progress bars +- **Success/error**: Color transitions, icon animations, gentle scale pulse +- **Enable/disable**: Opacity transitions, cursor changes + +### Navigation & Flow +- **Page transitions**: Crossfade between routes, shared element transitions +- **Tab switching**: Slide indicator, content fade/slide +- **Carousel/slider**: Smooth transforms, snap points, momentum +- **Scroll effects**: Parallax layers, sticky headers with state changes, scroll progress indicators + +### Feedback & Guidance +- **Hover hints**: Tooltip fade-ins, cursor changes, element highlights +- **Drag & drop**: Lift effect (shadow + scale), drop zone highlights, smooth repositioning +- **Copy/paste**: Brief highlight flash on paste, "copied" confirmation +- **Focus flow**: Highlight path through form or workflow + +### Delight Moments +- **Empty states**: Subtle floating animations on illustrations +- **Completed actions**: Confetti, check mark flourish, success celebrations +- **Easter eggs**: Hidden interactions for discovery +- **Contextual animation**: Weather effects, time-of-day themes, seasonal touches + +## Technical Implementation + +Use appropriate techniques for each animation: + +### Timing & Easing + +**Durations by purpose:** +- **100-150ms**: Instant feedback (button press, toggle) +- **200-300ms**: State changes (hover, menu open) +- **300-500ms**: Layout changes (accordion, modal) +- **500-800ms**: Entrance animations (page load) + +**Easing curves (use these, not CSS defaults):** +```css +/* Recommended: natural deceleration */ +--ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1); /* Smooth */ +--ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1); /* Slightly snappier */ +--ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1); /* Confident, decisive */ + +/* AVOID: feel dated and tacky */ +/* bounce: cubic-bezier(0.34, 1.56, 0.64, 1); */ +/* elastic: cubic-bezier(0.68, -0.6, 0.32, 1.6); */ +``` + +**Exit animations are faster than entrances.** Use ~75% of enter duration. + +### CSS Animations +```css +/* Prefer for simple, declarative animations */ +- transitions for state changes +- @keyframes for complex sequences +- transform and opacity for reliable movement +- blur, filters, masks, clip paths, shadows, and color shifts for premium atmospheric effects when verified smooth +``` + +### JavaScript Animation +```javascript +/* Use for complex, interactive animations */ +- Web Animations API for programmatic control +- Framer Motion for React +- GSAP for complex sequences +``` + +### Performance +- **Motion materials**: Use transform/opacity for reliable movement, but use blur, filters, masks, shadows, and color shifts when they materially improve the effect +- **Layout safety**: Avoid casual animation of layout-driving properties (`width`, `height`, `top`, `left`, margins) +- **will-change**: Add sparingly for known expensive animations +- **Bound expensive effects**: Keep blur/filter/shadow areas small or isolated, use `contain` where appropriate +- **Monitor FPS**: Ensure 60fps on target devices + +### Accessibility +```css +@media (prefers-reduced-motion: reduce) { + * { + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.01ms !important; + } +} +``` + +**NEVER**: +- Use bounce or elastic easing curves; they feel dated and draw attention to the animation itself +- Animate layout properties casually (`width`, `height`, `top`, `left`, margins) when transform, FLIP, or grid-based techniques would work +- Use durations over 500ms for feedback (it feels laggy) +- Animate without purpose (every animation needs a reason) +- Ignore `prefers-reduced-motion` (this is an accessibility violation) +- Animate everything (animation fatigue makes interfaces feel exhausting) +- Block interaction during animations unless intentional + +## Verify Quality + +Test animations thoroughly: + +- **Smooth at 60fps**: No jank on target devices +- **Feels natural**: Easing curves feel organic, not robotic +- **Appropriate timing**: Not too fast (jarring) or too slow (laggy) +- **Reduced motion works**: Animations disabled or simplified appropriately +- **Doesn't block**: Users can interact during/after animations +- **Adds value**: Makes interface clearer or more delightful + +When the motion clarifies state instead of decorating it, hand off to `$impeccable polish` for the final pass. diff --git a/.agents/skills/impeccable/reference/audit.md b/.agents/skills/impeccable/reference/audit.md new file mode 100644 index 00000000..10f5572f --- /dev/null +++ b/.agents/skills/impeccable/reference/audit.md @@ -0,0 +1,133 @@ +Run systematic **technical** quality checks and generate a comprehensive report. Don't fix issues; document them for other commands to address. + +This is a code-level audit, not a design critique. Check what's measurable and verifiable in the implementation. + +## Diagnostic Scan + +Run comprehensive checks across 5 dimensions. Score each dimension 0-4 using the criteria below. + +### 1. Accessibility (A11y) + +**Check for**: +- **Contrast issues**: Text contrast ratios < 4.5:1 (or 7:1 for AAA) +- **Missing ARIA**: Interactive elements without proper roles, labels, or states +- **Keyboard navigation**: Missing focus indicators, illogical tab order, keyboard traps +- **Semantic HTML**: Improper heading hierarchy, missing landmarks, divs instead of buttons +- **Alt text**: Missing or poor image descriptions +- **Form issues**: Inputs without labels, poor error messaging, missing required indicators + +**Score 0-4**: 0=Inaccessible (fails WCAG A), 1=Major gaps (few ARIA labels, no keyboard nav), 2=Partial (some a11y effort, significant gaps), 3=Good (WCAG AA mostly met, minor gaps), 4=Excellent (WCAG AA fully met, approaches AAA) + +### 2. Performance + +**Check for**: +- **Layout thrashing**: Reading/writing layout properties in loops +- **Expensive animations**: Casual layout-property animation, unbounded blur/filter/shadow effects, or effects that visibly drop frames +- **Missing optimization**: Images without lazy loading, unoptimized assets, missing will-change +- **Bundle size**: Unnecessary imports, unused dependencies +- **Render performance**: Unnecessary re-renders, missing memoization + +**Score 0-4**: 0=Severe issues (layout thrash, unoptimized everything), 1=Major problems (no lazy loading, expensive animations), 2=Partial (some optimization, gaps remain), 3=Good (mostly optimized, minor improvements possible), 4=Excellent (fast, lean, well-optimized) + +### 3. Theming + +**Check for**: +- **Hard-coded colors**: Colors not using design tokens +- **Broken dark mode**: Missing dark mode variants, poor contrast in dark theme +- **Inconsistent tokens**: Using wrong tokens, mixing token types +- **Theme switching issues**: Values that don't update on theme change + +**Score 0-4**: 0=No theming (hard-coded everything), 1=Minimal tokens (mostly hard-coded), 2=Partial (tokens exist but inconsistently used), 3=Good (tokens used, minor hard-coded values), 4=Excellent (full token system, dark mode works perfectly) + +### 4. Responsive Design + +**Check for**: +- **Fixed widths**: Hard-coded widths that break on mobile +- **Touch targets**: Interactive elements < 44x44px +- **Horizontal scroll**: Content overflow on narrow viewports +- **Text scaling**: Layouts that break when text size increases +- **Missing breakpoints**: No mobile/tablet variants + +**Score 0-4**: 0=Desktop-only (breaks on mobile), 1=Major issues (some breakpoints, many failures), 2=Partial (works on mobile, rough edges), 3=Good (responsive, minor touch target or overflow issues), 4=Excellent (fluid, all viewports, proper touch targets) + +### 5. Anti-Patterns (CRITICAL) + +Check against ALL the **DON'T** guidelines from the parent impeccable skill (already loaded in this context). Look for AI slop tells (AI color palette, gradient text, glassmorphism, hero metrics, card grids, generic fonts) and general design anti-patterns (gray on color, nested cards, bounce easing, redundant copy). + +**Score 0-4**: 0=AI slop gallery (5+ tells), 1=Heavy AI aesthetic (3-4 tells), 2=Some tells (1-2 noticeable), 3=Mostly clean (subtle issues only), 4=No AI tells (distinctive, intentional design) + +## Generate Report + +### Audit Health Score + +| # | Dimension | Score | Key Finding | +|---|-----------|-------|-------------| +| 1 | Accessibility | ? | [most critical a11y issue or "--"] | +| 2 | Performance | ? | | +| 3 | Responsive Design | ? | | +| 4 | Theming | ? | | +| 5 | Anti-Patterns | ? | | +| **Total** | | **??/20** | **[Rating band]** | + +**Rating bands**: 18-20 Excellent (minor polish), 14-17 Good (address weak dimensions), 10-13 Acceptable (significant work needed), 6-9 Poor (major overhaul), 0-5 Critical (fundamental issues) + +### Anti-Patterns Verdict +**Start here.** Pass/fail: Does this look AI-generated? List specific tells. Be brutally honest. + +### Executive Summary +- Audit Health Score: **??/20** ([rating band]) +- Total issues found (count by severity: P0/P1/P2/P3) +- Top 3-5 critical issues +- Recommended next steps + +### Detailed Findings by Severity + +Tag every issue with **P0-P3 severity**: +- **P0 Blocking**: Prevents task completion. Fix immediately +- **P1 Major**: Significant difficulty or WCAG AA violation. Fix before release +- **P2 Minor**: Annoyance, workaround exists. Fix in next pass +- **P3 Polish**: Nice-to-fix, no real user impact. Fix if time permits + +For each issue, document: +- **[P?] Issue name** +- **Location**: Component, file, line +- **Category**: Accessibility / Performance / Theming / Responsive / Anti-Pattern +- **Impact**: How it affects users +- **WCAG/Standard**: Which standard it violates (if applicable) +- **Recommendation**: How to fix it +- **Suggested command**: Which command to use (prefer: $impeccable adapt, $impeccable animate, $impeccable audit, $impeccable bolder, $impeccable clarify, $impeccable colorize, $impeccable critique, $impeccable delight, $impeccable distill, $impeccable document, $impeccable harden, $impeccable layout, $impeccable onboard, $impeccable optimize, $impeccable overdrive, $impeccable polish, $impeccable quieter, $impeccable shape, $impeccable typeset) + +### Patterns & Systemic Issues + +Identify recurring problems that indicate systemic gaps rather than one-off mistakes: +- "Hard-coded colors appear in 15+ components, should use design tokens" +- "Touch targets consistently too small (<44px) throughout mobile experience" + +### Positive Findings + +Note what's working well: good practices to maintain and replicate. + +## Recommended Actions + +List recommended commands in priority order (P0 first, then P1, then P2): + +1. **[P?] `$command-name`**: Brief description (specific context from audit findings) +2. **[P?] `$command-name`**: Brief description (specific context) + +**Rules**: Only recommend commands from: $impeccable adapt, $impeccable animate, $impeccable audit, $impeccable bolder, $impeccable clarify, $impeccable colorize, $impeccable critique, $impeccable delight, $impeccable distill, $impeccable document, $impeccable harden, $impeccable layout, $impeccable onboard, $impeccable optimize, $impeccable overdrive, $impeccable polish, $impeccable quieter, $impeccable shape, $impeccable typeset. Map findings to the most appropriate command. End with `$impeccable polish` as the final step if any fixes were recommended. + +After presenting the summary, tell the user: + +> You can ask me to run these one at a time, all at once, or in any order you prefer. +> +> Re-run `$impeccable audit` after fixes to see your score improve. + +**IMPORTANT**: Be thorough but actionable. Too many P3 issues creates noise. Focus on what actually matters. + +**NEVER**: +- Report issues without explaining impact (why does this matter?) +- Provide generic recommendations (be specific and actionable) +- Skip positive findings (celebrate what works) +- Forget to prioritize (everything can't be P0) +- Report false positives without verification + diff --git a/.agents/skills/impeccable/reference/bolder.md b/.agents/skills/impeccable/reference/bolder.md new file mode 100644 index 00000000..25e94d59 --- /dev/null +++ b/.agents/skills/impeccable/reference/bolder.md @@ -0,0 +1,113 @@ +When asked for "bolder," AI defaults to the same tired tricks: cyan/purple gradients, glassmorphism, neon accents on dark backgrounds, gradient text on metrics. These are the opposite of bold. Reject them first, then increase visual impact and personality through stronger hierarchy, committed scale, and decisive type. + +--- + +## Register + +Brand: "bolder" means distinctive. Extreme scale, unexpected color, typographic risk, committed POV. + +Product: "bolder" rarely means theatrics; those undermine trust. It means stronger hierarchy, clearer weight contrast, one sharper accent, more committed density. The amplification is in clarity, not drama. + +--- + +## Assess Current State + +Analyze what makes the design feel too safe or boring: + +1. **Identify weakness sources**: + - **Generic choices**: System fonts, basic colors, standard layouts + - **Timid scale**: Everything is medium-sized with no drama + - **Low contrast**: Everything has similar visual weight + - **Static**: No motion, no energy, no life + - **Predictable**: Standard patterns with no surprises + - **Flat hierarchy**: Nothing stands out or commands attention + +2. **Understand the context**: + - What's the brand personality? (How far can we push?) + - What's the purpose? (Marketing can be bolder than financial dashboards) + - Who's the audience? (What will resonate?) + - What are the constraints? (Brand guidelines, accessibility, performance) + +If any of these are unclear from the codebase, STOP and use Codex's structured user-input/question tool when available; if unavailable, ask directly in chat to clarify what you cannot infer. + +**CRITICAL**: "Bolder" doesn't mean chaotic or garish. It means distinctive, memorable, and confident. Think intentional drama, not random chaos. + +**WARNING - AI SLOP TRAP**: Review ALL the DON'T guidelines from the parent impeccable skill (already loaded in this context) before proceeding. Bold means distinctive, not "more effects." + +## Plan Amplification + +Create a strategy to increase impact while maintaining coherence: + +- **Focal point**: What should be the hero moment? (Pick ONE, make it amazing) +- **Personality direction**: Maximalist chaos? Elegant drama? Playful energy? Dark moody? Choose a lane. +- **Risk budget**: How experimental can we be? Push boundaries within constraints. +- **Hierarchy amplification**: Make big things BIGGER, small things smaller (increase contrast) + +**IMPORTANT**: Bold design must still be usable. Impact without function is just decoration. + +## Amplify the Design + +Systematically increase impact across these dimensions: + +### Typography Amplification +- **Replace generic fonts**: Swap system fonts for distinctive choices (see the parent skill's typography guidelines and [typography.md](typography.md) for inspiration) +- **Extreme scale**: Create dramatic size jumps (3x-5x differences, not 1.5x) +- **Weight contrast**: Pair 900 weights with 200 weights, not 600 with 400 +- **Unexpected choices**: Variable fonts, display fonts for headlines, condensed/extended widths, monospace as intentional accent (not as lazy "dev tool" default) + +### Color Intensification +- **Increase saturation**: Shift to more vibrant, energetic colors (but not neon) +- **Bold palette**: Introduce unexpected color combinations. Avoid the purple-blue gradient AI slop +- **Dominant color strategy**: Let one bold color own 60% of the design +- **Sharp accents**: High-contrast accent colors that pop +- **Tinted neutrals**: Replace pure grays with tinted grays that harmonize with your palette +- **Rich gradients**: Intentional multi-stop gradients (not generic purple-to-blue) + +### Spatial Drama +- **Extreme scale jumps**: Make important elements 3-5x larger than surroundings +- **Break the grid**: Let hero elements escape containers and cross boundaries +- **Asymmetric layouts**: Replace centered, balanced layouts with tension-filled asymmetry +- **Generous space**: Use white space dramatically (100-200px gaps, not 20-40px) +- **Overlap**: Layer elements intentionally for depth + +### Visual Effects +- **Dramatic shadows**: Large, soft shadows for elevation (but not generic drop shadows on rounded rectangles) +- **Background treatments**: Mesh patterns, noise textures, geometric patterns, intentional gradients (not purple-to-blue) +- **Texture & depth**: Grain, halftone, duotone, layered elements. NOT glassmorphism (it's overused AI slop) +- **Borders & frames**: Thick borders, decorative frames, custom shapes (not rounded rectangles with colored border on one side) +- **Custom elements**: Illustrative elements, custom icons, decorative details that reinforce brand + +### Motion & Animation +- **Entrance choreography**: Staggered, dramatic page load animations with 50-100ms delays +- **Scroll effects**: Parallax, reveal animations, scroll-triggered sequences +- **Micro-interactions**: Satisfying hover effects, click feedback, state changes +- **Transitions**: Smooth, noticeable transitions using ease-out-quart/quint/expo (not bounce or elastic, which cheapen the effect) + +### Composition Boldness +- **Hero moments**: Create clear focal points with dramatic treatment +- **Diagonal flows**: Escape horizontal/vertical rigidity with diagonal arrangements +- **Full-bleed elements**: Use full viewport width/height for impact +- **Unexpected proportions**: Golden ratio? Throw it out. Try 70/30, 80/20 splits + +**NEVER**: +- Add effects randomly without purpose (chaos ≠ bold) +- Sacrifice readability for aesthetics (body text must be readable) +- Make everything bold (then nothing is bold; you need contrast) +- Ignore accessibility (bold design must still meet WCAG standards) +- Overwhelm with motion (animation fatigue is real) +- Copy trendy aesthetics blindly (bold means distinctive, not derivative) + +## Verify Quality + +Ensure amplification maintains usability and coherence: + +- **NOT AI slop**: Does this look like every other AI-generated "bold" design? If yes, start over. +- **Still functional**: Can users accomplish tasks without distraction? +- **Coherent**: Does everything feel intentional and unified? +- **Memorable**: Will users remember this experience? +- **Performant**: Do all these effects run smoothly? +- **Accessible**: Does it still meet accessibility standards? + +**The test**: If you showed this to someone and said "AI made this bolder," would they believe you immediately? If yes, you've failed. Bold means distinctive, not "more AI effects." + +When the result feels right, hand off to `$impeccable polish` for the final pass. diff --git a/.agents/skills/impeccable/reference/brand.md b/.agents/skills/impeccable/reference/brand.md new file mode 100644 index 00000000..b069f255 --- /dev/null +++ b/.agents/skills/impeccable/reference/brand.md @@ -0,0 +1,114 @@ +# Brand register + +When design IS the product: brand sites, landing pages, marketing surfaces, campaign pages, portfolios, long-form content, about pages. The deliverable is the design itself; a visitor's impression is the thing being made. + +The register spans every genre. A tech brand (Stripe, Linear, Vercel). A luxury brand (a hotel, a fashion house). A consumer product (a restaurant, a travel site, a CPG packaging page). A creative studio, an agency portfolio, a band's album page. They all share the stance (*communicate, not transact*) and diverge wildly in aesthetic. Don't collapse them into a single look. + +## The brand slop test + +If someone could look at this and say "AI made that" without hesitation, it's failed. The bar is distinctiveness; a visitor should ask "how was this made?", not "which AI made this?" + +Brand isn't a neutral register. AI-generated landing pages have flooded the internet, and average is no longer findable. Restraint without intent now reads as mediocre, not refined. Brand surfaces need a POV, a specific audience, a willingness to risk strangeness. Go big or go home. + +**The second slop test: aesthetic lane.** Before committing to moves, name the reference. A Klim-style specimen page is one lane; Stripe-minimal is another; Liquid-Death-acid-maximalism is another. Don't drift into editorial-magazine aesthetics on a brief that isn't editorial. A hiking brand with Cormorant italic drop caps has the wrong register within the register. + +## Typography + +### Font selection procedure + +Every project. Never skip. + +1. Read the brief. Write three concrete brand-voice words. Not "modern" or "elegant," but "warm and mechanical and opinionated" or "calm and clinical and careful." Physical-object words. +2. List the three fonts you'd reach for by reflex. If any appear in the reflex-reject list below, reject them; they are training-data defaults and they create monoculture. +3. Browse a real catalog (Google Fonts, Pangram Pangram, Future Fonts, Adobe Fonts, ABC Dinamo, Klim, Velvetyne) with the three words in mind. Find the font for the brand as a *physical object*: a museum caption, a 1970s terminal manual, a fabric label, a cheap-newsprint children's book, a concert poster, a receipt from a mid-century diner. Reject the first thing that "looks designy." +4. Cross-check. "Elegant" is not necessarily serif. "Technical" is not necessarily sans. "Warm" is not Fraunces. If the final pick lines up with the original reflex, start over. + +### Reflex-reject list + +Training-data defaults. Ban list. Look further: + +Fraunces · Newsreader · Lora · Crimson · Crimson Pro · Crimson Text · Playfair Display · Cormorant · Cormorant Garamond · Syne · IBM Plex Mono · IBM Plex Sans · IBM Plex Serif · Space Mono · Space Grotesk · Inter · DM Sans · DM Serif Display · DM Serif Text · Outfit · Plus Jakarta Sans · Instrument Sans · Instrument Serif + +### Reflex-reject aesthetic lanes + +Parallel to the font list. Currently saturated aesthetic families that have flooded brand surfaces. If a brief lands in one of these lanes without a register reason that *requires* it (a literal magazine, a literal terminal, a literal industrial signage system), it's the second-order training reflex: the trap one tier deeper than picking a Fraunces font. Look further. + +- **Editorial-typographic.** Display serif (often italic) + small mono labels + ruled separators + monochromatic restraint. Klim-influenced, magazine-cover affectation. By 2026, every Stripe-adjacent and Notion-adjacent brand has landed here. The fingerprint: three rule-separated columns, an italic Fraunces / Recoleta / Newsreader headline, lowercase track-spaced metadata, no imagery. + +(More entries land here on the same cadence the font list updates. Brutalist-utility and acid-maximalism may join when they saturate. Removing entries when they fall back below saturation is also fine.) + +The reflex-reject lists apply to **new design choices**. When the existing brand has already committed to a font or a lane as part of its identity, identity-preservation wins; variants on an existing surface don't second-guess what's already shipping. The reflex-reject lists are for greenfield decisions and for departure-mode variants in [live.md](live.md). + +### Pairing and voice + +Distinctive + refined is the goal. The specific shape depends on the brand: + +- **Editorial / long-form / luxury**: display serif + sans body (a magazine shape). +- **Tech / dev tools / fintech**: one committed sans, usually; custom-tight tracking, strong weight contrast inside a single family. +- **Consumer / food / travel**: warmer pairings, often a humanist sans plus a script or display serif. +- **Creative studios / agencies**: rule-breaking welcome. Mono-only, or display-only, or custom-drawn type as voice. + +Two families minimum is the rule *only* when the voice needs it. A single well-chosen family with committed weight/size contrast is stronger than a timid display+body pair. + +Vary across projects. If the last brief was a serif-display landing page, this one isn't. + +### Scale + +Modular scale, fluid `clamp()` for headings, ≥1.25 ratio between steps. Flat scales (1.1× apart) read as uncommitted. + +Light text on dark backgrounds: add 0.05–0.1 to line-height. Light type reads as lighter weight and needs more breathing room. + +## Color + +Brand surfaces have permission for Committed, Full palette, and Drenched strategies. Use them. A single saturated color spread across a hero is not excess; it's voice. A beige-and-muted-slate landing page ignores the register. + +- Name a real reference before picking a strategy. "Klim Type Foundry #ff4500 orange drench", "Stripe purple-on-white restraint", "Liquid Death acid-green full palette", "Mailchimp yellow full palette", "Condé Nast Traveler muted navy restraint", "Vercel pure black monochrome". Unnamed ambition becomes beige. +- Palette IS voice. A calm brand and a restless brand should not share palette mechanics. +- When the strategy is Committed or Drenched, color carries the brand. Don't hedge with neutrals around the edges. Commit. +- Don't converge across projects. If the last brand surface was restrained-on-cream, this one is not. + +## Layout + +- Asymmetric compositions are one option. Break the grid intentionally for emphasis. +- Fluid spacing with `clamp()` that breathes on larger viewports. Vary for rhythm: generous separations, tight groupings. +- Alternative: a strict, visible grid as the voice (brutalist / Swiss / tech-spec aesthetics). Either asymmetric or rigorously-gridded can be "designed"; the failure mode is splitting the difference into a generic centered stack. +- Don't default to centering everything. Left-aligned with asymmetric layouts feels more designed; a strict grid reads as confident structure. A centered-stack hero with icon-title-subtitle cards reads as template. +- When cards ARE the right affordance, use `grid-template-columns: repeat(auto-fit, minmax(280px, 1fr))` for breakpoint-free responsiveness. + +## Imagery + +Brand surfaces lean on imagery. A restaurant, hotel, magazine, or product landing page without any imagery reads as incomplete, not as restrained. A solid-color rectangle where a hero image should go is worse than a representative stock photo. + +**When the brief implies imagery (restaurants, hotels, magazines, photography, hobbyist communities, food, travel, fashion, product), you must ship imagery.** Zero images is a bug, not a design choice. "Restraint" is not an excuse. + +- **For greenfield work without local assets, use stock imagery.** Unsplash is the default. The URL shape is `https://images.unsplash.com/photo-{id}?auto=format&fit=crop&w=1600&q=80`. Pick real Unsplash photo IDs you're confident exist (`photo-1559339352-11d035aa65de`, `photo-1590490360182-c33d57733427`, etc.); if unsure, pick fewer photos but don't substitute colored `
` placeholders. +- **Search for the brand's physical object**, not the generic category: "handmade pasta on a scratched wooden table" beats "Italian food"; "cypress trees above a limestone hotel facade at dusk" beats "luxury hotel". +- **One decisive photo beats five mediocre ones.** Hero imagery should commit to a mood; padding with more stock doesn't rescue an indecisive one. +- **Alt text is part of the voice.** "Coastal fettuccine, hand-cut, served on the terrace" beats "pasta dish". + +Tech / dev-tool brands are the exception where zero imagery can be correct; a developer landing page often carries its voice through typography, code samples, diagrams. Know which kind of brand you're working on. + +## Motion + +- One well-orchestrated page-load with staggered reveals beats scattered micro-interactions, when the brand invites it. Tech-minimal brands often skip entrance motion entirely; the restraint is the voice. +- For collapsing/expanding sections, transition `grid-template-rows` rather than `height`. + +## Brand bans (on top of the shared absolute bans) + +- Monospace as lazy shorthand for "technical / developer." If the brand isn't technical, mono reads as costume. +- Large rounded-corner icons above every heading. Screams template. +- Single-family pages that picked the family by reflex, not voice. (A single family chosen deliberately is fine.) +- All-caps body copy. Reserve caps for short labels and headings. +- Timid palettes and average layouts. Safe = invisible. +- Zero imagery on a brief that implies imagery (restaurant, hotel, food, travel, fashion, photography, hobbyist). Colored blocks where a hero photo belongs. +- Defaulting to editorial-magazine aesthetics (display serif + italic + drop caps + broadsheet grid) on briefs that aren't magazine-shaped. Editorial is ONE aesthetic lane, not the default brand aesthetic. + +## Brand permissions + +Brand can afford things product can't. Take them. + +- Ambitious first-load motion. Reveals, scroll-triggered transitions, typographic choreography. +- Single-purpose viewports. One dominant idea per fold, long scroll, deliberate pacing. +- Typographic risk. Enormous display type, unexpected italic cuts, mixed cases, hand-drawn headlines, a single oversize word as a hero. +- Unexpected color strategies. Palette IS voice; a calm brand and a restless brand should not share palette mechanics. +- Art direction per section. Different sections can have different visual worlds if the narrative demands it. Consistency of voice beats consistency of treatment. diff --git a/.agents/skills/impeccable/reference/clarify.md b/.agents/skills/impeccable/reference/clarify.md new file mode 100644 index 00000000..07b9d8d2 --- /dev/null +++ b/.agents/skills/impeccable/reference/clarify.md @@ -0,0 +1,174 @@ +> **Additional context needed**: audience technical level and users' mental state in context. + +Find the unclear, confusing, or poorly written interface text and rewrite it. Vague copy creates support tickets and abandonment; specific copy gets users through the task. + + +--- + +## Assess Current Copy + +Identify what makes the text unclear or ineffective: + +1. **Find clarity problems**: + - **Jargon**: Technical terms users won't understand + - **Ambiguity**: Multiple interpretations possible + - **Passive voice**: "Your file has been uploaded" vs "We uploaded your file" + - **Length**: Too wordy or too terse + - **Assumptions**: Assuming user knowledge they don't have + - **Missing context**: Users don't know what to do or why + - **Tone mismatch**: Too formal, too casual, or inappropriate for situation + +2. **Understand the context**: + - Who's the audience? (Technical? General? First-time users?) + - What's the user's mental state? (Stressed during error? Confident during success?) + - What's the action? (What do we want users to do?) + - What's the constraint? (Character limits? Space limitations?) + +**CRITICAL**: Clear copy helps users succeed. Unclear copy creates frustration, errors, and support tickets. + +## Plan Copy Improvements + +Create a strategy for clearer communication: + +- **Primary message**: What's the ONE thing users need to know? +- **Action needed**: What should users do next (if anything)? +- **Tone**: How should this feel? (Helpful? Apologetic? Encouraging?) +- **Constraints**: Length limits, brand voice, localization considerations + +**IMPORTANT**: Good UX writing is invisible. Users should understand immediately without noticing the words. + +## Improve Copy Systematically + +Refine text across these common areas: + +### Error Messages +**Bad**: "Error 403: Forbidden" +**Good**: "You don't have permission to view this page. Contact your admin for access." + +**Bad**: "Invalid input" +**Good**: "Email addresses need an @ symbol. Try: name@example.com" + +**Principles**: +- Explain what went wrong in plain language +- Suggest how to fix it +- Don't blame the user +- Include examples when helpful +- Link to help/support if applicable + +### Form Labels & Instructions +**Bad**: "DOB (MM/DD/YYYY)" +**Good**: "Date of birth" (with placeholder showing format) + +**Bad**: "Enter value here" +**Good**: "Your email address" or "Company name" + +**Principles**: +- Use clear, specific labels (not generic placeholders) +- Show format expectations with examples +- Explain why you're asking (when not obvious) +- Put instructions before the field, not after +- Keep required field indicators clear + +### Button & CTA Text +**Bad**: "Click here" | "Submit" | "OK" +**Good**: "Create account" | "Save changes" | "Got it, thanks" + +**Principles**: +- Describe the action specifically +- Use active voice (verb + noun) +- Match user's mental model +- Be specific ("Save" is better than "OK") + +### Help Text & Tooltips +**Bad**: "This is the username field" +**Good**: "Choose a username. You can change this later in Settings." + +**Principles**: +- Add value (don't just repeat the label) +- Answer the implicit question ("What is this?" or "Why do you need this?") +- Keep it brief but complete +- Link to detailed docs if needed + +### Empty States +**Bad**: "No items" +**Good**: "No projects yet. Create your first project to get started." + +**Principles**: +- Explain why it's empty (if not obvious) +- Show next action clearly +- Make it welcoming, not dead-end + +### Success Messages +**Bad**: "Success" +**Good**: "Settings saved! Your changes will take effect immediately." + +**Principles**: +- Confirm what happened +- Explain what happens next (if relevant) +- Be brief but complete +- Match the user's emotional moment (celebrate big wins) + +### Loading States +**Bad**: "Loading..." (for 30+ seconds) +**Good**: "Analyzing your data... this usually takes 30-60 seconds" + +**Principles**: +- Set expectations (how long?) +- Explain what's happening (when it's not obvious) +- Show progress when possible +- Offer escape hatch if appropriate ("Cancel") + +### Confirmation Dialogs +**Bad**: "Are you sure?" +**Good**: "Delete 'Project Alpha'? This can't be undone." + +**Principles**: +- State the specific action +- Explain consequences (especially for destructive actions) +- Use clear button labels ("Delete project" not "Yes") +- Don't overuse confirmations (only for risky actions) + +### Navigation & Wayfinding +**Bad**: Generic labels like "Items" | "Things" | "Stuff" +**Good**: Specific labels like "Your projects" | "Team members" | "Settings" + +**Principles**: +- Be specific and descriptive +- Use language users understand (not internal jargon) +- Make hierarchy clear +- Consider information scent (breadcrumbs, current location) + +## Apply Clarity Principles + +Every piece of copy should follow these rules: + +1. **Be specific**: "Enter email" not "Enter value" +2. **Be concise**: Cut unnecessary words (but don't sacrifice clarity) +3. **Be active**: "Save changes" not "Changes will be saved" +4. **Be human**: "Oops, something went wrong" not "System error encountered" +5. **Tell users what to do**, not just what happened +6. **Be consistent**: Use same terms throughout (don't vary for variety) + +**NEVER**: +- Use jargon without explanation +- Blame users ("You made an error" → "This field is required") +- Be vague ("Something went wrong" without explanation) +- Use passive voice unnecessarily +- Write overly long explanations (be concise) +- Use humor for errors (be empathetic instead) +- Assume technical knowledge +- Vary terminology (pick one term and stick with it) +- Repeat information (headers restating intros, redundant explanations) +- Use placeholders as the only labels (they disappear when users type) + +## Verify Improvements + +Test that copy improvements work: + +- **Comprehension**: Can users understand without context? +- **Actionability**: Do users know what to do next? +- **Brevity**: Is it as short as possible while remaining clear? +- **Consistency**: Does it match terminology elsewhere? +- **Tone**: Is it appropriate for the situation? + +When the copy reads cleanly, hand off to `$impeccable polish` for the final pass. diff --git a/.agents/skills/impeccable/reference/cognitive-load.md b/.agents/skills/impeccable/reference/cognitive-load.md new file mode 100644 index 00000000..48f8ad58 --- /dev/null +++ b/.agents/skills/impeccable/reference/cognitive-load.md @@ -0,0 +1,106 @@ +# Cognitive Load Assessment + +Cognitive load is the total mental effort required to use an interface. Overloaded users make mistakes, get frustrated, and leave. This reference helps identify and fix cognitive overload. + +--- + +## Three Types of Cognitive Load + +### Intrinsic Load: The Task Itself +Complexity inherent to what the user is trying to do. You can't eliminate this, but you can structure it. + +**Manage it by**: +- Breaking complex tasks into discrete steps +- Providing scaffolding (templates, defaults, examples) +- Progressive disclosure: show what's needed now, hide the rest +- Grouping related decisions together + +### Extraneous Load: Bad Design +Mental effort caused by poor design choices. **Eliminate this ruthlessly.** It's pure waste. + +**Common sources**: +- Confusing navigation that requires mental mapping +- Unclear labels that force users to guess meaning +- Visual clutter competing for attention +- Inconsistent patterns that prevent learning +- Unnecessary steps between user intent and result + +### Germane Load: Learning Effort +Mental effort spent building understanding. This is *good* cognitive load; it leads to mastery. + +**Support it by**: +- Progressive disclosure that reveals complexity gradually +- Consistent patterns that reward learning +- Feedback that confirms correct understanding +- Onboarding that teaches through action, not walls of text + +--- + +## Cognitive Load Checklist + +Evaluate the interface against these 8 items: + +- [ ] **Single focus**: Can the user complete their primary task without distraction from competing elements? +- [ ] **Chunking**: Is information presented in digestible groups (≤4 items per group)? +- [ ] **Grouping**: Are related items visually grouped together (proximity, borders, shared background)? +- [ ] **Visual hierarchy**: Is it immediately clear what's most important on the screen? +- [ ] **One thing at a time**: Can the user focus on a single decision before moving to the next? +- [ ] **Minimal choices**: Are decisions simplified (≤4 visible options at any decision point)? +- [ ] **Working memory**: Does the user need to remember information from a previous screen to act on the current one? +- [ ] **Progressive disclosure**: Is complexity revealed only when the user needs it? + +**Scoring**: Count the failed items. 0–1 failures = low cognitive load (good). 2–3 = moderate (address soon). 4+ = high cognitive load (critical fix needed). + +--- + +## The Working Memory Rule + +**Humans can hold ≤4 items in working memory at once** (Miller's Law revised by Cowan, 2001). + +At any decision point, count the number of distinct options, actions, or pieces of information a user must simultaneously consider: +- **≤4 items**: Within working memory limits, manageable +- **5–7 items**: Pushing the boundary; consider grouping or progressive disclosure +- **8+ items**: Overloaded; users will skip, misclick, or abandon + +**Practical applications**: +- Navigation menus: ≤5 top-level items (group the rest under clear categories) +- Form sections: ≤4 fields visible per group before a visual break +- Action buttons: 1 primary, 1–2 secondary, group the rest in a menu +- Dashboard widgets: ≤4 key metrics visible without scrolling +- Pricing tiers: ≤3 options (more causes analysis paralysis) + +--- + +## Common Cognitive Load Violations + +### 1. The Wall of Options +**Problem**: Presenting 10+ choices at once with no hierarchy. +**Fix**: Group into categories, highlight recommended, use progressive disclosure. + +### 2. The Memory Bridge +**Problem**: User must remember info from step 1 to complete step 3. +**Fix**: Keep relevant context visible, or repeat it where it's needed. + +### 3. The Hidden Navigation +**Problem**: User must build a mental map of where things are. +**Fix**: Always show current location (breadcrumbs, active states, progress indicators). + +### 4. The Jargon Barrier +**Problem**: Technical or domain language forces translation effort. +**Fix**: Use plain language. If domain terms are unavoidable, define them inline. + +### 5. The Visual Noise Floor +**Problem**: Every element has the same visual weight; nothing stands out. +**Fix**: Establish clear hierarchy: one primary element, 2–3 secondary, everything else muted. + +### 6. The Inconsistent Pattern +**Problem**: Similar actions work differently in different places. +**Fix**: Standardize interaction patterns. Same type of action = same type of UI. + +### 7. The Multi-Task Demand +**Problem**: Interface requires processing multiple simultaneous inputs (reading + deciding + navigating). +**Fix**: Sequence the steps. Let the user do one thing at a time. + +### 8. The Context Switch +**Problem**: User must jump between screens/tabs/modals to gather info for a single decision. +**Fix**: Co-locate the information needed for each decision. Reduce back-and-forth. diff --git a/.agents/skills/impeccable/reference/color-and-contrast.md b/.agents/skills/impeccable/reference/color-and-contrast.md new file mode 100644 index 00000000..110c2ee4 --- /dev/null +++ b/.agents/skills/impeccable/reference/color-and-contrast.md @@ -0,0 +1,105 @@ +# Color & Contrast + +## Color Spaces: Use OKLCH + +**Stop using HSL.** Use OKLCH (or LCH) instead. It's perceptually uniform, meaning equal steps in lightness *look* equal, unlike HSL where 50% lightness in yellow looks bright while 50% in blue looks dark. + +The OKLCH function takes three components: `oklch(lightness chroma hue)` where lightness is 0-100%, chroma is roughly 0-0.4, and hue is 0-360. To build a primary color and its lighter / darker variants, hold the chroma+hue roughly constant and vary the lightness, but **reduce chroma as you approach white or black**, because high chroma at extreme lightness looks garish. + +The hue you pick is a brand decision and should not come from a default. Do not reach for blue (hue 250) or warm orange (hue 60) by reflex; those are the dominant AI-design defaults, not the right answer for any specific brand. + +## Building Functional Palettes + +### Tinted Neutrals + +**Pure gray is dead.** A neutral with zero chroma feels lifeless next to a colored brand. Add a tiny chroma value (0.005-0.015) to all your neutrals, hued toward whatever your brand color is. The chroma is small enough not to read as "tinted" consciously, but it creates subconscious cohesion between brand color and UI surfaces. + +The hue you tint toward should come from THIS project's brand, not from a "warm = friendly, cool = tech" formula. If your brand color is teal, your neutrals lean toward teal. If your brand color is amber, they lean toward amber. The point is cohesion with the SPECIFIC brand, not a stock palette. + +**Avoid** the trap of always tinting toward warm orange or always tinting toward cool blue. Those are the two laziest defaults and they create their own monoculture across projects. + +### Palette Structure + +A complete system needs: + +| Role | Purpose | Example | +|------|---------|---------| +| **Primary** | Brand, CTAs, key actions | 1 color, 3-5 shades | +| **Neutral** | Text, backgrounds, borders | 9-11 shade scale | +| **Semantic** | Success, error, warning, info | 4 colors, 2-3 shades each | +| **Surface** | Cards, modals, overlays | 2-3 elevation levels | + +**Skip secondary/tertiary unless you need them.** Most apps work fine with one accent color. Adding more creates decision fatigue and visual noise. + +### The 60-30-10 Rule (Applied Correctly) + +This rule is about **visual weight**, not pixel count: + +- **60%**: Neutral backgrounds, white space, base surfaces +- **30%**: Secondary colors: text, borders, inactive states +- **10%**: Accent: CTAs, highlights, focus states + +The common mistake: using the accent color everywhere because it's "the brand color." Accent colors work *because* they're rare. Overuse kills their power. + +## Contrast & Accessibility + +### WCAG Requirements + +| Content Type | AA Minimum | AAA Target | +|--------------|------------|------------| +| Body text | 4.5:1 | 7:1 | +| Large text (18px+ or 14px bold) | 3:1 | 4.5:1 | +| UI components, icons | 3:1 | 4.5:1 | +| Non-essential decorations | None | None | + +**The gotcha**: Placeholder text still needs 4.5:1. That light gray placeholder you see everywhere? Usually fails WCAG. + +### Dangerous Color Combinations + +These commonly fail contrast or cause readability issues: + +- Light gray text on white (the #1 accessibility fail) +- **Gray text on any colored background**: gray looks washed out and dead on color. Use a darker shade of the background color, or transparency +- Red text on green background (or vice versa): 8% of men can't distinguish these +- Blue text on red background (vibrates visually) +- Yellow text on white (almost always fails) +- Thin light text on images (unpredictable contrast) + +### Never Use Pure Gray or Pure Black + +Pure gray (`oklch(50% 0 0)`) and pure black (`#000`) don't exist in nature; real shadows and surfaces always have a color cast. Even a chroma of 0.005-0.01 is enough to feel natural without being obviously tinted. (See tinted neutrals example above.) + +### Testing + +Don't trust your eyes. Use tools: + +- [WebAIM Contrast Checker](https://webaim.org/resources/contrastchecker/) +- Browser DevTools → Rendering → Emulate vision deficiencies +- [Polypane](https://polypane.app/) for real-time testing + +## Theming: Light & Dark Mode + +### Dark Mode Is Not Inverted Light Mode + +You can't just swap colors. Dark mode requires different design decisions: + +| Light Mode | Dark Mode | +|------------|-----------| +| Shadows for depth | Lighter surfaces for depth (no shadows) | +| Dark text on light | Light text on dark (reduce font weight) | +| Vibrant accents | Desaturate accents slightly | +| White backgrounds | Never pure black; use dark gray (oklch 12-18%) | + +In dark mode, depth comes from surface lightness, not shadow. Build a 3-step surface scale where higher elevations are lighter (e.g. 15% / 20% / 25% lightness). Use the SAME hue and chroma as your brand color (whatever it is for THIS project; do not reach for blue) and only vary the lightness. Reduce body text weight slightly (e.g. 350 instead of 400) because light text on dark reads as heavier than dark text on light. + +### Token Hierarchy + +Use two layers: primitive tokens (`--blue-500`) and semantic tokens (`--color-primary: var(--blue-500)`). For dark mode, only redefine the semantic layer; primitives stay the same. + +## Alpha Is A Design Smell + +Heavy use of transparency (rgba, hsla) usually means an incomplete palette. Alpha creates unpredictable contrast, performance overhead, and inconsistency. Define explicit overlay colors for each context instead. Exception: focus rings and interactive states where see-through is needed. + +--- + +**Avoid**: Relying on color alone to convey information. Creating palettes without clear roles for each color. Using pure black (#000) for large areas. Skipping color blindness testing (8% of men affected). diff --git a/.agents/skills/impeccable/reference/colorize.md b/.agents/skills/impeccable/reference/colorize.md new file mode 100644 index 00000000..a6ddfb29 --- /dev/null +++ b/.agents/skills/impeccable/reference/colorize.md @@ -0,0 +1,154 @@ +> **Additional context needed**: existing brand colors. + +Replace timid grayscale or single-accent designs with a strategic palette: pick a color strategy, choose a hue family that fits the brand, then apply color with intent. More color ≠ better. Strategic color beats rainbow vomit. + +--- + +## Register + +Brand: palette IS voice. Pick a color strategy first per SKILL.md (Restrained / Committed / Full palette / Drenched) and follow its dosage. Committed, Full palette, and Drenched deliberately exceed the ≤10% rule; that rule is Restrained only. Unexpected combinations are allowed; a dominant color can own the page when the chosen strategy calls for it. + +Product: semantic-first and almost always Restrained. Accent color is reserved for primary action, current selection, and state indicators. Not decoration. Every color has a consistent meaning across every screen. + +--- + +## Assess Color Opportunity + +Analyze the current state and identify opportunities: + +1. **Understand current state**: + - **Color absence**: Pure grayscale? Limited neutrals? One timid accent? + - **Missed opportunities**: Where could color add meaning, hierarchy, or delight? + - **Context**: What's appropriate for this domain and audience? + - **Brand**: Are there existing brand colors we should use? + +2. **Identify where color adds value**: + - **Semantic meaning**: Success (green), error (red), warning (yellow/orange), info (blue) + - **Hierarchy**: Drawing attention to important elements + - **Categorization**: Different sections, types, or states + - **Emotional tone**: Warmth, energy, trust, creativity + - **Wayfinding**: Helping users navigate and understand structure + - **Delight**: Moments of visual interest and personality + +If any of these are unclear from the codebase, STOP and use Codex's structured user-input/question tool when available; if unavailable, ask directly in chat to clarify what you cannot infer. + +**CRITICAL**: More color ≠ better. Strategic color beats rainbow vomit every time. Every color should have a purpose. + +## Plan Color Strategy + +Create a purposeful color introduction plan: + +- **Color palette**: What colors match the brand/context? (Choose 2-4 colors max beyond neutrals) +- **Dominant color**: Which color owns 60% of colored elements? +- **Accent colors**: Which colors provide contrast and highlights? (30% and 10%) +- **Application strategy**: Where does each color appear and why? + +**IMPORTANT**: Color should enhance hierarchy and meaning, not create chaos. Less is more when it matters more. + +## Introduce Color Strategically + +Add color systematically across these dimensions: + +### Semantic Color +- **State indicators**: + - Success: Green tones (emerald, forest, mint) + - Error: Red/pink tones (rose, crimson, coral) + - Warning: Orange/amber tones + - Info: Blue tones (sky, ocean, indigo) + - Neutral: Gray/slate for inactive states + +- **Status badges**: Colored backgrounds or borders for states (active, pending, completed, etc.) +- **Progress indicators**: Colored bars, rings, or charts showing completion or health + +### Accent Color Application +- **Primary actions**: Color the most important buttons/CTAs +- **Links**: Add color to clickable text (maintain accessibility) +- **Icons**: Colorize key icons for recognition and personality +- **Headers/titles**: Add color to section headers or key labels +- **Hover states**: Introduce color on interaction + +### Background & Surfaces +- **Tinted backgrounds**: Replace pure gray (`#f5f5f5`) with warm neutrals (`oklch(97% 0.01 60)`) or cool tints (`oklch(97% 0.01 250)`) +- **Colored sections**: Use subtle background colors to separate areas +- **Gradient backgrounds**: Add depth with subtle, intentional gradients (not generic purple-blue) +- **Cards & surfaces**: Tint cards or surfaces slightly for warmth + +**Use OKLCH for color**: It's perceptually uniform, meaning equal steps in lightness *look* equal. Great for generating harmonious scales. + +### Data Visualization +- **Charts & graphs**: Use color to encode categories or values +- **Heatmaps**: Color intensity shows density or importance +- **Comparison**: Color coding for different datasets or timeframes + +### Borders & Accents +- **Hairline borders**: 1px colored borders on full perimeter (not side-stripes; see the absolute ban on `border-left/right > 1px`) +- **Underlines**: Color underlines for emphasis or active states +- **Dividers**: Subtle colored dividers instead of gray lines +- **Focus rings**: Colored focus indicators matching brand +- **Surface tints**: A 4-8% background wash of the accent color instead of a stripe + +**NEVER**: `border-left` or `border-right` greater than 1px as a colored accent stripe. This is one of the three absolute bans in the parent skill. If you want to mark a card as "active" or "warning", use a full hairline border, a background tint, a leading glyph, or a numbered prefix. Not a side stripe. + +### Typography Color +- **Colored headings**: Use brand colors for section headings (maintain contrast) +- **Highlight text**: Color for emphasis or categories +- **Labels & tags**: Small colored labels for metadata or categories + +### Decorative Elements +- **Illustrations**: Add colored illustrations or icons +- **Shapes**: Geometric shapes in brand colors as background elements +- **Gradients**: Colorful gradient overlays or mesh backgrounds +- **Blobs/organic shapes**: Soft colored shapes for visual interest + +## Balance & Refinement + +Ensure color addition improves rather than overwhelms: + +### Maintain Hierarchy +- **Dominant color** (60%): Primary brand color or most used accent +- **Secondary color** (30%): Supporting color for variety +- **Accent color** (10%): High contrast for key moments +- **Neutrals** (remaining): Gray/black/white for structure + +### Accessibility +- **Contrast ratios**: Ensure WCAG compliance (4.5:1 for text, 3:1 for UI components) +- **Don't rely on color alone**: Use icons, labels, or patterns alongside color +- **Test for color blindness**: Verify red/green combinations work for all users + +### Cohesion +- **Consistent palette**: Use colors from defined palette, not arbitrary choices +- **Systematic application**: Same color meanings throughout (green always = success) +- **Temperature consistency**: Warm palette stays warm, cool stays cool + +**NEVER**: +- Use every color in the rainbow (choose 2-4 colors beyond neutrals) +- Apply color randomly without semantic meaning +- Put gray text on colored backgrounds. It looks washed out; use a darker shade of the background color or transparency instead +- Use pure gray for neutrals. Add subtle color tint (warm or cool) for depth +- Use pure black (`#000`) or pure white (`#fff`) for large areas +- Violate WCAG contrast requirements +- Use color as the only indicator (accessibility issue) +- Make everything colorful (defeats the purpose) +- Default to purple-blue gradients (AI slop aesthetic) + +## Verify Color Addition + +Test that colorization improves the experience: + +- **Better hierarchy**: Does color guide attention appropriately? +- **Clearer meaning**: Does color help users understand states/categories? +- **More engaging**: Does the interface feel warmer and more inviting? +- **Still accessible**: Do all color combinations meet WCAG standards? +- **Not overwhelming**: Is color balanced and purposeful? + +When the palette earns its place, hand off to `$impeccable polish` for the final pass. + +## Live-mode signature params + +When invoked from live mode, each variant MUST declare a `color-amount` param so the user can dial between a restrained accent and a drenched surface without regeneration. Author the variant's CSS against `var(--p-color-amount, 0.5)`, typically as the alpha multiplier on backgrounds, or as a scaling factor on the chroma axis in an OKLCH expression. 0 = neutral/monochrome, 1 = full saturation / dominant coverage. + +```json +{"id":"color-amount","kind":"range","min":0,"max":1,"step":0.05,"default":0.5,"label":"Color amount"} +``` + +Layer 1-2 variant-specific params on top: palette selection (`steps` with named options), temperature warmth, or tint vs. true color. See `reference/live.md` for the full params contract. diff --git a/.agents/skills/impeccable/reference/craft.md b/.agents/skills/impeccable/reference/craft.md new file mode 100644 index 00000000..337b5c9b --- /dev/null +++ b/.agents/skills/impeccable/reference/craft.md @@ -0,0 +1,193 @@ +# Craft Flow + +Build a feature with impeccable UX and UI quality through a structured process: shape the design, land the visual direction, build real production code, then inspect and improve in-browser until the result meets a high-end studio bar. + +## Build Gate + +Craft cannot build until all of these are true: + +1. PRODUCT context is valid and current. +2. The shape design brief is explicitly confirmed by the user for this task, unless the user already provided a confirmed brief. +3. Implementation references from the brief are loaded. +4. The shape visual probe decision is recorded: generated, skipped with reason, or already resolved. +5. The north-star mock decision is recorded: generated, skipped with reason, or not applicable. + +PRODUCT.md and `teach` answers do **not** satisfy the shape gate. They are project context only. A compact self-authored brief does not satisfy the shape gate either. `shape=pass` requires a separate user response approving the shape brief or an already-confirmed brief supplied by the user. + +Invalid image-skip reasons include: "the final implementation will be semantic HTML/CSS/SVG", "the diagram should stay editable", "a raster mock would not be used directly", or "the product is fictional." Generated probes and mocks are direction artifacts; they are not implementation assets. + +## Craft Contract + +Craft is not a first pass. It is a loop with these required artifacts: + +1. Confirmed design brief from `shape`. +2. Approved visual direction, from generated probes / mocks when image generation is available. +3. Mock fidelity inventory: the visible ingredients from the approved direction that must survive into code. +4. Semantic, functional implementation using the project's real stack and conventions. +5. Browser evidence across relevant viewports. +6. At least one critique-and-fix pass after the first browser inspection, unless the first pass has no material defects. + +Do not let generated mockups replace interface structure, copy, accessibility, responsive behavior, or state design. But do treat the approved mock as a concrete visual contract for composition, hierarchy, density, atmosphere, signature motifs, image needs, and distinctive visual moves. "North star" means "preserve the important visible ingredients in semantic code," not "use it as loose mood." + +## Step 1: Shape the Design + +Run $impeccable shape, passing along whatever feature description the user provided. + +Wait for the design brief to be fully confirmed by the user before proceeding. The brief is your blueprint, and every implementation decision should trace back to it. + +If this craft run resumed after `teach` created PRODUCT.md, run shape now. Do not treat the teach interview, PRODUCT.md, or a summary of project context as a substitute for shape. Shape is task-specific and must cover scope, content/states, visual direction, constraints, anti-goals, probes when applicable, and explicit brief confirmation. + +If the user has already run $impeccable shape and has a confirmed design brief, skip this step and use the existing brief. + +## Step 2: Load References + +Based on the design brief's "Recommended References" section, consult the relevant impeccable reference files. At minimum, always consult: + +- [spatial-design.md](spatial-design.md) for layout and spacing +- [typography.md](typography.md) for type hierarchy + +Then add references based on the brief's needs: +- Complex interactions or forms? Consult [interaction-design.md](interaction-design.md) +- Animation or transitions? Consult [motion-design.md](motion-design.md) +- Color-heavy or themed? Consult [color-and-contrast.md](color-and-contrast.md) +- Responsive requirements? Consult [responsive-design.md](responsive-design.md) +- Heavy on copy, labels, or errors? Consult [ux-writing.md](ux-writing.md) + +## Step 3: Land the Visual Direction (Capability-Gated) + +Before implementation, generate high-fidelity visual comps when all of these are true: + +- The work is **net-new** or visually open-ended enough that composition exploration will improve the build. +- The brief's scope is **mid-fi, high-fi, or production-ready**. +- The current harness has **built-in image generation capability** (for example, Codex with a native image tool). Do **not** ask the user to set up external APIs, shell scripts, or one-off tooling just to do this. + +When those conditions are met, this step is mandatory for **both brand and product work** in Codex and any harness with built-in image generation. Use native image generation; in Codex, use the built-in `image_gen` tool via the imagegen skill. If image generation is unavailable, do not ask the user to install APIs or tooling. State in one line that the image step is skipped because the harness lacks native image generation, then proceed. + +Do not skip this step because the eventual UI should be semantic, editable, code-native, responsive, or accessible. Those are implementation requirements, not reasons to avoid visual exploration. + +### Purpose + +Use the mock step to find a stronger visual lane than code-first generation would reliably discover on its own. The brief remains authoritative on user, purpose, content, constraints, states, and anti-goals. The mock clarifies composition, hierarchy, density, typography, and visual tone. + +### What to generate + +Generate **1 to 3** high-fidelity north-star comps based on the confirmed brief. If shape already produced direction probes, use those results as input and generate a more resolved mock from the winning lane, not another unrelated exploration. + +- For brand work, push visual identity, composition, and mood aggressively. +- For product work, still push hierarchy, topology, density, and tone, but keep the comps grounded in realistic product structure and states. +- For landing pages and long-form brand surfaces, show enough of the next section or second fold to establish the system beyond the hero. + +The comps must be genuinely different in primary visual direction, not just color variants. + +### Approval loop + +Show the comps and ask what should carry forward. If the user asks for changes or the best direction is still weak, generate a focused revision before implementation. Continue until one direction is approved, or until the user explicitly delegates the choice. + +If the user delegates, pick the strongest direction and explain the decision using the brief, not personal taste. + +Before moving to implementation, summarize: + +- What to carry into code +- What **not** to literalize from the mock + +This summary is required before Step 4. It is the handoff between visual exploration and semantic implementation. + +### Mock fidelity inventory + +Before building, inventory the approved mock's major visible ingredients: + +- Hero silhouette and dominant composition. +- Signature motifs: planets, devices, portraits, charts, route lines, insets, badges, or other memorable objects. +- Nav and primary CTA treatment. +- Section sequence visible in the mock, especially the second fold. +- Image-native content the concept depends on. +- Typography, density, color/material treatment, and motion cues. + +For each ingredient, decide how it will be implemented: semantic HTML/CSS/SVG, generated asset, sourced project asset, icon library, canvas/WebGL, or an explicitly accepted omission. Do not substitute a different hero composition or new visual driver after approval unless the user approves the change. + +Treat the mock as a **north star**, not a screenshot to trace. Do **not** rasterize core UI text or let the mock override the confirmed brief. But if the live result lacks the mock's major visible ingredients, the implementation is wrong. + +## Step 4: Asset Extraction (Need-Gated) + +If the chosen direction includes image-native visual ingredients that would materially improve the implementation, generate them as separate assets before building. + +Good candidates: + +- stickers +- badges +- seals +- tickets +- graphic labels +- textures +- abstract objects +- decorative marks +- non-semantic scene elements + +For travel, editorial, portfolio, venue, product showcase, entertainment, education, or any other image-led brand surface, visual assets are usually core content, not decoration. Do not ship abstract CSS panels where the approved mock or subject matter calls for real imagery, generated plates, illustrations, maps, product/object renders, or destination scenes. + +Do **not** export assets for core UI text, navigation, body copy, or any structure that should stay semantic and editable in code. + +Usually **1 to 5** extracted assets is enough. If the design can be built cleanly in HTML/CSS/SVG, prefer that over raster assets. If the mock contains major visual content that cannot be built credibly in code, asset extraction is not optional. + +## Step 5: Build to Production Quality + +Implement the feature following the design brief. Build in passes so structure, visual system, states, motion/media, and responsive behavior each get deliberate attention. The list below is the definition of done, not inspiration. + +### Production bar + +- Use real or realistic content. Remove placeholder copy, placeholder images, dead links, fake controls, and unused scaffold before presenting. +- Preserve the approved mock's major ingredients. Missing hero objects, missing world/product imagery, different section structure, downgraded CTA/nav treatment, or generic replacements for distinctive motifs are blocking defects unless the user accepted the change. +- Build semantically first: real headings, landmarks, labels, form associations, button/link semantics, accessible names, and state announcements where needed. +- Calibrate spacing, alignment, grid placement, and vertical rhythm deliberately. Do not accept default gaps, arbitrary margins, unbalanced whitespace, or accidental optical misalignment. +- Make typography intentional: chosen font loading strategy, clear hierarchy, readable measure, stable line breaks, tuned wrapping, and no overflow at mobile or large desktop sizes. +- Design realistic state coverage: default, hover where supported, focus-visible, active, disabled, loading, error, success, empty, overflow, long text, short text, and first-run states where relevant. +- Make interaction quality feel finished: keyboard paths, touch targets, feedback timing, scroll behavior, transitions between states, and no hover-only functionality. +- Use icons from the project's established icon set when available. If no set exists, choose a coherent library or use accessible text controls; do not mix unrelated icon styles. +- Optimize imagery and media: correct dimensions, useful alt text, lazy loading below the fold, modern formats when practical, responsive `srcset` / `picture` for raster assets, and no project-referenced asset left outside the workspace. +- Make motion feel premium: use atmospheric blur, filter, mask, shadow, or reveal effects when they improve the experience; avoid casual layout-property animation, bound expensive effects, verify smoothness in-browser, respect reduced motion, and avoid choreography that blocks task completion. +- Preserve maintainability: reusable local patterns, clear component boundaries, project conventions, no rasterized UI text, and no hard-coded one-off hacks when a better local pattern exists. +- Fit the technical context: production build passes, no obvious console errors, no avoidable layout shift, no needless dependency, and no broken asset path. +- If you discover a design question that materially changes the brief or approved direction, stop and ask rather than guessing. + +## Step 6: Browser-Based Iteration + +**This step is critical.** Do not stop after the first implementation pass. + +Open the result in a browser. In Codex, use browser-use or equivalent browser automation when available; otherwise use Playwright or ask the user for screenshots. Inspect screenshots, not just DOM or terminal output. + +### Required viewport pass + +Check the experience at the viewports that matter for the brief. Default minimum: + +- Mobile narrow +- Tablet or small laptop +- Desktop wide + +For each viewport, capture or inspect the rendered state and look for visual defects: overlap, clipping, weak hierarchy, off-grid alignment, awkward whitespace, cramped controls, unreadable type, broken imagery, hover-only functionality, layout shift, and text overflow. + +### Critique and fix loop + +After the first browser pass, write a short critique for yourself and patch the implementation. Repeat browser inspection after fixes. Continue until no material issues remain against this checklist: + +1. **Does it match the brief?** Compare the live result against every section of the design brief. Fix discrepancies. +2. **Does it match the approved mock?** Compare screenshots against the mock fidelity inventory: hero silhouette, major motifs, imagery, nav/CTA, section sequence, density, color/materials, and second-fold substance. Missing major ingredients are P0 defects. +3. **Does it pass the AI slop test?** If someone saw this and said "AI made this," would they believe it immediately? If yes, it needs more design intention. +4. **Check against impeccable's DON'T guidelines.** Fix any anti-pattern violations. +5. **Check every state.** Navigate through empty, error, loading, and edge case states. Each one should feel intentional, not like an afterthought. +6. **Check responsive behavior.** The design should adapt compositionally, not merely shrink. +7. **Check craft details.** Spacing consistency, optical alignment, type hierarchy, color contrast, image quality, icon coherence, interactive feedback, motion timing, and focus treatment. +8. **Check performance basics.** No obviously oversized images, avoidable layout thrash, blocking animations, or heavy assets without a reason. + +The exit bar is not "it works." It is: the rendered result looks intentional at all checked viewports, all expected states are handled, no placeholders remain unless explicitly accepted, and the implementation quality would be defensible in a high-end studio review. + +## Step 7: Present + +Present the result to the user: +- Show the feature in its primary state +- Summarize the browser/viewports checked and the most important fixes made after inspection +- Walk through the key states (empty, error, responsive) +- Explain design decisions that connect back to the design brief and, when used, the chosen north-star mock. Include any accepted deviations from the mock; do not hide unimplemented mock ingredients. +- Note any remaining limitations or follow-up risks honestly +- Ask: "What's working? What isn't?" + +Iterate based on feedback. Good design is rarely right on the first pass. diff --git a/.agents/skills/impeccable/reference/critique.md b/.agents/skills/impeccable/reference/critique.md new file mode 100644 index 00000000..4e9b73db --- /dev/null +++ b/.agents/skills/impeccable/reference/critique.md @@ -0,0 +1,213 @@ +> **Additional context needed**: what the interface is trying to accomplish. + +### Gather Assessments + +Launch two independent assessments. **Neither may see the other's output.** This isolation is what makes the combined score honest. Running both in one head silently anchors them to each other; do not shortcut it for cost, speed, or context-size reasons. + +Delegate each assessment to a separate sub-agent (Claude Code's `Agent` tool, Codex's subagent spawning, etc.). Each returns structured findings as text. Do NOT output findings to the user yet. + +Fall back to sequential in-head work only if the environment genuinely cannot spawn sub-agents. + +**Tab isolation**: When browser automation is available, each assessment MUST create its own new tab. Never reuse an existing tab, even if one is already open at the correct URL. This prevents the two assessments from interfering with each other's page state. + +#### Assessment A: LLM Design Review + +Read the relevant source files (HTML, CSS, JS/TS) and, if browser automation is available, visually inspect the live page. **Create a new tab** for this; do not reuse existing tabs. After navigation, label the tab by setting the document title: +```javascript +document.title = '[LLM] ' + document.title; +``` +Think like a design director. Evaluate: + +**AI Slop Detection (CRITICAL)**: Does this look like every other AI-generated interface? Review against ALL **DON'T** guidelines from the parent impeccable skill (already loaded in this context). Check for AI color palette, gradient text, dark glows, glassmorphism, hero metric layouts, identical card grids, generic fonts, and all other tells. **The test**: If someone said "AI made this," would you believe them immediately? + +**Holistic Design Review**: visual hierarchy (eye flow, primary action clarity), information architecture (structure, grouping, cognitive load), emotional resonance (does it match brand and audience?), discoverability (are interactive elements obvious?), composition (balance, whitespace, rhythm), typography (hierarchy, readability, font choices), color (purposeful use, cohesion, accessibility), states & edge cases (empty, loading, error, success), microcopy (clarity, tone, helpfulness). + +**Cognitive Load** (consult [cognitive-load](cognitive-load.md)): +- Run the 8-item cognitive load checklist. Report failure count: 0-1 = low (good), 2-3 = moderate, 4+ = critical. +- Count visible options at each decision point. If >4, flag it. +- Check for progressive disclosure: is complexity revealed only when needed? + +**Emotional Journey**: +- What emotion does this interface evoke? Is that intentional? +- **Peak-end rule**: Is the most intense moment positive? Does the experience end well? +- **Emotional valleys**: Check for anxiety spikes at high-stakes moments (payment, delete, commit). Are there design interventions (progress indicators, reassurance copy, undo options)? + +**Nielsen's Heuristics** (consult [heuristics-scoring](heuristics-scoring.md)): +Score each of the 10 heuristics 0-4. This scoring will be presented in the report. + +Return structured findings covering: AI slop verdict, heuristic scores, cognitive load assessment, what's working (2-3 items), priority issues (3-5 with what/why/fix), minor observations, and provocative questions. + +#### Assessment B: Automated Detection + +Run the bundled deterministic detector, which flags 27 specific patterns (AI slop tells + general design quality). + +**CLI scan**: +```bash +npx impeccable --json [--fast] [target] +``` + +- Pass HTML/JSX/TSX/Vue/Svelte files or directories as `[target]` (anything with markup). Do not pass CSS-only files. +- For URLs, skip the CLI scan (it requires Puppeteer). Use browser visualization instead. +- For large directories (200+ scannable files), use `--fast` (regex-only, skips jsdom) +- For 500+ files, narrow scope or ask the user +- Exit code 0 = clean, 2 = findings + +**Browser visualization**: **required** when browser automation tools are available AND the target is a viewable page. The `[Human]` overlay tab is the user-facing deliverable; the critique is incomplete without it. Skip only if the target is not a viewable page (CSS-only file, non-browser target). + +The overlay is a **visual aid for the user**. It highlights issues directly in their browser. Do NOT scroll through the page to screenshot overlays. Instead, read the console output to get the results programmatically. + +1. **Start the live detection server**: + ```bash + npx impeccable live & + ``` + Note the port printed to stdout (auto-assigned). Use `--port=PORT` to fix it. +2. **Create a new tab** and navigate to the page (use dev server URL for local files, or direct URL). Do not reuse existing tabs. +3. **Label the tab** via `javascript_tool` so the user can distinguish it: + ```javascript + document.title = '[Human] ' + document.title; + ``` +4. **Scroll to top** to ensure the page is scrolled to the very top before injection +5. **Inject** via `javascript_tool` (replace PORT with the port from step 1): + ```javascript + const s = document.createElement('script'); s.src = 'http://localhost:PORT/detect.js'; document.head.appendChild(s); + ``` +6. Wait 2-3 seconds for the detector to render overlays +7. **Read results from console** using `read_console_messages` with pattern `impeccable`. The detector logs all findings with the `[impeccable]` prefix. Do NOT scroll through the page to take screenshots of the overlays. +8. **Cleanup**: Stop the live server when done: + ```bash + npx impeccable live stop + ``` + +For multi-view targets, inject on 3-5 representative pages. If injection fails, continue with CLI results only. + +Return: CLI findings (JSON), browser console findings (if applicable), and any false positives noted. + +### Generate Combined Critique Report + +Synthesize both assessments into a single report. Do NOT simply concatenate. Weave the findings together, noting where the LLM review and detector agree, where the detector caught issues the LLM missed, and where detector findings are false positives. + +Structure your feedback as a design director would: + +#### Design Health Score +> *Consult [heuristics-scoring](heuristics-scoring.md)* + +Present the Nielsen's 10 heuristics scores as a table: + +| # | Heuristic | Score | Key Issue | +|---|-----------|-------|-----------| +| 1 | Visibility of System Status | ? | [specific finding or "n/a" if solid] | +| 2 | Match System / Real World | ? | | +| 3 | User Control and Freedom | ? | | +| 4 | Consistency and Standards | ? | | +| 5 | Error Prevention | ? | | +| 6 | Recognition Rather Than Recall | ? | | +| 7 | Flexibility and Efficiency | ? | | +| 8 | Aesthetic and Minimalist Design | ? | | +| 9 | Error Recovery | ? | | +| 10 | Help and Documentation | ? | | +| **Total** | | **??/40** | **[Rating band]** | + +Be honest with scores. A 4 means genuinely excellent. Most real interfaces score 20-32. + +#### Anti-Patterns Verdict + +**Start here.** Does this look AI-generated? + +**LLM assessment**: Your own evaluation of AI slop tells. Cover overall aesthetic feel, layout sameness, generic composition, missed opportunities for personality. + +**Deterministic scan**: Summarize what the automated detector found, with counts and file locations. Note any additional issues the detector caught that you missed, and flag any false positives. + +**Visual overlays** (if browser was used): Tell the user that overlays are now visible in the **[Human]** tab in their browser, highlighting the detected issues. Summarize what the console output reported. + +#### Overall Impression +A brief gut reaction: what works, what doesn't, and the single biggest opportunity. + +#### What's Working +Highlight 2-3 things done well. Be specific about why they work. + +#### Priority Issues +The 3-5 most impactful design problems, ordered by importance. + +For each issue, tag with **P0-P3 severity** (consult [heuristics-scoring](heuristics-scoring.md) for severity definitions): +- **[P?] What**: Name the problem clearly +- **Why it matters**: How this hurts users or undermines goals +- **Fix**: What to do about it (be concrete) +- **Suggested command**: Which command could address this (from: $impeccable adapt, $impeccable animate, $impeccable audit, $impeccable bolder, $impeccable clarify, $impeccable colorize, $impeccable critique, $impeccable delight, $impeccable distill, $impeccable document, $impeccable harden, $impeccable layout, $impeccable onboard, $impeccable optimize, $impeccable overdrive, $impeccable polish, $impeccable quieter, $impeccable shape, $impeccable typeset) + +#### Persona Red Flags +> *Consult [personas](personas.md)* + +Auto-select 2-3 personas most relevant to this interface type (use the selection table in the reference). If `AGENTS.md` contains a `## Design Context` section from `impeccable teach`, also generate 1-2 project-specific personas from the audience/brand info. + +For each selected persona, walk through the primary user action and list specific red flags found: + +**Alex (Power User)**: No keyboard shortcuts detected. Form requires 8 clicks for primary action. Forced modal onboarding. High abandonment risk. + +**Jordan (First-Timer)**: Icon-only nav in sidebar. Technical jargon in error messages ("404 Not Found"). No visible help. Will abandon at step 2. + +Be specific. Name the exact elements and interactions that fail each persona. Don't write generic persona descriptions; write what broke for them. + +#### Minor Observations +Quick notes on smaller issues worth addressing. + +#### Questions to Consider +Provocative questions that might unlock better solutions: +- "What if the primary action were more prominent?" +- "Does this need to feel this complex?" +- "What would a confident version of this look like?" + +**Remember**: +- Be direct. Vague feedback wastes everyone's time. +- Be specific. "The submit button," not "some elements." +- Say what's wrong AND why it matters to users. +- Give concrete suggestions. Cut "consider exploring..." entirely. +- Prioritize ruthlessly. If everything is important, nothing is. +- Don't soften criticism. Developers need honest feedback to ship great design. + +### Ask the User + +**After presenting findings**, use targeted questions based on what was actually found. STOP and use Codex's structured user-input/question tool when available; if unavailable, ask directly in chat to clarify what you cannot infer. These answers will shape the action plan. + +Ask questions along these lines (adapt to the specific findings; do NOT ask generic questions): + +1. **Priority direction**: Based on the issues found, ask which category matters most to the user right now. For example: "I found problems with visual hierarchy, color usage, and information overload. Which area should we tackle first?" Offer the top 2-3 issue categories as options. + +2. **Design intent**: If the critique found a tonal mismatch, ask whether it was intentional. For example: "The interface feels clinical and corporate. Is that the intended tone, or should it feel warmer/bolder/more playful?" Offer 2-3 tonal directions as options based on what would fix the issues found. + +3. **Scope**: Ask how much the user wants to take on. For example: "I found N issues. Want to address everything, or focus on the top 3?" Offer scope options like "Top 3 only", "All issues", "Critical issues only". + +4. **Constraints** (optional; only ask if relevant): If the findings touch many areas, ask if anything is off-limits. For example: "Should any sections stay as-is?" This prevents the plan from touching things the user considers done. + +**Rules for questions**: +- Every question must reference specific findings from the report. Never ask generic "who is your audience?" questions. +- Keep it to 2-4 questions maximum. Respect the user's time. +- Offer concrete options, not open-ended prompts. +- If findings are straightforward (e.g., only 1-2 clear issues), skip questions and go directly to Recommended Actions. + +### Recommended Actions + +**After receiving the user's answers**, present a prioritized action summary reflecting the user's priorities and scope from Ask the User. + +#### Action Summary + +List recommended commands in priority order, based on the user's answers: + +1. **`$command-name`**: Brief description of what to fix (specific context from critique findings) +2. **`$command-name`**: Brief description (specific context) +... + +**Rules for recommendations**: +- Only recommend commands from: $impeccable adapt, $impeccable animate, $impeccable audit, $impeccable bolder, $impeccable clarify, $impeccable colorize, $impeccable critique, $impeccable delight, $impeccable distill, $impeccable document, $impeccable harden, $impeccable layout, $impeccable onboard, $impeccable optimize, $impeccable overdrive, $impeccable polish, $impeccable quieter, $impeccable shape, $impeccable typeset +- Order by the user's stated priorities first, then by impact +- Each item's description should carry enough context that the command knows what to focus on +- Map each Priority Issue to the appropriate command +- Skip commands that would address zero issues +- If the user chose a limited scope, only include items within that scope +- If the user marked areas as off-limits, exclude commands that would touch those areas +- End with `$impeccable polish` as the final step if any fixes were recommended + +After presenting the summary, tell the user: + +> You can ask me to run these one at a time, all at once, or in any order you prefer. +> +> Re-run `$impeccable critique` after fixes to see your score improve. diff --git a/.agents/skills/impeccable/reference/delight.md b/.agents/skills/impeccable/reference/delight.md new file mode 100644 index 00000000..b3196705 --- /dev/null +++ b/.agents/skills/impeccable/reference/delight.md @@ -0,0 +1,302 @@ +> **Additional context needed**: what's appropriate for the domain (playful vs professional vs quirky vs elegant). + +Find the moments where personality and unexpected polish would turn a functional interface into one users remember and tell other people about. Add only where the moment earns it; delight everywhere reads as noise. + +--- + +## Register + +Brand: delight can be distributed across copy voice, section transitions, discovery rewards, seasonal touches, personality across the whole surface. + +Product: delight at specific moments, not pages. Completion, first-time actions, error recovery, milestone crossings. Reliability and consistency carry the rest of the experience; delight pushed everywhere reads as noise. + +--- + +## Assess Delight Opportunities + +Identify where delight would enhance (not distract from) the experience: + +1. **Find natural delight moments**: + - **Success states**: Completed actions (save, send, publish) + - **Empty states**: First-time experiences, onboarding + - **Loading states**: Waiting periods that could be entertaining + - **Achievements**: Milestones, streaks, completions + - **Interactions**: Hover states, clicks, drags + - **Errors**: Softening frustrating moments + - **Easter eggs**: Hidden discoveries for curious users + +2. **Understand the context**: + - What's the brand personality? (Playful? Professional? Quirky? Elegant?) + - Who's the audience? (Tech-savvy? Creative? Corporate?) + - What's the emotional context? (Accomplishment? Exploration? Frustration?) + - What's appropriate? (Banking app ≠ gaming app) + +3. **Define delight strategy**: + - **Subtle sophistication**: Refined micro-interactions (luxury brands) + - **Playful personality**: Whimsical illustrations and copy (consumer apps) + - **Helpful surprises**: Anticipating needs before users ask (productivity tools) + - **Sensory richness**: Satisfying sounds, smooth animations (creative tools) + +If any of these are unclear from the codebase, STOP and use Codex's structured user-input/question tool when available; if unavailable, ask directly in chat to clarify what you cannot infer. + +**CRITICAL**: Delight should enhance usability, never obscure it. If users notice the delight more than accomplishing their goal, you've gone too far. + +## Delight Principles + +Follow these guidelines: + +### Delight Amplifies, Never Blocks +- Delight moments should be quick (< 1 second) +- Never delay core functionality for delight +- Make delight skippable or subtle +- Respect user's time and task focus + +### Surprise and Discovery +- Hide delightful details for users to discover +- Reward exploration and curiosity +- Don't announce every delight moment +- Let users share discoveries with others + +### Appropriate to Context +- Match delight to emotional moment (celebrate success, empathize with errors) +- Respect the user's state (don't be playful during critical errors) +- Match brand personality and audience expectations +- Cultural sensitivity (what's delightful varies by culture) + +### Compound Over Time +- Delight should remain fresh with repeated use +- Vary responses (not same animation every time) +- Reveal deeper layers with continued use +- Build anticipation through patterns + +## Delight Techniques + +Add personality and joy through these methods: + +### Micro-interactions & Animation + +**Button delight**: +```css +/* Satisfying button press */ +.button { + transition: transform 0.1s, box-shadow 0.1s; +} +.button:active { + transform: translateY(2px); + box-shadow: 0 2px 4px rgba(0,0,0,0.2); +} + +/* Ripple effect on click */ +/* Smooth lift on hover */ +.button:hover { + transform: translateY(-2px); + transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1); /* ease-out-quart */ +} +``` + +**Loading delight**: +- Playful loading animations (not just spinners) +- Personality in loading messages (write product-specific ones, not generic AI filler) +- Progress indication with encouraging messages +- Skeleton screens with subtle animations + +**Success animations**: +- Checkmark draw animation +- Confetti burst for major achievements +- Gentle scale + fade for confirmation +- Satisfying sound effects (subtle) + +**Hover surprises**: +- Icons that animate on hover +- Color shifts or glow effects +- Tooltip reveals with personality +- Cursor changes (custom cursors for branded experiences) + +### Personality in Copy + +**Playful error messages**: +``` +"Error 404" +"This page is playing hide and seek. (And winning)" + +"Connection failed" +"Looks like the internet took a coffee break. Want to retry?" +``` + +**Encouraging empty states**: +``` +"No projects" +"Your canvas awaits. Create something amazing." + +"No messages" +"Inbox zero! You're crushing it today." +``` + +**Playful labels & tooltips**: +``` +"Delete" +"Send to void" (for playful brand) + +"Help" +"Rescue me" (tooltip) +``` + +**IMPORTANT**: Match copy personality to brand. Banks shouldn't be wacky, but they can be warm. + +### Illustrations & Visual Personality + +**Custom illustrations**: +- Empty state illustrations (not stock icons) +- Error state illustrations (friendly monsters, quirky characters) +- Loading state illustrations (animated characters) +- Success state illustrations (celebrations) + +**Icon personality**: +- Custom icon set matching brand personality +- Animated icons (subtle motion on hover/click) +- Illustrative icons (more detailed than generic) +- Consistent style across all icons + +**Background effects**: +- Subtle particle effects +- Gradient mesh backgrounds +- Geometric patterns +- Parallax depth +- Time-of-day themes (morning vs night) + +### Satisfying Interactions + +**Drag and drop delight**: +- Lift effect on drag (shadow, scale) +- Snap animation when dropped +- Satisfying placement sound +- Undo toast ("Dropped in wrong place? [Undo]") + +**Toggle switches**: +- Smooth slide with spring physics +- Color transition +- Haptic feedback on mobile +- Optional sound effect + +**Progress & achievements**: +- Streak counters with celebratory milestones +- Progress bars that "celebrate" at 100% +- Badge unlocks with animation +- Playful stats ("You're on fire! 5 days in a row") + +**Form interactions**: +- Input fields that animate on focus +- Checkboxes with a satisfying scale pulse when checked +- Success state that celebrates valid input +- Auto-grow textareas + +### Sound Design + +**Subtle audio cues** (when appropriate): +- Notification sounds (distinctive but not annoying) +- Success sounds (satisfying "ding") +- Error sounds (empathetic, not harsh) +- Typing sounds for chat/messaging +- Ambient background audio (very subtle) + +**IMPORTANT**: +- Respect system sound settings +- Provide mute option +- Keep volumes quiet (subtle cues, not alarms) +- Don't play on every interaction (sound fatigue is real) + +### Easter Eggs & Hidden Delights + +**Discovery rewards**: +- Konami code unlocks special theme +- Hidden keyboard shortcuts (Cmd+K for special features) +- Hover reveals on logos or illustrations +- Alt text jokes on images (for screen reader users too!) +- Console messages for developers ("Like what you see? We're hiring!") + +**Seasonal touches**: +- Holiday themes (subtle, tasteful) +- Seasonal color shifts +- Weather-based variations +- Time-based changes (dark at night, light during day) + +**Contextual personality**: +- Different messages based on time of day +- Responses to specific user actions +- Randomized variations (not same every time) +- Progressive reveals with continued use + +### Loading & Waiting States + +**Make waiting engaging**: +- Interesting loading messages that rotate +- Progress bars with personality +- Mini-games during long loads +- Fun facts or tips while waiting +- Countdown with encouraging messages + +``` +Loading messages: write ones specific to your product, not generic AI filler: +- "Crunching your latest numbers..." +- "Syncing with your team's changes..." +- "Preparing your dashboard..." +- "Checking for updates since yesterday..." +``` + +**WARNING**: Avoid cliched loading messages like "Herding pixels", "Teaching robots to dance", "Consulting the magic 8-ball", "Counting backwards from infinity". These are AI-slop copy, instantly recognizable as machine-generated. Write messages that are specific to what your product actually does. + +### Celebration Moments + +**Success celebrations**: +- Confetti for major milestones +- Animated checkmarks for completions +- Progress bar celebrations at 100% +- "Achievement unlocked" style notifications +- Personalized messages ("You published your 10th article!") + +**Milestone recognition**: +- First-time actions get special treatment +- Streak tracking and celebration +- Progress toward goals +- Anniversary celebrations + +## Implementation Patterns + +**Animation libraries**: +- Framer Motion (React) +- GSAP (universal) +- Lottie (After Effects animations) +- Canvas confetti (party effects) + +**Sound libraries**: +- Howler.js (audio management) +- Use-sound (React hook) + +**Physics libraries**: +- React Spring (spring physics) +- Popmotion (animation primitives) + +**IMPORTANT**: File size matters. Compress images, optimize animations, lazy load delight features. + +**NEVER**: +- Delay core functionality for delight +- Force users through delightful moments (make skippable) +- Use delight to hide poor UX +- Overdo it (less is more) +- Ignore accessibility (animate responsibly, provide alternatives) +- Make every interaction delightful (special moments should be special) +- Sacrifice performance for delight +- Be inappropriate for context (read the room) + +## Verify Delight Quality + +Test that delight actually delights: + +- **User reactions**: Do users smile? Share screenshots? +- **Doesn't annoy**: Still pleasant after 100th time? +- **Doesn't block**: Can users opt out or skip? +- **Performant**: No jank, no slowdown +- **Appropriate**: Matches brand and context +- **Accessible**: Works with reduced motion, screen readers + +When the moments feel earned, hand off to `$impeccable polish` for the final pass. diff --git a/.agents/skills/impeccable/reference/distill.md b/.agents/skills/impeccable/reference/distill.md new file mode 100644 index 00000000..2ac85043 --- /dev/null +++ b/.agents/skills/impeccable/reference/distill.md @@ -0,0 +1,111 @@ +Strip a design to its essence. Remove anything that doesn't earn its place: redundant elements, repeated information, decorative noise, cosmetic complexity. + + +--- + +## Assess Current State + +Analyze what makes the design feel complex or cluttered: + +1. **Identify complexity sources**: + - **Too many elements**: Competing buttons, redundant information, visual clutter + - **Excessive variation**: Too many colors, fonts, sizes, styles without purpose + - **Information overload**: Everything visible at once, no progressive disclosure + - **Visual noise**: Unnecessary borders, shadows, backgrounds, decorations + - **Confusing hierarchy**: Unclear what matters most + - **Feature creep**: Too many options, actions, or paths forward + +2. **Find the essence**: + - What's the primary user goal? (There should be ONE) + - What's actually necessary vs nice-to-have? + - What can be removed, hidden, or combined? + - What's the 20% that delivers 80% of value? + +If any of these are unclear from the codebase, STOP and use Codex's structured user-input/question tool when available; if unavailable, ask directly in chat to clarify what you cannot infer. + +**CRITICAL**: Simplicity is not about removing features. It's about removing obstacles between users and their goals. Every element should justify its existence. + +## Plan Simplification + +Create a ruthless editing strategy: + +- **Core purpose**: What's the ONE thing this should accomplish? +- **Essential elements**: What's truly necessary to achieve that purpose? +- **Progressive disclosure**: What can be hidden until needed? +- **Consolidation opportunities**: What can be combined or integrated? + +**IMPORTANT**: Simplification is hard. It requires saying no to good ideas to make room for great execution. Be ruthless. + +## Simplify the Design + +Systematically remove complexity across these dimensions: + +### Information Architecture +- **Reduce scope**: Remove secondary actions, optional features, redundant information +- **Progressive disclosure**: Hide complexity behind clear entry points (accordions, modals, step-through flows) +- **Combine related actions**: Merge similar buttons, consolidate forms, group related content +- **Clear hierarchy**: ONE primary action, few secondary actions, everything else tertiary or hidden +- **Remove redundancy**: If it's said elsewhere, don't repeat it here + +### Visual Simplification +- **Reduce color palette**: Use 1-2 colors plus neutrals, not 5-7 colors +- **Limit typography**: One font family, 3-4 sizes maximum, 2-3 weights +- **Remove decorations**: Eliminate borders, shadows, backgrounds that don't serve hierarchy or function +- **Flatten structure**: Reduce nesting, remove unnecessary containers; never nest cards inside cards +- **Remove unnecessary cards**: Cards aren't needed for basic layout; use spacing and alignment instead +- **Consistent spacing**: Use one spacing scale, remove arbitrary gaps + +### Layout Simplification +- **Linear flow**: Replace complex grids with simple vertical flow where possible +- **Remove sidebars**: Move secondary content inline or hide it +- **Full-width**: Use available space generously instead of complex multi-column layouts +- **Consistent alignment**: Pick left or center, stick with it +- **Generous white space**: Let content breathe, don't pack everything tight + +### Interaction Simplification +- **Reduce choices**: Fewer buttons, fewer options, clearer path forward (paradox of choice is real) +- **Smart defaults**: Make common choices automatic, only ask when necessary +- **Inline actions**: Replace modal flows with inline editing where possible +- **Remove steps**: Can signup be one step instead of three? Can checkout be simplified? +- **Clear CTAs**: ONE obvious next step, not five competing actions + +### Content Simplification +- **Shorter copy**: Cut every sentence in half, then do it again +- **Active voice**: "Save changes" not "Changes will be saved" +- **Remove jargon**: Plain language always wins +- **Scannable structure**: Short paragraphs, bullet points, clear headings +- **Essential information only**: Remove marketing fluff, legalese, hedging +- **Remove redundant copy**: No headers restating intros, no repeated explanations, say it once + +### Code Simplification +- **Remove unused code**: Dead CSS, unused components, orphaned files +- **Flatten component trees**: Reduce nesting depth +- **Consolidate styles**: Merge similar styles, use utilities consistently +- **Reduce variants**: Does that component need 12 variations, or can 3 cover 90% of cases? + +**NEVER**: +- Remove necessary functionality (simplicity ≠ feature-less) +- Sacrifice accessibility for simplicity (clear labels and ARIA still required) +- Make things so simple they're unclear (mystery ≠ minimalism) +- Remove information users need to make decisions +- Eliminate hierarchy completely (some things should stand out) +- Oversimplify complex domains (match complexity to actual task complexity) + +## Verify Simplification + +Ensure simplification improves usability: + +- **Faster task completion**: Can users accomplish goals more quickly? +- **Reduced cognitive load**: Is it easier to understand what to do? +- **Still complete**: Are all necessary features still accessible? +- **Clearer hierarchy**: Is it obvious what matters most? +- **Better performance**: Does simpler design load faster? + +## Document Removed Complexity + +If you removed features or options: +- Document why they were removed +- Consider if they need alternative access points +- Note any user feedback to monitor + +When the cuts feel right, hand off to `$impeccable polish` for the final pass. As Antoine de Saint-Exupéry put it: "Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away." diff --git a/.agents/skills/impeccable/reference/document.md b/.agents/skills/impeccable/reference/document.md new file mode 100644 index 00000000..ebafe4f4 --- /dev/null +++ b/.agents/skills/impeccable/reference/document.md @@ -0,0 +1,427 @@ +Generate a `DESIGN.md` file at the project root that captures the current visual design system, so AI agents generating new screens stay on-brand. + +DESIGN.md follows the [official Google Stitch DESIGN.md format](https://stitch.withgoogle.com/docs/design-md/format/): YAML frontmatter carrying machine-readable design tokens, followed by a markdown body with exactly six sections in a fixed order. **Tokens are normative; prose provides context for how to apply them.** Sections may be omitted when not relevant, but **do not reorder them and do not rename them**. Section headers must match the spec character-for-character so the file stays parseable by other DESIGN.md-aware tools (Stitch itself, awesome-design-md, skill-rest, etc.). + +## The frontmatter: token schema + +The YAML frontmatter is the machine-readable layer. It's what Stitch's linter validates and what the live panel renders tiles from. Keep it tight; every entry should correspond to a token the project actually uses. + +```yaml +--- +name: +description: +colors: + primary: "#b8422e" + neutral-bg: "#faf7f2" + # ...one entry per extracted color; key = descriptive slug +typography: + display: + fontFamily: "Cormorant Garamond, Georgia, serif" + fontSize: "clamp(2.5rem, 7vw, 4.5rem)" + fontWeight: 300 + lineHeight: 1 + letterSpacing: "normal" + body: + # ... +rounded: + sm: "4px" + md: "8px" +spacing: + sm: "8px" + md: "16px" +components: + button-primary: + backgroundColor: "{colors.primary}" + textColor: "{colors.neutral-bg}" + rounded: "{rounded.sm}" + padding: "16px 48px" + button-primary-hover: + backgroundColor: "{colors.primary-deep}" +--- +``` + +Rules that matter: + +- **Token refs** use `{path.to.token}` (e.g. `{colors.primary}`, `{rounded.md}`). Components may reference primitives; primitives may not reference each other. +- **Stitch validates colors as hex sRGB only** (`#RGB` / `#RGBA` / `#RRGGBB` / `#RRGGBBAA`); OKLCH/HSL/P3 trigger a linter warning, not a hard error. YAML accepts the string either way and our own parser is format-agnostic. Choose based on project posture: (a) if the project has an "OKLCH-only" doctrine or uses Display-P3 values that don't round-trip through sRGB, put OKLCH directly in the frontmatter and accept the Stitch linter warning; (b) if the project wants strict Stitch compliance or plans to use their Tailwind/DTCG export pipeline, put hex in the frontmatter and keep OKLCH in prose as the canonical reference. Never split the source of truth without explicit reason. +- **Component sub-tokens** are limited to 8 props: `backgroundColor`, `textColor`, `typography`, `rounded`, `padding`, `size`, `height`, `width`. Shadows, motion, focus rings, backdrop-filter: none of those fit. Carry them in the sidecar (Step 4b). +- **Scale keys are open-ended.** Use whatever names the project already uses (`warm-ash-cream`, `surface-container-low`). Don't rename to Material defaults. +- **Variants are naming convention, not schema.** `button-primary` / `button-primary-hover` / `button-primary-active` as sibling keys. + +## The markdown body: six sections (exact order) + +1. `## Overview` +2. `## Colors` +3. `## Typography` +4. `## Elevation` +5. `## Components` +6. `## Do's and Don'ts` + +Optional evocative subtitles are allowed in the form `## 2. Colors: The [Name] Palette` (Stitch's own outputs do this), but the literal word in each header (Overview, Colors, Typography, Elevation, Components, Do's and Don'ts) must be present. Do NOT add extra top-level sections (Layout Principles, Responsive Behavior, Motion, Agent Prompt Guide). Fold that content into the six spec sections where it naturally belongs. + +## When to run + +- The user just ran `$impeccable teach` and needs the visual side documented. +- The skill noticed no `DESIGN.md` exists and nudged the user to create one. +- An existing `DESIGN.md` is stale (the design has drifted). +- Before a large redesign, to capture the current state as a reference. + +If a `DESIGN.md` already exists, **do not silently overwrite it**. Show the user the existing file and STOP and use Codex's structured user-input/question tool when available; if unavailable, ask directly in chat to clarify what you cannot infer. whether to refresh, overwrite, or merge. + +## Two paths + +- **Scan mode** (default): the project has design tokens, components, or rendered output. Extract, then confirm descriptive language. Use when there's code to analyze. +- **Seed mode**: the project is pre-implementation (fresh teach, nothing built yet). Interview for five high-level answers, write a minimal DESIGN.md marked ``. Re-run in scan mode once there's code. + +Decide by scanning first (Scan mode Step 1). If the scan finds no tokens, no component files, and no rendered site, offer seed mode; don't silently switch. `$impeccable document --seed` forces seed mode regardless of code presence. + +## Scan mode (approach C: auto-extract, then confirm descriptive language) + +### Step 1: Find the design assets + +Search the codebase in priority order: + +1. **CSS custom properties**: grep for `--color-`, `--font-`, `--spacing-`, `--radius-`, `--shadow-`, `--ease-`, `--duration-` declarations in CSS files (usually `src/styles/`, `public/css/`, `app/globals.css`, etc.). Record name, value, and the file it's defined in. +2. **Tailwind config**: if `tailwind.config.{js,ts,mjs}` exists, read the `theme.extend` block for colors, fontFamily, spacing, borderRadius, boxShadow. +3. **CSS-in-JS theme files**: styled-components, emotion, vanilla-extract, stitches; look for `theme.ts`, `tokens.ts`, or equivalent. +4. **Design token files**: `tokens.json`, `design-tokens.json`, Style Dictionary output, W3C token community group format. +5. **Component library**: scan the main button, card, input, navigation, dialog components. Note their variant APIs and default styles. +6. **Global stylesheet**: the root CSS file usually has the base typography and color assignments. +7. **Visible rendered output**: if browser automation tools are available, load the live site and sample computed styles from key elements (body, h1, a, button, .card). This catches values that tokens miss. + +### Step 2: Auto-extract what can be auto-extracted + +Build a structured draft from the discovered tokens. For each token class: + +- **Colors**: Group into Primary / Secondary / Tertiary / Neutral (the Material-derived roles Stitch uses). If the project only has one accent, express it as Primary + Neutral; omit Secondary and Tertiary rather than inventing them. +- **Typography**: Map observed sizes and weights to the Material hierarchy (display / headline / title / body / label). Note font-family stacks and the scale ratio. +- **Elevation**: Catalogue the shadow vocabulary. If the project is flat and uses tonal layering instead, that's a valid answer; state it explicitly. +- **Components**: For each common component (button, card, input, chip, list item, tooltip, nav), extract shape (radius), color assignment, hover/focus treatment, internal padding. +- **Spacing + layout**: Fold into Overview or relevant Components. The spec does NOT have a Layout section. + +### Step 2b: Stage the frontmatter + +From the auto-extracted tokens, draft the YAML frontmatter now (you'll write it at the top of DESIGN.md in Step 4). This is the machine-readable layer: what the live panel and Stitch's linter consume. + +- **Colors**: one entry per extracted color. Key = descriptive slug (`warm-ash-cream`, `editorial-magenta`, not `blue-800`). Value = whichever format the project treats as canonical (OKLCH or hex; see the frontmatter rules above). Don't split the source of truth: one format in the frontmatter, don't redefine the same token in prose with a different value. +- **Typography**: one entry per role (`display`, `headline`, `title`, `body`, `label`). Typography is an object; include only the props that are real for the project (`fontFamily`, `fontSize`, `fontWeight`, `lineHeight`, `letterSpacing`, `fontFeature`, `fontVariation`). +- **Rounded / Spacing**: whatever scale steps the project actually uses, keyed by whatever scale name the project uses (`sm` / `md` / `lg`, or `surface-sm`, or numeric steps). +- **Components**: one entry per variant (`button-primary`, `button-primary-hover`, `button-ghost`). Reference primitives via `{colors.X}`, `{rounded.Y}`. If a variant needs a property Stitch's 8-prop set doesn't cover (shadow, focus ring, backdrop-filter), carry the full snippet in the sidecar instead. + +Skip anything the project doesn't have. Empty scale keys or fabricated tokens pollute the spec. + +### Step 3: Ask the user for qualitative language + +The following require creative input that cannot be auto-extracted. Group them into one `AskUserQuestion` interaction: + +- **Creative North Star**: a single named metaphor for the whole system ("The Editorial Sanctuary", "The Golden State Curator", "The Lab Notebook"). Offer 2-3 options that honor PRODUCT.md's brand personality. +- **Overview voice**: mood adjectives, aesthetic philosophy in 2-3 sentences, anti-references (what the system should not feel like). +- **Color character** (for auto-extracted colors): descriptive names ("Deep Muted Teal-Navy", not "blue-800"). Suggest 2-3 options per key color based on hue/saturation. +- **Elevation philosophy**: flat/layered/lifted. If shadows exist, is their role ambient or structural? +- **Component philosophy**: the feel of buttons, cards, inputs in one phrase ("tactile and confident" vs. "refined and restrained"). + +Quote a line from PRODUCT.md when possible so the user sees their own strategic language carry forward. + +### Step 4: Write DESIGN.md + +The file opens with the YAML frontmatter staged in Step 2b (schema documented at the top of this reference), then the markdown body using the structure below. Headers must match character-for-character. Optional evocative subtitles (e.g. `## 2. Colors: The Coastal Palette`) are allowed. + +```markdown +--- +name: [Project Title] +description: [one-line tagline] +colors: + # ... staged frontmatter from Step 2b +--- + +# Design System: [Project Title] + +## 1. Overview + +**Creative North Star: "[Named metaphor in quotes]"** + +[2-3 paragraph holistic description: personality, density, aesthetic philosophy. Start from the North Star and work outward. State what this system explicitly rejects (pulled from PRODUCT.md's anti-references). End with a short **Key Characteristics:** bullet list.] + +## 2. Colors + +[Describe the palette character in one sentence.] + +### Primary +- **[Descriptive Name]** (#HEX / oklch(...)): [Where and why this color is used. Be specific about context, not just role.] + +### Secondary (optional; omit if the project has only one accent) +- **[Descriptive Name]** (#HEX): [Role.] + +### Tertiary (optional) +- **[Descriptive Name]** (#HEX): [Role.] + +### Neutral +- **[Descriptive Name]** (#HEX): [Text / background / border / divider role.] +- [...] + +### Named Rules (optional, powerful) +**The [Rule Name] Rule.** [Short, forceful prohibition or doctrine, e.g. "The One Voice Rule. The primary accent is used on ≤10% of any given screen. Its rarity is the point."] + +## 3. Typography + +**Display Font:** [Family] (with [fallback]) +**Body Font:** [Family] (with [fallback]) +**Label/Mono Font:** [Family, if distinct] + +**Character:** [1-2 sentence personality description of the pairing.] + +### Hierarchy +- **Display** ([weight], [size/clamp], [line-height]): [Purpose; where it appears.] +- **Headline** ([weight], [size], [line-height]): [Purpose.] +- **Title** ([weight], [size], [line-height]): [Purpose.] +- **Body** ([weight], [size], [line-height]): [Purpose. Include max line length like 65–75ch if relevant.] +- **Label** ([weight], [size], [letter-spacing], [case if uppercase]): [Purpose.] + +### Named Rules (optional) +**The [Rule Name] Rule.** [Short doctrine about type use.] + +## 4. Elevation + +[One paragraph: does this system use shadows, tonal layering, or a hybrid? If "no shadows", say so explicitly and describe how depth is conveyed instead.] + +### Shadow Vocabulary (if applicable) +- **[Role name]** (`box-shadow: [exact value]`): [When to use it.] +- [...] + +### Named Rules (optional) +**The [Rule Name] Rule.** [e.g. "The Flat-By-Default Rule. Surfaces are flat at rest. Shadows appear only as a response to state (hover, elevation, focus)."] + +## 5. Components + +For each component, lead with a short character line, then specify shape, color assignment, states, and any distinctive behavior. + +### Buttons +- **Shape:** [radius described, exact value in parens] +- **Primary:** [color assignment + padding, in semantic + exact terms] +- **Hover / Focus:** [transitions, treatments] +- **Secondary / Ghost / Tertiary (if applicable):** [brief description] + +### Chips (if used) +- **Style:** [background, text color, border treatment] +- **State:** [selected / unselected, filter / action variants] + +### Cards / Containers +- **Corner Style:** [radius] +- **Background:** [colors used] +- **Shadow Strategy:** [reference Elevation section] +- **Border:** [if any] +- **Internal Padding:** [scale] + +### Inputs / Fields +- **Style:** [stroke, background, radius] +- **Focus:** [treatment, e.g. glow, border shift, etc.] +- **Error / Disabled:** [if applicable] + +### Navigation +- **Style, typography, default/hover/active states, mobile treatment.** + +### [Signature Component] (optional; if the project has a distinctive custom component worth documenting) +[Description.] + +## 6. Do's and Don'ts + +Concrete, forceful guardrails. Lead each with "Do" or "Don't". Be specific: include exact colors, pixel values, and named anti-patterns the user mentioned in PRODUCT.md. **Every anti-reference in PRODUCT.md should show up here as a "Don't" with the same language**, so the visual spec carries the strategic line through. Quote PRODUCT.md directly where possible: if PRODUCT.md says *"avoid dark mode with purple gradients, neon accents, glassmorphism"*, the Don'ts here should repeat that by name. + +### Do: +- **Do** [specific prescription with exact values / named rule]. +- **Do** [...] + +### Don't: +- **Don't** [specific prohibition, e.g. "use border-left greater than 1px as a colored stripe"]. +- **Don't** [...] +- **Don't** [...] +``` + +### Step 4b: Write .impeccable/design.json sidecar (extensions only) + +The frontmatter owns token primitives (colors, typography, rounded, spacing, components). The sidecar at `.impeccable/design.json` carries **what Stitch's schema can't hold**: tonal ramps per color, shadow/elevation tokens, motion tokens, breakpoints, full component HTML/CSS snippets (the panel renders these into a shadow DOM), and narrative (north star, rules, do's/don'ts). It extends the frontmatter, it doesn't duplicate it. + +Regenerate the sidecar whenever you regenerate root `DESIGN.md`. If the user only asks to refresh the sidecar (e.g., from the live panel's stale-hint), preserve `DESIGN.md` and write only `.impeccable/design.json`. + +#### Schema + +```json +{ + "schemaVersion": 2, + "generatedAt": "ISO-8601 string", + "title": "Design System: [Project Title]", + "extensions": { + "colorMeta": { + "primary": { "role": "primary", "displayName": "Editorial Magenta", "canonical": "oklch(60% 0.25 350)", "tonalRamp": ["...", "...", "..."] }, + "warm-ash-cream": { "role": "neutral", "displayName": "Warm Ash Cream", "canonical": "oklch(96% 0.005 350)", "tonalRamp": ["...", "...", "..."] } + }, + "typographyMeta": { + "display": { "displayName": "Display", "purpose": "Hero headlines only." } + }, + "shadows": [ + { "name": "ambient-low", "value": "0 4px 24px rgba(0,0,0,0.12)", "purpose": "Diffuse hover glow under accent elements." } + ], + "motion": [ + { "name": "ease-standard", "value": "cubic-bezier(0.4, 0, 0.2, 1)", "purpose": "Default easing for state transitions." } + ], + "breakpoints": [ + { "name": "sm", "value": "640px" } + ] + }, + "components": [ + { + "name": "Primary Button", + "kind": "button | input | nav | chip | card | custom", + "refersTo": "button-primary", + "description": "One-line what and when.", + "html": "", + "css": ".ds-btn-primary { background: #191c1d; color: #fff; padding: 16px 48px; letter-spacing: 0.05em; text-transform: uppercase; font-weight: 500; border: none; border-radius: 0; transition: background 0.2s, transform 0.2s; } .ds-btn-primary:hover { background: oklch(60% 0.25 350); transform: translateY(-2px); }" + } + ], + "narrative": { + "northStar": "The Editorial Sanctuary", + "overview": "2-3 paragraphs of the philosophy, pulled from DESIGN.md Overview section.", + "keyCharacteristics": ["...", "..."], + "rules": [{ "name": "The One Voice Rule", "body": "...", "section": "colors|typography|elevation" }], + "dos": ["Do use ..."], + "donts": ["Don't use ..."] + } +} +``` + +**What changed from schemaVersion 1.** The old sidecar carried token primitive arrays (`tokens.colors[]`, `tokens.typography[]`, etc.). Those values now live in the frontmatter. The sidecar only carries metadata that can't live in the frontmatter (tonal ramps, canonical OKLCH when the hex is an approximation, display names, role hints), keyed by the frontmatter token name (`colorMeta.`, `typographyMeta.`). Components still carry full HTML/CSS because Stitch's 8-prop set can't hold them. + +#### Component translation rules + +The `html` and `css` fields must be **self-contained, drop-in snippets** that render correctly when injected into a shadow DOM. The panel applies them directly: no post-processing, no framework runtime. + +1. **Tailwind expansion.** If the source uses Tailwind (className="bg-primary text-white rounded-lg px-6 py-3"), expand every utility to literal CSS properties in the `css` string. Do **not** reference Tailwind classes; do **not** assume a Tailwind CSS bundle is loaded. Each component is self-contained. +2. **Token resolution.** If the project exposes tokens as CSS custom properties on `:root` (e.g. `--color-primary`, `--radius-md`), reference them via `var(--color-primary)`; they inherit through the shadow DOM and stay live-bound. If tokens live only in JS theme objects (styled-components, CSS-in-JS), resolve to literal values at generation time. +3. **Icons.** Inline as SVG. Do not reference Lucide/Heroicons packages, icon fonts, or ``. A typical icon is 16-24px; copy the SVG path data directly. +4. **States.** Include `:hover`, `:focus-visible`, and (if meaningful) `:active` rules inline. A static default-only snapshot makes the panel feel dead. Hover + focus rules in the CSS make it feel alive. +5. **Reset bloat.** Extract only the component's *distinctive* CSS (background, color, padding, border-radius, typography, transition). Skip universal resets (`box-sizing: border-box`, `line-height: inherit`, `-webkit-font-smoothing`). The panel already has a neutral canvas; don't re-ship resets. +6. **Scoped class names.** Prefix every class with `ds-` (e.g. `ds-btn-primary`, `ds-input-search`) so component CSS doesn't collide with other components' CSS in the same shadow DOM. + +#### What to include + +Aim for a tight set of **5-10 components** that best represent the visual system: + +- **Canonical primitives (always include if the project has them):** button (each variant as a separate component entry), input/text field, navigation, chip/tag, card. +- **Signature components (include if distinctive):** hero CTA, featured card, filter pill, any custom pattern the user mentioned as important in PRODUCT.md. +- **Skip the rest.** Utility components, form building blocks, wrapper layouts: not worth documenting unless visually distinctive. + +If the project has **no component library yet** (bare landing page, new project), synthesize canonical primitives from the tokens using best-practice defaults consistent with the DESIGN.md's rules. Every `.impeccable/design.json` has *something* to render, even on day zero. + +#### Tonal ramps + +For each color token, generate an 8-step `tonalRamp` array: dark to light, same hue and chroma, stepped lightness from ~15% to ~95%. The panel renders this as a strip under the swatch. If the project already defines a tonal scale (Material `surface-container-low` family, Tailwind-style `blue-50..blue-900`), use those values. Otherwise synthesize in OKLCH. + +#### Narrative mapping + +Pull directly from the DESIGN.md you just wrote: + +- `narrative.northStar` → the `**Creative North Star: "..."**` line from Overview +- `narrative.overview` → the philosophy paragraphs from Overview +- `narrative.keyCharacteristics` → the bulleted `**Key Characteristics:**` list +- `narrative.rules` → every `**The [Name] Rule.** [body]` across all sections, tagged with `section` +- `narrative.dos` / `narrative.donts` → the bullet lists from Do's and Don'ts verbatim + +Do not reword. The panel shows these as secondary collapsible context; the same voice that's in the Markdown carries through. + +### Step 5: Confirm, refine, and refresh session cache + +1. Show the user the full DESIGN.md you wrote. Briefly highlight the non-obvious creative choices (descriptive color names, atmosphere language, named rules). +2. Mention that `.impeccable/design.json` was also written alongside; the live panel will now render this project's actual button/input/nav primitives instead of generic approximations. +3. Offer to refine any section: "Want me to revise a section, add component patterns I missed, or adjust the atmosphere language?" +4. **Refresh the session cache.** Run `node .agents/skills/impeccable/scripts/load-context.mjs` one final time so the newly-written DESIGN.md lands in conversation. Subsequent commands in this session will use the fresh version automatically without re-reading. + +## Seed mode + +For projects with no visual system to extract yet. Produces a minimal scaffold, not a full spec. + +### Step 1: Confirm seed mode + +Before interviewing: "There's no existing visual system to scan. I'll ask five quick questions to seed a starter DESIGN.md. You can re-run `$impeccable document` once there's code, to capture the real tokens and components. OK?" + +If the user prefers to skip, stop. No file. + +### Step 2: Five questions + +Group into one `AskUserQuestion` interaction. Options must be concrete. + +1. **Color strategy.** Pick one: + - Restrained: tinted neutrals + one accent ≤10% + - Committed: one saturated color carries 30–60% of the surface + - Full palette: 3–4 named color roles, each deliberate + - Drenched: the surface IS the color + + Then: one hue family or anchor reference ("deep teal", "mustard", "Klim #ff4500 orange"). + +2. **Typography direction.** Pick one (specific fonts come later): + - Serif display + sans body + - Single sans (warm / technical / geometric / humanist; pick a feel) + - Display + mono + - Mono-forward + - Editorial script + sans + +3. **Motion energy.** Pick one: + - Restrained: state changes only + - Responsive: feedback + transitions, no choreography + - Choreographed: orchestrated entrances, scroll-driven sequences + +4. **Three named references.** Brands, products, printed objects. Not adjectives. + +5. **One anti-reference.** What it should NOT feel like. Also named. + +### Step 3: Write seed DESIGN.md + +Use the six-section spec from Scan mode. Populate what the interview answers; leave the rest as honest placeholders. The seed is a scaffold, not a fabricated spec. + +Lead the file with: + +```markdown + +``` + +Per-section guidance in seed mode: + +- **Overview**: Creative North Star and philosophy phrased from the answers (color strategy + motion energy + references). Reference the user's anti-reference directly. +- **Colors**: Color strategy as a Named Rule (e.g. *"The Drenched Rule. The surface IS the color."*). Hue family or anchor reference. No hex values; mark as `[to be resolved during implementation]`. +- **Typography**: the direction the user picked (e.g. "Serif display + sans body"). No font names yet: `[font pairing to be chosen at implementation]`. +- **Elevation**: inferred from motion energy. Restrained/Responsive → flat by default; Choreographed → layered. One sentence. +- **Components**: omit entirely; no components exist yet. +- **Do's and Don'ts**: carry PRODUCT.md's anti-references directly plus the anti-reference named in Q5. + +Seed mode writes a minimal frontmatter with `name` and `description` only; no colors, typography, rounded, spacing, or components yet. Real tokens land on the next Scan-mode run. Skip the `.impeccable/design.json` sidecar in seed mode for the same reason: nothing to render. + +### Step 4: Confirm and refresh session cache + +1. Show the seed DESIGN.md. Call out that it is a seed (the marker is the literal commitment). +2. Tell the user: "Re-run `$impeccable document` once you have some code. That pass will extract real tokens and generate the sidecar." +3. Run `node .agents/skills/impeccable/scripts/load-context.mjs` once so the seed lands in conversation for the rest of the session. + +## Style guidelines + +- **Frontmatter first, prose second.** Tokens go in the YAML frontmatter; prose contextualizes them. Don't redefine a token value in two places; the frontmatter is normative. +- **Cite PRODUCT.md anti-references by name** in the Do's and Don'ts section. If PRODUCT.md lists "SaaS landing-page clichés" or "generic AI tool marketing" as anti-references, the DESIGN.md Don'ts should repeat those phrases verbatim so the visual spec enforces the strategic line. +- **Match the spec, don't invent new sections.** The six section names are fixed. If you have Layout/Motion/Responsive content to document, fold it into Overview (philosophy-level rules) or Components (per-component behavior). +- **Descriptive > technical**: "Gently curved edges (8px radius)" > "rounded-lg". Include the technical value in parens, lead with the description. +- **Functional > decorative**: for each token, explain WHERE and WHY it's used, not just WHAT it is. +- **Exact values in parens**: hex codes, px/rem values, font weights; always the number in parens alongside the description. +- **Use Named Rules**: `**The [Name] Rule.** [short doctrine]`. These are memorable, citable, and much stickier for AI consumers than bullet lists. Stitch's own outputs use them heavily ("The No-Line Rule", "The Ghost Border Fallback"). Aim for 1-3 per section. +- **Be forceful**. The voice of a design director. "Prohibited", "forbidden", "never", "always", not "consider", "might", "prefer". Match PRODUCT.md's tone. +- **Concrete anti-pattern tests**. Stitch writes things like *"If it looks like a 2014 app, the shadow is too dark and the blur is too small."* A one-sentence audit test beats a paragraph of principle. +- **Reference PRODUCT.md**. The anti-references section of PRODUCT.md should directly inform the Do's and Don'ts section here. Quote or paraphrase. +- **Group colors by role**, not by hex-order or hue-order. Primary / Secondary / Tertiary / Neutral is the spec ordering. + +## Pitfalls + +- Don't paste raw CSS class names. Translate to descriptive language. +- Don't extract every token. Stop at what's actually reused; one-offs pollute the system. +- Don't invent components that don't exist. If the project only has buttons and cards, only document those. +- Don't overwrite an existing DESIGN.md without asking. +- Don't duplicate content from PRODUCT.md. DESIGN.md is strictly visual. +- Don't add a "Layout Principles" or "Motion" or "Responsive Behavior" top-level section. The spec has six, not nine. Fold that content where it belongs. +- Don't rename sections even slightly. "Colors" not "Color Palette & Roles". "Typography" not "Typography Rules". Tooling parsing depends on exact headers. +- Don't duplicate token values between frontmatter and prose. If a color is in `colors.primary` as hex, the prose can name it and describe its role but should not reassert a different hex. The frontmatter is normative. +- Don't invent frontmatter token groups outside Stitch's schema (no `motion:`, `breakpoints:`, `shadows:` at the top level). Stitch's Zod schema only accepts `colors`, `typography`, `rounded`, `spacing`, `components`. Anything else belongs in the sidecar's `extensions`. diff --git a/.agents/skills/impeccable/reference/extract.md b/.agents/skills/impeccable/reference/extract.md new file mode 100644 index 00000000..f8d863ce --- /dev/null +++ b/.agents/skills/impeccable/reference/extract.md @@ -0,0 +1,69 @@ +# Extract Flow + +Identify reusable patterns, components, and design tokens, then extract and consolidate them into the design system for systematic reuse. + +## Step 1: Discover the Design System + +Find the design system, component library, or shared UI directory. Understand its structure: component organization, naming conventions, design token structure, import/export conventions. + +**CRITICAL**: If no design system exists, STOP and use Codex's structured user-input/question tool when available; if unavailable, ask directly in chat to clarify what you cannot infer. before creating one. Understand the preferred location and structure first. + +## Step 2: Identify Patterns + +Look for extraction opportunities in the target area: + +- **Repeated components**: Similar UI patterns used 3+ times (buttons, cards, inputs) +- **Hard-coded values**: Colors, spacing, typography, shadows that should be tokens +- **Inconsistent variations**: Multiple implementations of the same concept +- **Composition patterns**: Layout or interaction patterns that repeat (form rows, toolbar groups, empty states) +- **Type styles**: Repeated font-size + weight + line-height combinations +- **Animation patterns**: Repeated easing, duration, or keyframe combinations + +Assess value: only extract things used 3+ times with the same intent. Premature abstraction is worse than duplication. + +## Step 3: Plan Extraction + +Create a systematic plan: + +- **Components to extract**: Which UI elements become reusable components? +- **Tokens to create**: Which hard-coded values become design tokens? +- **Variants to support**: What variations does each component need? +- **Naming conventions**: Component names, token names, prop names that match existing patterns +- **Migration path**: How to refactor existing uses to consume the new shared versions + +**IMPORTANT**: Design systems grow incrementally. Extract what is clearly reusable now, not everything that might someday be reusable. + +## Step 4: Extract & Enrich + +Build improved, reusable versions: + +- **Components**: Clear props API with sensible defaults, proper variants for different use cases, accessibility built in (ARIA, keyboard navigation, focus management), documentation and usage examples +- **Design tokens**: Clear naming (primitive vs semantic), proper hierarchy and organization, documentation of when to use each token +- **Patterns**: When to use this pattern, code examples, variations and combinations + +## Step 5: Migrate + +Replace existing uses with the new shared versions: + +- **Find all instances**: Search for the patterns you extracted +- **Replace systematically**: Update each use to consume the shared version +- **Test thoroughly**: Ensure visual and functional parity +- **Delete dead code**: Remove the old implementations + +## Step 6: Document + +Update design system documentation: + +- Add new components to the component library +- Document token usage and values +- Add examples and guidelines +- Update any Storybook or component catalog + +**NEVER**: +- Extract one-off, context-specific implementations without generalization +- Create components so generic they are useless +- Extract without considering existing design system conventions +- Skip proper TypeScript types or prop documentation +- Create tokens for every single value (tokens should have semantic meaning) +- Extract things that differ in intent (two buttons that look similar but serve different purposes should stay separate) + diff --git a/.agents/skills/impeccable/reference/harden.md b/.agents/skills/impeccable/reference/harden.md new file mode 100644 index 00000000..917be521 --- /dev/null +++ b/.agents/skills/impeccable/reference/harden.md @@ -0,0 +1,347 @@ +Designs that only work with perfect data aren't production-ready. Harden the interface against the inputs, errors, languages, and network conditions that real users will throw at it. + +## Assess Hardening Needs + +Identify weaknesses and edge cases: + +1. **Test with extreme inputs**: + - Very long text (names, descriptions, titles) + - Very short text (empty, single character) + - Special characters (emoji, RTL text, accents) + - Large numbers (millions, billions) + - Many items (1000+ list items, 50+ options) + - No data (empty states) + +2. **Test error scenarios**: + - Network failures (offline, slow, timeout) + - API errors (400, 401, 403, 404, 500) + - Validation errors + - Permission errors + - Rate limiting + - Concurrent operations + +3. **Test internationalization**: + - Long translations (German is often 30% longer than English) + - RTL languages (Arabic, Hebrew) + - Character sets (Chinese, Japanese, Korean, emoji) + - Date/time formats + - Number formats (1,000 vs 1.000) + - Currency symbols + +**CRITICAL**: Designs that only work with perfect data aren't production-ready. Harden against reality. + +## Hardening Dimensions + +Systematically improve resilience: + +### Text Overflow & Wrapping + +**Long text handling**: +```css +/* Single line with ellipsis */ +.truncate { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +/* Multi-line with clamp */ +.line-clamp { + display: -webkit-box; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + overflow: hidden; +} + +/* Allow wrapping */ +.wrap { + word-wrap: break-word; + overflow-wrap: break-word; + hyphens: auto; +} +``` + +**Flex/Grid overflow**: +```css +/* Prevent flex items from overflowing */ +.flex-item { + min-width: 0; /* Allow shrinking below content size */ + overflow: hidden; +} + +/* Prevent grid items from overflowing */ +.grid-item { + min-width: 0; + min-height: 0; +} +``` + +**Responsive text sizing**: +- Use `clamp()` for fluid typography +- Set minimum readable sizes (14px on mobile) +- Test text scaling (zoom to 200%) +- Ensure containers expand with text + +### Internationalization (i18n) + +**Text expansion**: +- Add 30-40% space budget for translations +- Use flexbox/grid that adapts to content +- Test with longest language (usually German) +- Avoid fixed widths on text containers + +```jsx +// ❌ Bad: Assumes short English text + + +// ✅ Good: Adapts to content + +``` + +**RTL (Right-to-Left) support**: +```css +/* Use logical properties */ +margin-inline-start: 1rem; /* Not margin-left */ +padding-inline: 1rem; /* Not padding-left/right */ +border-inline-end: 1px solid; /* Not border-right */ + +/* Or use dir attribute */ +[dir="rtl"] .arrow { transform: scaleX(-1); } +``` + +**Character set support**: +- Use UTF-8 encoding everywhere +- Test with Chinese/Japanese/Korean (CJK) characters +- Test with emoji (they can be 2-4 bytes) +- Handle different scripts (Latin, Cyrillic, Arabic, etc.) + +**Date/Time formatting**: +```javascript +// ✅ Use Intl API for proper formatting +new Intl.DateTimeFormat('en-US').format(date); // 1/15/2024 +new Intl.DateTimeFormat('de-DE').format(date); // 15.1.2024 + +new Intl.NumberFormat('en-US', { + style: 'currency', + currency: 'USD' +}).format(1234.56); // $1,234.56 +``` + +**Pluralization**: +```javascript +// ❌ Bad: Assumes English pluralization +`${count} item${count !== 1 ? 's' : ''}` + +// ✅ Good: Use proper i18n library +t('items', { count }) // Handles complex plural rules +``` + +### Error Handling + +**Network errors**: +- Show clear error messages +- Provide retry button +- Explain what happened +- Offer offline mode (if applicable) +- Handle timeout scenarios + +```jsx +// Error states with recovery +{error && ( + +

Failed to load data. {error.message}

+ +
+)} +``` + +**Form validation errors**: +- Inline errors near fields +- Clear, specific messages +- Suggest corrections +- Don't block submission unnecessarily +- Preserve user input on error + +**API errors**: +- Handle each status code appropriately + - 400: Show validation errors + - 401: Redirect to login + - 403: Show permission error + - 404: Show not found state + - 429: Show rate limit message + - 500: Show generic error, offer support + +**Graceful degradation**: +- Core functionality works without JavaScript +- Images have alt text +- Progressive enhancement +- Fallbacks for unsupported features + +### Edge Cases & Boundary Conditions + +**Empty states**: +- No items in list +- No search results +- No notifications +- No data to display +- Provide clear next action + +**Loading states**: +- Initial load +- Pagination load +- Refresh +- Show what's loading ("Loading your projects...") +- Time estimates for long operations + +**Large datasets**: +- Pagination or virtual scrolling +- Search/filter capabilities +- Performance optimization +- Don't load all 10,000 items at once + +**Concurrent operations**: +- Prevent double-submission (disable button while loading) +- Handle race conditions +- Optimistic updates with rollback +- Conflict resolution + +**Permission states**: +- No permission to view +- No permission to edit +- Read-only mode +- Clear explanation of why + +**Browser compatibility**: +- Polyfills for modern features +- Fallbacks for unsupported CSS +- Feature detection (not browser detection) +- Test in target browsers + +### Input Validation & Sanitization + +**Client-side validation**: +- Required fields +- Format validation (email, phone, URL) +- Length limits +- Pattern matching +- Custom validation rules + +**Server-side validation** (always): +- Never trust client-side only +- Validate and sanitize all inputs +- Protect against injection attacks +- Rate limiting + +**Constraint handling**: +```html + + + + Letters and numbers only, up to 100 characters + +``` + +### Accessibility Resilience + +**Keyboard navigation**: +- All functionality accessible via keyboard +- Logical tab order +- Focus management in modals +- Skip links for long content + +**Screen reader support**: +- Proper ARIA labels +- Announce dynamic changes (live regions) +- Descriptive alt text +- Semantic HTML + +**Motion sensitivity**: +```css +@media (prefers-reduced-motion: reduce) { + * { + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.01ms !important; + } +} +``` + +**High contrast mode**: +- Test in Windows high contrast mode +- Don't rely only on color +- Provide alternative visual cues + +### Performance Resilience + +**Slow connections**: +- Progressive image loading +- Skeleton screens +- Optimistic UI updates +- Offline support (service workers) + +**Memory leaks**: +- Clean up event listeners +- Cancel subscriptions +- Clear timers/intervals +- Abort pending requests on unmount + +**Throttling & Debouncing**: +```javascript +// Debounce search input +const debouncedSearch = debounce(handleSearch, 300); + +// Throttle scroll handler +const throttledScroll = throttle(handleScroll, 100); +``` + +## Testing Strategies + +**Manual testing**: +- Test with extreme data (very long, very short, empty) +- Test in different languages +- Test offline +- Test slow connection (throttle to 3G) +- Test with screen reader +- Test keyboard-only navigation +- Test on old browsers + +**Automated testing**: +- Unit tests for edge cases +- Integration tests for error scenarios +- E2E tests for critical paths +- Visual regression tests +- Accessibility tests (axe, WAVE) + +**IMPORTANT**: Hardening is about expecting the unexpected. Real users will do things you never imagined. + +**NEVER**: +- Assume perfect input (validate everything) +- Ignore internationalization (design for global) +- Leave error messages generic ("Error occurred") +- Forget offline scenarios +- Trust client-side validation alone +- Use fixed widths for text +- Assume English-length text +- Block entire interface when one component errors + +## Verify Hardening + +Test thoroughly with edge cases: + +- **Long text**: Try names with 100+ characters +- **Emoji**: Use emoji in all text fields +- **RTL**: Test with Arabic or Hebrew +- **CJK**: Test with Chinese/Japanese/Korean +- **Network issues**: Disable internet, throttle connection +- **Large datasets**: Test with 1000+ items +- **Concurrent actions**: Click submit 10 times rapidly +- **Errors**: Force API errors, test all error states +- **Empty**: Remove all data, test empty states + +When edge cases are covered, hand off to `$impeccable polish` for the final pass. diff --git a/.agents/skills/impeccable/reference/heuristics-scoring.md b/.agents/skills/impeccable/reference/heuristics-scoring.md new file mode 100644 index 00000000..edbe5028 --- /dev/null +++ b/.agents/skills/impeccable/reference/heuristics-scoring.md @@ -0,0 +1,234 @@ +# Heuristics Scoring Guide + +Score each of Nielsen's 10 Usability Heuristics on a 0–4 scale. Be honest: a 4 means genuinely excellent, not "good enough." + +## Nielsen's 10 Heuristics + +### 1. Visibility of System Status + +Keep users informed about what's happening through timely, appropriate feedback. + +**Check for**: +- Loading indicators during async operations +- Confirmation of user actions (save, submit, delete) +- Progress indicators for multi-step processes +- Current location in navigation (breadcrumbs, active states) +- Form validation feedback (inline, not just on submit) + +**Scoring**: +| Score | Criteria | +|-------|----------| +| 0 | No feedback; user is guessing what happened | +| 1 | Rare feedback; most actions produce no visible response | +| 2 | Partial; some states communicated, major gaps remain | +| 3 | Good; most operations give clear feedback, minor gaps | +| 4 | Excellent; every action confirms, progress is always visible | + +### 2. Match Between System and Real World + +Speak the user's language. Follow real-world conventions. Information appears in natural, logical order. + +**Check for**: +- Familiar terminology (no unexplained jargon) +- Logical information order matching user expectations +- Recognizable icons and metaphors +- Domain-appropriate language for the target audience +- Natural reading flow (left-to-right, top-to-bottom priority) + +**Scoring**: +| Score | Criteria | +|-------|----------| +| 0 | Pure tech jargon, alien to users | +| 1 | Mostly confusing; requires domain expertise to navigate | +| 2 | Mixed; some plain language, some jargon leaks through | +| 3 | Mostly natural; occasional term needs context | +| 4 | Speaks the user's language fluently throughout | + +### 3. User Control and Freedom + +Users need a clear "emergency exit" from unwanted states without extended dialogue. + +**Check for**: +- Undo/redo functionality +- Cancel buttons on forms and modals +- Clear navigation back to safety (home, previous) +- Easy way to clear filters, search, selections +- Escape from long or multi-step processes + +**Scoring**: +| Score | Criteria | +|-------|----------| +| 0 | Users get trapped; no way out without refreshing | +| 1 | Difficult exits; must find obscure paths to escape | +| 2 | Some exits; main flows have escape, edge cases don't | +| 3 | Good control; users can exit and undo most actions | +| 4 | Full control; undo, cancel, back, and escape everywhere | + +### 4. Consistency and Standards + +Users shouldn't wonder whether different words, situations, or actions mean the same thing. + +**Check for**: +- Consistent terminology throughout the interface +- Same actions produce same results everywhere +- Platform conventions followed (standard UI patterns) +- Visual consistency (colors, typography, spacing, components) +- Consistent interaction patterns (same gesture = same behavior) + +**Scoring**: +| Score | Criteria | +|-------|----------| +| 0 | Inconsistent everywhere; feels like different products stitched together | +| 1 | Many inconsistencies; similar things look/behave differently | +| 2 | Partially consistent; main flows match, details diverge | +| 3 | Mostly consistent; occasional deviation, nothing confusing | +| 4 | Fully consistent; cohesive system, predictable behavior | + +### 5. Error Prevention + +Better than good error messages is a design that prevents problems in the first place. + +**Check for**: +- Confirmation before destructive actions (delete, overwrite) +- Constraints preventing invalid input (date pickers, dropdowns) +- Smart defaults that reduce errors +- Clear labels that prevent misunderstanding +- Autosave and draft recovery + +**Scoring**: +| Score | Criteria | +|-------|----------| +| 0 | Errors easy to make; no guardrails anywhere | +| 1 | Few safeguards; some inputs validated, most aren't | +| 2 | Partial prevention; common errors caught, edge cases slip | +| 3 | Good prevention; most error paths blocked proactively | +| 4 | Excellent; errors nearly impossible through smart constraints | + +### 6. Recognition Rather Than Recall + +Minimize memory load. Make objects, actions, and options visible or easily retrievable. + +**Check for**: +- Visible options (not buried in hidden menus) +- Contextual help when needed (tooltips, inline hints) +- Recent items and history +- Autocomplete and suggestions +- Labels on icons (not icon-only navigation) + +**Scoring**: +| Score | Criteria | +|-------|----------| +| 0 | Heavy memorization; users must remember paths and commands | +| 1 | Mostly recall; many hidden features, few visible cues | +| 2 | Some aids; main actions visible, secondary features hidden | +| 3 | Good recognition; most things discoverable, few memory demands | +| 4 | Everything discoverable; users never need to memorize | + +### 7. Flexibility and Efficiency of Use + +Accelerators, invisible to novices, speed up expert interaction. + +**Check for**: +- Keyboard shortcuts for common actions +- Customizable interface elements +- Recent items and favorites +- Bulk/batch actions +- Power user features that don't complicate the basics + +**Scoring**: +| Score | Criteria | +|-------|----------| +| 0 | One rigid path; no shortcuts or alternatives | +| 1 | Limited flexibility; few alternatives to the main path | +| 2 | Some shortcuts; basic keyboard support, limited bulk actions | +| 3 | Good accelerators; keyboard nav, some customization | +| 4 | Highly flexible; multiple paths, power features, customizable | + +### 8. Aesthetic and Minimalist Design + +Interfaces should not contain irrelevant or rarely needed information. Every element should serve a purpose. + +**Check for**: +- Only necessary information visible at each step +- Clear visual hierarchy directing attention +- Purposeful use of color and emphasis +- No decorative clutter competing for attention +- Focused, uncluttered layouts + +**Scoring**: +| Score | Criteria | +|-------|----------| +| 0 | Overwhelming; everything competes for attention equally | +| 1 | Cluttered; too much noise, hard to find what matters | +| 2 | Some clutter; main content clear, periphery noisy | +| 3 | Mostly clean; focused design, minor visual noise | +| 4 | Perfectly minimal; every element earns its pixel | + +### 9. Help Users Recognize, Diagnose, and Recover from Errors + +Error messages should use plain language, precisely indicate the problem, and constructively suggest a solution. + +**Check for**: +- Plain language error messages (no error codes for users) +- Specific problem identification ("Email is missing @" not "Invalid input") +- Actionable recovery suggestions +- Errors displayed near the source of the problem +- Non-blocking error handling (don't wipe the form) + +**Scoring**: +| Score | Criteria | +|-------|----------| +| 0 | Cryptic errors; codes, jargon, or no message at all | +| 1 | Vague errors; "Something went wrong" with no guidance | +| 2 | Clear but unhelpful; names the problem but not the fix | +| 3 | Clear with suggestions; identifies problem and offers next steps | +| 4 | Perfect recovery; pinpoints issue, suggests fix, preserves user work | + +### 10. Help and Documentation + +Even if the system is usable without docs, help should be easy to find, task-focused, and concise. + +**Check for**: +- Searchable help or documentation +- Contextual help (tooltips, inline hints, guided tours) +- Task-focused organization (not feature-organized) +- Concise, scannable content +- Easy access without leaving current context + +**Scoring**: +| Score | Criteria | +|-------|----------| +| 0 | No help available anywhere | +| 1 | Help exists but hard to find or irrelevant | +| 2 | Basic help; FAQ or docs exist, not contextual | +| 3 | Good documentation; searchable, mostly task-focused | +| 4 | Excellent contextual help; right info at the right moment | + +--- + +## Score Summary + +**Total possible**: 40 points (10 heuristics × 4 max) + +| Score Range | Rating | What It Means | +|-------------|--------|---------------| +| 36–40 | Excellent | Minor polish only; ship it | +| 28–35 | Good | Address weak areas, solid foundation | +| 20–27 | Acceptable | Significant improvements needed before users are happy | +| 12–19 | Poor | Major UX overhaul required; core experience broken | +| 0–11 | Critical | Redesign needed; unusable in current state | + +--- + +## Issue Severity (P0–P3) + +Tag each individual issue found during scoring with a priority level: + +| Priority | Name | Description | Action | +|----------|------|-------------|--------| +| **P0** | Blocking | Prevents task completion entirely | Fix immediately; this is a showstopper | +| **P1** | Major | Causes significant difficulty or confusion | Fix before release | +| **P2** | Minor | Annoyance, but workaround exists | Fix in next pass | +| **P3** | Polish | Nice-to-fix, no real user impact | Fix if time permits | + +**Tip**: If you're unsure between two levels, ask: "Would a user contact support about this?" If yes, it's at least P1. diff --git a/.agents/skills/impeccable/reference/interaction-design.md b/.agents/skills/impeccable/reference/interaction-design.md new file mode 100644 index 00000000..15aed5b2 --- /dev/null +++ b/.agents/skills/impeccable/reference/interaction-design.md @@ -0,0 +1,195 @@ +# Interaction Design + +## The Eight Interactive States + +Every interactive element needs these states designed: + +| State | When | Visual Treatment | +|-------|------|------------------| +| **Default** | At rest | Base styling | +| **Hover** | Pointer over (not touch) | Subtle lift, color shift | +| **Focus** | Keyboard/programmatic focus | Visible ring (see below) | +| **Active** | Being pressed | Pressed in, darker | +| **Disabled** | Not interactive | Reduced opacity, no pointer | +| **Loading** | Processing | Spinner, skeleton | +| **Error** | Invalid state | Red border, icon, message | +| **Success** | Completed | Green check, confirmation | + +**The common miss**: Designing hover without focus, or vice versa. They're different. Keyboard users never see hover states. + +## Focus Rings: Do Them Right + +**Never `outline: none` without replacement.** It's an accessibility violation. Instead, use `:focus-visible` to show focus only for keyboard users: + +```css +/* Hide focus ring for mouse/touch */ +button:focus { + outline: none; +} + +/* Show focus ring for keyboard */ +button:focus-visible { + outline: 2px solid var(--color-accent); + outline-offset: 2px; +} +``` + +**Focus ring design**: +- High contrast (3:1 minimum against adjacent colors) +- 2-3px thick +- Offset from element (not inside it) +- Consistent across all interactive elements + +## Form Design: The Non-Obvious + +**Placeholders aren't labels.** They disappear on input. Always use visible `