Skip to content

Improve foreach docs examples#6562

Merged
Alek99 merged 6 commits into
mainfrom
fix-foreach-docs
May 27, 2026
Merged

Improve foreach docs examples#6562
Alek99 merged 6 commits into
mainfrom
fix-foreach-docs

Conversation

@Alek99
Copy link
Copy Markdown
Member

@Alek99 Alek99 commented May 25, 2026

Summary

  • clarify when to use rx.foreach versus Python comprehensions
  • update foreach callback annotations to use rx.Var[...]
  • improve demo styling so color and dictionary examples render readably
  • make todo example buttons visible and wire finish_item as an event handler

Testing

  • Ran docs app locally with CI=1 and whitelisted /library/dynamic-rendering/foreach
  • Verified the page in the Codex in-app browser at http://localhost:3000/docs/library/dynamic-rendering/foreach/
  • Confirmed the todo Done button removes an item from the rendered list
  • Ran git diff --check

@Alek99 Alek99 requested a review from a team as a code owner May 25, 2026 19:25
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 25, 2026

Greptile Summary

This PR improves the rx.foreach documentation page: callback annotations are updated to rx.Var[...], color examples are replaced with readable hex swatches, the todo example gains proper UUID-based item identity and a wired "Done" button, and a dictionary-key coercion note is added. The structural change to watch is the removal of the YAML frontmatter that other component docs pages rely on for auto-generated API reference embedding.

  • Annotation and styling improvements are clear wins: rx.Var[...] annotations are now consistent across all callback signatures, and the demo components render visibly without relying on CSS named colors as both label and background.
  • The todo example is substantially improved with a TodoItem dataclass, UUID-based keying for React reconciliation, and finish_item correctly decorated with @rx.event.
  • The YAML frontmatter (components: - rx.foreach) was removed and replaced with a manually written API Reference section; other component pages retain this frontmatter for auto-generated prop tables, so its removal may silently drop documentation and affect search/navigation indexing.

Confidence Score: 4/5

The content changes are solid, but the frontmatter removal drops the auto-generated component API table that every other docs page in the library section relies on.

Cross-checking five other component docs pages (box, aspect_ratio, center, card, html/text) confirms they all keep the components frontmatter block so the docs system can embed the full prop reference. Stripping it from foreach.md means readers lose that auto-generated table, and depending on how the docs build uses the key, it may also break search indexing or the component registry for this page.

docs/library/dynamic-rendering/foreach.md — the removed YAML frontmatter and the inaccurate iterable-type list in the manual API Reference section both need a second look before merging.

Important Files Changed

Filename Overview
docs/library/dynamic-rendering/foreach.md Rewrites foreach docs with hex-color swatches, UUID-keyed todo items, updated rx.Var annotations, and a manual API Reference section — but removes the frontmatter that drives auto-generated component API docs, and the new API Reference section lists unsupported iterable types (sets, strings).

Reviews (2): Last reviewed commit: "Address foreach docs review comments" | Re-trigger Greptile

Comment thread docs/library/dynamic-rendering/foreach.md Outdated
Comment thread docs/library/dynamic-rendering/foreach.md Outdated
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 25, 2026

Merging this PR will not alter performance

✅ 24 untouched benchmarks


Comparing fix-foreach-docs (0d7cada) with main (cf5e4ed)

Open in CodSpeed

Copy link
Copy Markdown
Member Author

Alek99 commented May 25, 2026

Updated the complex dictionary example layout after local review: it now renders the three secondary colors as three grouped columns with spacing instead of wrapping the third group underneath.

Copy link
Copy Markdown
Member Author

Alek99 commented May 25, 2026

Updated the color examples again after visual review: they now use explicit site-friendly hex colors and a shared rounded color_swatch helper. The complex dictionary example renders the parent colors as swatches too, so the top row matches the child swatches.

Copy link
Copy Markdown
Member Author

Alek99 commented May 25, 2026

Simplified the swatch examples after review: the basic color example is back to List[str], and the complex dictionary example is back to Dict[str, List[str]]. The strings are now site-friendly hex colors, so the rendered swatches stay polished without introducing nested tuple data structures.

@Alek99 Alek99 requested a review from FarhanAliRaza May 26, 2026 18:53
@masenf masenf added the skip-changelog For doc/internal changes label May 27, 2026
Copy link
Copy Markdown
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API Reference at the bottom of this page seems weird. It only shows the iterable prop, which mismatches with how the foreach component is supposed to be used.

Comment thread docs/library/dynamic-rendering/foreach.md Outdated
Comment thread docs/library/dynamic-rendering/foreach.md Outdated
Comment thread docs/library/dynamic-rendering/foreach.md Outdated
Comment thread docs/library/dynamic-rendering/foreach.md Outdated
Comment thread docs/library/dynamic-rendering/foreach.md Outdated
@masenf
Copy link
Copy Markdown
Collaborator

masenf commented May 27, 2026

@greptile

@Alek99 Alek99 merged commit 8ad0f56 into main May 27, 2026
30 checks passed
@Alek99 Alek99 deleted the fix-foreach-docs branch May 27, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog For doc/internal changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants