Skip to content

Commit 499db94

Browse files
committed
ADD: Run claude /init to create a first version of a CLAUDE.md file
1 parent 1dc65bb commit 499db94

File tree

1 file changed

+169
-0
lines changed

1 file changed

+169
-0
lines changed

CLAUDE.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
FlexSeedScheme (FSS) is a Flutter package that provides a more flexible and powerful alternative to Flutter's `ColorScheme.fromSeed`. It enables using multiple seed colors (up to 6), custom chroma settings, and configurable tone mapping for Material Design 3 color schemes.
8+
9+
**Key Value Proposition:**
10+
- Use separate seed keys for primary, secondary, tertiary, error, neutral, and neutralVariant palettes
11+
- Customize chromacity (colorfulness) in the HCT (Hue-Chroma-Tone) color space
12+
- Customize tonal palette tone mappings to ColorScheme colors
13+
- Support for both FlexTones-based and DynamicSchemeVariant-based color generation
14+
- Built-in high contrast and accessibility variants
15+
16+
## Build, Test, and Lint Commands
17+
18+
### Testing
19+
```bash
20+
# Run all tests
21+
flutter test
22+
23+
# Run tests with coverage
24+
flutter test --coverage
25+
26+
# Run a single test file
27+
flutter test test/flex_seed_scheme_test.dart
28+
```
29+
30+
### Analysis and Formatting
31+
```bash
32+
# Analyze code
33+
dart analyze
34+
35+
# Format code (required before commits)
36+
dart format .
37+
38+
# Check if code is properly formatted (fails if not)
39+
dart format --output=none --set-exit-if-changed .
40+
```
41+
42+
### Package Management
43+
```bash
44+
# Get dependencies
45+
flutter pub get
46+
47+
# Check for outdated dependencies
48+
flutter pub outdated
49+
```
50+
51+
### Version Management
52+
The project uses FVM (Flutter Version Manager):
53+
```bash
54+
# FVM is configured via .fvmrc
55+
# Use the configured Flutter version
56+
fvm flutter <command>
57+
```
58+
59+
## Architecture
60+
61+
### Core Components
62+
63+
The codebase is organized into two main source directories:
64+
65+
#### 1. `/lib/src/flex/` - FlexSeedScheme Core API
66+
This is the primary public API layer:
67+
68+
- **`flex_seed_scheme.dart`**: Contains `SeedColorScheme.fromSeeds()` - the main entry point for creating color schemes. It's an extension on `ColorScheme` that orchestrates the entire seed generation process.
69+
70+
- **`flex_tones.dart`**: Defines `FlexTones` - the configuration class that maps tonal palette tones to ColorScheme colors. Contains 11+ predefined tone strategies (material, vivid, soft, candyPop, oneHue, etc.) and supports custom configurations via `.light()` and `.dark()` factories. Includes modifiers like `onMainsUseBW()`, `onSurfacesUseBW()`, `monochromeSurfaces()`, `higherContrastFixed()`, and `expressiveOnContainer()`.
71+
72+
- **`flex_core_palette.dart`**: Enhanced version of MCU's `CorePalette` that generates the six tonal palettes (primary, secondary, tertiary, error, neutral, neutralVariant) from multiple seed colors instead of just one.
73+
74+
- **`flex_tonal_palette.dart`**: Extended tonal palette that supports both `common` (15 tones) and `extended` (30 tones) palette types. Extended type is required for Flutter 3.22+ compatibility.
75+
76+
- **`flex_scheme_variant.dart`**: Enum defining all available scheme variant algorithms, including both Flutter SDK's DynamicSchemeVariant-based variants (tonalSpot, fidelity, content, etc.) and FlexTones-based variants.
77+
78+
- **`flex_color_seed_color_extensions.dart`**: Non-deprecated 8-bit color channel getters for Color (value32bit, alpha8bit, red8bit, green8bit, blue8bit).
79+
80+
#### 2. `/lib/src/mcu/` - Material Color Utilities Fork
81+
Internal fork of Google's Material Color Utilities with custom enhancements:
82+
83+
- **`hct/`**: HCT (Hue-Chroma-Tone) color space implementation including CAM16 color appearance model
84+
- **`palettes/`**: Core palette and tonal palette generation (base MCU functionality)
85+
- **`scheme/`**: DynamicScheme implementations for each variant (tonalSpot, vibrant, expressive, fidelity, content, monochrome, neutral, fruitSalad, rainbow)
86+
- **`dynamiccolor/`**: Dynamic color system with contrast curves and material dynamic colors
87+
- **`quantize/`**: Color quantization algorithms (Celebi, Wu, WSMeans, Map)
88+
- **`blend/`**: Color blending utilities
89+
- **`contrast/`**: Contrast calculation utilities
90+
- **`utils/`**: Math and color utility functions
91+
- **`temperature/`**: Color temperature cache
92+
- **`dislike/`**: Dislike analyzer for color preferences
93+
- **`score/`**: Color scoring algorithms
94+
95+
**Key Custom Enhancement**: The MCU fork enables using multiple seed colors with DynamicSchemeVariant-based schemes, which the official MCU/Flutter SDK doesn't support. This is a core differentiator of FlexSeedScheme.
96+
97+
### Key Architectural Patterns
98+
99+
**Seed-to-Scheme Flow:**
100+
1. User provides 1-6 seed colors to `SeedColorScheme.fromSeeds()`
101+
2. Either `FlexTones` or `FlexSchemeVariant` (with optional `contrastLevel`) is specified
102+
3. `FlexCorePalette` generates six tonal palettes from the seed colors
103+
4. Each palette contains 15 (common) or 30 (extended) tones
104+
5. Tones are mapped to the 40+ ColorScheme colors based on the selected strategy
105+
6. Returns a complete Material 3 `ColorScheme`
106+
107+
**Two Generation Paths:**
108+
- **FlexTones Path**: Uses custom FSS tone mapping configurations (more flexible, custom chroma control)
109+
- **DynamicScheme Path**: Uses Flutter SDK's MCU-based schemes (fidelity, content, etc.) but enhanced to support multiple seed colors
110+
111+
**Palette Type System:**
112+
- `FlexPaletteType.common`: 15 tones (legacy, pre-Flutter 3.22)
113+
- `FlexPaletteType.extended`: 30 tones (required for Flutter 3.22+, includes new surface tones and fixed colors)
114+
115+
## Important Development Notes
116+
117+
### Strict Analysis
118+
This project uses very strict linting rules (see `analysis_options.yaml`):
119+
- Includes ALL lint rules from `all_lint_rules.yaml`
120+
- Enables strict-casts, strict-inference, strict-raw-types
121+
- Must pass `dart analyze` with zero warnings/errors
122+
- Must be formatted with `dart format` (enforced in CI/CD)
123+
124+
### Test Coverage
125+
- Comprehensive test coverage is required
126+
- Tests are located in `/test/` with parallel structure to `/lib/src/`
127+
- MCU tests in `/test/mcu/` validate the forked Material Color Utilities
128+
- FSS tests validate the core FlexSeedScheme functionality
129+
- CI enforces that tests pass and uploads coverage to Codecov
130+
131+
### Version Compatibility
132+
- Requires Flutter SDK >=3.35.0
133+
- Requires Dart SDK >=3.0.0 <4.0.0
134+
- Uses Flutter 3.22+ extended ColorScheme features by default
135+
- Backward compatible with older Flutter via `FlexPaletteType.common`
136+
137+
### Key Implementation Details
138+
139+
**Monochrome Seed Handling:**
140+
When `respectMonochromeSeed: true`, monochrome RGB input (R=G=B) creates greyscale tonal palettes instead of the legacy behavior that produced cyan/red tones.
141+
142+
**Expressive On-Container Colors:**
143+
When `useExpressiveOnContainerColors: true` in light mode, on-container tones change from 10 to 30 for more expressive (but lower contrast) colors. This aligns with newer Material 3 specs.
144+
145+
**Brand Color Pinning:**
146+
Common pattern: Use brand color as both seed key and override the result (e.g., `primaryKey: brandColor, primary: brandColor`) to guarantee the brand color appears in the scheme. Works well for light mode; in dark mode, prefer pinning to `primaryContainer`.
147+
148+
**FlexTones Modifiers:**
149+
Modifiers can be chained on FlexTones configurations. Order matters when modifiers affect the same colors - last one wins:
150+
```dart
151+
FlexTones.vivid(Brightness.light)
152+
.monochromeSurfaces()
153+
.onMainsUseBW()
154+
.onSurfacesUseBW()
155+
```
156+
157+
### File Organization
158+
- Main library export: `/lib/flex_seed_scheme.dart`
159+
- Implementation: `/lib/src/flex/` and `/lib/src/mcu/`
160+
- Tests mirror source structure: `/test/flex_*_test.dart` and `/test/mcu/`
161+
- Example app: `/example/` (has web demo at rydmike.com/flexseedscheme/demo-v3)
162+
163+
### Dependencies
164+
- `collection: ^1.18.0` - Used by MCU tonal_palette.dart
165+
- `meta: ^1.9.1` - For @internal annotations
166+
- Flutter SDK's material package
167+
168+
### Relationship to FlexColorScheme
169+
FlexSeedScheme was extracted from FlexColorScheme v6+. FlexColorScheme depends on this package and re-exports its API. This package can be used standalone without FlexColorScheme.

0 commit comments

Comments
 (0)