yvee 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -103,6 +103,41 @@ base. Set `client` to a directory or explicit JavaScript file to change it:
103
103
  new Yvee({ base: "/my-project/", client: "/my-project/client.js" });
104
104
  ```
105
105
 
106
+ ## Component authoring
107
+
108
+ A Yvee component is a function called by `dom`. Attributes are its first
109
+ argument; **JSX children are rest arguments**:
110
+
111
+ ```tsx
112
+ import { dom, type DOMContext } from "yvee";
113
+
114
+ function Card(props: { title: string }, ...children: DOMContext[]) {
115
+ return (
116
+ <article class="card">
117
+ <h2>{props.title}</h2>
118
+ {children}
119
+ </article>
120
+ );
121
+ }
122
+
123
+ const view = (
124
+ <Card title="Hello">
125
+ <p>Body</p>
126
+ </Card>
127
+ );
128
+ ```
129
+
130
+ > **Children are not on `props`.** Because `dom` forwards JSX children only as
131
+ > rest arguments, `props.children` is always `undefined`, and rendering it
132
+ > silently drops the children. Type the props parameter as your own props
133
+ > object and render the `...children` rest parameter instead. (`DOMComponent`
134
+ > and `DOMComponentProps` describe this shape for typed components.)
135
+
136
+ Components may be async; the renderer awaits them during SSR and navigation.
137
+ Optional attributes accept an explicit `undefined` (`disabled={props.disabled}`,
138
+ `on={props.on}`) and are omitted from the markup, so a conditionally-present
139
+ value can be forwarded without normalizing it first.
140
+
106
141
  ## Documentation
107
142
 
108
143
  | Guide | What it covers |