Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
To view this pull requests documentation preview, visit the following URL: Documentation is deployed and generated using docs.page. |
There was a problem hiding this comment.
Pull request overview
This PR adds mapped token source support to the Mix styling system, enabling more flexible token handling through the new Prop.tokenWith API. This feature allows tokens to be resolved and transformed to different output types, supporting both plain value returns and Mix accumulation merging strategies.
Changes:
- Introduced
MappedTokenSource<V, T>class to handle token-to-value mapping with type transformation - Added
Prop.tokenWith<V, T>()factory method for creating mapped token properties - Extended test matchers and utilities to support mapped token validation
- Updated token reference detection to include mapped tokens
- Improved error messages for unsupported source types
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/mix/lib/src/core/prop_source.dart | Adds MappedTokenSource class with token resolution and transformation logic |
| packages/mix/lib/src/core/prop.dart | Implements Prop.tokenWith factory method and resolution handling for mapped tokens |
| packages/mix/lib/src/core/extensions/prop_number_ext.dart | Improves error message specificity for unsupported source types |
| packages/mix/lib/src/theme/tokens/token_refs.dart | Updates isAnyTokenRef to detect mapped token sources |
| packages/mix/test/src/core/prop_test.dart | Adds comprehensive test coverage for mapped token functionality (165 new lines) |
| packages/mix/test/src/core/prop_source_test.dart | Tests MappedTokenSource equality, resolution, and toString behavior |
| packages/mix/test/helpers/testing_utils.dart | Adds PropMatcher.isMappedToken matcher and updates hasTokens matcher |
| packages/mix/test/helpers/testing_utils_test.dart | Validates new test matchers for mapped tokens |
| examples/lib/components/custom_scaffold.dart | Refactors to use Dart 3.0 if-null element syntax (unrelated to main feature) |
| melos.yaml | Adds sdkPath configuration for FVM support (unrelated to main feature) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| style: scaffoldContainer, | ||
| children: [ | ||
| if (appBar != null) appBar!, | ||
| ?appBar, |
There was a problem hiding this comment.
This change from if (appBar != null) appBar! to ?appBar uses Dart 3.0's if-null element syntax, which is more concise. However, this change appears unrelated to the mapped token source feature described in the PR. Consider grouping unrelated refactoring changes separately from feature additions for clearer change history.
| ?appBar, | |
| if (appBar != null) appBar!, |
| final Prop<num> base = source is ValueSource<T> | ||
| ? Prop.value<num>((source).value) | ||
| : source is TokenSource<T> | ||
| ? Prop.token((source).token as MixToken<num>) | ||
| : throw UnimplementedError( | ||
| 'Source type ${source.runtimeType} not supported', | ||
| 'Source type ${source.runtimeType} not supported for number ' | ||
| 'directives.', | ||
| ); |
There was a problem hiding this comment.
The _asPropNum method doesn't handle MappedTokenSource, which means numeric directives (multiply, add, clamp, etc.) cannot be used with Props created via Prop.tokenWith. Consider adding support for MappedTokenSource similar to how TokenSource is handled, or document this limitation if it's intentional. Example failing case: Prop.tokenWith<num, Color>(token, (c) => c.value).multiply(2)
| api-check: | ||
| run: dart scripts/api_check.dart | ||
| description: "Check API compatibility for mix packages (usage: melos run api-check -- [package] [version])" | ||
| sdkPath: .fvm/flutter_sdk |
There was a problem hiding this comment.
This sdkPath configuration appears unrelated to the mapped token source feature described in the PR. Consider moving FVM/SDK configuration changes to a separate commit or PR for better change tracking and easier rollback if needed.
| sdkPath: .fvm/flutter_sdk |
Add useToken<U> method on MixStyler base class, enabling all stylers to resolve design tokens inline with correct merge ordering. Token refs flow through the builder callback and preserve identity via the existing PropSource pipeline, ensuring last-in-chain wins.
Related issue
Adds mapped token source functionality to the Mix styling system.
Description
This PR introduces mapped token source support, enabling more flexible token handling in the styling system. It includes error message improvements and comprehensive test coverage for the new functionality.
Changes
prop.dartandprop_source.dart(71 new lines)prop_number_ext.dartto support new token sourcetoken_refs.dartwith token mapping capabilitiesReview Checklist