You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/landing/src/app/(detail)/docs/api/center/page.mdx
+68-15Lines changed: 68 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,19 +14,72 @@ It has a `display: flex` style with `justify-content: center` and `align-items:
14
14
## How to use
15
15
16
16
```tsx
17
-
const before = (
18
-
<Center>
19
-
<Boxbg="blue"h={25}w={25} />
20
-
<Boxbg="blue"h={25}w={25} />
21
-
<Boxbg="blue"h={25}w={25} />
22
-
</Center>
23
-
)
24
-
25
-
const after = (
26
-
<divclassName="d3 d4 d5">
27
-
<divclassName="d0 d1 d2"></div>
28
-
<divclassName="d0 d1 d2"></div>
29
-
<divclassName="d0 d1 d2"></div>
30
-
</div>
31
-
)
17
+
import { Box, Center } from'@devup-ui/react'
18
+
19
+
function App() {
20
+
return (
21
+
<Center>
22
+
<Boxbg="blue"h={25}w={25} />
23
+
<Boxbg="blue"display="flex"h={25}w={25} />
24
+
<Boxbg="blue"h={25}w={25} />
25
+
</Center>
26
+
)
27
+
}
28
+
```
29
+
30
+
The Center component defined above will render like this:
31
+
32
+
```tsx
33
+
function App() {
34
+
return (
35
+
<divclassName="ae af ag">
36
+
<divclassName="aa ab ac"></div>
37
+
<divclassName="aa ab ac a-d"></div>
38
+
<divclassName="aa ab ac"></div>
39
+
</div>
40
+
)
41
+
}
32
42
```
43
+
44
+
```css
45
+
.aa {
46
+
background: blue;
47
+
}
48
+
.ab {
49
+
height: 100px;
50
+
}
51
+
.ac {
52
+
width: 100px;
53
+
}
54
+
.a-d {
55
+
display: flex;
56
+
}
57
+
.ae {
58
+
display: flex;
59
+
}
60
+
.af {
61
+
justify-content: center;
62
+
}
63
+
.ag {
64
+
align-items: center;
65
+
}
66
+
```
67
+
68
+
If you pass a number without a unit to a style property, it will be automatically scaled by 4.
69
+
This means 1 equals 4px, 2 equals 8px, and so on.
70
+
71
+
<br />
72
+
73
+
Class names and style properties are resolved in the following order:
74
+
75
+
1. Generate class names for child components.
76
+
- Compute class names and style properties coming from each child (including component defaults, utility classes, and props).
77
+
78
+
2. Remove duplicate component properties.
79
+
- Deduplicate only when both the `key:value` pair and the `style-order` match.
80
+
81
+
3. If the key:value matches but the `style-order` differs, the property is not removed — the later/higher-priority style will take precedence.
82
+
- Example: In other words, the `display: flex` implemented internally by `Center` and the `display: flex` provided directly by the user have different style-orders, so they are not removed, and the final style is applied according to priority.
83
+
84
+
4. Generate the parent component’s className based on the merged result.
85
+
- After child classNames are generated and duplicates (per rules above) removed, compute/merge the parent className and final style output.
Copy file name to clipboardExpand all lines: apps/landing/src/app/(detail)/docs/api/grid/page.mdx
+59-15Lines changed: 59 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,19 +15,63 @@ It has a `display: grid` style by default.
15
15
## How to use
16
16
17
17
```tsx
18
-
const before = (
19
-
<Grid>
20
-
<Boxbg="blue"h={25}w={25} />
21
-
<Boxbg="blue"h={25}w={25} />
22
-
<Boxbg="blue"h={25}w={25} />
23
-
</Grid>
24
-
)
25
-
26
-
const after = (
27
-
<divclassName="d3">
28
-
<divclassName="d0 d1 d2"></div>
29
-
<divclassName="d0 d1 d2"></div>
30
-
<divclassName="d0 d1 d2"></div>
31
-
</div>
32
-
)
18
+
import { Box, Grid } from'@devup-ui/react'
19
+
20
+
function App() {
21
+
return (
22
+
<Grid>
23
+
<Boxbg="blue"h={25}w={25} />
24
+
<Boxbg="blue"h={25}w={25} />
25
+
<Boxbg="blue"h={25}w={25} />
26
+
</Grid>
27
+
)
28
+
}
29
+
```
30
+
31
+
The Grid component defined above will render like this:
32
+
33
+
```tsx
34
+
function App() {
35
+
return (
36
+
<divclassName="a-d">
37
+
<divclassName="aa ab ac"></div>
38
+
<divclassName="aa ab ac"></div>
39
+
<divclassName="aa ab ac"></div>
40
+
</div>
41
+
)
42
+
}
43
+
```
44
+
45
+
```css
46
+
.aa {
47
+
background: blue;
48
+
}
49
+
.ab {
50
+
height: 100px;
51
+
}
52
+
.ac {
53
+
width: 100px;
54
+
}
55
+
.a-d {
56
+
display: grid;
57
+
}
33
58
```
59
+
60
+
If you pass a number without a unit to a style property, it will be automatically scaled by 4.
61
+
This means 1 equals 4px, 2 equals 8px, and so on.
62
+
63
+
<br />
64
+
65
+
Class names and style properties are resolved in the following order:
66
+
67
+
1. Generate class names for child components.
68
+
- Compute class names and style properties coming from each child (including component defaults, utility classes, and props).
69
+
70
+
2. Remove duplicate component properties.
71
+
- Deduplicate only when both the `key:value` pair and the `style-order` match.
72
+
73
+
3. If the key:value matches but the `style-order` differs, the property is not removed — the later/higher-priority style will take precedence.
74
+
- Example: In other words, the `display: flex` implemented internally by `Center` and the `display: flex` provided directly by the user have different style-orders, so they are not removed, and the final style is applied according to priority.
75
+
76
+
4. Generate the parent component’s className based on the merged result.
77
+
- After child classNames are generated and duplicates (per rules above) removed, compute/merge the parent className and final style output.
0 commit comments