Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 3c27915

Browse files
committed
docs(readme): initial commit
1 parent 44203bd commit 3c27915

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

readme.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Typed CSS X
2+
3+
**Zero-runtime CSS in JS and Compiler**
4+
5+
- For Next.js App router(RSC)
6+
- Console lover
7+
- Server Component
8+
- Client Component
9+
- Zero-runtime (statically generated during build)
10+
- Hot Reload (A smooth development experience)
11+
- Hard Type (Benefit from type completion development experience)
12+
- Media (Media Query provides modern functions)
13+
14+
All types are Property(CamelCase): String and can't write directly to a tsx file.
15+
In development mode with we can see hot reloading preview by adding 'use client'.
16+
17+
## Scoped.style
18+
19+
```ts
20+
import { Scoped } from 'typedcssx';
21+
22+
export const style = Scoped.style({
23+
fontSize: '16px',
24+
color: 'black',
25+
});
26+
```
27+
28+
## Scoped.sheet
29+
30+
```ts
31+
export const styles = Scoped.sheet({
32+
header_nav: {
33+
position: 'absolute',
34+
top: '0',
35+
},
36+
});
37+
```
38+
39+
## Example of use
40+
41+
```tsx
42+
import { styles } from './style.css';
43+
44+
const Header = () => {
45+
return (
46+
<header className={styles.header_nav}>
47+
<nav>
48+
<a>content</a>
49+
<a>home</a>
50+
</nav>
51+
</header>
52+
);
53+
};
54+
```
55+
56+
## Global API
57+
58+
Scoped.gloabl and Scoped.root is do not use it in a variable scope.
59+
Wherever they are, the compiler reads them and writes them to the StyleSheet.
60+
61+
```ts
62+
Scoped.global({
63+
h1: {
64+
color: 'var(--color-font)',
65+
background: 'var(--color-background)',
66+
},
67+
});
68+
69+
Scoped.root({
70+
'--color-font': '#333',
71+
'--color-background': '#fff',
72+
});
73+
```
74+
75+
## MediaQuery
76+
77+
```ts
78+
import { Scoped, media } from 'typedcssx';
79+
const small = media('300px <= width <= 600px');
80+
const xlarge = media('200px <= width <= 1400px');
81+
82+
export const styles = Scoped.sheet({
83+
header_nav: {
84+
fontSize: '18px',
85+
color: 'white',
86+
...small({
87+
fontSize: '12px',
88+
color: 'pink',
89+
}),
90+
},
91+
...small({
92+
footer_nav: {
93+
margin: '24px'
94+
padding: '24px'
95+
},
96+
})
97+
});
98+
```
99+
100+
It's can enclose selectors or properties directly.
101+
media is a higher-order function, so you can directly create wrapper functions for small, large, etc.
102+
103+
## Build Setting and Global CSS
104+
105+
add file extension in tsconfig.json
106+
107+
```json
108+
"include": ["**/*.css.ts"]
109+
```
110+
111+
add package.json scripts field.
112+
113+
```json
114+
"scripts": {
115+
"build": "npm run compile && next build",
116+
"compile": "cd node_modules/typedcssx && npm run compile"
117+
}
118+
```
119+
120+
import the global style in layout.tsx
121+
122+
```tsx
123+
import '../../node_modules/typedcssx/dist/core/styles/global.css';
124+
```
125+
126+
## License
127+
128+
MIT License

0 commit comments

Comments
 (0)