Skip to content

Commit dd83ee1

Browse files
committed
chore: let CSS decide what it can before JS in ui-component skill
1 parent f0224c4 commit dd83ee1

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎skills/ui-component/SKILL.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ metadata:
3737
## CSS
3838

3939
- Follow the BEM methodology — the principles, not the class naming. Key rule: a block must not affect its surroundings, i.e. no external geometry (margins, size-affecting borders) or positioning on the block itself. A block does not place itself: its margin, its insets, its stacking (`z-index`), `position: absolute`, `fixed` or `sticky`, its place in a parent's flex or grid (`align-self`, `grid-area`, `order`) and whether it shows at a breakpoint are the consumer's. Its own size is its own, `flex: none` included, and so are its pseudo-elements, placed inside it. What is out of the flow by its nature (a skip link, visually hidden words, a modal in the top layer) says so where it does it.
40+
- **CSS before JS.** What CSS can decide, it decides: a layout by width (media and container queries); a look from the element's own state (`:checked`, `:open`, `[aria-expanded]`, `:has()`); a variant on its parts (a selector under the root); a mark or a shape; a scroll's shade (scroll-driven animations); a sticky band; overlays on the top layer (`<dialog>` and the Popover API). JS keeps what CSS cannot know: data, an answer, focus and what a press changes. A state copied into JS only to set a class is the sign to look again.
4041
- CSS Modules:
4142
- The root element's class must be named `.root`.
4243
- Use simple camelCase class names (easy to access from JS), not BEM naming:

0 commit comments

Comments
 (0)