Rapid On-Demand Atomic CSS framework AdorableCSS๋ฅผ ๋ง๋ค๊ฒ ๋ ๋ฐฐ๊ฒฝ์ด ๊ถ๊ธํ๋ค๋ฉด ์ฌ๊ธฐ๋ฅผ ํตํด ํ์ธํด๋ณด์ธ์.
- Try it online here.
// Button.tsx
export const Button = () =>
<button class="hbox pack gap(6) bg(#333) c(#fff) b(#000.2) r(6) p(8/12) font(14/16/-1%) bold pointer transition(.2s)
hover:bg(#555)
active:bg(#000)! active:b(#000.2)">
<div>๐</div>
<div>Like</div>
</button>
/* @adorable.css */
* {margin:0;padding:0;box-sizing:border-box;font:inherit;color:inherit;flex-shrink:0;}
.c\(\#fff\){color:#fff;}
html .active\:bg\(\#000\)\!:active,html .active\:bg\(\#000\)\!.\:active{background-color:#000!important;}
.bg\(\#333\){background-color:#333;}
@media (hover:hover){.hover\:bg\(\#555\):hover,.hover\:bg\(\#555\).\:hover{background-color:#555;}}
.font\(14\/16\/-1\%\){font-size:14px;line-height:16px;letter-spacing:-0.01em}
.bold{font-weight:700;}
.hbox{display:flex;flex-flow:row;align-items: center;}
.p\(8\/12\){padding:8px 12px;}
.pack{display:flex;align-items:center;justify-content:center;}
.pointer{cursor:pointer;}
html .active\:b\(\#000\.2\):active,html .active\:b\(\#000\.2\).\:active{border:1px solid rgba(0,0,0,.2);}
.b\(\#000\.2\){border:1px solid rgba(0,0,0,.2);}
.r\(6\){border-radius:6px;}
.gap\(6\){gap:6px;}
.layer{position:absolute;top:0;right:0;bottom:0;left:0}
.transition\(\.2s\){transition:all .2s;}
- โฑ vite, webpack, postcss๋ฑ ๋ค๋ฅธ ๋ณต์กํ ์ค์ ์์ด ๊ทธ๋ฅ script ํ์ค๋ง ์ถ๊ฐํ๋ฉด adorableCSS๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
- โก๏ธ adorableCSS๋ฅผ ๊ฐํธํ๊ฒ ์ฐ๋ ๋ฐฉ๋ฒ! body ๋งจ ์๋
<script src="https://unpkg.com/adorable-css"></script>
๋ง ์ถ๊ฐํด๋ณด์ธ์. - ๋ฐํ์ ๋ฐฉ์์ผ๋ก css in js ๋ฐฉ์์ ํตํด์ ๋์ ์ผ๋ก style์ ์์ฑํ์ฌ ์ ์ฉํด์ค๋๋ค.
- (์ง๊ธ ๊ฐ๋ฐ์ ๋๊ตฌ๋ฅผ ์ด์ด์ ์๋ฌด ์๋ฆฌ๋จผํธ๋ class="bg(red)" ๋ฅผ ํ๋ฒ ์ถ๊ฐํด๋ณด์ธ์.)
<script src="https://unpkg.com/adorable-css"></script>
</body>
</html>
- run-time์ด ์๋๋ผ Build-time์์ ์ต์ข css๋ฅผ ๋ง๋ค์ด๋ ๋๋ค. (zero run-time)
- ์ต์ข ์ ์ผ๋ก ๋ง๋ค์ด์ง css๋ฅผ ํตํด์ ๋ฐํ์ ๋น์ฉ์ ๋ ์ค์ผ ์ ์๊ณ css์ ์บ์ฑ ๊ธฐ๋ฅ์ ๋ ํ์ฉํ ์ ์์ต๋๋ค.
npm i -D adorable-css
// vite.config.js
import {adorableCSS} from "adorable-css/vite" // <-
export default defineConfig({
plugins: [adorableCSS(), ...] // <- plugin์ ๋งจ ์ฒ์์ ๋ฑ๋กํฉ๋๋ค.
})
// main.tsx
import "@adorable.css" // <- virtual css๋ฅผ import ํฉ๋๋ค.
import React from "react"
import ReactDOM from "react-dom"
import "./index.css"
import {App} from "./App"
ReactDOM.render(
<React.StrictMode>
<App/>
</React.StrictMode>,
document.getElementById("root")
)
npm i -D adorable-css
Usage:
$ adorable-css [root]
Commands:
[root] build for production
For more info, run any command with the `--help` flag:
$ adorable-css --help
Options:
-o, --out <dir> [string] output Directory (default: adorable.css)
-w, --watch [boolean] rebuilds when modules have changed on disk (default: false)
-m, --minify [boolean] minify output css (default: false)
-v, --verbose [boolean] verbose build output (default: false)
--no-reset [boolean] exclude reset css from output (default: true)
vite ํ๊ฒฝ์ด ์๋๋ผ๋ฉด cdn์ ํตํด์ ์ค์๊ฐ์ผ๋ก ๊ฐ๋ฐํ๊ณ cli๋ก ์ต์ข ๋น๋์ css๋ง ํฌํจํ๋ ๋ฐฉ์์ ์๊ฐํ๊ณ ์์ต๋๋ค. ๋ค์ํ ํ๊ฒฝ์์ ์กฐ๊ธ๋ DX๋ฅผ ๋์ด๋ ๋ฐฉํฅ์ฑ์ ๊ณ ๋ฏผํด๋ณด๊ฒ ์ต๋๋ค.
Rapid On-Demand Atomic CSS framework
๊ณจ์น์ํ css ์ด๋ฆ์ง๊ธฐ๋ ์ด์ ๊ทธ๋ง!
๋ ์ด์ ์๋ก์ด css๋ฅผ ์์ฑํ๋ ๋ฐ ํ๋นผ์ง ๋ง์ธ์. ๊ฑฐ์ ๋ชจ๋ class๋ฅผ ๋ฏธ๋ฆฌ ์ ์ํด๋์์ต๋๋ค.
class="font(20) c(red)"์ ๊ฐ์ด ํจ์ํ์ผ๋ก ์ ์๋ ํ์์ผ๋ก ์ ๋ ฅํด๋ณด์ธ์.
๋ชจ๋ ์์น์ ์์์ ์ง์ํ๋ฉฐ, ํ์ํ ๋งํผ์ CSS๋ง ๋ง๋ค์ด ๋ ๋๋ค.
Easy! : ๋์์ธ ๊ฐ๋ฐ์ ์ํด ์ด๋ฆ์ ์ง๋ ์๊ณ ๊ฐ ์ฌ๋ผ์ง๋ฉฐ, ํ๋ฒ ์ธ์ด ์ด๋ฆ์ ๊ณ์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
Write less do more! : ๊ธฐ์กด css๋ฌธ๋ฒ๋ณด๋ค ํจ์ฌ ๋ ์ ์ ์ฝ๋๋ก ๋ ๋ง์ ์์ ์ ํ ์ ์์ต๋๋ค.
Fast Writing and No switching! : html, jsx์ ๋ฐ๋ก ๋์์ธ์ ์ ์ฉํ ์ ์์ด ๋งค์ฐ ๋น ๋ฅธ ๋์์ธ ๊ฐ๋ฐ ์๋๋ฅผ ๊ฐ์ง๋๋ค.
Portable! : css ์์ด HTML๋ง์ผ๋ก UI๋ฅผ ๋ง๋ค ์ ์์ด ์ด๋๊ณผ ๋ฆฌํฉํ ๋ง์์ ์์ ๋กญ์ต๋๋ค.
Compact! : ๊ธฐ์กด css ๋ฐฉ์๋ณด๋ค ํจ์ฌ ๋ ์ ์ ๋ผ์ธ์ ์ต์ ํ๋ css๋ฅผ ์์ฐํฉ๋๋ค.
Great for Auto Design HandOff! : ์ด๋ฆ์ด ํ์์๊ธฐ์ figma๋ฑ์ HandOff์์ ๋ณํํ๊ธฐ์ ์ต์ ํ๋ ํํ์ ๋๋ค.
figma AdorableCSS plugin link
For full documentation, visit here.