Skip to content

Commit

Permalink
## 1.6.2
Browse files Browse the repository at this point in the history
- ✨ `transition(1s/2s)` 와 같이 `transition`값이 여러개 입력시 문제가 있던 현상을 수정하였습니다..
- 📦 package 최신화
  • Loading branch information
유용태 committed Jun 24, 2024
1 parent 5e4dabf commit fb7c91f
Show file tree
Hide file tree
Showing 11 changed files with 430 additions and 261 deletions.
176 changes: 155 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,172 @@
# create-svelte
# AdorableCSS
> Rapid On-Demand Atomic CSS framework
> AdorableCSS를 만들게 된 배경이 궁금하다면 [여기](https://velog.io/@teo/adorable-css)를 통해 확인해보세요.
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
![](https://images.velog.io/images/teo/post/0282cd6a-7530-4674-ad56-2cea0b55b773/%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202022-01-12%20%E1%84%8B%E1%85%A9%E1%84%8C%E1%85%A5%E1%86%AB%2012.06.40.png)

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!
## Try It Online
- Try it online [here](https://developer-1px.github.io/adorable-css/).

```bash
# create a new project in the current directory
npm create svelte@latest
![AdorableCSS](https://images.velog.io/images/teo/post/dde8bc56-15d0-4fc0-a15a-f3c204f50494/AdorableCSS.gif)

# create a new project in my-app
npm create svelte@latest my-app
#### Don't write your own css. Just write down in HTML.

```tsx
// 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>
```

#### ... and auto generate css on realtime! 😎

```css
/* @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;}
```

---

## Getting Started

### CDN
- ⛱ vite, webpack, postcss등 다른 복잡한 설정 없이 그냥 script 한줄만 추가하면 adorableCSS를 사용할 수 있습니다.
- ⚡️ adorableCSS를 간편하게 쓰는 방법! body 맨 아래 `<script src="https://unpkg.com/adorable-css"></script>`만 추가해보세요.
- 런타임 방식으로 css in js 방식을 통해서 동적으로 style을 생성하여 적용해줍니다.
- (지금 개발자 도구를 열어서 아무 엘리먼트나 class="bg(red)" 를 한번 추가해보세요.)

```html
<script src="https://unpkg.com/adorable-css"></script>
</body>
</html>
```


### Vite(Recommanded)
- run-time이 아니라 Build-time에서 최종 css를 만들어냅니다. (zero run-time)
- 최종적으로 만들어진 css를 통해서 런타임 비용을 더 줄일 수 있고 css의 캐싱 기능을 더 활용할 수 있습니다.

```sh
npm i -D adorable-css
```

```ts
// vite.config.js
import {adorableCSS} from "adorable-css/vite" // <-
export default defineConfig({
plugins: [adorableCSS(), ...] // <- plugin을 맨 처음에 등록합니다.
})
```

```tsx
// 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")
)
```

## Developing
#### React, Svelte, Vue ... Almost Web framework support with Vite.


Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
### CLI(beta): Build Time + Watch mode
[Remix + adorable css example](./examples/adorable-css-remix/)

```bash
npm run dev
```
npm i -D adorable-css
```

# or start the server and open the app in a new browser tab
npm run dev -- --open
```
Usage:
$ adorable-css [root]
## Building
Commands:
[root] build for production
To create a production version of your app:
For more info, run any command with the `--help` flag:
$ adorable-css --help
```bash
npm run build
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)
```

You can preview the production build with `npm run preview`.
> vite 환경이 아니라면 cdn을 통해서 실시간으로 개발하고 cli로 최종 빌드시 css만 포함하는 방식을 생각하고 있습니다.
> 다양한 환경에서 조금더 DX를 높이는 방향성을 고민해보겠습니다.
---

## What is AdorableCSS?
> Rapid On-Demand Atomic CSS framework
골치아픈 css 이름짓기는 이제 그만!

더 이상 새로운 css를 작성하는 데 힘빼지 마세요. 거의 모든 class를 미리 정의해두었습니다.

class="font(20) c(red)"와 같이 함수형으로 정의된 형식으로 입력해보세요.

모든 수치와 색상을 지원하며, 필요한 만큼의 CSS만 만들어 냅니다.

## Why Use AdorableCSS?

**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에서 변환하기에 최적화된 형태입니다.

## Handshake
> figma AdorableCSS plugin [link](https://github.com/developer-1px/adorable-css/tree/master/src%5Bfigma-handshake%5D)
![](https://images.velog.io/images/teo/post/579cdb7b-8819-4902-8f97-06c3400b2021/%E1%84%92%E1%85%AA%E1%84%86%E1%85%A7%E1%86%AB%20%E1%84%80%E1%85%B5%E1%84%85%E1%85%A9%E1%86%A8%202021-09-01%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%203.17.17.mov.gif)

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
## Documentation
For full documentation, visit [here](https://github.com/developer-1px/adorable-css/tree/master/src%5Badorable-css%5D).
46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "adorable-css-docs",
"version": "1.3.0",
"version": "1.3.1",
"homepage": "https://developer-1px.github.io/adorable-css",
"scripts": {
"dev": "vite dev",
Expand All @@ -15,32 +15,32 @@
"lint": "eslint --ignore-path .gitignore ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/adapter-static": "^3.0.2",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "^8.56.7",
"eslint": "^9.0.0",
"@sveltejs/kit": "^2.5.17",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@types/eslint": "^8.56.10",
"eslint": "^9.5.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0",
"globals": "^15.0.0",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"eslint-plugin-svelte": "^2.40.0",
"globals": "^15.6.0",
"prettier": "^3.3.2",
"prettier-plugin-svelte": "^3.2.5",
"svelte": "^4.2.18",
"svelte-check": "^3.8.1",
"tslib": "^2.6.3",
"typescript": "^5.5.2",
"typescript-eslint": "^8.0.0-alpha.20",
"vite": "^5.0.3",
"@types/clean-css": "^4.2.7",
"vite": "^5.3.1",
"@types/clean-css": "^4.2.11",
"@types/glob": "^8.1.0",
"cac": "^6.7.14",
"clean-css": "^5.3.2",
"gh-pages": "^6.0.0",
"clean-css": "^5.3.3",
"gh-pages": "^6.1.1",
"glob-to-regexp": "^0.4.1",
"mdsvex": "^0.11.0",
"micromatch": "^4.0.5",
"monaco-editor": "^0.43.0",
"chokidar": "^3.5.3",
"glob": "^10.3.4" }
"mdsvex": "^0.11.2",
"micromatch": "^4.0.7",
"monaco-editor": "^0.50.0",
"chokidar": "^3.6.0",
"glob": "^10.4.2" }
}
20 changes: 13 additions & 7 deletions packages/vite/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ var makeTransition = (value) => {
if (!/\d/.test(value))
return value;
if (!value.includes("="))
return `all ${value}`;
return makeValues(value);
return value.split(/[/|]/).map((item) => item.replace("=", " ")).join(",");
};
var makePosition1 = (value) => {
Expand Down Expand Up @@ -879,8 +879,8 @@ ol,ul,menu,dir{list-style:none;}
--a-skew-y:0;
--a-scale-x:1;
--a-scale-y:1;
--a-transform:translateX(var(--a-translate-x)) translateY(var(--a-translate-y)) rotate(var(--a-rotate)) skewX(var(--a-skew-x)) skewY(var(--a-skew-y)) scaleX(var(--a-scale-x)) scaleY(var(--a-scale-y));
--a-transform3d:translate3d(var(--a-translate-x),var(--a-translate-y),0) rotate(var(--a-rotate)) skewX(var(--a-skew-x)) skewY(var(--a-skew-y)) scaleX(var(--a-scale-x)) scaleY(var(--a-scale-y));
--a-transform: translateX(var(--a-translate-x)) translateY(var(--a-translate-y)) rotate(var(--a-rotate)) skewX(var(--a-skew-x)) skewY(var(--a-skew-y)) scaleX(var(--a-scale-x)) scaleY(var(--a-scale-y));
--a-transform3d: translate3d(var(--a-translate-x),var(--a-translate-y),0) rotate(var(--a-rotate)) skewX(var(--a-skew-x)) skewY(var(--a-skew-y)) scaleX(var(--a-scale-x)) scaleY(var(--a-scale-y));
}
`;
var RULES = {
Expand Down Expand Up @@ -1029,14 +1029,18 @@ var RULES = {
const values = value.split("~");
if (values.length <= 2) {
const [min2, max2] = value.split("~");
min2 && result.push(`min-height:${px(min2)};`);
max2 && result.push(`max-height:${px(max2)};`);
if (min2)
result.push(`min-height:${px(min2)};`);
if (max2)
result.push(`max-height:${px(max2)};`);
return result.join("");
}
const [min, height, max] = values;
min && result.push(`min-height:${px(min)};`);
if (min)
result.push(`min-height:${px(min)};`);
result.push(`height:${px(height)};`);
max && result.push(`max-height:${px(max)};`);
if (max)
result.push(`max-height:${px(max)};`);
return result.join("");
}
return `height:${px(value)};`;
Expand Down Expand Up @@ -1441,13 +1445,15 @@ var RULES = {
},
"skewX": (value) => `--a-skew-x:${deg(value)};transform:var(--a-transform);`,
"skewY": (value) => `--a-skew-y:${deg(value)};transform:var(--a-transform);`,
"matrix": (value) => `transform:matrix(${value});`,
// @TODO: 3d transform
// "translate3d": (value:string) => `--a-translate-x:${px(value)};--a-translate-y:${px(value)};--a-translate-z:${px(value)};transform:var(--a-transform);`,
// "rotate3d": (value:string) => `--a-rotate-x:${deg(value)};--a-rotate-y:${deg(value)};--a-rotate-z:${deg(value)};transform:var(--a-transform);`,
// "translateZ": (value:string) => `--a-translate-z:${px(value)};transform:var(--a-transform);`,
// "rotateZ": (value:string) => `--a-rotate-z:${deg(value)};transform:var(--a-transform);`,
// "skewZ": (value:string) => `--a-skew-z:${deg(value)};transform:var(--a-transform);`,
// "scaleZ": (value:string) => `--a-scale-z:${makeCommaValues(value)};transform:var(--a-transform);`,
// "matrix3d": (value:string) => `transform:matrix(${value});`,
// Util
"ratio": (value) => `&{position:relative;}&:before{content:"";display:block;width:100%;padding-top:${makeRatio(value)};}&>*{position:absolute;top:0;left:0;width:100%;height:100%;}`,
"aspect": (value) => `aspect-ratio:${cssvar(value.replace(/:/g, "/"))};`,
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/dist/vite/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ declare const makePosition2Y: (y: string) => string;
declare const makePosition2: (value: string) => string;
declare const makePositionWithSemi: (value?: string) => string;

declare const reset = "\n*,:after,:before{margin:0;padding:0;font:inherit;color:inherit;box-sizing:border-box;}\n:root{-webkit-tap-highlight-color:transparent;text-size-adjust:100%;-webkit-text-size-adjust:100%;line-height:1.5;overflow-wrap:break-word;word-break:break-word;tab-size:2;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}\nhtml,body{height:100%;}\nimg,picture,video,canvas{display:block;max-width:100%;}\nimg{text-indent:-9999px;}\nbutton{background:none;border:0;cursor:pointer;}\na{text-decoration:none;}\ntable{border-collapse:collapse;border-spacing:0;}\nol,ul,menu,dir{list-style:none;}\n*,:after,:before{--w-grow:initial;--w-align:initial;--h-grow:initial;--h-align:initial;}\n*,:after,:before{\n--a-translate-x:0;\n--a-translate-y:0;\n--a-rotate:0;\n--a-skew-x:0;\n--a-skew-y:0;\n--a-scale-x:1;\n--a-scale-y:1;\n--a-transform:translateX(var(--a-translate-x)) translateY(var(--a-translate-y)) rotate(var(--a-rotate)) skewX(var(--a-skew-x)) skewY(var(--a-skew-y)) scaleX(var(--a-scale-x)) scaleY(var(--a-scale-y));\n--a-transform3d:translate3d(var(--a-translate-x),var(--a-translate-y),0) rotate(var(--a-rotate)) skewX(var(--a-skew-x)) skewY(var(--a-skew-y)) scaleX(var(--a-scale-x)) scaleY(var(--a-scale-y));\n}\n";
declare const reset = "\n*,:after,:before{margin:0;padding:0;font:inherit;color:inherit;box-sizing:border-box;}\n:root{-webkit-tap-highlight-color:transparent;text-size-adjust:100%;-webkit-text-size-adjust:100%;line-height:1.5;overflow-wrap:break-word;word-break:break-word;tab-size:2;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}\nhtml,body{height:100%;}\nimg,picture,video,canvas{display:block;max-width:100%;}\nimg{text-indent:-9999px;}\nbutton{background:none;border:0;cursor:pointer;}\na{text-decoration:none;}\ntable{border-collapse:collapse;border-spacing:0;}\nol,ul,menu,dir{list-style:none;}\n*,:after,:before{--w-grow:initial;--w-align:initial;--h-grow:initial;--h-align:initial;}\n*,:after,:before{\n--a-translate-x:0;\n--a-translate-y:0;\n--a-rotate:0;\n--a-skew-x:0;\n--a-skew-y:0;\n--a-scale-x:1;\n--a-scale-y:1;\n--a-transform: translateX(var(--a-translate-x)) translateY(var(--a-translate-y)) rotate(var(--a-rotate)) skewX(var(--a-skew-x)) skewY(var(--a-skew-y)) scaleX(var(--a-scale-x)) scaleY(var(--a-scale-y));\n--a-transform3d: translate3d(var(--a-translate-x),var(--a-translate-y),0) rotate(var(--a-rotate)) skewX(var(--a-skew-x)) skewY(var(--a-skew-y)) scaleX(var(--a-scale-x)) scaleY(var(--a-scale-y));\n}\n";
declare const RULES: Rules;
declare const PREFIX_PSEUDO_CLASS: PrefixRules;
declare const PREFIX_MEDIA_QUERY: PrefixRules;
Expand Down
Loading

0 comments on commit fb7c91f

Please sign in to comment.