Skip to content

Commit aff2d3a

Browse files
committed
release 1.3.2
1 parent f300af3 commit aff2d3a

File tree

10 files changed

+1301
-913
lines changed

10 files changed

+1301
-913
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
build:
77
strategy:
88
matrix:
9-
os: [windows-latest, macos-latest, ubuntu-latest]
9+
os: [macos-latest, ubuntu-latest]
1010

1111
runs-on: ${{ matrix.os }}
1212
steps:
@@ -16,7 +16,7 @@ jobs:
1616
node-version: '18.x'
1717
- uses: pnpm/action-setup@v2
1818
with:
19-
version: 7
19+
version: 8
2020
- name: Install dependencies
2121
run: pnpm install
2222
- name: Build package

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Tests
22

3-
on: [push, pull_request]
3+
on: [push]
44

55
jobs:
66
tests:
@@ -12,7 +12,7 @@ jobs:
1212
node-version: '18.x'
1313
- uses: pnpm/action-setup@v2
1414
with:
15-
version: 7
15+
version: 8
1616
- name: Install dependencies
1717
run: pnpm install
1818
- name: Install Playwright

README.md

+68-22
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Zero dependency, highly customizable rating component for React.
77

88
![react-rating](https://i.ibb.co/L6M0hfw/new.png)
99

10-
[Demo and Examples](https://react-rating.onrender.com/)[NextJS SSR](https://stackblitz.com/edit/nextjs-5qw9id?file=pages/index.tsx)[Vite](https://stackblitz.com/edit/vitejs-vite-gwqytd?file=src/App.tsx)
10+
[Demo and Examples](https://react-rating.onrender.com/)[NextJS Page Router](https://stackblitz.com/edit/nextjs-5qw9id?file=pages/index.tsx)[Vite](https://stackblitz.com/edit/vitejs-vite-gwqytd?file=src/App.tsx)
1111

1212
<br />
1313

@@ -71,7 +71,7 @@ export default function App() {
7171
// ...
7272
```
7373
74-
**in any page/component:**
74+
**in any page.tsx**
7575
7676
```tsx
7777
import { Rating } from '@smastrom/react-rating';
@@ -82,77 +82,123 @@ export default function Index() {
8282
8383
</details>
8484
85-
<details><summary><strong>Next</strong></summary>
85+
<details><summary><strong>NextJS 13 - App Router</strong></summary>
8686
87-
<br />
87+
### Interactive rating
8888
89-
**pages/\_app.js**
89+
**app/layout.tsx**
9090
91-
```jsx
92-
import '@smastrom/react-rating/style.css';
91+
```tsx
92+
import '@smastrom/react-rating/style.css' // Import it only once in the whole app
93+
```
9394
94-
function MyApp({ Component, pageProps }) {
95-
// ...
95+
**components/Rating.tsx**
96+
97+
```tsx
98+
'use client'
99+
100+
import { useState } from 'react'
101+
import { Rating as ReactRating } from '@smastrom/react-rating'
102+
103+
export function Rating() {
104+
const [rating, setRating] = useState(0)
105+
106+
return <ReactRating style={{ maxWidth: 100 }} value={rating} onChange={setRating} />
107+
}
96108
```
97109
98110
**in any page/component:**
99111
100112
```tsx
101-
import { Rating } from '@smastrom/react-rating';
113+
import { Rating } from './components/Rating'
102114

103115
export default function Home() {
104-
// ...
116+
return (
117+
<div>
118+
{/* Other nodes... */}
119+
<Rating />
120+
{/* Other nodes... */}
121+
</div>
122+
)
123+
}
124+
```
125+
126+
### Non-interactive rating
127+
128+
**app/layout.tsx**
129+
130+
```tsx
131+
import '@smastrom/react-rating/style.css' // Import it only once in the whole app
132+
```
133+
134+
**in any page/component:**
135+
136+
```tsx
137+
import { Rating } from '@smastrom/react-rating'
138+
139+
export default function Home() {
140+
return (
141+
<div>
142+
{/* Other nodes... */}
143+
<Rating style={{ maxWidth: 100 }} value={3} readOnly />
144+
{/* Other nodes... */}
145+
</div>
146+
)
147+
}
105148
```
106149
107150
</details>
108151
109-
<details><summary><strong>Gatsby</strong></summary>
152+
<details><summary><strong>NextJS - Pages Router</strong></summary>
110153
111154
<br />
112155
113-
**gatsby-browser.js** - Create the file at the root of your project if it doesn't exist, and relaunch the dev server.
156+
**pages/\_app.js**
114157
115158
```jsx
116-
import '@smastrom/react-rating/style.css'
159+
import '@smastrom/react-rating/style.css';
160+
161+
function MyApp({ Component, pageProps }) {
162+
// ...
117163
```
118164
119165
**in any page/component:**
120166
121167
```tsx
122168
import { Rating } from '@smastrom/react-rating';
123169

124-
const IndexPage = () => {
170+
export default function Home() {
125171
// ...
126172
```
127173
128174
</details>
129175
130-
<details><summary><strong>Vite</strong></summary>
176+
<details><summary><strong>Gatsby</strong></summary>
131177
132178
<br />
133179
134-
**main.jsx**
180+
**gatsby-browser.js** - Create the file at the root of your project if it doesn't exist, and relaunch the dev server.
135181
136182
```jsx
137183
import '@smastrom/react-rating/style.css'
138184
```
139185
140-
**in any component:**
186+
**in any page/component:**
141187
142-
```jsx
188+
```tsx
143189
import { Rating } from '@smastrom/react-rating';
144190

145-
function App() {
191+
const IndexPage = () => {
146192
// ...
147193
```
148194
149195
</details>
150196
151-
<details><summary><strong>Create React App</strong></summary>
197+
<details><summary><strong>Vite</strong></summary>
152198
153199
<br />
154200
155-
**index.js**
201+
**main.jsx**
156202
157203
```jsx
158204
import '@smastrom/react-rating/style.css'

package.json

+29-33
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@smastrom/react-rating",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"private": false,
55
"keywords": [
66
"react",
@@ -35,28 +35,24 @@
3535
"exports": {
3636
".": {
3737
"import": "./dist/index.mjs",
38-
"require": "./dist/index.js"
38+
"require": "./dist/index.js",
39+
"types": "./dist/index.d.ts"
3940
},
40-
"./style.css": "./style.css",
41-
"./style": "./style.css",
42-
"./styles.css": "./style.css",
43-
"./styles": "./style.css"
41+
"./style.css": "./dist/style.css",
42+
"./style": "./dist/style.css",
43+
"./styles.css": "./dist/style.css",
44+
"./styles": "./dist/style.css"
4445
},
4546
"main": "dist/index.js",
4647
"module": "dist/index.mjs",
47-
"browser": "dist/index.js",
4848
"types": "dist/index.d.ts",
49-
"style": "style.css",
5049
"files": [
51-
"dist",
52-
"style.css"
50+
"dist/*"
5351
],
5452
"scripts": {
55-
"prebuild": "rimraf dist style.css src/exportedTypes.d.ts",
56-
"build": "tsc && vite build && pnpm declare",
57-
"postbuild": "cpy dist/style.css ./ --flat && cpy src/exportedTypes.d.ts dist --rename index.d.ts --flat && rimraf src/exportedTypes.d.ts dist/style.css",
53+
"build": "rm -rf dist && tsc && vite build",
54+
"postbuild": "./scripts/add-use-client.sh",
5855
"coverage": "vitest run --coverage",
59-
"declare": "tsc src/exportedTypes --declaration --emitDeclarationOnly",
6056
"dev": "vite",
6157
"test": "vitest",
6258
"test:ct": "playwright test -c playwright-ct.config.ts",
@@ -71,36 +67,36 @@
7167
"devDependencies": {
7268
"@playwright/experimental-ct-react": "1.29.0",
7369
"@playwright/test": "1.29.0",
74-
"@rollup/plugin-terser": "^0.4.1",
75-
"@testing-library/dom": "^9.2.0",
76-
"@testing-library/jest-dom": "^5.16.5",
70+
"@rollup/plugin-terser": "^0.4.3",
71+
"@testing-library/dom": "^9.3.1",
72+
"@testing-library/jest-dom": "^5.17.0",
7773
"@testing-library/react": "^14.0.0",
7874
"@testing-library/user-event": "^14.4.3",
79-
"@types/node": "^18.16.1",
80-
"@types/react": "^18.2.0",
81-
"@types/react-dom": "^18.2.1",
82-
"@types/testing-library__jest-dom": "^5.14.5",
83-
"@typescript-eslint/eslint-plugin": "^5.59.1",
84-
"@typescript-eslint/parser": "^5.59.1",
75+
"@types/node": "^18.17.5",
76+
"@types/react": "^18.2.20",
77+
"@types/react-dom": "^18.2.7",
78+
"@types/testing-library__jest-dom": "^5.14.9",
79+
"@typescript-eslint/eslint-plugin": "^5.62.0",
80+
"@typescript-eslint/parser": "^5.62.0",
8581
"@vitejs/plugin-react": "^3.1.0",
8682
"@vitest/coverage-c8": "^0.29.8",
8783
"cpy-cli": "^4.2.0",
88-
"eslint": "^8.39.0",
89-
"eslint-plugin-react": "^7.32.2",
84+
"eslint": "^8.47.0",
85+
"eslint-plugin-react": "^7.33.2",
9086
"eslint-plugin-react-hooks": "^4.6.0",
9187
"husky": "^8.0.3",
92-
"jsdom": "^21.1.1",
93-
"lint-staged": "^13.2.2",
88+
"jsdom": "^21.1.2",
89+
"lint-staged": "^13.3.0",
9490
"prettier": "^2.8.8",
9591
"react": "^18.2.0",
9692
"react-dom": "^18.2.0",
97-
"rimraf": "^4.4.1",
98-
"typescript": "^5.0.4",
99-
"vite": "^4.3.3",
100-
"vitest": "^0.29.8"
93+
"typescript": "^5.1.6",
94+
"vite": "^4.4.9",
95+
"vitest": "^0.29.8",
96+
"vite-plugin-dts": "^3.5.2"
10197
},
10298
"peerDependencies": {
103-
"react": ">=17",
104-
"react-dom": ">=17"
99+
"react": ">=18",
100+
"react-dom": ">=18"
105101
}
106102
}

0 commit comments

Comments
 (0)