Skip to content

Commit

Permalink
feat: Replace JedWatson/classnames with lukeed/clsx
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed May 7, 2024
1 parent 5c00f6d commit d9dd2ff
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 14 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![NPM Weekly Downloads](https://badgen.net/npm/dw/reclsx)](https://www.npmjs.com/package/reclsx)
[![License](https://badgen.net/npm/license/reclsx)](https://www.npmjs.com/package/reclsx)

> Dynamically `classnames` in `React`<br>Based on [react/jsx-runtime](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)<br>Using [classNames/dedupe](https://github.com/JedWatson/classnames#alternate-dedupe-version)
> Dynamically `classnames` in `React`<br>Based on [react/jsx-runtime](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)<br>Using [clsx](https://github.com/lukeed/clsx)
## Example

Expand All @@ -15,16 +15,19 @@
## Install

```bash
# via pnpm
$ pnpm i reclsx clsx

# via npm
$ npm i reclsx classnames
$ npm i reclsx clsx

# via yarn
$ yarn add reclsx classnames
$ yarn add reclsx clsx
```

## Usage

The constructing `className` conditionally using [JedWatson/classnames](https://github.com/JedWatson/classnames), For detailed API options, please refer to [classNames/dedupe](https://github.com/JedWatson/classnames#alternate-dedupe-version)
The constructing `className` conditionally using [lukeed/clsx](https://github.com/lukeed/clsx), For detailed API options, please refer to [clsx](https://github.com/lukeed/clsx?tab=readme-ov-file#clsx---)

```javascript
// basic
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reclsx",
"version": "1.0.9",
"version": "1.1.0",
"description": "Dynamically classnames in React",
"main": "dist/jsx-runtime.js",
"module": "dist/jsx-runtime.js",
Expand All @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/daniel-zd/reclsx.git"
"url": "git+https://github.com/domisooo/reclsx.git"
},
"keywords": [
"react",
Expand All @@ -26,16 +26,16 @@
"author": "Daniel Zhao",
"license": "MIT",
"bugs": {
"url": "https://github.com/daniel-zd/reclsx/issues"
"url": "https://github.com/domisooo/reclsx/issues"
},
"homepage": "https://github.com/daniel-zd/reclsx#readme",
"homepage": "https://github.com/domisooo/reclsx#readme",
"peerDependencies": {
"classnames": "^2.3.1",
"clsx": "^2.1.1",
"react": ">=17.0.0"
},
"devDependencies": {
"classnames": "^2.3.1",
"react": "^18.1.0",
"typescript": "^4.7.3"
"clsx": "^2.1.1",
"react": "^18.3.1",
"typescript": "^5.4.5"
}
}
57 changes: 57 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/create-clsx-props.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classNames from "classnames/dedupe";
import clsx from "clsx";

const hasOwnProperty = Object.prototype.hasOwnProperty;

Expand All @@ -13,7 +13,7 @@ const createClsxProps = (props: any) => {
}

const newProps: any = { ...props };
newProps.className = classNames(className);
newProps.className = clsx(className);

return newProps;
};
Expand Down

0 comments on commit d9dd2ff

Please sign in to comment.