Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A more intuitive nesting order example #8

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion text/001-css-nesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -583,18 +583,58 @@ This decision can be overturned later based on benchmark results, ease of debugg

### Exmaples

You can now answer the question.

**Code:**
```typescript
const myCss = css({
"nav li > &": {
"@media (prefers-color-scheme: dark)": {
_hover: {
background: "red"
}
}
}
});
```

**Convert to Vanilla Extract:**
```typescript
export const myCss = style({
"@media": {
"(prefers-color-scheme: dark)": {
selectors: {
"nav li > &:hover": {
background: "red"
}
}
}
}
});
```

It sounds complicated, but it's always transfiled with the following structure:

**Convert to Vanilla Extract:**
```typescript
export const myCss = style({
"@layout": {
// Level1: @layer
"@layer": {
"framework.layout": {

// Level2: @supports
"@supports": {
"gap: 1rem": {

// Level3: @media
"@media": {
"(prefers-color-scheme: dark) and (prefers-reduced-motion)": {

// Level4: @container
"@container": {
"(min-width: 500px)": {

// Level5: selectors
"selectors": {
"nav li > &:hover": {
background: "red"
Expand Down