Skip to content

Commit 8ed714c

Browse files
authored
V5: API changes (danilowoz#176)
* feat(api): updates background and foreground BREAKING CHANGE: Rename `primaryColor` to `backgroundColor` and `secondaryColor` to `foregroundColor`. * feat(api): updates uniqueKey BREAKING CHANGE: Renamed prop key `uniquekey` to `uniqueKey` * fix(svg): removes unnecessary keys * fix(web svg): adds display name * feat(a11y): improves attrs BREAKING CHANGE: Shift `ariaLabel` to `title` prop, the value remains * refactor(codebase): reestructure * test(web native): updates with new structure * test(native): sets animate false on tests * fix(svg): removes viewBox, width and height from api * fix(presets): updates to new api and some design updates * feat(content loader): sets new default as facebook instead of a box * docs(readme storybook): updates to new api * test(web native): updates
1 parent 06432e2 commit 8ed714c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2260
-1683
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"plugins": ["jest"],
44
"rules": {
55
"@typescript-eslint/interface-name-prefix": "off",
6-
"@typescript-eslint/ban-ts-ignore": "off"
6+
"@typescript-eslint/ban-ts-ignore": "off",
7+
"sort-exports/sort-exports": "off"
78
},
89
"env": {
910
"jest": true

.storybook/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { themes } from '@storybook/theming'
55
addParameters({ options: { theme: themes.normal } })
66

77
addDecorator(storyFn => (
8-
<div style={{ maxWidth: '400px', margin: 'auto', fontFamily: 'sans-serif' }}>
8+
<div style={{ maxWidth: '500px', margin: 'auto', fontFamily: 'sans-serif' }}>
99
{storyFn()}
1010
</div>
1111
))

README.md

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const MyFacebookLoader = () => <Facebook />
6868

6969
```jsx
7070
const MyLoader = () => (
71-
<ContentLoader>
71+
<ContentLoader viewBox="0 0 380 70">
7272
{/* Only SVG shapes */}    
7373
<rect x="0" y="0" rx="5" ry="5" width="70" height="70" />
7474
<rect x="80" y="17" rx="4" ry="4" width="300" height="13" />
@@ -101,7 +101,7 @@ const MyFacebookLoader = () => <Facebook />
101101
import ContentLoader, { Rect, Circle } from 'react-content-loader/native'
102102

103103
const MyLoader = () => (
104-
<ContentLoader>
104+
<ContentLoader viewBox="0 0 380 70">
105105
<Circle cx="30" cy="30" r="30" />
106106
<Rect x="80" y="17" rx="4" ry="4" width="300" height="13" />
107107
<Rect x="80" y="40" rx="3" ry="3" width="250" height="10" />
@@ -115,7 +115,7 @@ const MyLoader = () => (
115115

116116
Defaults to `true`. Opt-out of animations with `false`
117117

118-
#### **`ariaLabel?: string`** - _Web only_
118+
#### **`title?: string`** - _Web only_
119119

120120
Defaults to `Loading interface...`. It's used to describe what element it is. Use ''(empty string) to remove.
121121

@@ -126,61 +126,45 @@ Defaults to an empty string. This prop is common used as: `<ContentLo
126126

127127
#### **`speed?: number`**
128128

129-
Defaults to `2`. Animation speed in seconds.
129+
Defaults to `1.2`. Animation speed in seconds.
130130

131131
#### **`interval?: number`** - _Web only_
132132

133133
Defaults to `0.25`. Interval of time between runs of the animation, as a fraction of the animation speed.
134134

135-
#### **`className?: string`**
136-
137-
Defaults to an empty string. The classname will be set in the `<svg />` element.
138-
139-
#### **`width?: number`**
140-
141-
Defaults to `400`. It will be set in the viewbox attr in the `<svg />`.
142-
143-
#### **`height?: number`**
144-
145-
Defaults to `130`. It will be set in the viewbox attr in the `<svg />`.
146-
147135
#### **`viewBox?: string`**
148136

149-
Use viewBox props to set a custom viewBox value. Additionally, pass viewBox props as empty string to remove viewBox.
137+
Use viewBox props to set a custom viewBox value, for more information about how to use it, read the article [How to Scale SVG](https://css-tricks.com/scale-svg/).
150138

151139
#### **`gradientRatio?: number`** - _Web only_
152140

153-
Defaults to `2`. Width of the animated gradient as a fraction of the viewbox width.
141+
Defaults to `1.2`. Width of the animated gradient as a fraction of the viewbox width.
154142

155143
#### **`rtl?: boolean`**
156144

157145
Defaults to `false`. Content right-to-left.
158146

159-
#### **`preserveAspectRatio?: string`**
160-
161-
Defaults to `xMidYMid meet`. Aspect ratio option of `<svg/>`. See the available options [here](https://github.com/danilowoz/react-content-loader/blob/master/src/interface.ts#L7).
162-
163-
#### **`primaryColor?: string`**
147+
#### **`backgroundColor?: string`**
164148

165-
Defaults to `#f3f3f3` which is used as background of animation.
149+
Defaults to `#f5f6f7` which is used as background of animation.
166150

167-
#### **`secondaryColor?: string`**
151+
#### **`foregroundColor?: string`**
168152

169-
Defaults to `#ecebeb` which is used as the foreground of animation.
153+
Defaults to `#eee` which is used as the foreground of animation.
170154

171-
#### **`primaryOpacity?: number`** - _Web only_
155+
#### **`backgroundOpacity?: number`** - _Web only_
172156

173157
Defaults to `1`. Background opacity (0 = transparent, 1 = opaque) used to solve a issue in [Safari](#safari--ios)
174158

175-
#### **`secondaryOpacity?: number`** - _Web only_
159+
#### **`foregroundOpacity?: number`** - _Web only_
176160

177161
Defaults to `1`. Animation opacity (0 = transparent, 1 = opaque) used to solve a issue in [Safari](#safari--ios)
178162

179163
#### **`style?: React.CSSProperties`**
180164

181165
Defaults to an empty object.
182166

183-
#### **`uniquekey?: string`** - _Web only_
167+
#### **`uniqueKey?: string`** - _Web only_
184168

185169
Defaults to random unique id. Use the same value of prop key, that will solve inconsistency on the SSR, see more [here](https://github.com/danilowoz/react-content-loader/issues/78).
186170

@@ -246,17 +230,14 @@ const MyLoader = () => (
246230
<ContentLoader
247231
height={140}
248232
speed={1}
249-
primaryColor={'#333'}
250-
secondaryColor={'#999'}
233+
backgroundColor={'#333'}
234+
foregroundColor={'#999'}
235+
viewBox="0 0 380 70"
251236
>
252-
    {/* Only SVG shapes */}
253-
    
237+
{/* Only SVG shapes */}
254238
<rect x="0" y="0" rx="5" ry="5" width="70" height="70" />
255-
    
256239
<rect x="80" y="17" rx="4" ry="4" width="300" height="13" />
257-
    
258240
<rect x="80" y="40" rx="3" ry="3" width="250" height="10" />
259-
  
260241
</ContentLoader>
261242
)
262243
```
@@ -306,21 +287,21 @@ Commit messages should follow the [commit message convention](https://con
306287

307288
##### **Alpha is not working: Safari / iOS**
308289

309-
When using `rgba` as a `primaryColor` or `secondaryColor` value, [Safari does not respect the alpha channel](https://github.com/w3c/svgwg/issues/180), meaning that the color will be opaque. To prevent this, instead of using an `rgba` value for `primaryColor`/`secondaryColor`, use the `rgb` equivalent and move the alpha channel value to the `primaryOpacity`/`secondaryOpacity` props.
290+
When using `rgba` as a `backgroundColor` or `foregroundColor` value, [Safari does not respect the alpha channel](https://github.com/w3c/svgwg/issues/180), meaning that the color will be opaque. To prevent this, instead of using an `rgba` value for `backgroundColor`/`foregroundColor`, use the `rgb` equivalent and move the alpha channel value to the `backgroundOpacity`/`foregroundOpacity` props.
310291

311292
```jsx
312293
{/* Opaque color in Safari and iOS */}
313294
<ContentLoader
314-
  primaryColor="rgba(0,0,0,0.06)"
315-
  secondaryColor="rgba(0,0,0,0.12)">
295+
  backgroundColor="rgba(0,0,0,0.06)"
296+
  foregroundColor="rgba(0,0,0,0.12)">
316297

317298

318299
{/_ Semi-transparent color in Safari and iOS _/}
319300
<ContentLoader
320-
    primaryColor="rgb(0,0,0)"
321-
    secondaryColor="rgb(0,0,0)"
322-
    primaryOpacity={0.06}
323-
    secondaryOpacity={0.12}>
301+
    backgroundColor="rgb(0,0,0)"
302+
    foregroundColor="rgb(0,0,0)"
303+
    backgroundOpacity={0.06}
304+
    foregroundOpacity={0.12}>
324305

325306

326307
```

0 commit comments

Comments
 (0)