tadka-css 1.0.0 → 1.0.1

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 CHANGED
@@ -1,80 +1,120 @@
1
1
  # tadka-css
2
2
 
3
- ![npm](https://img.shields.io/npm/v/tadka-css)
3
+ Add spice to your styles. Utility-first CSS engine in vanilla JS.
4
+
5
+ ![npm](https://img.shields.io/npm/v/tadka-css?label=npm)
6
+ ![npm downloads](https://img.shields.io/npm/dm/tadka-css)
4
7
  ![license](https://img.shields.io/npm/l/tadka-css)
5
8
  ![bundlephobia](https://img.shields.io/bundlephobia/minzip/tadka-css)
6
- ![stars](https://img.shields.io/github/stars/your-username/tadka-css?style=social)
9
+ ![github stars](https://img.shields.io/github/stars/ashaafkhan/tadka-css)
7
10
 
8
- Add spice to your styles. Utility-first CSS engine in vanilla JS.
11
+ - npm: https://www.npmjs.com/package/tadka-css
12
+ - GitHub: https://github.com/ashaafkhan/tadka-css
13
+ - Live Demo: https://tadkacss.vercel.app/
14
+ - Playground: https://tadkacss.vercel.app/playground/
15
+
16
+ TypeScript typings are included out of the box through `types/index.d.ts`.
17
+
18
+ ## What Is This?
19
+
20
+ tadka-css is a utility-first styling engine that runs in the browser.
21
+
22
+ Instead of writing custom CSS rules, you write class names like:
23
+
24
+ - `tadka-p-4`
25
+ - `tadka-bg-orange-500`
26
+ - `tadka-text-white`
27
+
28
+ The library scans your DOM, converts those class names into style objects, and applies styles automatically.
9
29
 
10
- ## Installation
30
+ ## Why Beginners Like It
31
+
32
+ - You can style pages without writing separate CSS files.
33
+ - You can learn utility-first thinking quickly.
34
+ - You can inspect styles directly in browser devtools.
35
+ - You can switch from this to Tailwind-style workflows later very easily.
36
+
37
+ ## Install
38
+
39
+ ### npm
11
40
 
12
41
  ```bash
13
42
  npm install tadka-css
14
43
  ```
15
44
 
16
- ```html
17
- <script src="https://unpkg.com/tadka-css/dist/tadka-css.js"></script>
18
- ```
45
+ ### yarn / pnpm
19
46
 
20
47
  ```bash
21
48
  yarn add tadka-css
22
49
  pnpm add tadka-css
23
50
  ```
24
51
 
25
- ## Quick Start
52
+ ### CDN
26
53
 
27
54
  ```html
28
- <div class="tadka-p-4 tadka-bg-blue-500 tadka-text-white tadka-rounded-lg">
29
- Hello World
30
- </div>
31
-
32
- <script type="module">
33
- import TadkaCSS from "tadka-css";
34
- TadkaCSS.init();
35
- </script>
55
+ <script src="https://unpkg.com/tadka-css/dist/tadka-css.js"></script>
36
56
  ```
37
57
 
38
- ## How It Works
58
+ ## 2-Minute Quick Start
39
59
 
40
- - Scans the DOM for classes prefixed with `tadka-`.
41
- - Tokenizes each class and resolves it to a JS style object.
42
- - Applies styles inline, and injects responsive rules into a runtime `<style>` tag.
60
+ Create an HTML file and paste this:
43
61
 
44
- ## API Reference
62
+ ```html
63
+ <!doctype html>
64
+ <html>
65
+ <head>
66
+ <meta charset="UTF-8" />
67
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
68
+ <script src="https://unpkg.com/tadka-css/dist/tadka-css.js"></script>
69
+ </head>
70
+ <body class="tadka-bg-slate-100 tadka-p-8">
71
+ <div class="tadka-bg-orange-600 tadka-text-white tadka-p-6 tadka-rounded-lg tadka-shadow-lg">
72
+ Hello from tadka-css
73
+ </div>
74
+ </body>
75
+ </html>
76
+ ```
45
77
 
46
- | Method | Description |
47
- |---|---|
48
- | `init(options)` | Initialize engine, scan DOM, and start observer |
49
- | `refresh()` | Re-scan DOM |
50
- | `apply(element)` | Apply to one element |
51
- | `applyAll(nodeList)` | Apply to many elements |
52
- | `parse(className)` | Return parsed style object |
53
- | `register(name, styles)` | Add custom utility |
54
- | `unregister(name)` | Remove custom utility |
55
- | `getConfig()` | Get active config |
56
- | `setConfig(options)` | Merge new config |
57
- | `reset()` | Remove generated styles and listeners |
58
- | `on(event, handler)` | Listen to `ready`, `apply`, `parse-error`, `refresh` |
78
+ If you are using npm in a module project:
59
79
 
60
- ## init() Options
80
+ ```js
81
+ import TadkaCSS from "tadka-css";
82
+ TadkaCSS.init();
83
+ ```
61
84
 
62
- | Option | Type | Default |
63
- |---|---|---|
64
- | `prefix` | `string` | `tadka` |
65
- | `scale` | `number` | `4` |
66
- | `removeClasses` | `boolean` | `false` |
67
- | `watch` | `boolean` | `true` |
68
- | `breakpoints` | `object` | `sm/md/lg/xl/2xl` |
69
- | `extend` | `object` | `{}` |
70
- | `colors` | `object` | generated 22-color palette |
85
+ ## How It Works Internally
86
+
87
+ 1. Finds classes with the configured prefix (`tadka-` by default).
88
+ 2. Parses each utility token into a CSS style object.
89
+ 3. Applies standard utilities as inline styles.
90
+ 4. Handles responsive utilities by injecting media query rules.
91
+ 5. Handles pseudo-like interactions (hover/focus/active) via JS listeners.
92
+
93
+ ## Most Common Utilities
71
94
 
72
- ## Utility Cheatsheet
95
+ ### Spacing
73
96
 
74
- - Spacing: `tadka-p-4`, `tadka-mx-auto`, `tadka-gap-6`, `tadka-p-[13px]`
75
- - Colors: `tadka-bg-orange-500`, `tadka-text-slate-900`, `tadka-border-blue-300`
76
- - Layout: `tadka-flex`, `tadka-items-center`, `tadka-grid`, `tadka-grid-cols-3`
77
- - Typography: `tadka-text-2xl`, `tadka-font-bold`, `tadka-underline`
97
+ - `tadka-p-4` (padding)
98
+ - `tadka-mx-auto` (horizontal auto margin)
99
+ - `tadka-gap-4` (gap)
100
+ - `tadka-p-[13px]` (arbitrary value)
101
+
102
+ ### Colors
103
+
104
+ - `tadka-bg-orange-500`
105
+ - `tadka-text-slate-900`
106
+ - `tadka-border-blue-300`
107
+
108
+ ### Typography
109
+
110
+ - `tadka-text-sm`, `tadka-text-lg`, `tadka-text-3xl`
111
+ - `tadka-font-bold`
112
+ - `tadka-underline`
113
+
114
+ ### Layout
115
+
116
+ - `tadka-flex`, `tadka-items-center`, `tadka-justify-between`
117
+ - `tadka-grid`, `tadka-grid-cols-3`
78
118
 
79
119
  ## Responsive Usage
80
120
 
@@ -86,6 +126,8 @@ pnpm add tadka-css
86
126
  | `tadka-xl:` | `1280px` |
87
127
  | `tadka-2xl:` | `1536px` |
88
128
 
129
+ Example:
130
+
89
131
  ```html
90
132
  <div class="tadka-w-full tadka-lg:w-1/2 tadka-xl:w-1/4"></div>
91
133
  ```
@@ -95,22 +137,25 @@ pnpm add tadka-css
95
137
  - `tadka-hover:*`
96
138
  - `tadka-focus:*`
97
139
  - `tadka-active:*`
98
- - `tadka-group-hover:*`
99
140
  - `tadka-disabled:*`
100
141
  - `tadka-checked:*`
101
142
 
143
+ Example:
144
+
102
145
  ```html
103
146
  <button class="tadka-bg-orange-500 tadka-hover:bg-orange-700 tadka-active:scale-95">
104
147
  Hover me
105
148
  </button>
106
149
  ```
107
150
 
108
- ## Extending tadka-css
151
+ ## Config and Custom Utilities
109
152
 
110
153
  ```js
111
154
  import TadkaCSS from "tadka-css";
112
155
 
113
156
  TadkaCSS.init({
157
+ prefix: "tadka",
158
+ watch: true,
114
159
  extend: {
115
160
  spicy: { color: "#E8550A", fontWeight: "800" },
116
161
  btn: (value) => ({
@@ -124,16 +169,64 @@ TadkaCSS.init({
124
169
  });
125
170
  ```
126
171
 
172
+ ## Public API
173
+
174
+ | Method | Description |
175
+ |---|---|
176
+ | `init(options)` | Initialize engine, scan DOM, start observer |
177
+ | `refresh()` | Re-scan the DOM |
178
+ | `apply(element)` | Apply utilities to one element |
179
+ | `applyAll(nodeList)` | Apply utilities to many elements |
180
+ | `parse(className)` | Return parsed style object |
181
+ | `register(name, styles)` | Register a custom utility |
182
+ | `unregister(name)` | Remove a custom utility |
183
+ | `getConfig()` | Get active config |
184
+ | `setConfig(options)` | Merge and apply config changes |
185
+ | `reset()` | Remove generated styles/listeners |
186
+ | `on(event, handler)` | Subscribe to `ready`, `apply`, `parse-error`, `refresh` |
187
+
188
+ ### init Options
189
+
190
+ | Option | Type | Default |
191
+ |---|---|---|
192
+ | `prefix` | `string` | `tadka` |
193
+ | `scale` | `number` | `4` |
194
+ | `removeClasses` | `boolean` | `false` |
195
+ | `watch` | `boolean` | `true` |
196
+ | `breakpoints` | `object` | `sm/md/lg/xl/2xl` |
197
+ | `extend` | `object` | `{}` |
198
+ | `colors` | `object` | generated palette |
199
+
127
200
  ## Arbitrary Values
128
201
 
202
+ Use square brackets for direct values:
203
+
129
204
  ```html
130
205
  <div class="tadka-p-[13px] tadka-w-[420px] tadka-bg-[#FF5733]"></div>
131
206
  ```
132
207
 
208
+ ## Troubleshooting
209
+
210
+ ### My classes are not applying
211
+
212
+ - Make sure class names start with `tadka-`.
213
+ - If using npm import, ensure `TadkaCSS.init()` runs after DOM is ready.
214
+ - If you add HTML dynamically, call `TadkaCSS.refresh()` (or keep `watch: true`).
215
+
216
+ ### Responsive classes are not showing
217
+
218
+ - Confirm prefixes like `tadka-md:` are written correctly.
219
+ - Check if viewport width actually matches breakpoint.
220
+
221
+ ### npm page did not update after README edit
222
+
223
+ - npm README updates only after publishing a new version.
224
+ - Bump version and publish again (for example, 1.0.1).
225
+
133
226
  ## Development
134
227
 
135
228
  ```bash
136
- git clone https://github.com/your-username/tadka-css.git
229
+ git clone https://github.com/ashaafkhan/tadka-css.git
137
230
  cd tadka-css
138
231
  npm install
139
232
  npm run build
@@ -142,12 +235,19 @@ npm test
142
235
 
143
236
  ## Demo
144
237
 
145
- - Main demo: [demo/index.html](demo/index.html)
146
- - Playground: [demo/playground/index.html](demo/playground/index.html)
238
+ - Main demo: https://tadkacss.vercel.app/
239
+ - Playground: https://tadkacss.vercel.app/playground/
240
+ - Demo source: https://github.com/ashaafkhan/tadka-css/blob/main/demo/index.html
147
241
 
148
242
  ## Contributing
149
243
 
150
- Issues and PRs are welcome. Please run tests before opening a PR.
244
+ Issues and pull requests are welcome.
245
+
246
+ Before opening a PR:
247
+
248
+ 1. Run `npm test`
249
+ 2. Run `npm run build`
250
+ 3. Add or update tests for behavior changes
151
251
 
152
252
  ## License
153
253
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tadka-css",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Utility-first CSS engine for the DOM. Add spice to your styles.",
5
5
  "main": "dist/tadka-css.cjs.js",
6
6
  "module": "dist/tadka-css.esm.js",
package/types/index.d.ts CHANGED
@@ -39,7 +39,7 @@ interface TadkaCSSApi {
39
39
  on(event: "apply" | "parse-error" | "ready" | "refresh", handler: (payload: unknown) => void): () => void;
40
40
  }
41
41
 
42
- declare const TadkaCSS: TadkaCSSApi;
43
-
44
- export { TadkaCSS as default };
45
- export type { TadkaBreakpoints, TadkaCSSApi, TadkaDynamicStyle, TadkaInitOptions, TadkaParseResult, TadkaStyleObject };
42
+ declare const TadkaCSS: TadkaCSSApi;
43
+
44
+ export { TadkaCSS as default };
45
+ export type { TadkaBreakpoints, TadkaCSSApi, TadkaDynamicStyle, TadkaInitOptions, TadkaParseResult, TadkaStyleObject };