Skip to content

Commit 5faf798

Browse files
committed
chore: put class first in nanoviews-component and react-component skills
1 parent d18e4aa commit 5faf798

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎skills/nanoviews-component/SKILL.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,22 @@ If the project's linter rejects this layout, or its `--fix` collapses it back, t
405405
```
406406

407407
- A component that owns classes and also accepts a `class` prop reads `$class` and folds it into the `classList$` list, as the reference `Button` does.
408+
- `class` / `[classList$]` is always the first attribute of an element and the first prop taken out of `props$`, as the reference `Button` does:
409+
410+
```js
411+
// not
412+
div({
413+
id: 'card',
414+
class: styles.root
415+
})
416+
417+
// but
418+
div({
419+
class: styles.root,
420+
id: 'card'
421+
})
422+
```
423+
408424
- Import views from `nanoviews` and reactivity from `nanoviews/store`, by name:
409425

410426
```ts

‎skills/react-component/SKILL.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ Name event handlers in the `on*` form, never `handle*`: `onCloseCallback`, `onCl
244244
```
245245

246246
- Universal components must forward all remaining props to the root element, spreading `...props` after the explicitly set props — see the reference `Button` above: `onClick`, `type`, etc. reach `<button>` via the spread instead of being listed one by one.
247+
- `className` is always the first prop — first among the JSX attributes and first in the props destructuring, as the reference `Button` does:
248+
249+
```jsx
250+
// not
251+
<div id="card" className={styles.root}/>
252+
253+
// but
254+
<div className={styles.root} id="card"/>
255+
```
256+
247257
- Don't pass unneeded props to the root element — destructure props consumed by hooks so they don't leak into the rest spread:
248258

249259
```jsx

0 commit comments

Comments
 (0)