Skip to content

Commit 6f81aad

Browse files
Fix: Added support for SSR, Revised license and README (#15)
1 parent 48769a9 commit 6f81aad

File tree

5 files changed

+48
-85
lines changed

5 files changed

+48
-85
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Francisco Hodge
3+
Copyright (c) 2023 keyvalue software systems
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+29-67
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ b. Rename the style key `Chart` to `Bar` within `styles` prop.
7070
<b>Before</b>
7171

7272
```jsx
73-
const stylesOverride = {
74-
Chart: (ratingId) => ({...styles}),
75-
Count: (ratingId) => ({...styles})
76-
};
77-
7873
<RatingSummary
7974
ratings={ratingValues}
8075
chartColors={{
@@ -84,18 +79,16 @@ b. Rename the style key `Chart` to `Bar` within `styles` prop.
8479
2: 'blue',
8580
1: 'green'
8681
}}
87-
styles={stylesOverride}
82+
styles={{
83+
Chart: (ratingId) => ({...styles}),
84+
Count: (ratingId) => ({...styles})
85+
}}
8886
/>
8987
```
9088

9189
<b>After</b>
9290

9391
```jsx
94-
const stylesOverride = {
95-
Bar: (ratingId) => ({...styles}),
96-
Count: (ratingId) => ({...styles})
97-
};
98-
9992
<RatingSummary
10093
ratings={ratingValues}
10194
barColors={{
@@ -105,7 +98,10 @@ b. Rename the style key `Chart` to `Bar` within `styles` prop.
10598
2: 'blue',
10699
1: 'green'
107100
}}
108-
styles={stylesOverride}
101+
styles={{
102+
Bar: (ratingId) => ({...styles}),
103+
Count: (ratingId) => ({...styles})
104+
}}
109105
/>
110106
```
111107

@@ -250,14 +246,6 @@ import RatingSummary from '@keyvaluesystems/react-star-rating-summary';
250246

251247
function App() {
252248

253-
const ratings = {
254-
1: 100,
255-
2: 200,
256-
3: 300,
257-
4: 400,
258-
5: 500
259-
};
260-
261249
const countColors = {
262250
1: 'red',
263251
2: 'yellow',
@@ -266,24 +254,28 @@ function App() {
266254
5: 'white'
267255
};
268256

269-
const stylesOverride = {
270-
Average: { color: 'purple' },
271-
AverageStarIcon: {
272-
width: '20px',
273-
height: '20px'
274-
},
275-
LabelStarIcon: () => ({
276-
width: '15px',
277-
height: '15px'
278-
}),
279-
Label: (ratingId) => ({ fontSize: '12px' }),
280-
Count: (ratingId) => ({color: countColors[ratingId]})
281-
};
282-
283257
return (
284258
<RatingSummary
285-
ratings={ratings}
286-
styles={stylesOverride}
259+
ratings={{
260+
1: 100,
261+
2: 200,
262+
3: 300,
263+
4: 400,
264+
5: 500
265+
}}
266+
styles={{
267+
Average: { color: 'purple' },
268+
AverageStarIcon: {
269+
width: '20px',
270+
height: '20px'
271+
},
272+
LabelStarIcon: () => ({
273+
width: '15px',
274+
height: '15px'
275+
}),
276+
Label: (ratingId) => ({ fontSize: '12px' }),
277+
Count: (ratingId) => ({color: countColors[ratingId]})
278+
}}
287279
/>
288280
);
289281
}
@@ -322,39 +314,9 @@ import RatingSummary from '@keyvaluesystems/react-star-rating-summary';
322314

323315
function App() {
324316

325-
const ratings = {
326-
1: 100,
327-
2: 200,
328-
3: 300,
329-
4: 400,
330-
5: 500
331-
};
332-
333-
const countColors = {
334-
1: 'red',
335-
2: 'yellow',
336-
3: 'blue',
337-
4: 'orange',
338-
5: 'white'
339-
};
340-
341-
const stylesOverride = {
342-
Average: { color: 'purple' },
343-
AverageStarIcon: {
344-
width: '20px',
345-
height: '20px'
346-
},
347-
LabelStarIcon: () => ({
348-
width: '15px',
349-
height: '15px'
350-
}),
351-
Label: (ratingId) => ({ fontSize: '12px' }),
352-
Count: (ratingId) => ({color: countColors[ratingId]})
353-
};
354-
355317
return (
356318
<RatingSummary
357-
ratings={ratings}
319+
ratings={ratingValues}
358320
showAnimation={false}
359321
showCount={false}
360322
averageRatingPrecision={2}

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"url": "git+https://github.com/KeyValueSoftwareSystems/react-star-rating-summary"
2525
},
2626
"author": "Keyvalue",
27-
"license": "ISC",
27+
"license": "MIT",
2828
"homepage": "https://github.com/KeyValueSoftwareSystems/react-star-rating-summary",
2929
"keywords": [
3030
"library",

webpack.config.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,38 @@ const path = require('path');
22
const webpack = require('webpack');
33
const TerserPlugin = require('terser-webpack-plugin');
44
const getPackageJson = require('./scripts/getPackageJson');
5-
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
6-
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
5+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
77

8-
const {
9-
version,
10-
name,
11-
license,
12-
repository,
13-
author,
14-
} = getPackageJson('version', 'name', 'license', 'repository', 'author');
8+
const { version, name, license, repository, author } = getPackageJson(
9+
'version',
10+
'name',
11+
'license',
12+
'repository',
13+
'author'
14+
);
1515

1616
const banner = `
1717
${name} v${version}
1818
${repository.url}
1919
20-
Copyright (c) ${author.replace(/ *<[^)]*> */g, " ")} and project contributors.
20+
Copyright (c) ${author.replace(/ *<[^)]*> */g, ' ')} and project contributors.
2121
2222
This source code is licensed under the ${license} license found in the
2323
LICENSE file in the root directory of this source tree.
2424
`;
2525

2626
module.exports = {
27-
mode: "production",
27+
mode: 'production',
2828
devtool: 'source-map',
2929
entry: './src/index.tsx',
3030
output: {
3131
filename: 'index.js',
3232
path: path.resolve(__dirname, 'build'),
33-
library: "MyLibrary",
33+
library: 'React Star Rating Summary',
3434
libraryTarget: 'umd',
35-
clean: true
35+
clean: true,
36+
globalObject: 'this'
3637
},
3738
externals: {
3839
react: 'react'
@@ -42,7 +43,7 @@ module.exports = {
4243
minimizer: [
4344
new TerserPlugin({ extractComments: false }),
4445
new CssMinimizerPlugin()
45-
],
46+
]
4647
},
4748
module: {
4849
rules: [
@@ -78,6 +79,6 @@ module.exports = {
7879
new webpack.BannerPlugin(banner)
7980
],
8081
resolve: {
81-
extensions: ['.ts', '.js', '.tsx', '.json', ".css", ".scss"]
82+
extensions: ['.ts', '.js', '.tsx', '.json', '.css', '.scss']
8283
}
8384
};

0 commit comments

Comments
 (0)