Skip to content

Commit a7caea4

Browse files
authored
fix(Aria): Option to remove it (#128)
1 parent 84d10dd commit a7caea4

File tree

5 files changed

+1588
-2853
lines changed

5 files changed

+1588
-2853
lines changed

docs/intro.mdx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ const MyFacebookLoader = () => <Facebook />
4949

5050
| <p align="left">Name</p>|<p align="left">Type</p>|<p align="left">Default</p>| <p align="left">Description</p> |
5151
| ----------------------- | ----------- | ---------------------- | ------------------------------------------------------------------------- |
52-
| **animate** | Boolean | true | `false` to render with no animation |
53-
| **ariaLabel** | String | Loading interface... | Describe what element it is |
54-
| **speed** | Number | 2 | Animation speed in seconds |
55-
| **className** | String | '' | Classname in the `<svg/>` |
56-
| **width** | Number | 400 | viewBox width of `<svg/>` |
57-
| **height** | Number | 130 | viewBox height of `<svg/>` |
58-
| **rtl** | Boolean | false | Right-to-left animation |
59-
| **preserveAspectRatio** | String | xMidYMid meet | Aspect ratio option of `<svg/>` |
60-
| **primaryColor** | String | #f3f3f3 | Background |
61-
| **secondaryColor** | String | #ecebeb | Animation color |
62-
| **primaryOpacity** | Number | 1 | Background opacity (0 = transparent, 1 = opaque) |
63-
| **secondaryOpacity** | Number | 1 | Animation opacity (0 = transparent, 1 = opaque) |
64-
| **style** | Object | null | Ex: `{ width: '100%', height: '70px' }` |
65-
| **uniquekey** | String | random unique id | Use the same value of prop key, that will solve inconsistency on the SSR. |
52+
| **animate** | `Boolean` | `true` | `false` to render with no animation |
53+
| **ariaLabel** | `String | Boolean` | `Loading interface...` | Describe what element it is |
54+
| **speed** | `Number` | `2` | Animation speed in seconds |
55+
| **className** | `String` | ` ` | Classname in the `<svg/>` |
56+
| **width** | `Number` | `400` | viewBox width of `<svg/>` |
57+
| **height** | `Number` | `130` | viewBox height of `<svg/>` |
58+
| **rtl** | `Boolean` | `false` | Right-to-left animation |
59+
| **preserveAspectRatio** | `String` | `xMidYMid meet` | Aspect ratio option of `<svg/>` |
60+
| **primaryColor** | `String` | `#f3f3f3` | Background |
61+
| **secondaryColor** | `String` | `#ecebeb` | Animation color |
62+
| **primaryOpacity** | `Number` | `1` | Background opacity (0 = transparent, 1 = opaque) |
63+
| **secondaryOpacity** | `Number` | `1` | Animation opacity (0 = transparent, 1 = opaque) |
64+
| **style** | `Object` | `null` | Ex: `{ width: '100%', height: '70px' }` |
65+
| **uniquekey** | `String` | random unique id | Use the same value of prop key, that will solve inconsistency on the SSR. |

docs/usage.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ Additionally, pass viewBox props as empty string to remove viewBox.
8282
<ContentLoader viewBox="" />
8383
</Playground>
8484

85+
## Custom aria label
86+
<Playground>
87+
<ContentLoader ariaLabel="My custom loader" />
88+
</Playground>
89+
90+
### Remove aria label
91+
<Playground>
92+
<ContentLoader ariaLabel={false} />
93+
</Playground>
94+
8595
## BugFix in Safari
8696
When using `rgba` as a `primaryColor` or `secondaryColor` value,
8797
[Safari does not respect the alpha channel](https://github.com/w3c/svgwg/issues/180),

src/Holder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Svg from "./Svg"
44

55
export type Props = {
66
animate: boolean,
7-
ariaLabel: string,
7+
ariaLabel: string | boolean,
88
className: string,
99
height: number,
1010
preserveAspectRatio: string,

src/Svg.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ export default ({
3939
role="img"
4040
style={style}
4141
className={className}
42-
aria-labelledby={ariaLabel}
42+
aria-labelledby={ariaLabel ? ariaLabel : null}
4343
viewBox={`0 0 ${width} ${height}`}
4444
preserveAspectRatio={preserveAspectRatio}
4545
{...props}
4646
>
47-
<title>{ariaLabel}</title>
47+
{ariaLabel ? <title>{ariaLabel}</title> : null}
4848
<rect
4949
x="0"
5050
y="0"

0 commit comments

Comments
 (0)