clases 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.
Files changed (2) hide show
  1. package/README.md +131 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # 🚀 Class Utilities
2
+
3
+ A high-performance, recursive, and type-safe utility for managing CSS classes. Designed specifically for Tailwind CSS users who want to replace messy string concatenations with structured, maintainable objects.
4
+
5
+ ## ✨ Features
6
+
7
+ - 🔄 **Deep Recursion:** Nest variants like `md: { hover: '...' }` to stack prefixes automatically.
8
+ - 🛡️ **Hard Typing:** Full IntelliSense autocomplete for all Tailwind variants and custom plugins.
9
+ - 🔌 **Stackable Plugins:** Merge multiple design systems or custom configurations into a single `cl` function.
10
+ - 🗜️ **Zero Overhead:** Built on top of `tailwind-merge` and `clsx` for optimal performance and conflict resolution.
11
+ - 📦 **Monorepo Ready:** Lightweight, tree-shakable packages.
12
+
13
+ ---
14
+
15
+ ## 📦 Packages
16
+
17
+ | Package | Description |
18
+ | :--- | :--- |
19
+ | **clases** | The recursive engine. Use this to build custom variants or plugins. |
20
+ | **clases-tailwind** | Pre-configured with all Tailwind CSS variants and type definitions. |
21
+
22
+ ---
23
+
24
+ ## 🚀 Quick Start
25
+
26
+ ### 1. Installation
27
+
28
+ ```bash
29
+ pnpm add clases-tailwind clases
30
+ ```
31
+
32
+ ### 2. Basic Usage
33
+
34
+ ```typescript
35
+ import { cl } from 'clases-tailwind';
36
+
37
+ const className = cl({
38
+ base: 'p-4 text-sm transition-all',
39
+ hover: 'bg-blue-500 text-white',
40
+ md: 'text-lg p-8',
41
+ dark: {
42
+ base: 'bg-gray-900',
43
+ hover: 'bg-gray-800'
44
+ }
45
+ });
46
+ ```
47
+
48
+ ---
49
+
50
+ ## 💡 Advanced Use Cases
51
+
52
+ ### 🔄 Recursive Stacking (The "Secret Sauce")
53
+ Stop repeating prefixes. Nesting objects automatically stacks variants in the correct order.
54
+
55
+ ```typescript
56
+ cl({
57
+ md: {
58
+ hover: {
59
+ base: 'scale-105',
60
+ after: 'content-["*"]'
61
+ }
62
+ }
63
+ });
64
+ // Result: "md:hover:scale-105 md:hover:after:content-['*']"
65
+ ```
66
+
67
+
68
+
69
+ ### 🛠️ Custom Plugin Management
70
+ You can stack the Tailwind plugin with your own semantic aliases or project-specific configs.
71
+
72
+ ```typescript
73
+ import { createCl } from 'clases';
74
+ import { tailwind } from 'clases-tailwind';
75
+
76
+ const cl = createCl(
77
+ tailwind,
78
+ {
79
+ hocus: 'hover:focus',
80
+ brand: 'text-indigo-600 dark:text-indigo-400'
81
+ }
82
+ );
83
+
84
+ cl({
85
+ hocus: 'outline-none ring-2',
86
+ brand: 'font-bold'
87
+ });
88
+ ```
89
+
90
+ ### 📂 Clean Multi-line Layouts
91
+ Use backticks and commas to organize large chunks of layout logic without losing readability.
92
+
93
+ ```typescript
94
+ cl({
95
+ base: `
96
+ grid grid-cols-1,
97
+ gap-4 items-center,
98
+ w-full max-w-7xl mx-auto
99
+ `,
100
+ lg: 'grid-cols-3 gap-8'
101
+ });
102
+ ```
103
+
104
+ ---
105
+
106
+ ## ⌨️ Why Objects?
107
+
108
+ | Feature | Standard Tailwind Strings | Class Utilities Objects |
109
+ | :--- | :--- | :--- |
110
+ | **Readability** | ❌ Hard to scan long lines | ✅ Grouped by variant |
111
+ | **Maintenance** | ❌ Easy to forget prefixes | ✅ Automatic stacking |
112
+ | **Logic** | ❌ Messy ternary operators | ✅ Native JS object logic |
113
+ | **Types** | ❌ String-based (no safety) | ✅ Full Autocomplete |
114
+
115
+ ---
116
+
117
+ ## 🛠️ API Reference
118
+
119
+ ### `cl(...inputs)`
120
+ The main utility function. Accepts strings, arrays, objects, or nested structures.
121
+
122
+ ### `createCl(...plugins)`
123
+ Factory function to create a customized `cl` instance. Merges all provided objects into a single type-safe registry.
124
+
125
+ ### `tailwind`
126
+ The raw plugin data containing all Tailwind CSS variants.
127
+
128
+ ---
129
+
130
+ ## 📄 License
131
+ MIT © Mauricio Frías
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clases",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",