docs: worked component-authoring examples in components guide#57
Merged
Conversation
Replace the thin 'Pure-Elixir composite components' section with complete,
runnable screen modules for both composite forms:
- Function composite: a screen defining stat_card/3 and using it via {...},
with a button inside it routing back to the screen's handle_info/2.
- Tag composite: the expander modules (Card + LabeledButton), both
registration paths (manifest ui_components and Mob.Composite.register/2),
and a consuming screen that uses the tags.
Also pins down the PascalCase->snake_case tag atom rule and clarifies that
on_* auto-injection applies only to a composite tag's own props (a plain
widget still needs an explicit {self(), tag}).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The section was renamed to 'Defining your own components', which drops the old auto-generated anchor. PR #56 links to #pure-elixir-composite-components from the @assigns note; add an explicit anchor so that link resolves regardless of merge order. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
GenericJam
added a commit
that referenced
this pull request
Jul 1, 2026
MOB-5: ~MOB raises a helpful CompileError when @foo is used without an `assigns` in scope (guard via Macro.Env.has_var?, mirroring ~H), instead of a cryptic "undefined variable assigns". Plus worked component-authoring examples in the Components guide. (#56, #57) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fills a gap in
guides/components.md: the guide documented every built-in component well but only had a thin fragment for authoring your own components and dropping them into a screen.Replaces the old "Pure-Elixir composite components" section with a "Defining your own components" section containing two complete, runnable screen modules:
MyApp.DashboardScreen): definesstat_card/3, uses it via{...}interpolation, and wires a<Button>inside the composite back to the screen'shandle_info/2.<Card>+<LabeledButton>): the two expander modules (modeled onMobDemoKit.Card), both registration paths (manifestui_componentsand runtimeMob.Composite.register/2), and a consumingMyApp.ProfileScreen.Why it matters
Two things that were previously implicit and easy to get wrong are now explicit:
<Card>->:card, verified againstMob.Sigil'sMacro.underscore), so registration atoms line up.on_*auto-injection applies: only a composite tag's own props are shaped to{screen_pid, tag}. A plain<Button>/<TextField>placed directly (even inside a composite's children) still needs an explicit{self(), tag}. The two examples deliberately contrast these.Scope
Docs only, single file (
guides/components.md). No code changes. Section heading renamed from "Pure-Elixir composite components" to "Defining your own components"; confirmed nothing links to the old anchor.🤖 Generated with Claude Code