@mysetup/classnames 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 +29 -0
- package/dist/classnames.d.ts +4 -0
- package/dist/classnames.d.ts.map +1 -0
- package/dist/classnames.js +13 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @mysetup/classnames
|
|
2
|
+
|
|
3
|
+
`classNames` is a utility function that merges classes conditionally and removes Tailwind CSS style conflicts.
|
|
4
|
+
|
|
5
|
+
Based on [clsx](https://github.com/lukeed/clsx) and [tailwind-merge](https://github.com/dcastil/tailwind-merge).
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
By passing the `className` prop as the last argument to the `classNames` function, it allows us to override styles in another component.
|
|
10
|
+
|
|
11
|
+
Typically with Tailwind CSS the only way to override `w-10` with `w-5` is to remove `w-10`. `classNames` takes care of those conflicts automatically.
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { classNames } from "@mysetup/classnames";
|
|
15
|
+
|
|
16
|
+
interface BoxProps {
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Box = function Box({ className }: BoxProps) {
|
|
21
|
+
const classes = classNames("h-10 w-10 bg-black", className);
|
|
22
|
+
|
|
23
|
+
return <div className={classes} />; // <div class="h-10 w-10 bg-black" />
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const SmallBox = function SmallBox() {
|
|
27
|
+
return <Box className="h-5 w-5" />; // <div class="h-5 w-5 bg-black" />
|
|
28
|
+
};
|
|
29
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classnames.d.ts","sourceRoot":"","sources":["../classnames.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B,eAAO,MAAM,UAAU,eAAgB,UAAU,EAAE,WAA2B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.classNames = void 0;
|
|
4
|
+
var tailwind_merge_1 = require("tailwind-merge");
|
|
5
|
+
var clsx_1 = require("clsx");
|
|
6
|
+
var classNames = function () {
|
|
7
|
+
var classes = [];
|
|
8
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
9
|
+
classes[_i] = arguments[_i];
|
|
10
|
+
}
|
|
11
|
+
return (0, tailwind_merge_1.twMerge)((0, clsx_1.clsx)(classes));
|
|
12
|
+
};
|
|
13
|
+
exports.classNames = classNames;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./classnames"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mysetup/classnames",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "rm -rf ./dist && tsc -p tsconfig.build.json",
|
|
19
|
+
"lint": "eslint .",
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"test": "jest",
|
|
22
|
+
"test:coverage": "jest --coverage",
|
|
23
|
+
"format": "prettier --write \"**/*.{ts,tsx,md,js}\"",
|
|
24
|
+
"checks": "pnpm typecheck && pnpm lint && pnpm test",
|
|
25
|
+
"clean": "rm -rf node_modules .swc dist pnpm-lock.yaml && echo \"✅ Successfully removed \""
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"clsx": "^2.1.1",
|
|
29
|
+
"tailwind-merge": "^2.5.4"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@mysetup/eslint-config": "latest",
|
|
33
|
+
"@mysetup/jest-config": "latest",
|
|
34
|
+
"@mysetup/prettier-config": "latest",
|
|
35
|
+
"@mysetup/tsconfig": "latest",
|
|
36
|
+
"@types/jest": "^29.5.14",
|
|
37
|
+
"eslint": "8.57.0",
|
|
38
|
+
"jest": "^29.7.0",
|
|
39
|
+
"typescript": "^5.6.3"
|
|
40
|
+
},
|
|
41
|
+
"prettier": "@mysetup/prettier-config",
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18.0.0"
|
|
44
|
+
},
|
|
45
|
+
"packageManager": "pnpm@9.9.0"
|
|
46
|
+
}
|