You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+78-5Lines changed: 78 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,41 @@
1
1
# Better rounded corners
2
+
2
3
*for HTML divs in React.js*
3
4
4
-
`react-round-div` makes your rounded rectangles look smoother for a more pleasant feel. With a simple and easy integration into your code you have to do almost nothing to up the style of your project.
5
+
`react-round-div` makes your rounded rectangles look smoother for a more pleasant feel. The package
6
+
weighs [just under 10KB](#size) and has an almost "plug and play"-integration into your code, so that you have to do
7
+
next to nothing to up the style of your project.
5
8
6
9
Here is a very clear demonstration of these smooth corners:
7
10
8
11

9
12
13
+
-[Installation](#installation)
14
+
-[Usage](#usage)
15
+
-[Options](#options)
16
+
- [`dontConvertShadow`](#dontconvertshadow)
17
+
-[Things to note & caveats](#things-to-note--caveats)
18
+
-[Intended differences to the html `<div>`](#intended-differences-to-the-html-div)
Simply import the package and replace any divs with rounded corners (`border-radius`) that you want to improve. `react-round-div` will handle the rest.
35
+
36
+
Simply import the package and replace any divs with rounded corners (`border-radius`) that you want to
37
+
improve. `react-round-div` will handle the rest.
38
+
18
39
```jsx
19
40
importRoundDivfrom'react-round-div';
20
41
@@ -29,8 +50,60 @@ const App = () => {
29
50
exportdefaultApp;
30
51
```
31
52
53
+
Also, [turn off or polyfill `url`, `path`, and `fs`](#webpack)
54
+
55
+
### Options
56
+
57
+
#### `dontConvertShadow`
58
+
59
+
If you have set a `box-shadow` in your CSS, `react-round-div` will convert it to
60
+
a [`drop-shadow()`](https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/drop-shadow()). This happens
61
+
because otherwise, the old rounded corners may shine through. If you want `react-round-div` to not convert
62
+
your `box-shadow`s, add the `dontConvertShadow` option:
63
+
64
+
```jsx
65
+
<RoundDiv dontConvertShadow>
66
+
<p>Content</p>
67
+
</RoundDiv>
68
+
```
69
+
70
+
## Things to note & caveats
71
+
72
+
This package is still in the starting blocks, some cases where it might not behave as expected. For example, some border
73
+
styles are not rendered correctly, and some transitions and animations on the div may not work properly.
74
+
75
+
There are a couple of css properties, that you can't reliably set _inline_ with `RoundDiv`:
76
+
77
+
- the `background` property and all the properties it is a shorthand for
78
+
- the `border`, `border-image`, and all the properties they are a shorthand for
79
+
-`box-shadow`
80
+
-`filter`, if you haven't set [`dontConvertShadow`](#dontconvertshadow)
81
+
82
+
You shouldn't set these properties inline. Instead, set them in a stylesheet. This behaviour may change in future
83
+
versions. The `filter` property in particular will only not work, if you have set a `box-shadow` AND have not
84
+
set [`dontConvertShadow`](#dontconvertshadow). This may also change in future versions.
32
85
33
-
## Caveats
34
-
This package is still in the starting blocks, so for now borders are only supported in the `solid` style and some transitions on the div may not work properly.
86
+
### Intended differences to the html `<div>`
87
+
88
+
Unlike the html `<div>`, `RoundDiv` still rounds the corners of borders of there is a border image set. This looks great with gradients, but might clash with the use of actual images as borders.
89
+
90
+
### webpack
91
+
92
+
If you use a preprocessor like webpack (which you most likely are), you need to turn off or polyfill the node
93
+
modules `url` and `path`, and turn off `fs`. This is due to the module [`css`](https://www.npmjs.com/package/css), which
94
+
uses them. In webpack, you can do this with
95
+
the [`resolve.fallback.<module_name>`](https://webpack.js.org/configuration/resolve/#resolvefallback) option:
96
+
97
+
```javascript
98
+
module.exports= {
99
+
resolve: {
100
+
fallback: {
101
+
path:false,
102
+
url:false,
103
+
fs:false,
104
+
}
105
+
}
106
+
}
107
+
```
35
108
36
-
Moreover, children inside `RoundDiv` get cut off when are placed (partly) outside the div due to `clip-path` being used to make the smooth corners. There will probably an option in later versions to use a pseudo-element for the shape, so that children can be rendered outside.
109
+
If you use `create-react-app`, take a look at [`react-app-rewired`](https://www.npmjs.com/package/react-app-rewired).
0 commit comments