classix 2.1.9 → 2.1.12

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 +24 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -47,35 +47,46 @@ cx(...["class1", "class2", "class3"]);
47
47
  cx(
48
48
  "flex",
49
49
  isPrimary ? "bg-primary-100" : "bg-secondary-100",
50
- isLarge ? "m-4 p-4" : "m-2 py-2"
50
+ isLarge ? "m-4 p-4" : "m-2 p-2"
51
51
  );
52
52
  // => "flex bg-primary-100 m-2 p-2" *assuming isPrimary is true and isLarge is false
53
53
  ```
54
54
 
55
+ ## Why?
56
+
57
+ classix considers string expressions faster to type and easier to reason about (conditions first, followed by classNames) than the alternative:
58
+
59
+ ```js
60
+ // 🚫
61
+ clsx({ "class-1": isPrimary });
62
+ // ✅
63
+ cx(isPrimary && "class-1");
64
+
65
+ // 🚫
66
+ clsx({ "class-1": isPrimary && isLarge, "class-2": !isPrimary || !isLarge });
67
+ // ✅
68
+ cx(isPrimary && isLarge ? "class-1" : "class-2");
69
+ ```
70
+
71
+ This reasoning enables classix to simplify its API by allowing only string expressions as arguments. Not only does it provide a consistent way of joining classNames, but using classix also leads to [better performance](#comparison) and a [smaller bundle size](#comparison) for your application.
72
+
55
73
  ## Comparison
56
74
 
57
75
  ![Size comparison chart](media/size.png)
58
76
 
59
- Sources: [classix](https://bundlejs.com/?q=classix), [clsx](https://bundlejs.com/?q=clsx), [classnames](https://bundlejs.com/?q=classnames)
77
+ Sources: [classix](https://bundlejs.com/api?q=classix), [clsx](https://bundlejs.com/api?q=clsx), [classnames](https://bundlejs.com/api?q=classnames)
60
78
 
61
79
  ![Performance comparison chart](media/perf.png)
62
80
 
63
81
  Sources: Ran [benchmark](benchmark/) on an AMD Ryzen 5 5600x.
64
82
 
65
- Compared to other libraries, classix simplifies its API by omitting the use of object arguments, which it considers less ergonomic than string expressions:
66
-
67
- ```js
68
- // 🚫
69
- cx({ "class-1": isPrimary && isLarge, "class-2": !isPrimary || !isLarge });
70
- // ✅
71
- cx(isPrimary && isLarge ? "class-1" : "class-2");
72
- ```
73
-
74
83
  ## Highlights
75
84
 
76
- - Fastest & tiniest
85
+ - Supports all major browsers
86
+ - Supports all versions of Node.js
87
+ - Works with both ES Modules and CommonJS
77
88
  - Zero dependencies
78
- - Fully typed (with TypeScript)
89
+ - Fully typed with TypeScript
79
90
  - Fully tested
80
91
  - [Semver](https://semver.org/) compliant
81
92
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "classix",
3
- "version": "2.1.9",
3
+ "version": "2.1.12",
4
4
  "description": "The fastest and tiniest utility for conditionally joining classNames.",
5
5
  "main": "dist/cjs/classix.js",
6
6
  "module": "dist/esm/classix.js",