Skip to content

docs: use prop atoms directly in counter and tabs examples#11

Merged
psd-coder merged 2 commits into
mainfrom
fix/simplify-tabs-example
Jun 22, 2026
Merged

docs: use prop atoms directly in counter and tabs examples#11
psd-coder merged 2 commits into
mainfrom
fix/simplify-tabs-example

Conversation

@psd-coder

Copy link
Copy Markdown
Owner

Overview

Simplifies the Counter and Tabs documentation examples to use their prop atoms directly instead of copying them into redundant local atoms. Addresses issue #10.

Problem Statement

Both examples created a new Nano Stores atom seeded from a prop (atom(ctx.props.$x.get())), even though ctx.props.$x is already a WritableAtom. As reported in #10, this made the examples harder to follow: it added an extra concept, an extra nanostores import, and suggested the copy was necessary when it wasn't. In Tabs the local $active was a one-to-one mirror of the active prop, and in Counter the seeded $count could be expressed directly through the prop.

Solution Approach

  • Tabs: drive ctx.props.$active directly in the focus handler, click handler, effect, and context provider; removed the redundant $active copy.
  • Counter: renamed the initial prop to value and read/write ctx.props.$value directly for increment, decrement, and display.
  • Removed the now-unused atom import and the orphaned nanostores importmap entry from both examples, keeping them self-contained and consistent with the other examples.

Breaking Changes

None. Documentation examples only.

@psd-coder psd-coder self-assigned this Jun 22, 2026
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

size-limit report 📦

Path Size
.size-check/index.mjs 2.36 KB (0%)
.size-check/render.mjs 417 B (0%)
.size-check/context.mjs 402 B (0%)

ctx.props.$active is already a WritableAtom; drop the redundant local
copy and the unused atom import.
Rename the seed prop to "value" and drive it via ctx.props.$value
(already a WritableAtom); drop the unused atom import.
@psd-coder psd-coder force-pushed the fix/simplify-tabs-example branch from 5c924ee to 8f45443 Compare June 22, 2026 01:14
@psd-coder psd-coder merged commit a7a3d2f into main Jun 22, 2026
9 checks passed
@psd-coder psd-coder deleted the fix/simplify-tabs-example branch June 22, 2026 01:18
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