Skip to content

Commit dfe6373

Browse files
authored
feat:Improvised component and added relevant templates (#11) (#12)
* Updated test files, storybook, readme and some code refactoring (#11) * Renamed few functions and variables * Updated storybook readme and test files * Updated the codesandbox link and email * Formatted the files and readme changes * Added pull request template and style guidelines * Added version and prettier config in package.json * Fixed bug in the initial width calculation * fix: package version change
1 parent 0006788 commit dfe6373

19 files changed

+595
-311
lines changed

.eslintrc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"plugins": [
1616
"@typescript-eslint",
1717
"react",
18-
"react-hooks"
18+
"react-hooks",
19+
"import"
1920
],
2021
"rules": {
2122
"no-console": "warn",
@@ -32,7 +33,21 @@
3233
"prefer-spread": ["off"],
3334
"react-hooks/exhaustive-deps": "off",
3435
"arrow-parens": "error",
35-
"arrow-spacing": "error"
36+
"arrow-spacing": "error",
37+
"sort-imports": ["error", {"ignoreCase": true, "ignoreDeclarationSort": true}],
38+
"import/order": [
39+
"error",
40+
{ "groups":
41+
[
42+
"external",
43+
"builtin",
44+
"internal",
45+
"parent",
46+
"sibling",
47+
"index"
48+
]
49+
}
50+
]
3651
},
3752
"settings": {
3853
"react": {

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ node_modules
88
build
99
dist
1010
.rpt2_cache
11+
coverage
1112

1213
# misc
1314
.DS_Store

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
5555
## Enforcement
5656

5757
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58-
reported by contacting the project team at [email protected]. All
58+
reported by contacting the project team at [email protected]. All
5959
complaints will be reviewed and investigated and will result in a response that
6060
is deemed necessary and appropriate to the circumstances. The project team is
6161
obligated to maintain confidentiality with regard to the reporter of an incident.

PULL_REQUEST_TEMPLATE.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!-- Thank you for contributing to @keyvaluesystems/react-dot-matrix-chart! -->
2+
<!-- Before submitting a pull request, please review our contributing guidelines. -->
3+
4+
5+
6+
## Pull Request Checklist
7+
8+
9+
10+
- [ ] **Read the contributing guidelines.**
11+
- [ ] **Linked to an issue:** Fixes # (replace with the issue number, if applicable)
12+
- [ ] **Branch is up-to-date with the base branch:** `main`
13+
- [ ] **Changes pass tests locally:** `npm test` or `yarn test`
14+
- [ ] **Documentation has been updated, if necessary**
15+
- [ ] **Code follows the style guide of the project**
16+
17+
18+
## Description
19+
20+
21+
22+
<!-- Provide a brief description of your changes. -->
23+
24+
25+
26+
## Screenshots (if applicable)
27+
28+
29+
30+
<!-- Add screenshots or GIFs to help explain your changes. -->
31+
32+
33+
34+
## Additional Notes
35+
36+
37+
38+
<!-- Any additional information you want to provide that is not covered by the checklist or description. -->
39+
40+
41+
42+
## Related Issues or PRs
43+
44+
45+
46+
<!-- If your pull request is related to any issue(s) or other pull request(s), mention them here. -->
47+
48+
49+
50+
## Reviewer Guidelines
51+
52+
53+
54+
<!-- Suggest specific areas of the codebase that you would like the reviewer to focus on. -->
55+
56+
57+
58+
## Testing Instructions
59+
60+
61+
62+
<!-- Provide step-by-step instructions on how to test your changes. -->
63+
64+
65+
66+
## Checklist for Reviewers
67+
68+
69+
70+
- [ ] Code follows project conventions and style
71+
- [ ] Changes do not introduce new warnings or errors
72+
- [ ] Unit tests cover the changes
73+
- [ ] Documentation is updated
74+
75+
76+
## By submitting this pull request, I confirm that my contribution is made under the terms of the MIT License.

README.md

Lines changed: 41 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
2-
3-
4-
51
# React Dot Matrix Chart
62

73
<a href="https://www.npmjs.com/package/@keyvaluesystems/react-dot-matrix-chart"><img src="https://badgen.net/npm/v/@keyvaluesystems/react-dot-matrix-chart?color=blue" alt="npm version"></a> <a href="https://www.npmjs.com/package/@keyvaluesystems/react-dot-matrix-chart" ><img src="https://img.shields.io/npm/dw/@keyvaluesystems/react-dot-matrix-chart?label=Downloads" /></a> <a href="https://github.com/KeyValueSoftwareSystems/react-dot-matrix-chart"><img src="https://github.com/KeyValueSoftwareSystems/react-dot-matrix-chart/actions/workflows/deploy.yml/badge.svg" alt="" /></a>
@@ -10,10 +6,9 @@
106
<img src="./screenshot.png" alt="" width="573" height="199"/>
117
</div>
128

13-
14-
>A customizable ready to use Dot Matrix Chart Component for React
9+
> A customizable ready to use Dot Matrix Chart Component for React
1510
16-
Try tweaking a dot matrix using this codesandbox link <a href="https://codesandbox.io/s/dot-matrix-chart-hqw9z0" >here</a>
11+
Try tweaking a dot matrix using this codesandbox link <a href="https://codesandbox.io/s/dot-matrix-chart-996cd3" >here</a>
1712

1813
## Installation
1914

@@ -25,85 +20,64 @@ npm install @keyvaluesystems/react-dot-matrix-chart
2520

2621
You’ll need to install React separately since it isn't included in the package.
2722

28-
29-
3023
## Usage
3124

32-
33-
3425
React Dot Matrix Chart can run in a very basic mode by just providing the `dataPoints` like given below:
3526

3627
```jsx
28+
import DotMatrix from "@keyvaluesystems/react-dot-matrix-chart";
3729

38-
import DotMatrix from '@keyvaluesystems/react-dot-matrix-chart';
39-
40-
<DotMatrix
41-
dataPoints={dataPointsArray}
42-
/>
43-
30+
<DotMatrix dataPoints={dataPointsArray} />;
4431
```
4532

4633
The datapoints is an array of objects with the following keys:
4734

48-
- `name` - a string that represents each category
49-
- `count` - a number to specify the count of each category present(used to find the number of dots to be displayed)
50-
- `color` - a string to specify which colour to be used to represent the category in the dot matrix
51-
52-
35+
- `name` - a string that represents each category
36+
- `count` - a number to specify the count of each category present(used to find the number of dots to be displayed)
37+
- `color` - a string to specify which colour to be used to represent the category in the dot matrix
5338

5439
An example for dataPoints array is shown below:
5540

5641
```jsx
5742
const dataPointsArray = [
5843
{
59-
name: 'Category 1',
44+
name: "Category 1",
6045
count: 10,
61-
color: 'gray'
46+
color: "gray"
6247
},
6348
{
64-
name: 'Category 2',
49+
name: "Category 2",
6550
count: 10,
66-
color: 'black'
51+
color: "black"
6752
},
6853
{
69-
name: 'Category 3',
54+
name: "Category 3",
7055
count: 10,
71-
color: 'green'
56+
color: "green"
7257
}
7358
];
74-
7559
```
7660

7761
You can specify the number of rows or columns to be present in the chart as well using the dimensions prop.
7862

7963
```jsx
8064
<DotMatrix
8165
dataPoints={dataPointsArray}
82-
dimensions={
66+
dimensions={{
8367
rows: 5,
8468
columns: 10
85-
}
69+
}}
8670
/>
8771
```
8872

8973
If the count given in the dataPoints array results in a partial percentage (decimal value), a gradient dot will be displayed as shown below
74+
9075
<div align="center">
9176
<img src="./screenshotPartial.png" alt="" width="208" height="199"/>
9277
</div>
9378

94-
We can also control the display of the legend consisting of the details regarding the colour distribution using the props 'showLegend' and 'legendPosition' as follows.
95-
96-
```jsx
97-
<DotMatrix
98-
dataPoints={dataPointsArray}
99-
showLegend={true}
100-
legendPosition="top"
101-
/>
102-
```
10379
## Props
10480

105-
106-
10781
Props that can be passed to the component are listed below:
10882

10983
<table>
@@ -130,11 +104,11 @@ Props that can be passed to the component are listed below:
130104
<td><code>{ rows: 5, columns: 12 }</code></td>
131105
</tr>
132106
<tr>
133-
<td><code><b>styles?:</b> object</code></td>
107+
<td><code><b>spaceBetweenDots?:</b> number</code></td>
134108
<td>
135-
Provides you with a bunch of callback functions to override the default styles.
109+
To specify the distance between each dot
136110
</td>
137-
<td><code>undefined</code></td>
111+
<td><code>4</code></td>
138112
</tr>
139113
<tr>
140114
<td><code><b>showLegend?:</b> boolean</code></td>
@@ -144,16 +118,22 @@ Props that can be passed to the component are listed below:
144118
<td><code>false</code></td>
145119
</tr>
146120
<tr>
147-
<td><code><b>legendPosition?:</b> string</code></td>
121+
<td><code><b>legendPosition?:</b> 'left' | 'left-start' | 'left-end | 'right' | 'right-start' | 'right-end' | 'top'| 'top-start' | 'top-bottom' | 'bottom' | 'bottom-start' | 'bottom-end' </code></td>
148122
<td>
149-
To specify the position of the legend. The values that can be passed using this prop are 'left', 'right', 'top' and 'bottom'
123+
To specify the position of the legend.
150124
</td>
151-
<td><code>right</code></td>
125+
<td><code>right-end</code></td>
126+
</tr>
127+
<tr>
128+
<td><code><b>styles?:</b> object</code></td>
129+
<td>
130+
Provides you with a bunch of callback functions to override the default styles.
131+
</td>
132+
<td><code>undefined</code></td>
152133
</tr>
153134
</tbody>
154135
</table>
155136

156-
157137
## Style Customizations
158138

159139
All the default styles provided by this package are overridable using the `styles` prop.
@@ -163,20 +143,19 @@ the below code shows all the overridable styles:
163143
<DotMatrix
164144
dataPoints={dataPointsArray}
165145
styles={{
166-
Container: () => ({...styles}),
167-
DotsContainer: () => ({...styles}),
168-
Dot: () => ({...styles}),
169-
LegendContainer: () => ({...styles}),
170-
LegendName: () => ({...styles}),
171-
LegendDot: () => ({...styles})
146+
Container: () => ({ ...styles }),
147+
DotsContainer: () => ({ ...styles }),
148+
Dot: () => ({ ...styles }),
149+
LegendContainer: () => ({ ...styles }),
150+
LegendName: () => ({ ...styles }),
151+
LegendDot: () => ({ ...styles })
172152
}}
173153
/>
174-
175154
```
176155

177-
- `Container` - overrides the dot matrix chart container style
178-
- `DotsContainer` - overrides the dot matrix chart dots container style
179-
- `Dot` - overrides the style of each dot in the chart
180-
- `LegendContainer` - overrides the legend (details) container style
181-
- `LegendName` - overrides the legend name style
182-
- `LegendDot` - overrides the legend dot style
156+
- `Container` - overrides the dot matrix chart container style
157+
- `DotsContainer` - overrides the dot matrix chart dots container style
158+
- `Dot` - overrides the style of each dot in the chart
159+
- `LegendContainer` - overrides the legend (details) container style
160+
- `LegendName` - overrides the legend name style
161+
- `LegendDot` - overrides the legend dot style

STYLE_GUIDELINES.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## SCSS Style Guidelines for @keyvaluesystems/react-dot-matrix-chart
2+
3+
**Introduction**
4+
5+
As an open-source project utilizing SCSS, @keyvaluesystems/react-dot-matrix-chart strives to maintain a consistent and well-structured codebase. These SCSS style guidelines serve as a reference for contributors, ensuring that their SCSS code adheres to established conventions and best practices.
6+
7+
**SCSS Coding Conventions**
8+
9+
- Organize SCSS files into a logical structure.
10+
- Use meaningful and descriptive names for variables, mixins, and classes.
11+
- Use SCSS nesting judiciously to organize complex styles.
12+
- Include comments to explain non-obvious logic and complex styles.
13+
- Utilize SCSS variables to define reusable values.
14+
- Employ a SCSS linting tool.
15+
- Should support devices with all resolutions.
16+
- Follow CamelCase conventions for class names that concisely convey their purpose, enhancing code organization and readability.
17+
- Adhere to the practice of reusing style classes to improve code organization and maintainability.
18+
19+
**Documentation Practices**
20+
21+
- Provide clear documentation for exported mixins and variables.
22+
- Include a README file within the SCSS directory if necessary.
23+
- Add comments to SCSS files.

package-lock.json

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
"ts-loader": "^9.4.2",
7878
"typescript": "^4.9.5",
7979
"url-loader": "^4.1.1",
80-
"uuid": "^9.0.0",
8180
"webpack": "^5.75.0",
8281
"webpack-cli": "^5.0.1",
8382
"webpack-dev-server": "4.11.1",
@@ -92,6 +91,9 @@
9291
"eslintConfig": {
9392
"extends": "./.eslintrc.json"
9493
},
94+
"prettier": {
95+
"trailingComma": "none"
96+
},
9597
"jest": {
9698
"moduleNameMapper": {
9799
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/scripts/testMock.js",

0 commit comments

Comments
 (0)