|
| 1 | +--- |
| 2 | +name: Props |
| 3 | +route: /props |
| 4 | +--- |
| 5 | + |
| 6 | +import { Playground, PropsTable } from 'docz' |
| 7 | +import ContentLoader, { Facebook, Instagram } from '../src' |
| 8 | + |
| 9 | +## `animate?: boolean` |
| 10 | + |
| 11 | +Defaults to `true`. Opt-out of animations with `false` |
| 12 | + |
| 13 | +<Playground> |
| 14 | + <Facebook animate={false} /> |
| 15 | +</Playground> |
| 16 | + |
| 17 | +## `ariaLabel? string | boolean` |
| 18 | + |
| 19 | +Defaults to `Loading interface...`. It's used to describe what element it is. Use `false` to remove. |
| 20 | + |
| 21 | +<Playground> |
| 22 | + <Facebook ariaLabel="my custom loader" /> |
| 23 | +</Playground> |
| 24 | + |
| 25 | +## `speed?: number` |
| 26 | + |
| 27 | +Defaults to `2`. Animation speed in seconds. |
| 28 | + |
| 29 | +<Playground> |
| 30 | + <Facebook speed={4} /> |
| 31 | + <Facebook speed={1} /> |
| 32 | +</Playground> |
| 33 | + |
| 34 | +## `interval?: number` |
| 35 | + |
| 36 | +Defaults to `0.25`. Interval of time between runs of the animation, as a fraction of the animation speed. |
| 37 | + |
| 38 | +<Playground> |
| 39 | + <Facebook interval={0.8} /> |
| 40 | +</Playground> |
| 41 | + |
| 42 | +## `className? string` |
| 43 | + |
| 44 | +Defaults to an empty string. The classname will be set in the `<svg />` element. |
| 45 | + |
| 46 | +<Playground> |
| 47 | + <Facebook className="custom-classname" /> |
| 48 | +</Playground> |
| 49 | + |
| 50 | +## `width? number` |
| 51 | + |
| 52 | +Defaults to `400`. It will be set in the viewbox attr in the `<svg />`. |
| 53 | + |
| 54 | +<Playground> |
| 55 | + <Facebook width={200} /> |
| 56 | +</Playground> |
| 57 | + |
| 58 | +## `height? number` |
| 59 | + |
| 60 | +Defaults to `130`. It will be set in the viewbox attr in the `<svg />`. |
| 61 | + |
| 62 | +<Playground> |
| 63 | + <Facebook height={50} /> |
| 64 | +</Playground> |
| 65 | + |
| 66 | +## `gradientRatio? number` |
| 67 | + |
| 68 | +Defaults to `2`. Width of the animated gradient as a fraction of the viewbox width. |
| 69 | + |
| 70 | +<Playground> |
| 71 | + <Instagram |
| 72 | + gradientRatio={0.2} |
| 73 | + primaryColor={'#333'} |
| 74 | + secondaryColor={'#999'} |
| 75 | + /> |
| 76 | + <Instagram gradientRatio={4} primaryColor={'#333'} secondaryColor={'#999'} /> |
| 77 | +</Playground> |
| 78 | + |
| 79 | +## `rtl? boolean` |
| 80 | + |
| 81 | +Defaults to `false`. Content right-to-left. |
| 82 | + |
| 83 | +<Playground> |
| 84 | + <Instagram rtl /> |
| 85 | +</Playground> |
| 86 | + |
| 87 | +## `preserveAspectRatio?: string` |
| 88 | + |
| 89 | +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). |
| 90 | + |
| 91 | +<Playground> |
| 92 | + <Instagram preserveAspectRatio="none" /> |
| 93 | +</Playground> |
| 94 | + |
| 95 | +## `primaryColor?: string` |
| 96 | + |
| 97 | +Defaults to `#f3f3f3` which is used as background of animation. |
| 98 | + |
| 99 | +<Playground> |
| 100 | + <Facebook primaryColor="#333" /> |
| 101 | +</Playground> |
| 102 | + |
| 103 | +## `secondaryColor?: string` |
| 104 | + |
| 105 | +Defaults to `#ecebeb` which is used as the placeholder/layer of animation. |
| 106 | + |
| 107 | +<Playground> |
| 108 | + <Facebook secondaryColor="#333" /> |
| 109 | +</Playground> |
| 110 | + |
| 111 | +## `primaryOpacity?: string` |
| 112 | + |
| 113 | +Defaults to `1`. Background opacity (0 = transparent, 1 = opaque) used to solve a issue in [Safari](#bugfix-in-safari) |
| 114 | + |
| 115 | +<Playground> |
| 116 | + <Facebook primaryOpacity={0.06} /> |
| 117 | +</Playground> |
| 118 | + |
| 119 | +## `secondaryOpacity?: string` |
| 120 | + |
| 121 | +Defaults to `1`. Animation opacity (0 = transparent, 1 = opaque) used to solve a issue in [Safari](#bugfix-in-safari) |
| 122 | + |
| 123 | +<Playground> |
| 124 | + <Facebook secondaryOpacity={0.06} /> |
| 125 | +</Playground> |
| 126 | + |
| 127 | +## `style?: React.CSSProperties` |
| 128 | + |
| 129 | +Defaults to an empty object. |
| 130 | + |
| 131 | +<Playground> |
| 132 | + <Facebook style={{ width: '100%' }} /> |
| 133 | +</Playground> |
| 134 | + |
| 135 | +## **`uniquekey?: string`** |
| 136 | + |
| 137 | +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). |
| 138 | + |
| 139 | +<Playground> |
| 140 | + <Facebook uniquekey="my-uniqye-key" /> |
| 141 | +</Playground> |
| 142 | + |
| 143 | +## `viewBox?: string` |
| 144 | + |
| 145 | +Use viewbox props to set viewbox value. |
| 146 | +Additionally, pass viewBox props as empty string to remove viewBox. |
| 147 | + |
| 148 | +<Playground> |
| 149 | + <ContentLoader viewBox="" /> |
| 150 | +</Playground> |
| 151 | + |
| 152 | +# Issues known |
| 153 | + |
| 154 | +## BugFix in Safari |
| 155 | + |
| 156 | +When using `rgba` as a `primaryColor` or `secondaryColor` value, |
| 157 | +[Safari does not respect the alpha channel](https://github.com/w3c/svgwg/issues/180), |
| 158 | +meaning that the color will be opaque. To prevent this, instead of using an |
| 159 | +`rgba` value for `primaryColor`/`secondaryColor`, use the `rgb` equivalent and |
| 160 | +move the alpha channel value to the `primaryOpacity`/`secondaryOpacity` props. |
| 161 | + |
| 162 | +<Playground> |
| 163 | + <ContentLoader |
| 164 | + primaryColor="rgb(0,0,0)" |
| 165 | + secondaryColor="rgb(0,0,0)" |
| 166 | + primaryOpacity={0.06} |
| 167 | + secondaryOpacity={0.12} |
| 168 | + /> |
| 169 | +</Playground> |
0 commit comments