Skip to content

Commit 9e23aca

Browse files
authored
Merge pull request realvjy#8 from realvjy/dev
Update Read Me + Bug Fix
2 parents 90b93f4 + a021d87 commit 9e23aca

File tree

6 files changed

+130
-86
lines changed

6 files changed

+130
-86
lines changed

.github/workflows/coolshapes.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
steps:
1414
- uses: actions/checkout@v3
15-
- name: Builds and t
15+
- name: Builds and test
1616
uses: actions/setup-node@v3
1717
with:
1818
node-version: 16.x

.github/workflows/release.js.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Publish Package
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: actions/setup-node@v4
11+
with:
12+
node-version: '20.x'
13+
registry-url: 'https://registry.npmjs.org'
14+
- run: npm ci
15+
- run: npm run test
16+
- run: npm run build
17+
- run: npm publish
18+
env:
19+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.DS_Store
22
node_modules
33
dist/
4+
.idea
5+
*.env

README.md

Lines changed: 106 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
1-
[![Coolshapes](https://coolshap.es/react-preview.jpg)](https://coolshap.es)
1+
<a align="center"><img width="100%" src="https://coolshap.es/react-preview.jpg" href="https://coolshap.es"/></a>
22

33
# <p align=center>Coolshapes</p>
44

55
<p align="center">
66
<a href="https://github.com/realvjy/coolshapes-react/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/coolshapes-react" alt="license"></a>
77
<a href="https://www.npmjs.com/package/coolshapes-react"><img src="https://img.shields.io/npm/v/coolshapes-react" alt="npm package"></a>
8-
98
</p>
109

11-
A simple, fun project for the sake of creating some cool-looking abstract shapes with little grainy gradients crafted by [@realvjy](https://x.com/realvjy). Coolshapes is a completely open-source set of 100+ abstract shapes crafted for any design and development projects. Free for both commercial and personal use. Licensed under MIT.
10+
A simple, fun project for the sake of creating some cool-looking abstract shapes with little grainy gradients crafted
11+
by [@realvjy](https://x.com/realvjy). Coolshapes is a completely open-source set of 100+ abstract shapes crafted for any
12+
design and development projects. Free for both commercial and personal use. Licensed under MIT.
1213

1314
### Table of Contents
1415

1516
- [Coolshapes](#coolshapes)
16-
- [Table of Contents](#table-of-contents)
17-
- [Installation](#installation)
18-
- [How to use](#how-to-use)
19-
- [Global component example](#global-component-example)
20-
- [Component with shape category example](#component-with-shape-category-example)
21-
- [Generating random shapes](#generating-random-shapes)
22-
- [Using random shape function](#using-random-shape-function)
23-
- [Other Methods](#other-methods)
24-
- [Renders the shapes from all catagories](#renders-the-shapes-from-all-catagories)
25-
- [syntax](#syntax)
26-
- [Props](#props)
27-
- [Categories](#categories)
28-
- [Others](#others)
29-
- [cjs](#cjs)
30-
- [Figma File](#figma-file)
31-
- [Contributing](#contributing)
32-
- [Support \& Donation](#support--donation)
17+
- [Table of Contents](#table-of-contents)
18+
- [Installation](#installation)
19+
- [How to use](#how-to-use)
20+
- [Global component example](#global-component-example)
21+
- [Shape category components example](#component-with-shape-category-example)
22+
- [Generating random shapes](#generating-random-shapes)
23+
- [Random shape function](#using-random-shape-function)
24+
- [Other Methods](#other-methods)
25+
- [Accessing the shapes object](#renders-the-shapes-from-all-catagories)
26+
- [Props](#props)
27+
- [Categories](#categories)
28+
- [Others](#others)
29+
- [Classname and css](#classnames-and-css)
30+
- [Builds](#builds)
31+
- [Figma File](#figma-file)
32+
- [Credits](#credits)
33+
- [Contributing](#contributing)
34+
- [Support \& Donation](#support--donation)
3335

3436
## Installation
3537

@@ -45,7 +47,8 @@ yarn add coolshapes-react
4547

4648
## How to use
4749

48-
There are two types of components available in **Coolshapes**, which you can use: **Global component** and **Component with a category of shapes**. Then, you can pass additional [props](#props) to adjust the shapes and their properties available on Coolshapes SVG elements.
50+
There are two types of components available in **Coolshapes**, which you can use: **Global component** and **Component
51+
for each category of shapes**. and, you can pass additional [props](#props) to adjust the shapes.
4952

5053
#### Global component example
5154

@@ -55,7 +58,7 @@ Just import the Global component `Coolshape` and it will work.
5558
import { Coolshape } from "coolshapes-react";
5659

5760
const App = () => {
58-
return <Coolshape type="star" index={0} size={48} noise={true} />;
61+
return <Coolshape type="star" index={0} size={48} noise={true}/>;
5962
};
6063

6164
export default App;
@@ -69,30 +72,29 @@ You can import the component for specific category - `Star`,`Ellipse`... etc - a
6972
import { Star } from "coolshapes-react";
7073

7174
const App = () => {
72-
return <Star index={0} size={48} />;
75+
return <Star index={0} size={48}/>;
7376
};
7477

7578
export default App;
7679
```
7780

78-
7981
#### Generating random shapes
8082

81-
setting the `random` [prop](#props) to true or leaving the `index` or `type` prop empty would replace the shape with a random shape every time it renders.
83+
setting the `random` [prop](#props) to true or leaving the `index` or `type` prop empty would replace the shape with a
84+
random shape every time it renders.
8285

8386
```js
8487
// renders a random shape from any category
8588
const Component = () => {
86-
return <Coolshape random={true} />;
89+
return <Coolshape random={true}/>;
8790
};
8891
// renders a shape from the category star
8992
const Component2 = () => {
90-
return <Coolshape type="star" random={true} />;
93+
return <Coolshape type="star" random={true}/>;
9194
};
9295
```
9396

9497
#### Using random shape function
95-
9698
```js
9799
import { getRandomShape } from "coolshapes-react";
98100
```
@@ -127,17 +129,18 @@ const shapes = {
127129
}
128130
```
129131

130-
#### Renders the shapes from all catagories
132+
#### Renders the shapes from all categories
131133

132134
```jsx
133135
import { shapes } from "coolshapes-react";
134136

135137
const ShapeGrid = () => {
136138
return (
137139
<>
138-
{Object.keys(shapes).map((shapeType, _) => {
139-
return shapes[shapeType].map((Shape, index) => {
140-
return <Shape size={48} />;
140+
{
141+
Object.keys(shapes).map((shapeType, _) => {
142+
return shapes[shapeType].map((Shape, index) => {
143+
return <Shape size={48} />;
141144
});
142145
})}
143146
</>
@@ -158,85 +161,106 @@ const StarComponent1 = starComponents[0];
158161

159162
### Props
160163

161-
| name | data type | default | description |
162-
| --------------------- | --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
163-
| `size` | _Number_ | 200 | The dimension of shape |
164-
| [`type`](#categories) | _String_ | random | The category of shapes, if left empty it would randomly select a category. |
165-
| `noise` | _Boolean_ | true | Whether to add noise to the shape or not. |
166-
| `index` | _Number_ | random | The index of shape within the shape [category](#categories), it will randomly select a shape from the category if type prop given. Start from 0. |
167-
| `random` | _Boolean_ | false | If set true it would select a random component |
164+
| name | data type | default | description |
165+
|-----------------------|-----------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
166+
| `size` | _Number_ | 200 | The dimension of shape |
167+
| [`type`](#categories) | _String_ | random | The category of shapes, if left empty it will randomly select a category. |
168+
| `noise` | _Boolean_ | true | Whether to add noise to the shape or not. |
169+
| `index` | _Number_ | random | The index of shape within the shape [category](#categories), it would randomly select a shape from the category if type prop given. index starts from 0. |
170+
| `random` | _Boolean_ | false | If set true it will select a random component |
168171

169-
**Notes:**
170-
Index starts from number 0, so if you want to retrive the first shape of any category, you would use the index number 0.
172+
#### notes
173+
> Index starts from number 0, so if you want to retrieve the first shape of any category, you would use the index number 0.
171174
175+
> The shapes are SVG components behind the hood, so it's also supports all the props that can be passed in a svg element.
172176
### Categories
173177

174178
There are a total of **115** shapes available in Coolshapes under the following categories.
175-
| name | count |
176-
| ------------- | -------- |
177-
| `star` | 13 |
178-
| `triangle` | 14 |
179-
| `moon` | 15 |
180-
| `polygon` | 8 |
181-
| `flower` | 16 |
182-
| `rectangle` | 9 |
183-
| `ellipse` | 12 |
184-
| `wheel` | 7 |
185-
| `misc` | 11 |
186-
| `number` | 10 |
187-
188-
**Note:** When importing the components the name would be capitalized, but when passing as prop, the name would be lower case.
189179

180+
| name | count |
181+
|-------------|-------|
182+
| `star` | 13 |
183+
| `triangle` | 14 |
184+
| `moon` | 15 |
185+
| `polygon` | 8 |
186+
| `flower` | 16 |
187+
| `rectangle` | 9 |
188+
| `ellipse` | 12 |
189+
| `wheel` | 7 |
190+
| `misc` | 11 |
191+
| `number` | 10 |
192+
193+
**Note:** While passing the category name in the component, the name will be in lower case.
190194

191195
### Others
192196

193-
#### Name & Class
194-
All components have inbuilt name starting 1. But, index starts from 0.
195-
*Example: `<Star index={0} />` when rendered it's component name and class name is `Star1`*
197+
#### ClassNames and css
196198

197-
#### umd & es
198-
There are `umd` and `es` included in bundled version of the module,
199+
all the components have classname `coolshapes` assigned as default, but you can also pass custom classname of yours.
200+
```jsx
201+
import { Star } from 'coolshapes-react';
202+
203+
export const Shape = () => {
204+
return(
205+
<Star className={"myshape"}/>
206+
)
207+
}
208+
```
209+
```scss
210+
// make the shapes size responsive similar to img elements.
211+
.coolshapes{
212+
width: 100%;
213+
max-height: 48px;
214+
}
215+
```
216+
#### Builds
217+
218+
We have given `umd`, `es` and `cjs` versions of the build.
199219

200220
#### cjs
201221

202222
```js
203223
const Coolshapes = require("coolshapes-react");
204224
```
205225

206-
using with react in the browser
226+
Using with react in the browser
207227

208228
```html
209229
<!doctype html>
210230
<html>
211-
<head>
212-
<meta charset="UTF-8" />
213-
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
214-
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
215-
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
216-
<script src="https://unpkg.com/coolshapes-react/dist/umd/coolshapes.js"></script>
217-
</head>
218-
<body>
219-
<div id="root"></div>
220-
<script type="text/babel">
221-
const domContainer = document.querySelector("#root");
222-
const root = ReactDOM.createRoot(domContainer);
223-
const coolshapes = window.coolshapes;
224-
const Coolshape = coolshapes.Coolshape;
225-
root.render(<Coolshape />);
226-
</script>
227-
</body>
231+
<head>
232+
<meta charset="UTF-8" />
233+
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
234+
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
235+
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
236+
<script src="https://unpkg.com/coolshapes-react/dist/umd/coolshapes.js"></script>
237+
</head>
238+
<body>
239+
<div id="root"></div>
240+
<script type="text/babel">
241+
const domContainer = document.querySelector("#root");
242+
const root = ReactDOM.createRoot(domContainer);
243+
const coolshapes = window.coolshapes;
244+
const Coolshape = coolshapes.Coolshape;
245+
root.render(<Coolshape />);
246+
</script>
247+
</body>
228248
</html>
229249
```
250+
##### unpkg
251+
```
252+
https://unpkg.com/coolshapes-react/dist/umd/coolshapes.js
253+
```
230254

231255
## Figma File
232256

233257
Figma file coming soon on community
234258

235-
## Contributing
236-
237-
Created by realvjy. You are always welcome to share your feedback on twitter or any social media platform.
259+
## Credits
260+
Crafted by realvjy. You are always welcome to share your feedback on twitter or any other social media platform.
238261

239-
If you want to contribute. Just create a [pull request](https://github.com/realvjy/coolshapes-react/pulls).
262+
## Contributing
263+
If you want to contribute, create a [pull request](https://github.com/realvjy/coolshapes-react/pulls).
240264

241265
## Support & Donation
242266

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
{
4141
"name": "0xgreenapple",
4242
"url": "https://greenapple.one",
43-
"twitter": "https://x.com/0xgreenapple",
4443
"email": "0xgreenapple@gmail.com"
4544
}
4645
],

tests/shape.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { render } from "@testing-library/react";
44
import React, { ForwardRefExoticComponent } from "react";
55
import shapes, { componentId, getRandomShape, shapeTypes } from "../src/shapes";
66
import { ShapeType } from "../src/lib";
7-
import { Coolshape, Star } from "../src/lib/shapes";
7+
import { Coolshape, Star } from "../src";
88

9-
describe("using every icons from the defined component list", async () => {
9+
describe("using every icons from the defined component list", () => {
1010
const shapeTypes = Object.keys(shapes) as Array<shapeTypes>;
1111
shapeTypes.forEach((type) => {
1212
shapes[type].forEach((Shape, i) => {

0 commit comments

Comments
 (0)