Skip to content

Commit cde6c4c

Browse files
committed
Update README
1 parent 09e43b7 commit cde6c4c

File tree

4 files changed

+110
-3
lines changed

4 files changed

+110
-3
lines changed

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,98 @@
11
# React Rough Fiber
22

33
![banner](https://user-images.githubusercontent.com/27432981/233581368-3b8bb5e1-5d18-48ff-b0ee-89d78abb7796.png)
4+
5+
`react-rough-fiber` -- A React renderer for rendering hand-drawn SVGs.
6+
7+
## Installation
8+
9+
``` bash
10+
npm install react-rough-fiber react-reconciler
11+
```
12+
13+
> If you are using React 17, you need to install react-reconciler@0.26.2
14+
15+
## Quick Start
16+
17+
To render the SVG in a hand-drawn style, you only need to add three lines of code:
18+
``` js
19+
import { RoughSVG } from 'react-rough-fiber'
20+
export default function App() {
21+
return (
22+
<RoughSVG>
23+
<svg viewBox="0 0 128 128" width="128" height="128">
24+
<circle cx={64} cy={64} r={48} stroke="currentColor" fill="#82ca9d" />
25+
</svg>
26+
</RoughSVG>
27+
)
28+
}
29+
```
30+
31+
## Usage
32+
33+
react-rough-fiber can integrate with many existing SVG-based libraries:
34+
35+
- [Icon](https://react-rough-fiber.amind.app/examples/icon)
36+
- Chart
37+
- [recharts](https://react-rough-fiber.amind.app/examples/chart/recharts)
38+
- [vis](https://react-rough-fiber.amind.app/examples/chart/visx)
39+
- [react-d3-tree](https://react-rough-fiber.amind.app/examples/chart/react-d3-tree)
40+
- [Text](https://react-rough-fiber.amind.app/examples/text)
41+
- [SVG string](https://react-rough-fiber.amind.app/examples/svg-string)
42+
- [Remove SVG](https://react-rough-fiber.amind.app/examples/remote-svg)
43+
- [Emoji](https://react-rough-fiber.amind.app/examples/emoji)
44+
45+
## API
46+
47+
[Full Documentation](https://react-rough-fiber.amind.app/apis).
48+
49+
### RoughSVG
50+
51+
``` jsx
52+
import { RoughSVG } from "react-rough-fiber";
53+
// ... your component code
54+
<RoughSVG containerType="div" options={options}>
55+
{/* your SVG */}
56+
</RoughSVG>
57+
```
58+
59+
- containerType = 'div': The type of container to use for the `RoughSVG`. Optional.
60+
- options: RoughOptions | ((shape: SVGShape, props: React.HTMLAttributes<SVGElement>) => RoughOptions = {}. It can be a `RoughOptions` for [Rough.js](https://github.com/rough-stuff/rough/wiki#options). Also support a function that returns `RoughOptions`. Optional
61+
62+
### WCRoughSVG
63+
64+
> `WCRoughSVG` is only compatible with React version 18.0.0 or later.
65+
66+
If you want to use context in `RoughSVG`, you can use `WCRoughSVG` instead of `RoughSVG`. See [FAQ](https://react-rough-fiber.amind.app/faq) for more details.
67+
68+
All parameters of `WCRoughSVG` are identical to `RoughSVG`.
69+
70+
## Development
71+
72+
This library is a monorepo project. The core package can be found under `/packages/react-rough-fiber`, and the docs are under `/apps/docs`
73+
74+
- clone this repo
75+
- run `pnpm install` to install dependencies
76+
- run `pnpm dev`, and open `localhost:3000` to view the documentation.
77+
- run `pnpm test` to run tests.
78+
79+
PRs are welcome!
80+
81+
## Showcases
82+
83+
- [Add your project by creating a PR](https://github.com/Bowen7/react-rough-fiber/pulls)
84+
85+
## Credits
86+
87+
react-rough-fiber is powered or inspired by these open source projects:
88+
89+
- [roughjs](https://github.com/rough-stuff/rough)
90+
- [nextra](https://github.com/shuding/nextra)
91+
- [perfect-freehand](https://github.com/steveruizok/perfect-freehand)
92+
- [react-three-fiber](https://github.com/pmndrs/react-three-fiber)
93+
- [preact](https://github.com/preactjs/preact)
94+
- [shadcn/ui](https://github.com/shadcn/ui)
95+
96+
## License
97+
98+
MIT

apps/docs/pages/apis.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ import { FilStyleDemo } from "../components/demos/fillStyle"
88
``` jsx
99
import { RoughSVG } from "react-rough-fiber";
1010
// ... your component code
11-
<RougSVG containerType="div" options={options}>
11+
<RoughSVG containerType="div" options={options}>
1212
{/* your SVG */}
1313
</RoughSVG>
1414
```
1515

1616
### Parameters
1717

1818
- **containerType**:
19-
`string: = 'div'{:ts}` The type of container to use for the `RoughSVG`.
19+
`string: = 'div'{:ts}` The type of container to use for the `RoughSVG`. Optional.
2020
- **options**:
2121
`RoughOptions | ((shape: SVGShape, props: React.HTMLAttributes<SVGElement>) => RoughOptions) = {}{:ts}`
2222
It can be a `RoughOptions` for [Rough.js](https://github.com/rough-stuff/rough/wiki#options).
23-
Also support a function that returns `RoughOptions`.
23+
Also support a function that returns `RoughOptions`. Optional.
2424

2525
#### RoughOptions
2626

apps/docs/pages/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export default function App() {
6969

7070
## Usage
7171

72+
react-rough-fiber can integrate with many existing SVG-based libraries:
73+
7274
### Icons
7375

7476
<IconDemo />

assets/simply-circle.svg

Lines changed: 10 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)