docs(website): Clean up and modernize all documentation examples#869
docs(website): Clean up and modernize all documentation examples#869leoafarias wants to merge 16 commits intomainfrom
Conversation
…stently This comprehensive documentation update removes internal Prop implementation details from user-facing examples across 20 documentation pages. Changes ensure: - Fluent API is the primary pattern (BoxStyler().color(...).padding(...)) - Token call syntax is used instead of Prop.token() ($primary() instead of Prop.token($primary)) - Prop.value() / Prop.token() shown only in number directives context (.multiply(), .clamp()) - Corrected animation API usage (springDurationBased has bounce parameter, not spring) - Consistent use of Dart 3.11+ dot-shorthand in typed contexts - Removed verbose class name prefixes (WidgetModifierConfig, AnimationConfig, BorderRadiusGeometryMix) Files modified: - introduction.mdx: Removed Prop-Based API sections; fixed dot-shorthand - design-token.mdx: Removed Prop.token subsection - animations.mdx: Fixed spring() → springDurationBased() for bounce parameter - creating-a-widget.mdx: Replaced TextStyleMix wrapping with fluent API - widget-modifiers.mdx: Replaced Prop.token with token call syntax - Plus 15 additional documentation files for consistency pass This ensures users learn the correct public API without internal implementation details, improving documentation clarity and learning curve.
|
To view this pull requests documentation preview, visit the following URL: Documentation is deployed and generated using docs.page. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…details Remove .create()/Prop patterns from introduction and directives guide, fix build_runner command in tutorial, add frontmatter descriptions, fix code examples, and add frontmatter validation CI step.
The dart formatter needs package resolution to read the language version from pubspec.yaml. Without it, dot-shorthand syntax fails to parse.
…y across 24 pages - Fix pressable.mdx compile error (.border → .borderAll) - Fix introduction.mdx MixScope to use canonical typed maps pattern - Add missing H1 heading to introduction.mdx - Document elevation enum values in box.mdx - Document TextStyleToken.mix() pattern in design-token.mdx - Replace all "here" anchor text with descriptive links in stylewidgets.mdx - Add Related sections with internal links to all guide and widget pages - Add variant types disambiguation table in dynamic-styling.mdx - Document BoxStyler.create() vs BoxStyler() and style vs styleSpec in styling.mdx - Add auto-tracking scope table in controlling-widget-state.mdx - Add DEPRECATED markers to migration.mdx code blocks - Replace passive voice, marketing language, and colloquialisms across docs - Standardize to direct second-person voice (remove we/let's) - Expand widget meta descriptions to 150+ chars for SEO - Add prerequisites to tutorial pages - Fix image alt text in theming.mdx and creating-a-widget.mdx - Fix animations.mdx: remove non-standard id frontmatter, add imports - Fix utility-first.mdx: "Declarative Semantic" → "Declarative Semantics" - Add early development callout to mix-schema.mdx - Fix widget-modifiers.mdx: use custom ModifierMix in Step 3, add shorthand callout - Fix migration.mdx: use .wrap(.opacity()) shorthand instead of OpacityModifierMix - Fix comparison.mdx: use dot-shorthand in onHovered variant - Fix creating-context-variants.mdx: use dot-shorthand and arrow functions - Clean v2 API leakage from 0.0.7→1.0.0 migration table
- Fix .capitalize() description (capitalizes first letter only, not each word) - Fix BoxStyler.create(width:) examples that won't compile (width/height not valid params) - Replace sealed Variant subclassing with enum-based pattern in best-practices - Correct modifier ordering docs (framework enforces predefined order, not chain order) - Fix wrong mouse cursor (SystemMouseCursors.forbidden, not basic) in pressable - Fix broken GitHub links to removed deprecations.dart in migration - Fix missing semicolon syntax error in controlling-widget-state - Add $prefix token convention note to theming tutorial - Add MaterialApp wrapper to theme switching example - Convert old switch statements to switch expressions in creating-a-widget - Add BoxShadowMix explanatory comment - Fix [onBuilder] dartdoc syntax to backtick-quoted across 6 widget pages - Fix ModifierMix terminology to WidgetModifierConfig where appropriate - Fix comparison page heading hierarchy and colloquialisms
theming.mdx used <Callout> without importing it, causing the Next.js build to fail. Also run dart format on 8 example files flagged by CI.
…ar, update version - styling.mdx: Replace invalid width: parameter in BoxStyler.create() example with padding: (a valid .create() param) - _meta.js: Add missing StackBox entry to widgets sidebar navigation - getting-started.mdx: Update version from 2.0.0-rc.0 to 2.0.0-rc.1
Fix code examples to use correct Mix 2.0 API patterns (static styler access, BorderRadiusMix, EdgeInsetsGeometryMix, TextStyleMix), simplify modifier ordering docs, remove redundant description frontmatter and Related sections, and update creating-a-widget tutorial with switch statement syntax.
There was a problem hiding this comment.
Pull request overview
This PR modernizes all Mix documentation to consistently use the fluent Styler API pattern and adds proper frontmatter metadata to all documentation pages. The changes systematically replace internal Prop implementation details with public-facing fluent API patterns, ensuring users learn the correct API without being exposed to internal plumbing.
Changes:
- Standardized all code examples to use
BoxStyler()with parentheses followed by method chains (.color(),.padding(), etc.) - Added frontmatter blocks with
titleanddescriptionto 20 documentation pages for improved SEO and discoverability - Fixed animation API to use correct method name (
springDurationBasedwithbounceparameter instead ofspring) - Added frontmatter validation script and CI integration to enforce documentation metadata standards
- Updated all examples to use Dart 3.11+ dot-shorthand syntax in typed contexts (
.solid,.bold, etc.) - Replaced deprecated
withOpacity()withwithValues(alpha:)API
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/content/documentation/widgets/*.mdx | Added frontmatter and standardized fluent API examples across all widget reference pages |
| website/src/content/documentation/tutorials/*.mdx | Added frontmatter and modernized tutorial examples with fluent API patterns |
| website/src/content/documentation/overview/*.mdx | Added frontmatter and updated all overview pages with consistent API patterns |
| website/src/content/documentation/guides/*.mdx | Added frontmatter and corrected animation API usage |
| website/src/content/documentation/ecosystem/*.mdx | Added frontmatter to ecosystem documentation |
| website/scripts/check-docs-frontmatter.mjs | New validation script to enforce frontmatter requirements |
| .github/workflows/*.yml | Integrated frontmatter validation and Melos bootstrap steps |
| website/package.json | Added check:frontmatter script |
| guides/documentation-quality-checklist.md | New quality checklist for documentation PRs |
| examples/lib/**/*.dart | Reformatted code examples for consistency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…horthand support Convert static methods (spring, springDescription, springWithDampingRatio, withDefaults) to factory constructors and add new factories for all CurveAnimationConfig and SpringAnimationConfig spring variants so that Dart dot-shorthands resolve correctly when the expected type is AnimationConfig.
website/src/content/documentation/tutorials/controlling-widget-state.mdx
Outdated
Show resolved
Hide resolved
- Use Duration extension shorthand (100.ms) in comparison.mdx examples - Fix Dart 3.11 explanation: required for factory bug fix, not where dot-shorthands were introduced - Replace hardcoded version pin with ^<latest> in getting-started.mdx - Clarify callable stylers description in migration.mdx - Remove SizedBox() placeholder child in controlling-widget-state.mdx
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 45 out of 45 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (5)
website/src/content/documentation/overview/best-practices.mdx:36
- This section still claims
button.variant.dartcontains aCustomButtonVariantclass and Variant instances, but the updated “Defining Variants” section switches to plain Dart enums and no longer defines a MixVarianttype. Please reconcile the file-structure guidance with the new approach (either update/remove thebutton.variant.dartdescription, or reintroduce theVariant-based example).
- `button.dart` - This file will contain the CustomButton class and define the component's structure.
- `button.variant.dart` - Contains the CustomButtonVariant class and all its Variant instances.
website/src/content/documentation/widgets/stylewidgets.mdx:91
- The new “Callable Pattern” snippet isn’t copy/pasteable Dart as written because the
box(child: ...)call is missing a trailing semicolon. Please terminate the statement (or assign it to a variable) so the example compiles as-is.
website/src/content/documentation/widgets/stylewidgets.mdx:95 - This callable example is missing a trailing semicolon after
text('Hello'), which makes the snippet invalid Dart when copied. Please add the semicolon (or show it assigned to a widget variable).
website/src/content/documentation/widgets/stylewidgets.mdx:99 - This callable example is missing a trailing semicolon after
icon(...), which prevents copy/paste compilation. Please add the semicolon (or assign the result).
website/src/content/documentation/widgets/stylewidgets.mdx:86 - The statement “All Styler classes support a callable pattern” appears too broad: some
*Stylertypes (e.g.,FlexStyler,StackStyler) don’t define acalloperator. Consider rephrasing to explicitly scope this to widget stylers / StyleWidgets (e.g.,BoxStyler,TextStyler,IconStyler, etc.).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ```yaml | ||
| dependencies: | ||
| mix: ^2.0.0-rc.0 | ||
| mix: ^<latest> |
There was a problem hiding this comment.
mix: ^<latest> isn’t valid YAML/version syntax and will confuse users. Please replace it with a concrete version constraint (e.g., the current stable/RC) or link to the pub.dev install instructions if you want to avoid hardcoding.
| mix: ^<latest> | |
| mix: ^2.0.0 |
| | `Mix` | `Style` | | ||
| | `Mix.withVariant` | Use `.variant()` on Styler classes | | ||
| | `Mix.withManyVariants` | Use multiple `.variant()` calls | | ||
| | `Mix.withVariant` | `Style.withVariant()` | | ||
| | `Mix.withManyVariants` | `Style.withManyVariants()` | |
There was a problem hiding this comment.
The migration table says Mix.withVariant / Mix.withManyVariants map to Style.withVariant() / Style.withManyVariants(), but there is no Style.withVariant API in packages/mix/lib/src/core/style.dart. This mapping looks incorrect; please update the doc to point to the actual v2 approach (e.g., .variant(...) on Styler classes / styles, depending on the intended target).
| @@ -333,33 +330,126 @@ sealed class AnimationConfig { | |||
| onEnd: onEnd, | |||
| ); | |||
|
|
|||
| static SpringAnimationConfig spring( | |||
| factory AnimationConfig.spring( | |||
| Duration duration, { | |||
| double bounce = 0, | |||
| // Duration delay = Duration.zero, | |||
| VoidCallback? onEnd, | |||
| }) => .new( | |||
| }) => SpringAnimationConfig( | |||
| spring: SpringDescription.withDurationAndBounce( | |||
| duration: duration, | |||
| bounce: bounce, | |||
| ), | |||
| onEnd: onEnd, | |||
| ); | |||
|
|
|||
| static SpringAnimationConfig springWithDampingRatio({ | |||
| factory AnimationConfig.springWithDampingRatio({ | |||
| double mass = 1.0, | |||
| double stiffness = 180.0, | |||
| double dampingRatio = 0.8, | |||
| // Duration delay = Duration.zero, | |||
| VoidCallback? onEnd, | |||
| }) => .new( | |||
| }) => SpringAnimationConfig( | |||
| spring: SpringDescription.withDampingRatio( | |||
| mass: mass, | |||
| stiffness: stiffness, | |||
| ratio: dampingRatio, | |||
| ), | |||
| onEnd: onEnd, | |||
| ); | |||
There was a problem hiding this comment.
Changing AnimationConfig.withDefaults()/springDescription()/spring()/springWithDampingRatio() from static ... methods returning concrete config types into factory AnimationConfig... constructors weakens the return type to AnimationConfig. This is a source-breaking API change for callers that previously relied on CurveAnimationConfig/SpringAnimationConfig members without casting. Consider keeping typed static helpers (possibly under different names) alongside the new factory wrappers, or provide typed alternatives so downstream code doesn’t need as CurveAnimationConfig / as SpringAnimationConfig.
…meter propagation tests Remove shadow from chain-only methods table since it already exists as a factory constructor. Add tests verifying AnimationConfig factories properly propagate parameter values, not just return types.
Summary
This PR removes internal
Propimplementation details from user-facing documentation and standardizes all examples to use the fluent API. After comprehensive review of all 26 documentation pages, this update ensures users learn the correct public API without being exposed to internal plumbing.Changes
Key Changes:
Proppatterns from user-facing examples (introduction.mdx, design-token.mdx)Files Modified: 20 documentation pages
Test Plan
Verification Checklist