Skip to content

Commit 48e04b8

Browse files
committed
chore: bump to v1.2.0
1 parent 3687fd3 commit 48e04b8

File tree

9 files changed

+3494
-5791
lines changed

9 files changed

+3494
-5791
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ on: [push]
55
env:
66
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
77
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
8-
NPM_PACKAGE_NAME: 'react-usage-bar'
9-
VERSION: ''
10-
PUBLISHED_VERSION: ''
11-
NODE_VERSION: '18.x'
8+
NPM_PACKAGE_NAME: "react-usage-bar"
9+
VERSION: ""
10+
PUBLISHED_VERSION: ""
11+
NODE_VERSION: "18.x"
1212

1313
jobs:
1414
build-and-test:
@@ -29,8 +29,6 @@ jobs:
2929
run: | # Install npm packages and build the src files
3030
npm install --force
3131
npm run build --if-present
32-
# - name: Semantic release
33-
# run: npx semantic-release
3432
3533
tag-and-npm-publish:
3634
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

README.md

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
![React Usage Bar first example](example.png)
44
![React Usage Bar compact design](example_compact.png)
55

6-
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
7-
![Dependencies](https://img.shields.io/badge/dependencies-up%20to%20date-brightgreen.svg)
8-
![Contributions welcome](https://img.shields.io/badge/contributions-welcome-orange.svg)
6+
![Latest version](https://img.shields.io/npm/v/react-usage-bar?logo=npm)
7+
![Build passing](https://img.shields.io/badge/build-passing-darkgreen.svg)
8+
![Contributions welcome](https://img.shields.io/badge/contributions-welcome-darkorange.svg)
99
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
1010

11+
Display disc sectors, stats and more with this lightweight user-friendly React component.\
12+
Now compatible with [Tailwind](https://tailwindcss.com/).
13+
1114
## 🔌 Installation
1215

1316
Install via npm
@@ -41,15 +44,23 @@ The usage bar needs to receive an array of items. In order to display all the va
4144

4245
### Item type
4346

44-
| Attribute | Type | Required |
45-
| --------- | ------ | -------- |
46-
| value | number | Yes |
47-
| name | string | Yes |
48-
| color | string | No |
47+
| Attribute | Type | Required | |
48+
| ------------ | ------ | -------- | -------------------------------------------------------------------------------------- |
49+
| value | number | Yes | |
50+
| name | string | Yes | |
51+
| color | string | No | |
52+
| className | string | No | ![tailwind compatible](https://img.shields.io/badge/Tailwind-compatible-darkgreen.svg) |
53+
| dotClassName | string | No | ![tailwind compatible](https://img.shields.io/badge/Tailwind-compatible-darkgreen.svg) |
54+
55+
The `value` attribute indicates the amount of space taken up by the sector with a specific `name`. The `color` property can be utilized to define the background color of that particular portion in the bar.
56+
57+
To further customize the sector element, you can apply your own CSS classes or Tailwind classes using the `className` attribute.
4958

50-
The `value` represents the quantity of space occupied by the sector with a certain `name`. The `color` property could be used to specify the background color of that portion in the bar.
59+
In case you are using the **compact layout** and have not specified a `color` value, you can customize the `dotClassName` similarly to the `className` attribute.
5160

52-
The `total` value is also required.
61+
> The defined `color` property value will have a **priority on the background color** defined in the `className` and/or `dotClassName` ones.\
62+
> <br />
63+
> It is recommended to use **exclusively** `color` or one of the two other properties per item.
5364
5465
### Example
5566

@@ -89,25 +100,57 @@ const App = () => {
89100
export default App
90101
```
91102

103+
The `total` prop is also required.
104+
92105
<br>
93106

94107
## Props (Options)
95108

96109
### **showPercentage** | _boolean_ | default: `false`
97110

98-
When true shows the percentage value of all the elements.
111+
When true, shows the percentage value of all the elements.
99112

100-
### **removeLabels** | _boolean_ | default: `false`
113+
### **showLabels** | _boolean_ | default: `true`
101114

102-
When true hides all the tooltips or lables of the items.
115+
When false, hides all the tooltips or lables of the items.
103116

104117
### **darkMode** | _boolean_ | default: `false`
105118

106-
Enables the component to work in dark-mode.
119+
When true, enables the component to work in dark-mode.
107120

108121
### **compactLayout** | _boolean_ | default: `false`
109122

110-
The new compact design. _**Try it**_.
123+
When true, enables the new compact design. _**Try it**_. 😎
124+
125+
### **showFallbackColors** | _boolean_ | default: `false`
126+
127+
When true, this feature dynamically assigns a random color to the background of any items where a value has not been specified
128+
129+
### **errorMessage** | _string_ | default: `Error: Total elements values exceed 100%.`
130+
131+
Customize the error string that appears when the total values of the provided items exceeds 100%.
132+
133+
---
134+
135+
<br>
136+
137+
**Custom classes props:** add custom or Tailwind classes to elements of the component.
138+
139+
### **usageBarContainerClassName** | _string_
140+
141+
Can customize the main div of the component.
142+
143+
### **usageBarClassName** | _string_
144+
145+
Can customize the actual bar element of the component.
146+
147+
### **tooltipClassName** | _string_
148+
149+
Can customize the tooltip div of the item in which are written all the textual info.
150+
151+
### **errorMessageClassName** | _string_
152+
153+
Can customize the style of the error message.
111154

112155
<br>
113156

@@ -156,7 +199,6 @@ The single item represented in the bar. This class is vastly used.
156199
The tooltip of the item in which are written all the textual info.
157200

158201
- `.o-UsageBar__bar__tooltip__percentage` - Used to control the style of the percentage lables.
159-
160202
- `::after` - Is used to make the triangular shape on the bottom (or top) of the tooltips.
161203

162204
### `.o-UsageBar__bar__elements__labels__container`
@@ -185,7 +227,8 @@ $ yarn storybook
185227

186228
## Contribution
187229

188-
If you have a suggestion that would make this component better feel free to open a pull request or create an issue for any bug you find.
230+
If you have a suggestion that would make this component better feel free to fork the project and open a pull request or create an issue for any idea or bug you find.\
231+
Remeber to follow the [Contributing Guidelines](https://github.com/ChrisUser/.github/blob/main/CONTRIBUTING.md).
189232

190233
<br>
191234

package.json

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-usage-bar",
3-
"version": "1.1.22",
3+
"version": "1.2.0",
44
"description": "Usage bar, graphic component for React",
55
"type": "module",
66
"main": "build/index.js",
@@ -38,62 +38,49 @@
3838
"homepage": "http://ChrisUser.github.io/react-usage-bar",
3939
"license": "MIT",
4040
"devDependencies": {
41-
"@babel/core": "^7.22.7",
42-
"@babel/preset-env": "^7.22.7",
43-
"@babel/preset-react": "^7.22.5",
44-
"@babel/preset-typescript": "^7.22.5",
45-
"@storybook/addon-a11y": "^7.0.26",
46-
"@storybook/addon-docs": "^7.0.26",
47-
"@storybook/addon-viewport": "^7.0.26",
48-
"@storybook/react": "^7.0.26",
49-
"@storybook/react-webpack5": "^7.0.26",
50-
"@testing-library/jest-dom": "^5.16.5",
51-
"@testing-library/react": "^14.0.0",
52-
"@types/jest": "^26.0.19",
53-
"@types/react": "^18.2.14",
54-
"@types/react-dom": "^18.2.6",
41+
"@babel/core": "^7.23.3",
42+
"@babel/preset-env": "^7.23.3",
43+
"@babel/preset-react": "^7.23.3",
44+
"@babel/preset-typescript": "^7.23.3",
45+
"@storybook/addon-a11y": "^7.5.3",
46+
"@storybook/addon-docs": "^7.5.3",
47+
"@storybook/addon-viewport": "^7.5.3",
48+
"@storybook/react": "^7.5.3",
49+
"@storybook/react-webpack5": "^7.5.3",
50+
"@testing-library/jest-dom": "^6.1.4",
51+
"@testing-library/react": "^14.1.2",
52+
"@types/jest": "^29.5.10",
53+
"@types/react": "^18.2.38",
54+
"@types/react-dom": "^18.2.17",
5555
"awesome-typescript-loader": "^5.2.1",
56-
"babel-loader": "^9.1.2",
57-
"esbuild": "^0.18.11",
58-
"jest": "^26.0.19",
56+
"babel-loader": "^9.1.3",
57+
"esbuild": "^0.19.7",
58+
"jest": "^29.7.0",
5959
"postcss": "^8.4.24",
6060
"prettier-standard": "^16.3.0",
6161
"react": "^18.2.0",
6262
"react-docgen-typescript-loader": "^3.7.2",
6363
"react-dom": "^18.2.0",
64-
"rollup": "^3.26.1",
64+
"rollup": "^4.5.2",
6565
"rollup-plugin-commonjs": "^10.1.0",
66-
"rollup-plugin-dts": "^5.3.0",
67-
"rollup-plugin-esbuild": "^5.0.0",
66+
"rollup-plugin-dts": "^6.1.0",
67+
"rollup-plugin-esbuild": "^6.1.0",
6868
"rollup-plugin-node-resolve": "^5.2.0",
6969
"rollup-plugin-peer-deps-external": "^2.2.2",
7070
"rollup-plugin-postcss": "^4.0.2",
7171
"rollup-plugin-terser": "^7.0.2",
72-
"rollup-plugin-typescript2": "^0.35.0",
73-
"semantic-release": "^21.0.7",
72+
"rollup-plugin-typescript2": "^0.36.0",
7473
"standard": "^17.1.0",
7574
"standard-prettier": "^1.0.1",
76-
"storybook": "future",
75+
"storybook": "7.5.3",
7776
"ts-jest": "^29.1.1",
78-
"ts-loader": "^9.4.4",
79-
"typescript": "^5.1.6"
77+
"ts-loader": "^9.5.1",
78+
"typescript": "^5.3.2"
8079
},
8180
"peerDependencies": {
8281
"react": "^17",
8382
"react-dom": "^17"
8483
},
85-
"resolutions": {
86-
"minimist": "1.2.6",
87-
"semver": "7.5.2"
88-
},
89-
"plugins": [
90-
"@semantic-release/commit-analyzer",
91-
"@semantic-release/release-notes-generator",
92-
"@semantic-release/changelog",
93-
"@semantic-release/github",
94-
"@semantic-release/npm",
95-
"@semantic-release/git"
96-
],
9784
"jest": {
9885
"preset": "ts-jest",
9986
"testEnvironment": "jsdom",
@@ -114,5 +101,10 @@
114101
"afterAll",
115102
"jest"
116103
]
104+
},
105+
"dependencies": {
106+
"minimist": "1.2.8",
107+
"semver": "7.5.4",
108+
"tslib": "^2.6.2"
117109
}
118110
}

rollup.config.js

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
1-
import typescript from 'rollup-plugin-typescript2'
2-
import commonjs from 'rollup-plugin-commonjs'
3-
import external from 'rollup-plugin-peer-deps-external'
4-
import resolve from 'rollup-plugin-node-resolve'
5-
import postcss from 'rollup-plugin-postcss'
6-
import { terser } from 'rollup-plugin-terser'
1+
import typescript from "rollup-plugin-typescript2"
2+
import commonjs from "rollup-plugin-commonjs"
3+
import external from "rollup-plugin-peer-deps-external"
4+
import resolve from "rollup-plugin-node-resolve"
5+
import postcss from "rollup-plugin-postcss"
6+
import { terser } from "rollup-plugin-terser"
77

8-
import pkg from './package.json' assert { type: "json" }
8+
import pkg from "./package.json" assert { type: "json" }
99

1010
export default {
11-
input: 'src/index.ts',
11+
input: "src/index.ts",
1212
output: [
1313
{
1414
file: pkg.main,
15-
format: 'cjs',
16-
exports: 'named',
17-
sourcemap: true
18-
}
15+
format: "cjs",
16+
exports: "named",
17+
sourcemap: true,
18+
},
1919
],
2020
plugins: [
2121
resolve(),
2222
postcss({
23-
extensions: ['.css'],
24-
extract: true
23+
extensions: [".css"],
24+
extract: true,
2525
}),
2626
external(),
2727
typescript({
28-
rollupCommonJSResolveHack: true,
29-
exclude: ['**/__tests__/**', '**/*.stories.tsx'],
30-
clean: true
28+
exclude: ["**/__tests__/**", "**/*.stories.tsx"],
29+
clean: true,
3130
}),
3231
terser(),
3332
commonjs({
34-
include: ['node_modules/**'],
33+
include: ["node_modules/**"],
3534
namedExports: {
36-
'node_modules/react/react.js': [
37-
'Children',
38-
'Component',
39-
'PropTypes',
40-
'createElement'
35+
"node_modules/react/react.js": [
36+
"Children",
37+
"Component",
38+
"PropTypes",
39+
"createElement",
4140
],
42-
'node_modules/react-dom/index.js': ['render']
43-
}
44-
})
45-
]
41+
"node_modules/react-dom/index.js": ["render"],
42+
},
43+
}),
44+
],
4645
}

src/UsageBar.stories.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ const items = [
3131
},
3232
]
3333

34-
export const lightMode = () => <UsageBar items={items} total={100} />
34+
export const lightMode = () => (
35+
<UsageBar showFallbackColors items={items} total={100} />
36+
)
3537

3638
export const withoutLabels = () => (
3739
<UsageBar showLabels={false} showFallbackColors items={items} total={100} />
@@ -42,11 +44,23 @@ export const withPercentages = () => (
4244
)
4345

4446
export const compactLayout = () => (
45-
<UsageBar showPercentage compactLayout items={items} total={100} />
47+
<UsageBar
48+
showPercentage
49+
showFallbackColors
50+
compactLayout
51+
items={items}
52+
total={100}
53+
/>
4654
)
4755

4856
export const compactLayoutWithoutLabels = () => (
49-
<UsageBar showLabels={false} compactLayout items={items} total={100} />
57+
<UsageBar
58+
showLabels={false}
59+
showFallbackColors
60+
compactLayout
61+
items={items}
62+
total={100}
63+
/>
5064
)
5165

5266
export const error = () => (

0 commit comments

Comments
 (0)