simple-merge-class-names 1.0.5 → 1.0.7
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 +10 -21
- package/mergeClassNames.js +20 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ function MyComponent() {
|
|
|
46
46
|
}
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
While using separate strings for each class name can be tedious
|
|
49
|
+
While using separate strings for each class name can be tedious, see [Workflow To Minimize Typing Strain](#workflow-to-minimize-typing-strain), it significantly enhances code readability and Developer Experience (DX). This is in contrast to hard-to-read strings like:
|
|
50
50
|
|
|
51
51
|
```jsx
|
|
52
52
|
function MyComponent() {
|
|
@@ -63,6 +63,13 @@ function MyComponent() {
|
|
|
63
63
|

|
|
64
64
|
|
|
65
65
|
- Have `Prettier` installed
|
|
66
|
+
- Have `Editor: Word Wrap` enabled in VS Code:
|
|
67
|
+
|
|
68
|
+
- `Open Settings (UI)` → `Editor: Word Wrap` → `on`
|
|
69
|
+
- Or `Open User Settings (JSON)` and add this entry:
|
|
70
|
+
|
|
71
|
+
`"editor.wordWrap": "on"`
|
|
72
|
+
|
|
66
73
|
- Use single quotes (<kbd>'</kbd>) for class names, often a single key press on many keyboards.
|
|
67
74
|
- Save the file (<kbd>Ctrl+S</kbd>), and Prettier does the formatting heavy-lifting, it automatically:
|
|
68
75
|
- Replaces single quotes with double quotes.
|
|
@@ -82,27 +89,9 @@ While similar packages exist (`clsx`) with better features and potentially impro
|
|
|
82
89
|
|
|
83
90
|
```javascript
|
|
84
91
|
/**
|
|
85
|
-
* mergeClassNames -
|
|
86
|
-
|
|
87
|
-
* Example usage: <div className = {mergeClassNames("flex", "flex-col")}/>
|
|
88
|
-
*
|
|
89
|
-
* @license AGPL-3.0
|
|
90
|
-
* Copyright (C) 2025 Abdullah Fatota
|
|
91
|
-
*
|
|
92
|
-
* This program is free software: you can redistribute it and/or modify
|
|
93
|
-
* it under the terms of the GNU Affero General Public License as published by
|
|
94
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
95
|
-
* (at your option) any later version.
|
|
96
|
-
*
|
|
97
|
-
* This program is distributed in the hope that it will be useful,
|
|
98
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
99
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
100
|
-
* GNU Affero General Public License for more details.
|
|
101
|
-
*
|
|
102
|
-
* You should have received a copy of the GNU Affero General Public License
|
|
103
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
92
|
+
* mergeClassNames - A straightforward utility for merging CSS class names in React + Tailwind, and other JavaScript projects.
|
|
93
|
+
...
|
|
104
94
|
*/
|
|
105
|
-
|
|
106
95
|
const isDefined = (val) => val !== undefined && val !== null;
|
|
107
96
|
|
|
108
97
|
const isNotEmptyString = (val) => val !== "";
|
package/mergeClassNames.js
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* mergeClassNames -
|
|
3
|
-
*
|
|
4
|
-
* Example usage: <div className = {mergeClassNames("flex", "flex-col")}/>
|
|
2
|
+
* mergeClassNames - A straightforward utility for merging CSS class names in React + Tailwind, and other JavaScript projects.
|
|
5
3
|
*
|
|
6
4
|
* @license AGPL-3.0
|
|
7
5
|
* Copyright (C) 2025 Abdullah Fatota
|
|
8
6
|
*
|
|
7
|
+
* Example usage:
|
|
8
|
+
* import { mergeClassNames } from "simple-merge-class-names";
|
|
9
|
+
*
|
|
10
|
+
* function MyComponent() {
|
|
11
|
+
* return (
|
|
12
|
+
* <div
|
|
13
|
+
* className={mergeClassNames(
|
|
14
|
+
* "app",
|
|
15
|
+
* "min-h-dvh",
|
|
16
|
+
* "grid",
|
|
17
|
+
* "grid-rows-[auto_1fr_auto]",
|
|
18
|
+
* "outline"
|
|
19
|
+
* )}
|
|
20
|
+
* >
|
|
21
|
+
* Hello, world!
|
|
22
|
+
* </div>
|
|
23
|
+
* );
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
9
26
|
* This program is free software: you can redistribute it and/or modify
|
|
10
27
|
* it under the terms of the GNU Affero General Public License as published by
|
|
11
28
|
* the Free Software Foundation, either version 3 of the License, or
|
package/package.json
CHANGED