chai-sutta-css 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -0
- package/chai.js +776 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# ☕ Chai CSS
|
|
2
|
+
|
|
3
|
+
A **lightweight, zero-dependency utility-first CSS engine** that scans your DOM for `chai-*` classes and applies styles dynamically. No build step. No configuration. Just classes.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ⚡ Quick Start
|
|
8
|
+
|
|
9
|
+
### npm
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install chai-sutta-css
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then in your JS entry file:
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
require('chai-sutta-css');
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### CDN / Script Tag
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<script src="https://unpkg.com/chai-sutta-css"></script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or include the file directly:
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<script src="chai.js"></script>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🛠️ Usage
|
|
36
|
+
|
|
37
|
+
Add `chai-` prefixed utility classes to any HTML element:
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<div class="chai-flex chai-gap-4 chai-p-8 chai-bg-blue-500 chai-text-white chai-rounded-xl chai-shadow-lg">
|
|
41
|
+
<h2 class="chai-text-2xl chai-font-bold">Hello Chai! ☕</h2>
|
|
42
|
+
<p class="chai-text-sm chai-text-blue-100">Styled with utility classes.</p>
|
|
43
|
+
</div>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 📖 Available Utilities
|
|
49
|
+
|
|
50
|
+
### Display
|
|
51
|
+
`chai-flex` · `chai-grid` · `chai-block` · `chai-inline-block` · `chai-inline` · `chai-inline-flex` · `chai-hidden`
|
|
52
|
+
|
|
53
|
+
### Flexbox
|
|
54
|
+
`chai-flex-row` · `chai-flex-col` · `chai-flex-wrap` · `chai-flex-1` · `chai-flex-none` · `chai-flex-grow` · `chai-flex-shrink`
|
|
55
|
+
|
|
56
|
+
`chai-justify-start` · `chai-justify-center` · `chai-justify-end` · `chai-justify-between` · `chai-justify-around` · `chai-justify-evenly`
|
|
57
|
+
|
|
58
|
+
`chai-items-start` · `chai-items-center` · `chai-items-end` · `chai-items-stretch` · `chai-items-baseline`
|
|
59
|
+
|
|
60
|
+
`chai-gap-{n}`
|
|
61
|
+
|
|
62
|
+
### Grid
|
|
63
|
+
`chai-grid-cols-{1-12}` · `chai-col-span-{n}`
|
|
64
|
+
|
|
65
|
+
### Spacing
|
|
66
|
+
`chai-p-{n}` · `chai-px-{n}` · `chai-py-{n}` · `chai-pt-{n}` · `chai-pr-{n}` · `chai-pb-{n}` · `chai-pl-{n}`
|
|
67
|
+
|
|
68
|
+
`chai-m-{n}` · `chai-mx-{n}` · `chai-my-{n}` · `chai-mt-{n}` · `chai-mr-{n}` · `chai-mb-{n}` · `chai-ml-{n}` · `chai-mx-auto`
|
|
69
|
+
|
|
70
|
+
Scale: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, 96
|
|
71
|
+
|
|
72
|
+
### Typography
|
|
73
|
+
`chai-text-xs` · `chai-text-sm` · `chai-text-base` · `chai-text-lg` · `chai-text-xl` · `chai-text-2xl` … `chai-text-9xl` · `chai-text-{n}` (px)
|
|
74
|
+
|
|
75
|
+
`chai-font-thin` · `chai-font-light` · `chai-font-normal` · `chai-font-medium` · `chai-font-semibold` · `chai-font-bold` · `chai-font-extrabold` · `chai-font-black`
|
|
76
|
+
|
|
77
|
+
`chai-italic` · `chai-uppercase` · `chai-lowercase` · `chai-capitalize` · `chai-underline` · `chai-line-through`
|
|
78
|
+
|
|
79
|
+
`chai-text-center` · `chai-text-left` · `chai-text-right` · `chai-text-justify`
|
|
80
|
+
|
|
81
|
+
`chai-leading-none` · `chai-leading-tight` · `chai-leading-normal` · `chai-leading-relaxed` · `chai-leading-loose`
|
|
82
|
+
|
|
83
|
+
`chai-tracking-tight` · `chai-tracking-normal` · `chai-tracking-wide` · `chai-tracking-widest`
|
|
84
|
+
|
|
85
|
+
### Colors
|
|
86
|
+
20 color families: **slate**, **gray**, **zinc**, **neutral**, **red**, **orange**, **amber**, **yellow**, **lime**, **green**, **emerald**, **teal**, **cyan**, **sky**, **blue**, **indigo**, **violet**, **purple**, **fuchsia**, **pink**, **rose**
|
|
87
|
+
|
|
88
|
+
Each with shades: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950
|
|
89
|
+
|
|
90
|
+
Usage: `chai-bg-blue-500` · `chai-text-emerald-400` · `chai-border-red-600`
|
|
91
|
+
|
|
92
|
+
### Width & Height
|
|
93
|
+
`chai-w-{n}` · `chai-w-full` · `chai-w-screen` · `chai-w-auto`
|
|
94
|
+
|
|
95
|
+
`chai-h-{n}` · `chai-h-full` · `chai-h-screen` · `chai-h-auto`
|
|
96
|
+
|
|
97
|
+
`chai-max-w-{xs|sm|md|lg|xl|2xl|…|7xl|full|none}` · `chai-min-h-screen`
|
|
98
|
+
|
|
99
|
+
### Border & Radius
|
|
100
|
+
`chai-border` · `chai-border-{n}` · `chai-border-t` · `chai-border-r` · `chai-border-b` · `chai-border-l` · `chai-border-none`
|
|
101
|
+
|
|
102
|
+
`chai-rounded` · `chai-rounded-sm` · `chai-rounded-md` · `chai-rounded-lg` · `chai-rounded-xl` · `chai-rounded-2xl` · `chai-rounded-full` · `chai-rounded-none`
|
|
103
|
+
|
|
104
|
+
### Shadows
|
|
105
|
+
`chai-shadow-sm` · `chai-shadow` · `chai-shadow-md` · `chai-shadow-lg` · `chai-shadow-xl` · `chai-shadow-2xl` · `chai-shadow-none`
|
|
106
|
+
|
|
107
|
+
### Position
|
|
108
|
+
`chai-relative` · `chai-absolute` · `chai-fixed` · `chai-sticky` · `chai-static`
|
|
109
|
+
|
|
110
|
+
`chai-top-{n}` · `chai-right-{n}` · `chai-bottom-{n}` · `chai-left-{n}` · `chai-inset-0` · `chai-z-{n}`
|
|
111
|
+
|
|
112
|
+
### Opacity
|
|
113
|
+
`chai-opacity-{0|25|50|75|100}`
|
|
114
|
+
|
|
115
|
+
### Overflow
|
|
116
|
+
`chai-overflow-hidden` · `chai-overflow-auto` · `chai-overflow-scroll` · `chai-overflow-visible`
|
|
117
|
+
|
|
118
|
+
### Cursor
|
|
119
|
+
`chai-cursor-pointer` · `chai-cursor-default` · `chai-cursor-not-allowed` · `chai-cursor-grab`
|
|
120
|
+
|
|
121
|
+
### Transitions
|
|
122
|
+
`chai-transition` · `chai-transition-colors` · `chai-transition-transform` · `chai-transition-opacity`
|
|
123
|
+
|
|
124
|
+
`chai-duration-{ms}` · `chai-ease-linear` · `chai-ease-in` · `chai-ease-out` · `chai-ease-in-out`
|
|
125
|
+
|
|
126
|
+
### Transform
|
|
127
|
+
`chai-scale-{n}` · `chai-rotate-{n}`
|
|
128
|
+
|
|
129
|
+
### Misc
|
|
130
|
+
`chai-select-none` · `chai-truncate` · `chai-whitespace-nowrap` · `chai-list-none` · `chai-object-cover` · `chai-object-contain`
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 💡 How It Works
|
|
135
|
+
|
|
136
|
+
1. Scans DOM for elements with `chai-*` classes
|
|
137
|
+
2. Parses each class against utility rules
|
|
138
|
+
3. Generates + caches inline styles
|
|
139
|
+
4. Applies styles via `element.style`
|
|
140
|
+
5. Watches for DOM mutations to auto-style new elements
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 📄 License
|
|
145
|
+
|
|
146
|
+
MIT — use it, fork it, brew it. ☕
|
package/chai.js
ADDED
|
@@ -0,0 +1,776 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chai CSS ☕ — A lightweight utility-first CSS engine
|
|
3
|
+
* Version 1.0.0
|
|
4
|
+
*
|
|
5
|
+
* Scans the DOM for chai-* classes and applies
|
|
6
|
+
* corresponding inline styles dynamically.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const cache = {};
|
|
10
|
+
|
|
11
|
+
// ========================================
|
|
12
|
+
// Design Tokens
|
|
13
|
+
// ========================================
|
|
14
|
+
|
|
15
|
+
const spacingScale = {
|
|
16
|
+
0: "0px",
|
|
17
|
+
0.5: "2px",
|
|
18
|
+
1: "4px",
|
|
19
|
+
2: "8px",
|
|
20
|
+
3: "12px",
|
|
21
|
+
4: "16px",
|
|
22
|
+
5: "20px",
|
|
23
|
+
6: "24px",
|
|
24
|
+
7: "28px",
|
|
25
|
+
8: "32px",
|
|
26
|
+
9: "36px",
|
|
27
|
+
10: "40px",
|
|
28
|
+
11: "44px",
|
|
29
|
+
12: "48px",
|
|
30
|
+
14: "56px",
|
|
31
|
+
16: "64px",
|
|
32
|
+
20: "80px",
|
|
33
|
+
24: "96px",
|
|
34
|
+
28: "112px",
|
|
35
|
+
32: "128px",
|
|
36
|
+
36: "144px",
|
|
37
|
+
40: "160px",
|
|
38
|
+
44: "176px",
|
|
39
|
+
48: "192px",
|
|
40
|
+
52: "208px",
|
|
41
|
+
56: "224px",
|
|
42
|
+
60: "240px",
|
|
43
|
+
64: "256px",
|
|
44
|
+
72: "288px",
|
|
45
|
+
80: "320px",
|
|
46
|
+
96: "384px",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const colorPalette = {
|
|
50
|
+
// Neutrals
|
|
51
|
+
slate: {
|
|
52
|
+
50: "#f8fafc", 100: "#f1f5f9", 200: "#e2e8f0", 300: "#cbd5e1",
|
|
53
|
+
400: "#94a3b8", 500: "#64748b", 600: "#475569", 700: "#334155",
|
|
54
|
+
800: "#1e293b", 900: "#0f172a", 950: "#020617",
|
|
55
|
+
},
|
|
56
|
+
gray: {
|
|
57
|
+
50: "#f9fafb", 100: "#f3f4f6", 200: "#e5e7eb", 300: "#d1d5db",
|
|
58
|
+
400: "#9ca3af", 500: "#6b7280", 600: "#4b5563", 700: "#374151",
|
|
59
|
+
800: "#1f2937", 900: "#111827", 950: "#030712",
|
|
60
|
+
},
|
|
61
|
+
zinc: {
|
|
62
|
+
50: "#fafafa", 100: "#f4f4f5", 200: "#e4e4e7", 300: "#d4d4d8",
|
|
63
|
+
400: "#a1a1aa", 500: "#71717a", 600: "#52525b", 700: "#3f3f46",
|
|
64
|
+
800: "#27272a", 900: "#18181b", 950: "#09090b",
|
|
65
|
+
},
|
|
66
|
+
neutral: {
|
|
67
|
+
50: "#fafafa", 100: "#f5f5f5", 200: "#e5e5e5", 300: "#d4d4d4",
|
|
68
|
+
400: "#a3a3a3", 500: "#737373", 600: "#525252", 700: "#404040",
|
|
69
|
+
800: "#262626", 900: "#171717", 950: "#0a0a0a",
|
|
70
|
+
},
|
|
71
|
+
// Colors
|
|
72
|
+
red: {
|
|
73
|
+
50: "#fef2f2", 100: "#fee2e2", 200: "#fecaca", 300: "#fca5a5",
|
|
74
|
+
400: "#f87171", 500: "#ef4444", 600: "#dc2626", 700: "#b91c1c",
|
|
75
|
+
800: "#991b1b", 900: "#7f1d1d", 950: "#450a0a",
|
|
76
|
+
},
|
|
77
|
+
orange: {
|
|
78
|
+
50: "#fff7ed", 100: "#ffedd5", 200: "#fed7aa", 300: "#fdba74",
|
|
79
|
+
400: "#fb923c", 500: "#f97316", 600: "#ea580c", 700: "#c2410c",
|
|
80
|
+
800: "#9a3412", 900: "#7c2d12", 950: "#431407",
|
|
81
|
+
},
|
|
82
|
+
amber: {
|
|
83
|
+
50: "#fffbeb", 100: "#fef3c7", 200: "#fde68a", 300: "#fcd34d",
|
|
84
|
+
400: "#fbbf24", 500: "#f59e0b", 600: "#d97706", 700: "#b45309",
|
|
85
|
+
800: "#92400e", 900: "#78350f", 950: "#451a03",
|
|
86
|
+
},
|
|
87
|
+
yellow: {
|
|
88
|
+
50: "#fefce8", 100: "#fef9c3", 200: "#fef08a", 300: "#fde047",
|
|
89
|
+
400: "#facc15", 500: "#eab308", 600: "#ca8a04", 700: "#a16207",
|
|
90
|
+
800: "#854d0e", 900: "#713f12", 950: "#422006",
|
|
91
|
+
},
|
|
92
|
+
lime: {
|
|
93
|
+
50: "#f7fee7", 100: "#ecfccb", 200: "#d9f99d", 300: "#bef264",
|
|
94
|
+
400: "#a3e635", 500: "#84cc16", 600: "#65a30d", 700: "#4d7c0f",
|
|
95
|
+
800: "#3f6212", 900: "#365314", 950: "#1a2e05",
|
|
96
|
+
},
|
|
97
|
+
green: {
|
|
98
|
+
50: "#f0fdf4", 100: "#dcfce7", 200: "#bbf7d0", 300: "#86efac",
|
|
99
|
+
400: "#4ade80", 500: "#22c55e", 600: "#16a34a", 700: "#15803d",
|
|
100
|
+
800: "#166534", 900: "#14532d", 950: "#052e16",
|
|
101
|
+
},
|
|
102
|
+
emerald: {
|
|
103
|
+
50: "#ecfdf5", 100: "#d1fae5", 200: "#a7f3d0", 300: "#6ee7b7",
|
|
104
|
+
400: "#34d399", 500: "#10b981", 600: "#059669", 700: "#047857",
|
|
105
|
+
800: "#065f46", 900: "#064e3b", 950: "#022c22",
|
|
106
|
+
},
|
|
107
|
+
teal: {
|
|
108
|
+
50: "#f0fdfa", 100: "#ccfbf1", 200: "#99f6e4", 300: "#5eead4",
|
|
109
|
+
400: "#2dd4bf", 500: "#14b8a6", 600: "#0d9488", 700: "#0f766e",
|
|
110
|
+
800: "#115e59", 900: "#134e4a", 950: "#042f2e",
|
|
111
|
+
},
|
|
112
|
+
cyan: {
|
|
113
|
+
50: "#ecfeff", 100: "#cffafe", 200: "#a5f3fc", 300: "#67e8f9",
|
|
114
|
+
400: "#22d3ee", 500: "#06b6d4", 600: "#0891b2", 700: "#0e7490",
|
|
115
|
+
800: "#155e75", 900: "#164e63", 950: "#083344",
|
|
116
|
+
},
|
|
117
|
+
sky: {
|
|
118
|
+
50: "#f0f9ff", 100: "#e0f2fe", 200: "#bae6fd", 300: "#7dd3fc",
|
|
119
|
+
400: "#38bdf8", 500: "#0ea5e9", 600: "#0284c7", 700: "#0369a1",
|
|
120
|
+
800: "#075985", 900: "#0c4a6e", 950: "#082f49",
|
|
121
|
+
},
|
|
122
|
+
blue: {
|
|
123
|
+
50: "#eff6ff", 100: "#dbeafe", 200: "#bfdbfe", 300: "#93c5fd",
|
|
124
|
+
400: "#60a5fa", 500: "#3b82f6", 600: "#2563eb", 700: "#1d4ed8",
|
|
125
|
+
800: "#1e40af", 900: "#1e3a8a", 950: "#172554",
|
|
126
|
+
},
|
|
127
|
+
indigo: {
|
|
128
|
+
50: "#eef2ff", 100: "#e0e7ff", 200: "#c7d2fe", 300: "#a5b4fc",
|
|
129
|
+
400: "#818cf8", 500: "#6366f1", 600: "#4f46e5", 700: "#4338ca",
|
|
130
|
+
800: "#3730a3", 900: "#312e81", 950: "#1e1b4b",
|
|
131
|
+
},
|
|
132
|
+
violet: {
|
|
133
|
+
50: "#f5f3ff", 100: "#ede9fe", 200: "#ddd6fe", 300: "#c4b5fd",
|
|
134
|
+
400: "#a78bfa", 500: "#8b5cf6", 600: "#7c3aed", 700: "#6d28d9",
|
|
135
|
+
800: "#5b21b6", 900: "#4c1d95", 950: "#2e1065",
|
|
136
|
+
},
|
|
137
|
+
purple: {
|
|
138
|
+
50: "#faf5ff", 100: "#f3e8ff", 200: "#e9d5ff", 300: "#d8b4fe",
|
|
139
|
+
400: "#c084fc", 500: "#a855f7", 600: "#9333ea", 700: "#7e22ce",
|
|
140
|
+
800: "#6b21a8", 900: "#581c87", 950: "#3b0764",
|
|
141
|
+
},
|
|
142
|
+
fuchsia: {
|
|
143
|
+
50: "#fdf4ff", 100: "#fae8ff", 200: "#f5d0fe", 300: "#f0abfc",
|
|
144
|
+
400: "#e879f9", 500: "#d946ef", 600: "#c026d3", 700: "#a21caf",
|
|
145
|
+
800: "#86198f", 900: "#701a75", 950: "#4a044e",
|
|
146
|
+
},
|
|
147
|
+
pink: {
|
|
148
|
+
50: "#fdf2f8", 100: "#fce7f3", 200: "#fbcfe8", 300: "#f9a8d4",
|
|
149
|
+
400: "#f472b6", 500: "#ec4899", 600: "#db2777", 700: "#be185d",
|
|
150
|
+
800: "#9d174d", 900: "#831843", 950: "#500724",
|
|
151
|
+
},
|
|
152
|
+
rose: {
|
|
153
|
+
50: "#fff1f2", 100: "#ffe4e6", 200: "#fecdd3", 300: "#fda4af",
|
|
154
|
+
400: "#fb7185", 500: "#f43f5e", 600: "#e11d48", 700: "#be123c",
|
|
155
|
+
800: "#9f1239", 900: "#881337", 950: "#4c0519",
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const fontSizeScale = {
|
|
160
|
+
xs: "12px",
|
|
161
|
+
sm: "14px",
|
|
162
|
+
base: "16px",
|
|
163
|
+
lg: "18px",
|
|
164
|
+
xl: "20px",
|
|
165
|
+
"2xl": "24px",
|
|
166
|
+
"3xl": "30px",
|
|
167
|
+
"4xl": "36px",
|
|
168
|
+
"5xl": "48px",
|
|
169
|
+
"6xl": "60px",
|
|
170
|
+
"7xl": "72px",
|
|
171
|
+
"8xl": "96px",
|
|
172
|
+
"9xl": "128px",
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const borderRadiusScale = {
|
|
176
|
+
none: "0px",
|
|
177
|
+
sm: "2px",
|
|
178
|
+
md: "6px",
|
|
179
|
+
lg: "8px",
|
|
180
|
+
xl: "12px",
|
|
181
|
+
"2xl": "16px",
|
|
182
|
+
"3xl": "24px",
|
|
183
|
+
full: "9999px",
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const shadowScale = {
|
|
187
|
+
sm: "0 1px 2px 0 rgba(0,0,0,0.05)",
|
|
188
|
+
DEFAULT: "0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1)",
|
|
189
|
+
md: "0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)",
|
|
190
|
+
lg: "0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)",
|
|
191
|
+
xl: "0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1)",
|
|
192
|
+
"2xl": "0 25px 50px -12px rgba(0,0,0,0.25)",
|
|
193
|
+
none: "none",
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// ========================================
|
|
197
|
+
// Helper: resolve color from palette or plain name
|
|
198
|
+
// ========================================
|
|
199
|
+
function resolveColor(raw) {
|
|
200
|
+
// Handle palette colors like "blue-500", "emerald-400"
|
|
201
|
+
const parts = raw.split("-");
|
|
202
|
+
if (parts.length === 2 && colorPalette[parts[0]] && colorPalette[parts[0]][parts[1]]) {
|
|
203
|
+
return colorPalette[parts[0]][parts[1]];
|
|
204
|
+
}
|
|
205
|
+
// CSS named colors or hex — pass through
|
|
206
|
+
if (raw.startsWith("#") || CSS.supports("color", raw)) {
|
|
207
|
+
return raw;
|
|
208
|
+
}
|
|
209
|
+
return raw;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ========================================
|
|
213
|
+
// Rules
|
|
214
|
+
// ========================================
|
|
215
|
+
const rules = [
|
|
216
|
+
// ======================
|
|
217
|
+
// Display
|
|
218
|
+
// ======================
|
|
219
|
+
{ match: (c) => c === "flex", apply: () => ({ display: "flex" }) },
|
|
220
|
+
{ match: (c) => c === "grid", apply: () => ({ display: "grid" }) },
|
|
221
|
+
{ match: (c) => c === "block", apply: () => ({ display: "block" }) },
|
|
222
|
+
{ match: (c) => c === "inline-block", apply: () => ({ display: "inline-block" }) },
|
|
223
|
+
{ match: (c) => c === "inline", apply: () => ({ display: "inline" }) },
|
|
224
|
+
{ match: (c) => c === "inline-flex", apply: () => ({ display: "inline-flex" }) },
|
|
225
|
+
{ match: (c) => c === "inline-grid", apply: () => ({ display: "inline-grid" }) },
|
|
226
|
+
{ match: (c) => c === "hidden", apply: () => ({ display: "none" }) },
|
|
227
|
+
{ match: (c) => c === "table", apply: () => ({ display: "table" }) },
|
|
228
|
+
|
|
229
|
+
// ======================
|
|
230
|
+
// Flexbox
|
|
231
|
+
// ======================
|
|
232
|
+
{ match: (c) => c === "flex-col", apply: () => ({ flexDirection: "column" }) },
|
|
233
|
+
{ match: (c) => c === "flex-row", apply: () => ({ flexDirection: "row" }) },
|
|
234
|
+
{ match: (c) => c === "flex-wrap", apply: () => ({ flexWrap: "wrap" }) },
|
|
235
|
+
{ match: (c) => c === "flex-nowrap", apply: () => ({ flexWrap: "nowrap" }) },
|
|
236
|
+
{ match: (c) => c === "flex-1", apply: () => ({ flex: "1 1 0%" }) },
|
|
237
|
+
{ match: (c) => c === "flex-auto", apply: () => ({ flex: "1 1 auto" }) },
|
|
238
|
+
{ match: (c) => c === "flex-none", apply: () => ({ flex: "none" }) },
|
|
239
|
+
{ match: (c) => c === "flex-grow", apply: () => ({ flexGrow: "1" }) },
|
|
240
|
+
{ match: (c) => c === "flex-shrink", apply: () => ({ flexShrink: "1" }) },
|
|
241
|
+
{ match: (c) => c === "flex-shrink-0", apply: () => ({ flexShrink: "0" }) },
|
|
242
|
+
|
|
243
|
+
// Justify
|
|
244
|
+
{ match: (c) => c === "justify-start", apply: () => ({ justifyContent: "flex-start" }) },
|
|
245
|
+
{ match: (c) => c === "justify-center", apply: () => ({ justifyContent: "center" }) },
|
|
246
|
+
{ match: (c) => c === "justify-end", apply: () => ({ justifyContent: "flex-end" }) },
|
|
247
|
+
{ match: (c) => c === "justify-between", apply: () => ({ justifyContent: "space-between" }) },
|
|
248
|
+
{ match: (c) => c === "justify-around", apply: () => ({ justifyContent: "space-around" }) },
|
|
249
|
+
{ match: (c) => c === "justify-evenly", apply: () => ({ justifyContent: "space-evenly" }) },
|
|
250
|
+
|
|
251
|
+
// Align Items
|
|
252
|
+
{ match: (c) => c === "items-start", apply: () => ({ alignItems: "flex-start" }) },
|
|
253
|
+
{ match: (c) => c === "items-center", apply: () => ({ alignItems: "center" }) },
|
|
254
|
+
{ match: (c) => c === "items-end", apply: () => ({ alignItems: "flex-end" }) },
|
|
255
|
+
{ match: (c) => c === "items-stretch", apply: () => ({ alignItems: "stretch" }) },
|
|
256
|
+
{ match: (c) => c === "items-baseline", apply: () => ({ alignItems: "baseline" }) },
|
|
257
|
+
|
|
258
|
+
// Align Self
|
|
259
|
+
{ match: (c) => c === "self-auto", apply: () => ({ alignSelf: "auto" }) },
|
|
260
|
+
{ match: (c) => c === "self-start", apply: () => ({ alignSelf: "flex-start" }) },
|
|
261
|
+
{ match: (c) => c === "self-center", apply: () => ({ alignSelf: "center" }) },
|
|
262
|
+
{ match: (c) => c === "self-end", apply: () => ({ alignSelf: "flex-end" }) },
|
|
263
|
+
{ match: (c) => c === "self-stretch", apply: () => ({ alignSelf: "stretch" }) },
|
|
264
|
+
|
|
265
|
+
// Gap
|
|
266
|
+
{
|
|
267
|
+
match: (c) => c.startsWith("gap-"),
|
|
268
|
+
apply: (c) => {
|
|
269
|
+
const v = c.split("-")[1];
|
|
270
|
+
return { gap: spacingScale[v] || v + "px" };
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
// ======================
|
|
275
|
+
// Grid
|
|
276
|
+
// ======================
|
|
277
|
+
{
|
|
278
|
+
match: (c) => /^grid-cols-\d+$/.test(c),
|
|
279
|
+
apply: (c) => {
|
|
280
|
+
const n = c.split("-")[2];
|
|
281
|
+
return { gridTemplateColumns: `repeat(${n}, minmax(0, 1fr))` };
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
match: (c) => /^col-span-\d+$/.test(c),
|
|
286
|
+
apply: (c) => {
|
|
287
|
+
const n = c.split("-")[2];
|
|
288
|
+
return { gridColumn: `span ${n} / span ${n}` };
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
// ======================
|
|
293
|
+
// Spacing (Padding)
|
|
294
|
+
// ======================
|
|
295
|
+
{
|
|
296
|
+
match: (c) => /^p[trblxy]?-[\d.]+$/.test(c),
|
|
297
|
+
apply: (c) => {
|
|
298
|
+
const [prop, val] = c.split("-");
|
|
299
|
+
const size = spacingScale[val] || val + "px";
|
|
300
|
+
const map = {
|
|
301
|
+
p: ["padding"],
|
|
302
|
+
px: ["paddingLeft", "paddingRight"],
|
|
303
|
+
py: ["paddingTop", "paddingBottom"],
|
|
304
|
+
pt: ["paddingTop"],
|
|
305
|
+
pb: ["paddingBottom"],
|
|
306
|
+
pl: ["paddingLeft"],
|
|
307
|
+
pr: ["paddingRight"],
|
|
308
|
+
};
|
|
309
|
+
const style = {};
|
|
310
|
+
(map[prop] || []).forEach((key) => (style[key] = size));
|
|
311
|
+
return style;
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
// ======================
|
|
316
|
+
// Spacing (Margin)
|
|
317
|
+
// ======================
|
|
318
|
+
{
|
|
319
|
+
match: (c) => /^m[trblxy]?-[\d.]+$/.test(c),
|
|
320
|
+
apply: (c) => {
|
|
321
|
+
const [prop, val] = c.split("-");
|
|
322
|
+
const size = spacingScale[val] || val + "px";
|
|
323
|
+
const map = {
|
|
324
|
+
m: ["margin"],
|
|
325
|
+
mx: ["marginLeft", "marginRight"],
|
|
326
|
+
my: ["marginTop", "marginBottom"],
|
|
327
|
+
mt: ["marginTop"],
|
|
328
|
+
mb: ["marginBottom"],
|
|
329
|
+
ml: ["marginLeft"],
|
|
330
|
+
mr: ["marginRight"],
|
|
331
|
+
};
|
|
332
|
+
const style = {};
|
|
333
|
+
(map[prop] || []).forEach((key) => (style[key] = size));
|
|
334
|
+
return style;
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
{ match: (c) => c === "mx-auto", apply: () => ({ marginLeft: "auto", marginRight: "auto" }) },
|
|
338
|
+
|
|
339
|
+
// ======================
|
|
340
|
+
// Background Color
|
|
341
|
+
// ======================
|
|
342
|
+
{
|
|
343
|
+
match: (c) => /^bg-/.test(c),
|
|
344
|
+
apply: (c) => {
|
|
345
|
+
const raw = c.replace("bg-", "");
|
|
346
|
+
if (raw === "transparent") return { backgroundColor: "transparent" };
|
|
347
|
+
return { backgroundColor: resolveColor(raw) };
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
// ======================
|
|
352
|
+
// Text (color, size, align)
|
|
353
|
+
// ======================
|
|
354
|
+
{
|
|
355
|
+
match: (c) => /^text-/.test(c),
|
|
356
|
+
apply: (c) => {
|
|
357
|
+
const val = c.replace("text-", "");
|
|
358
|
+
|
|
359
|
+
// Alignment
|
|
360
|
+
if (["center", "left", "right", "justify"].includes(val)) {
|
|
361
|
+
return { textAlign: val };
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Named font size scale
|
|
365
|
+
if (fontSizeScale[val]) {
|
|
366
|
+
return { fontSize: fontSizeScale[val] };
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Pixel size
|
|
370
|
+
if (/^\d+$/.test(val)) return { fontSize: val + "px" };
|
|
371
|
+
|
|
372
|
+
// Color (with palette support)
|
|
373
|
+
return { color: resolveColor(val) };
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
// ======================
|
|
378
|
+
// Typography
|
|
379
|
+
// ======================
|
|
380
|
+
{ match: (c) => c === "font-thin", apply: () => ({ fontWeight: "100" }) },
|
|
381
|
+
{ match: (c) => c === "font-extralight", apply: () => ({ fontWeight: "200" }) },
|
|
382
|
+
{ match: (c) => c === "font-light", apply: () => ({ fontWeight: "300" }) },
|
|
383
|
+
{ match: (c) => c === "font-normal", apply: () => ({ fontWeight: "400" }) },
|
|
384
|
+
{ match: (c) => c === "font-medium", apply: () => ({ fontWeight: "500" }) },
|
|
385
|
+
{ match: (c) => c === "font-semibold", apply: () => ({ fontWeight: "600" }) },
|
|
386
|
+
{ match: (c) => c === "font-bold", apply: () => ({ fontWeight: "700" }) },
|
|
387
|
+
{ match: (c) => c === "font-extrabold", apply: () => ({ fontWeight: "800" }) },
|
|
388
|
+
{ match: (c) => c === "font-black", apply: () => ({ fontWeight: "900" }) },
|
|
389
|
+
|
|
390
|
+
{ match: (c) => c === "italic", apply: () => ({ fontStyle: "italic" }) },
|
|
391
|
+
{ match: (c) => c === "not-italic", apply: () => ({ fontStyle: "normal" }) },
|
|
392
|
+
|
|
393
|
+
{ match: (c) => c === "uppercase", apply: () => ({ textTransform: "uppercase" }) },
|
|
394
|
+
{ match: (c) => c === "lowercase", apply: () => ({ textTransform: "lowercase" }) },
|
|
395
|
+
{ match: (c) => c === "capitalize", apply: () => ({ textTransform: "capitalize" }) },
|
|
396
|
+
{ match: (c) => c === "normal-case", apply: () => ({ textTransform: "none" }) },
|
|
397
|
+
|
|
398
|
+
{ match: (c) => c === "underline", apply: () => ({ textDecoration: "underline" }) },
|
|
399
|
+
{ match: (c) => c === "line-through", apply: () => ({ textDecoration: "line-through" }) },
|
|
400
|
+
{ match: (c) => c === "no-underline", apply: () => ({ textDecoration: "none" }) },
|
|
401
|
+
|
|
402
|
+
{ match: (c) => c === "leading-none", apply: () => ({ lineHeight: "1" }) },
|
|
403
|
+
{ match: (c) => c === "leading-tight", apply: () => ({ lineHeight: "1.25" }) },
|
|
404
|
+
{ match: (c) => c === "leading-snug", apply: () => ({ lineHeight: "1.375" }) },
|
|
405
|
+
{ match: (c) => c === "leading-normal", apply: () => ({ lineHeight: "1.5" }) },
|
|
406
|
+
{ match: (c) => c === "leading-relaxed", apply: () => ({ lineHeight: "1.625" }) },
|
|
407
|
+
{ match: (c) => c === "leading-loose", apply: () => ({ lineHeight: "2" }) },
|
|
408
|
+
|
|
409
|
+
{ match: (c) => c === "tracking-tighter", apply: () => ({ letterSpacing: "-0.05em" }) },
|
|
410
|
+
{ match: (c) => c === "tracking-tight", apply: () => ({ letterSpacing: "-0.025em" }) },
|
|
411
|
+
{ match: (c) => c === "tracking-normal", apply: () => ({ letterSpacing: "0em" }) },
|
|
412
|
+
{ match: (c) => c === "tracking-wide", apply: () => ({ letterSpacing: "0.025em" }) },
|
|
413
|
+
{ match: (c) => c === "tracking-wider", apply: () => ({ letterSpacing: "0.05em" }) },
|
|
414
|
+
{ match: (c) => c === "tracking-widest", apply: () => ({ letterSpacing: "0.1em" }) },
|
|
415
|
+
|
|
416
|
+
// ======================
|
|
417
|
+
// Width & Height
|
|
418
|
+
// ======================
|
|
419
|
+
{
|
|
420
|
+
match: (c) => /^w-/.test(c),
|
|
421
|
+
apply: (c) => {
|
|
422
|
+
const val = c.replace("w-", "");
|
|
423
|
+
const map = {
|
|
424
|
+
full: "100%",
|
|
425
|
+
screen: "100vw",
|
|
426
|
+
auto: "auto",
|
|
427
|
+
min: "min-content",
|
|
428
|
+
max: "max-content",
|
|
429
|
+
fit: "fit-content",
|
|
430
|
+
};
|
|
431
|
+
if (map[val]) return { width: map[val] };
|
|
432
|
+
if (spacingScale[val]) return { width: spacingScale[val] };
|
|
433
|
+
return { width: val + "px" };
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
match: (c) => /^h-/.test(c),
|
|
438
|
+
apply: (c) => {
|
|
439
|
+
const val = c.replace("h-", "");
|
|
440
|
+
const map = {
|
|
441
|
+
full: "100%",
|
|
442
|
+
screen: "100vh",
|
|
443
|
+
auto: "auto",
|
|
444
|
+
min: "min-content",
|
|
445
|
+
max: "max-content",
|
|
446
|
+
fit: "fit-content",
|
|
447
|
+
};
|
|
448
|
+
if (map[val]) return { height: map[val] };
|
|
449
|
+
if (spacingScale[val]) return { height: spacingScale[val] };
|
|
450
|
+
return { height: val + "px" };
|
|
451
|
+
},
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
match: (c) => /^min-w-/.test(c),
|
|
455
|
+
apply: (c) => {
|
|
456
|
+
const val = c.replace("min-w-", "");
|
|
457
|
+
return { minWidth: val === "0" ? "0px" : val === "full" ? "100%" : val + "px" };
|
|
458
|
+
},
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
match: (c) => /^min-h-/.test(c),
|
|
462
|
+
apply: (c) => {
|
|
463
|
+
const val = c.replace("min-h-", "");
|
|
464
|
+
return { minHeight: val === "0" ? "0px" : val === "full" ? "100%" : val === "screen" ? "100vh" : val + "px" };
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
match: (c) => /^max-w-/.test(c),
|
|
469
|
+
apply: (c) => {
|
|
470
|
+
const val = c.replace("max-w-", "");
|
|
471
|
+
const map = {
|
|
472
|
+
xs: "320px", sm: "384px", md: "448px", lg: "512px", xl: "576px",
|
|
473
|
+
"2xl": "672px", "3xl": "768px", "4xl": "896px", "5xl": "1024px",
|
|
474
|
+
"6xl": "1152px", "7xl": "1280px", full: "100%", none: "none",
|
|
475
|
+
screen: "100vw",
|
|
476
|
+
};
|
|
477
|
+
return { maxWidth: map[val] || val + "px" };
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
match: (c) => /^max-h-/.test(c),
|
|
482
|
+
apply: (c) => {
|
|
483
|
+
const val = c.replace("max-h-", "");
|
|
484
|
+
return { maxHeight: val === "full" ? "100%" : val === "screen" ? "100vh" : val + "px" };
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
|
|
488
|
+
// ======================
|
|
489
|
+
// Border & Radius
|
|
490
|
+
// ======================
|
|
491
|
+
{ match: (c) => c === "border", apply: () => ({ border: "1px solid currentColor" }) },
|
|
492
|
+
{
|
|
493
|
+
match: (c) => /^border-\d+$/.test(c),
|
|
494
|
+
apply: (c) => ({ border: `${c.split("-")[1]}px solid currentColor` }),
|
|
495
|
+
},
|
|
496
|
+
{ match: (c) => c === "border-t", apply: () => ({ borderTop: "1px solid currentColor" }) },
|
|
497
|
+
{ match: (c) => c === "border-r", apply: () => ({ borderRight: "1px solid currentColor" }) },
|
|
498
|
+
{ match: (c) => c === "border-b", apply: () => ({ borderBottom: "1px solid currentColor" }) },
|
|
499
|
+
{ match: (c) => c === "border-l", apply: () => ({ borderLeft: "1px solid currentColor" }) },
|
|
500
|
+
{ match: (c) => c === "border-none", apply: () => ({ border: "none" }) },
|
|
501
|
+
{
|
|
502
|
+
match: (c) => /^border-(?!t$|r$|b$|l$|none$|\d+$)[a-z]/.test(c),
|
|
503
|
+
apply: (c) => {
|
|
504
|
+
const raw = c.replace("border-", "");
|
|
505
|
+
return { borderColor: resolveColor(raw) };
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
|
|
509
|
+
// Rounded
|
|
510
|
+
{
|
|
511
|
+
match: (c) => /^rounded/.test(c),
|
|
512
|
+
apply: (c) => {
|
|
513
|
+
const val = c.replace("rounded-", "").replace("rounded", "");
|
|
514
|
+
if (!val || val === "") return { borderRadius: "6px" };
|
|
515
|
+
if (borderRadiusScale[val]) return { borderRadius: borderRadiusScale[val] };
|
|
516
|
+
return { borderRadius: val + "px" };
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
|
|
520
|
+
// ======================
|
|
521
|
+
// Position
|
|
522
|
+
// ======================
|
|
523
|
+
{ match: (c) => c === "relative", apply: () => ({ position: "relative" }) },
|
|
524
|
+
{ match: (c) => c === "absolute", apply: () => ({ position: "absolute" }) },
|
|
525
|
+
{ match: (c) => c === "fixed", apply: () => ({ position: "fixed" }) },
|
|
526
|
+
{ match: (c) => c === "sticky", apply: () => ({ position: "sticky" }) },
|
|
527
|
+
{ match: (c) => c === "static", apply: () => ({ position: "static" }) },
|
|
528
|
+
|
|
529
|
+
{ match: (c) => c === "inset-0", apply: () => ({ top: "0", right: "0", bottom: "0", left: "0" }) },
|
|
530
|
+
{
|
|
531
|
+
match: (c) => /^top-/.test(c),
|
|
532
|
+
apply: (c) => {
|
|
533
|
+
const val = c.replace("top-", "");
|
|
534
|
+
return { top: spacingScale[val] || val + "px" };
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
match: (c) => /^right-/.test(c),
|
|
539
|
+
apply: (c) => {
|
|
540
|
+
const val = c.replace("right-", "");
|
|
541
|
+
return { right: spacingScale[val] || val + "px" };
|
|
542
|
+
},
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
match: (c) => /^bottom-/.test(c),
|
|
546
|
+
apply: (c) => {
|
|
547
|
+
const val = c.replace("bottom-", "");
|
|
548
|
+
return { bottom: spacingScale[val] || val + "px" };
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
match: (c) => /^left-/.test(c),
|
|
553
|
+
apply: (c) => {
|
|
554
|
+
const val = c.replace("left-", "");
|
|
555
|
+
return { left: spacingScale[val] || val + "px" };
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
|
|
559
|
+
// Z-Index
|
|
560
|
+
{
|
|
561
|
+
match: (c) => /^z-/.test(c),
|
|
562
|
+
apply: (c) => {
|
|
563
|
+
const val = c.replace("z-", "");
|
|
564
|
+
return { zIndex: val };
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
|
|
568
|
+
// ======================
|
|
569
|
+
// Shadow
|
|
570
|
+
// ======================
|
|
571
|
+
{
|
|
572
|
+
match: (c) => /^shadow/.test(c),
|
|
573
|
+
apply: (c) => {
|
|
574
|
+
const val = c.replace("shadow-", "").replace("shadow", "");
|
|
575
|
+
if (!val || val === "") return { boxShadow: shadowScale.DEFAULT };
|
|
576
|
+
return { boxShadow: shadowScale[val] || shadowScale.DEFAULT };
|
|
577
|
+
},
|
|
578
|
+
},
|
|
579
|
+
|
|
580
|
+
// ======================
|
|
581
|
+
// Opacity
|
|
582
|
+
// ======================
|
|
583
|
+
{
|
|
584
|
+
match: (c) => /^opacity-\d+$/.test(c),
|
|
585
|
+
apply: (c) => {
|
|
586
|
+
const val = parseInt(c.split("-")[1], 10);
|
|
587
|
+
return { opacity: String(val / 100) };
|
|
588
|
+
},
|
|
589
|
+
},
|
|
590
|
+
|
|
591
|
+
// ======================
|
|
592
|
+
// Overflow
|
|
593
|
+
// ======================
|
|
594
|
+
{ match: (c) => c === "overflow-hidden", apply: () => ({ overflow: "hidden" }) },
|
|
595
|
+
{ match: (c) => c === "overflow-auto", apply: () => ({ overflow: "auto" }) },
|
|
596
|
+
{ match: (c) => c === "overflow-scroll", apply: () => ({ overflow: "scroll" }) },
|
|
597
|
+
{ match: (c) => c === "overflow-visible", apply: () => ({ overflow: "visible" }) },
|
|
598
|
+
{ match: (c) => c === "overflow-x-auto", apply: () => ({ overflowX: "auto" }) },
|
|
599
|
+
{ match: (c) => c === "overflow-y-auto", apply: () => ({ overflowY: "auto" }) },
|
|
600
|
+
{ match: (c) => c === "overflow-x-hidden", apply: () => ({ overflowX: "hidden" }) },
|
|
601
|
+
{ match: (c) => c === "overflow-y-hidden", apply: () => ({ overflowY: "hidden" }) },
|
|
602
|
+
|
|
603
|
+
// ======================
|
|
604
|
+
// Cursor
|
|
605
|
+
// ======================
|
|
606
|
+
{ match: (c) => c === "cursor-pointer", apply: () => ({ cursor: "pointer" }) },
|
|
607
|
+
{ match: (c) => c === "cursor-default", apply: () => ({ cursor: "default" }) },
|
|
608
|
+
{ match: (c) => c === "cursor-not-allowed", apply: () => ({ cursor: "not-allowed" }) },
|
|
609
|
+
{ match: (c) => c === "cursor-grab", apply: () => ({ cursor: "grab" }) },
|
|
610
|
+
{ match: (c) => c === "cursor-text", apply: () => ({ cursor: "text" }) },
|
|
611
|
+
|
|
612
|
+
// ======================
|
|
613
|
+
// Transitions
|
|
614
|
+
// ======================
|
|
615
|
+
{ match: (c) => c === "transition", apply: () => ({ transition: "all 150ms cubic-bezier(0.4, 0, 0.2, 1)" }) },
|
|
616
|
+
{ match: (c) => c === "transition-none", apply: () => ({ transition: "none" }) },
|
|
617
|
+
{ match: (c) => c === "transition-colors", apply: () => ({ transition: "color, background-color, border-color 150ms cubic-bezier(0.4, 0, 0.2, 1)" }) },
|
|
618
|
+
{ match: (c) => c === "transition-transform", apply: () => ({ transition: "transform 150ms cubic-bezier(0.4, 0, 0.2, 1)" }) },
|
|
619
|
+
{ match: (c) => c === "transition-opacity", apply: () => ({ transition: "opacity 150ms cubic-bezier(0.4, 0, 0.2, 1)" }) },
|
|
620
|
+
{ match: (c) => c === "transition-shadow", apply: () => ({ transition: "box-shadow 150ms cubic-bezier(0.4, 0, 0.2, 1)" }) },
|
|
621
|
+
{
|
|
622
|
+
match: (c) => /^duration-\d+$/.test(c),
|
|
623
|
+
apply: (c) => ({ transitionDuration: c.split("-")[1] + "ms" }),
|
|
624
|
+
},
|
|
625
|
+
{ match: (c) => c === "ease-linear", apply: () => ({ transitionTimingFunction: "linear" }) },
|
|
626
|
+
{ match: (c) => c === "ease-in", apply: () => ({ transitionTimingFunction: "cubic-bezier(0.4, 0, 1, 1)" }) },
|
|
627
|
+
{ match: (c) => c === "ease-out", apply: () => ({ transitionTimingFunction: "cubic-bezier(0, 0, 0.2, 1)" }) },
|
|
628
|
+
{ match: (c) => c === "ease-in-out", apply: () => ({ transitionTimingFunction: "cubic-bezier(0.4, 0, 0.2, 1)" }) },
|
|
629
|
+
|
|
630
|
+
// ======================
|
|
631
|
+
// Transform
|
|
632
|
+
// ======================
|
|
633
|
+
{
|
|
634
|
+
match: (c) => /^scale-\d+$/.test(c),
|
|
635
|
+
apply: (c) => {
|
|
636
|
+
const val = parseInt(c.split("-")[1], 10);
|
|
637
|
+
return { transform: `scale(${val / 100})` };
|
|
638
|
+
},
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
match: (c) => /^rotate-\d+$/.test(c),
|
|
642
|
+
apply: (c) => ({ transform: `rotate(${c.split("-")[1]}deg)` }),
|
|
643
|
+
},
|
|
644
|
+
|
|
645
|
+
// ======================
|
|
646
|
+
// Object Fit
|
|
647
|
+
// ======================
|
|
648
|
+
{ match: (c) => c === "object-cover", apply: () => ({ objectFit: "cover" }) },
|
|
649
|
+
{ match: (c) => c === "object-contain", apply: () => ({ objectFit: "contain" }) },
|
|
650
|
+
{ match: (c) => c === "object-fill", apply: () => ({ objectFit: "fill" }) },
|
|
651
|
+
{ match: (c) => c === "object-none", apply: () => ({ objectFit: "none" }) },
|
|
652
|
+
|
|
653
|
+
// ======================
|
|
654
|
+
// List Style
|
|
655
|
+
// ======================
|
|
656
|
+
{ match: (c) => c === "list-none", apply: () => ({ listStyle: "none" }) },
|
|
657
|
+
{ match: (c) => c === "list-disc", apply: () => ({ listStyle: "disc" }) },
|
|
658
|
+
{ match: (c) => c === "list-decimal", apply: () => ({ listStyle: "decimal" }) },
|
|
659
|
+
|
|
660
|
+
// ======================
|
|
661
|
+
// Whitespace & Text Overflow
|
|
662
|
+
// ======================
|
|
663
|
+
{ match: (c) => c === "whitespace-nowrap", apply: () => ({ whiteSpace: "nowrap" }) },
|
|
664
|
+
{ match: (c) => c === "whitespace-pre", apply: () => ({ whiteSpace: "pre" }) },
|
|
665
|
+
{ match: (c) => c === "whitespace-pre-wrap", apply: () => ({ whiteSpace: "pre-wrap" }) },
|
|
666
|
+
{ match: (c) => c === "whitespace-normal", apply: () => ({ whiteSpace: "normal" }) },
|
|
667
|
+
{
|
|
668
|
+
match: (c) => c === "truncate",
|
|
669
|
+
apply: () => ({
|
|
670
|
+
overflow: "hidden",
|
|
671
|
+
textOverflow: "ellipsis",
|
|
672
|
+
whiteSpace: "nowrap",
|
|
673
|
+
}),
|
|
674
|
+
},
|
|
675
|
+
|
|
676
|
+
// ======================
|
|
677
|
+
// User Select & Pointer Events
|
|
678
|
+
// ======================
|
|
679
|
+
{ match: (c) => c === "select-none", apply: () => ({ userSelect: "none" }) },
|
|
680
|
+
{ match: (c) => c === "select-text", apply: () => ({ userSelect: "text" }) },
|
|
681
|
+
{ match: (c) => c === "select-all", apply: () => ({ userSelect: "all" }) },
|
|
682
|
+
{ match: (c) => c === "pointer-events-none", apply: () => ({ pointerEvents: "none" }) },
|
|
683
|
+
{ match: (c) => c === "pointer-events-auto", apply: () => ({ pointerEvents: "auto" }) },
|
|
684
|
+
|
|
685
|
+
// ======================
|
|
686
|
+
// Appearance & Outline
|
|
687
|
+
// ======================
|
|
688
|
+
{ match: (c) => c === "outline-none", apply: () => ({ outline: "none" }) },
|
|
689
|
+
{ match: (c) => c === "appearance-none", apply: () => ({ appearance: "none" }) },
|
|
690
|
+
{ match: (c) => c === "resize-none", apply: () => ({ resize: "none" }) },
|
|
691
|
+
|
|
692
|
+
// ======================
|
|
693
|
+
// Background
|
|
694
|
+
// ======================
|
|
695
|
+
{
|
|
696
|
+
match: (c) => c === "bg-gradient-to-r",
|
|
697
|
+
apply: () => ({ backgroundImage: "linear-gradient(to right, var(--chai-gradient-from, transparent), var(--chai-gradient-to, transparent))" }),
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
match: (c) => c === "bg-gradient-to-b",
|
|
701
|
+
apply: () => ({ backgroundImage: "linear-gradient(to bottom, var(--chai-gradient-from, transparent), var(--chai-gradient-to, transparent))" }),
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
match: (c) => c === "bg-gradient-to-br",
|
|
705
|
+
apply: () => ({ backgroundImage: "linear-gradient(to bottom right, var(--chai-gradient-from, transparent), var(--chai-gradient-to, transparent))" }),
|
|
706
|
+
},
|
|
707
|
+
];
|
|
708
|
+
|
|
709
|
+
// ========================================
|
|
710
|
+
// Core Engine
|
|
711
|
+
// ========================================
|
|
712
|
+
|
|
713
|
+
function generateStyle(cls) {
|
|
714
|
+
if (cache[cls]) return cache[cls];
|
|
715
|
+
|
|
716
|
+
let finalStyle = {};
|
|
717
|
+
|
|
718
|
+
for (let rule of rules) {
|
|
719
|
+
if (rule.match(cls)) {
|
|
720
|
+
Object.assign(finalStyle, rule.apply(cls));
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
cache[cls] = finalStyle;
|
|
725
|
+
return finalStyle;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function applyChai() {
|
|
729
|
+
const elements = document.querySelectorAll('[class*="chai-"]');
|
|
730
|
+
|
|
731
|
+
elements.forEach((el) => {
|
|
732
|
+
const classList = el.className.split(" ");
|
|
733
|
+
let finalStyle = {};
|
|
734
|
+
|
|
735
|
+
classList.forEach((cls) => {
|
|
736
|
+
if (!cls.startsWith("chai-")) return;
|
|
737
|
+
|
|
738
|
+
const pureClass = cls.replace("chai-", "");
|
|
739
|
+
const style = generateStyle(pureClass);
|
|
740
|
+
|
|
741
|
+
Object.assign(finalStyle, style);
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
Object.assign(el.style, finalStyle);
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
function observeDOM() {
|
|
749
|
+
const observer = new MutationObserver(() => {
|
|
750
|
+
applyChai();
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
observer.observe(document.body, {
|
|
754
|
+
childList: true,
|
|
755
|
+
subtree: true,
|
|
756
|
+
attributes: true,
|
|
757
|
+
attributeFilter: ["class"],
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
function initChai() {
|
|
762
|
+
applyChai();
|
|
763
|
+
observeDOM();
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// Auto-init when DOM is ready
|
|
767
|
+
if (document.readyState === "loading") {
|
|
768
|
+
document.addEventListener("DOMContentLoaded", initChai);
|
|
769
|
+
} else {
|
|
770
|
+
initChai();
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// Export for npm / module environments
|
|
774
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
775
|
+
module.exports = { initChai, applyChai };
|
|
776
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chai-sutta-css",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A lightweight, zero-dependency utility-first CSS engine. Build beautiful UIs fast with chai-* utility classes.",
|
|
5
|
+
"main": "chai.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"chai.js"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"No tests yet\""
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"css",
|
|
14
|
+
"utility",
|
|
15
|
+
"utility-first",
|
|
16
|
+
"lightweight",
|
|
17
|
+
"tailwind-alternative",
|
|
18
|
+
"inline-styles",
|
|
19
|
+
"zero-config",
|
|
20
|
+
"frontend",
|
|
21
|
+
"chai-css"
|
|
22
|
+
],
|
|
23
|
+
"author": "Sameer",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/Sameer-ts-tech/my-chai-css"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/Sameer-ts-tech/my-chai-css#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/Sameer-ts-tech/my-chai-css/issues"
|
|
32
|
+
}
|
|
33
|
+
}
|