Skip to content

docs: worked component-authoring examples in components guide#57

Merged
GenericJam merged 2 commits into
masterfrom
docs/component-authoring-examples
Jul 1, 2026
Merged

docs: worked component-authoring examples in components guide#57
GenericJam merged 2 commits into
masterfrom
docs/component-authoring-examples

Conversation

@GenericJam

Copy link
Copy Markdown
Owner

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:

  • Function composite (MyApp.DashboardScreen): defines stat_card/3, uses it via {...} interpolation, and wires a <Button> inside the composite back to the screen's handle_info/2.
  • Tag composite (<Card> + <LabeledButton>): the two expander modules (modeled on MobDemoKit.Card), both registration paths (manifest ui_components and runtime Mob.Composite.register/2), and a consuming MyApp.ProfileScreen.

Why it matters

Two things that were previously implicit and easy to get wrong are now explicit:

  • The tag-to-atom rule (<Card> -> :card, verified against Mob.Sigil's Macro.underscore), so registration atoms line up.
  • Where 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

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 GenericJam merged commit e4d829d into master Jul 1, 2026
4 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant