Skip to content

Commit 1c15318

Browse files
Merge pull request #5 from drinking-code/v1.3.0
v1.3.0
2 parents 7850c1a + 2998fc7 commit 1c15318

20 files changed

+3278
-15915
lines changed

.babelrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"presets": [
3-
"@babel/react",
4-
"@babel/env"
3+
"@babel/react"
54
],
65
"plugins": [
7-
"@babel/plugin-proposal-class-properties"
6+
"babel-plugin-remove-template-literals-whitespace"
87
],
98
"comments": false
109
}

README.md

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
11
# Better rounded corners
2+
23
*for HTML divs in React.js*
34

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.
58

69
Here is a very clear demonstration of these smooth corners:
710

811
![Figure showing that these corners are very much hunky-dory](img/compare.svg)
912

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)
19+
- [webpack](#webpack)
20+
1021
## Installation
1122

1223
```shell
1324
npm i react-round-div
1425
```
1526

27+
#### Size
28+
29+
| | Gzipped | Minified + Gzipped |
30+
|----------------------------------|---------:|-------------------:|
31+
| `react-round-div` | 7.71 KB | 5.18 KB |
32+
| `react-round-div` + dependencies | 14.88 KB | **9.07 KB** |
33+
1634
## Usage
17-
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+
1839
```jsx
1940
import RoundDiv from 'react-round-div';
2041

@@ -29,8 +50,60 @@ const App = () => {
2950
export default App;
3051
```
3152

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.
3285

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+
```
35108

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

Comments
 (0)