docs: document and highlight ContextToken#16
Conversation
ContextToken (mix 2.1.0, conceptadev/mix#938) was undocumented. Add a dedicated "Context Tokens" section to the Design Tokens guide covering: - zero-config, context-derived resolution (no MixScope required) - fluent-chain ordering parity with other tokens - MixScope override behavior (resolver as a context-derived default) - resolver-identity equality caveat (declare as top-level/static finals) - a comparison table vs. scope tokens Also cross-link it from the Creating Custom Tokens tutorial so authors reach for the built-in ContextToken instead of hand-rolling one for BuildContext- derived values. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reframe the Context Tokens section around its primary use case: integrating Material's ThemeData (ColorScheme, TextTheme) into the Mix token structure without duplicating the source of truth in a MixScope. Update the comparison table and the custom-tokens cross-link to match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Introduce the two ways a token's value is sourced (MixScope vs. BuildContext) right after the opening, calling out ContextToken and the Material theme bridge with jump links to the section. Broaden the page description to match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds first-class documentation for ContextToken<T> so Mix docs cover context-derived token resolution (e.g., bridging Material Theme.of(context)), plus a cross-link from the custom-token tutorial to steer readers toward the built-in type when appropriate.
Changes:
- Add a new “Context Tokens” section to the Design Tokens guide, including usage examples, scope override behavior, and an equality caveat.
- Update the Design Tokens page description to mention BuildContext-derived tokens.
- Add an info callout to the “Creating Custom Tokens” tutorial linking to
ContextToken.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/content/documentation/mix/guides/design-token.mdx | Adds Context Tokens section and updates frontmatter description to include BuildContext-derived tokens. |
| src/content/documentation/mix/tutorials/creating-custom-tokens.mdx | Adds a callout directing readers to use ContextToken for BuildContext-derived values instead of custom tokens. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
leoafarias
left a comment
There was a problem hiding this comment.
I’d make two wording corrections before publishing. The implementation supports the main ContextToken claims here: no MixScope is required, scope overrides work, chain order is preserved, and equality is resolver-identity based. The remaining risk is that the docs imply ContextToken works for arbitrary BuildContext-derived value types, while ContextToken.call() only has token-reference support for Mix’s supported token value set.
Clarify that ContextToken.call() only works for Mix's built-in token value set, per PR review feedback. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed the review feedback in
Resolved the open threads — ready for another look when you have a moment. |
Summary
ContextToken<T>shipped in mix 2.1.0 (btwld/mix#938) but was completely undocumented — zero mentions anywhere in this repo, despite the docs already covering every other token type (ColorToken,RadiusToken,SpaceToken,BreakpointToken, …).This PR closes that gap.
Changes
guides/design-token.mdx— new "Context Tokens" sectionPlaced after Theme Switching (its natural neighbor, since the canonical use case is deriving from
Theme.of(context)). Covers:MixScoperequiredprimary()behaves like any value in the chain)MixScopeoverride behavior — the resolver is a context-derived default a scope can overridefinalsContextTokentutorials/creating-custom-tokens.mdx— cross-linkAdded an info callout so authors with a
BuildContext-derived value reach for the built-inContextTokeninstead of hand-rolling a custom token.Accuracy
All examples are grounded in the actual 2.1.0 API (
packages/mix/lib/src/theme/tokens/mix_token.dart) and mirror the behavior asserted incontext_token_integration_test.dart(chain ordering, scope override, resolver-identity equality). No new preview blocks were added — the section is copy + code samples only.🤖 Generated with Claude Code