@carbon/icons-react 10.4.0-rc.3 → 10.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +97 -4
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -23,10 +23,10 @@ yarn add @carbon/icons-react
23
23
 
24
24
  Icons in this package support the following sizes: `16`, `20`, `24`, and `32`
25
25
  pixels. These sizes refer to the width and height of the icon. You can import an
26
- icon component into your project by doing one of the following:
26
+ icon component into your project by referring to its name and size:
27
27
 
28
28
  ```jsx
29
- import Add24 from '@carbon/icons-react/es/add/16';
29
+ import { Add24 } from '@carbon/icons-react';
30
30
  ```
31
31
 
32
32
  We also provide CommonJS and UMD files in the `lib` and `umd` directories,
@@ -35,11 +35,104 @@ respectively.
35
35
  To import using CommonJS, you can do the following:
36
36
 
37
37
  ```js
38
- const Add24 = require('@carbon/icons-react/lib/Add/24');
38
+ const { Add24 } = require('@carbon/icons-react');
39
39
  ```
40
40
 
41
41
  _Note: if you would like to find the import path for an icon, you can reference
42
- our [icon preview](https://carbon-elements.netlify.com/icons/examples/preview/)_
42
+ our
43
+ [Icon Library](https://www.carbondesignsystem.com/guidelines/iconography/library)_
44
+
45
+ ### Icon fill
46
+
47
+ All icons from the library support being styled by the `fill` property. You can
48
+ change the color of an icon by passing in a custom class name that sets this
49
+ property (preferred), or by passing in an inline style. For example:
50
+
51
+ ```css
52
+ // CSS custom class name to set the fill of the icon to `rebeccapurple`
53
+ svg.my-custom-class {
54
+ fill: rebeccapurple;
55
+ }
56
+ ```
57
+
58
+ ```jsx
59
+ import { Add16 } from '@carbon/icons-react';
60
+
61
+ function MyComponent() {
62
+ return (
63
+ <button>
64
+ <Add16 aria-label="Add" className="my-custom-class" />
65
+ </button>
66
+ );
67
+ }
68
+ ```
69
+
70
+ #### Two-tone icons
71
+
72
+ Certain icons in the library support two distinct fill colors. You can target
73
+ the inner path by using the `[data-icon-path="inner-path"]` attribute selector.
74
+ For example:
75
+
76
+ ```scss
77
+ // CSS custom class name to set the fill of the icon to `yellow`
78
+ svg.outer-icon-fill {
79
+ fill: yellow;
80
+ }
81
+
82
+ // Use the `data-icon-path` attribute selector to target the inner path
83
+ // where we want to set the fill to `black`. We also set `opacity` to `1` so
84
+ // that this inner-path is visible.
85
+ svg.outer-icon-fill [data-icon-path='inner-path'] {
86
+ fill: black;
87
+ opacity: 1;
88
+ }
89
+ ```
90
+
91
+ ```jsx
92
+ import { WarningFilled16 } from '@carbon/icons-react';
93
+
94
+ function MyComponent() {
95
+ return <WarningFilled16 aria-label="Add" className="my-custom-class" />;
96
+ }
97
+ ```
98
+
99
+ ### Focus and `aria-label`
100
+
101
+ By default, the icon components from `@carbon/icons-react` are treated as
102
+ decorative content. This means that we set `aria-hidden="true"` unless certain
103
+ props are passed to the component.
104
+
105
+ If you would like the icon to be announced by a screen reader, you can supply an
106
+ `aria-label` or `aria-labelledby`. For example:
107
+
108
+ ```jsx
109
+ import { Add16 } from '@carbon/icons-react';
110
+
111
+ function MyComponent() {
112
+ return (
113
+ <button>
114
+ <Add16 aria-label="Add" />
115
+ </button>
116
+ );
117
+ }
118
+ ```
119
+
120
+ Doing this will add the appropriate `role` to the `<svg>` node, as well.
121
+
122
+ If you would like the `<svg>` to receive focus, you will need to pass in a
123
+ `tabIndex` value. For example:
124
+
125
+ ```jsx
126
+ import { Add16 } from '@carbon/icons-react';
127
+
128
+ function MyComponent() {
129
+ return <Add16 aria-label="Add" tabIndex="0" />;
130
+ }
131
+ ```
132
+
133
+ Including `tabIndex` and `aria-label` (or `aria-labelledby`) will set the
134
+ corresponding `tabindex` on the underlying `<svg>` and verify support in older
135
+ browsers like Internet Explorer 11 by setting `focusable` to `true`.
43
136
 
44
137
  ## 🙌 Contributing
45
138
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/icons-react",
3
3
  "description": "React components for icons in digital and software products using the Carbon Design System",
4
- "version": "10.4.0-rc.3",
4
+ "version": "10.4.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -29,14 +29,14 @@
29
29
  "clean": "rimraf es lib umd"
30
30
  },
31
31
  "dependencies": {
32
- "@carbon/icon-helpers": "10.3.0-rc.3"
32
+ "@carbon/icon-helpers": "10.3.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@babel/preset-env": "^7.4.5",
36
36
  "@babel/preset-react": "^7.0.0",
37
- "@carbon/cli-reporter": "10.3.0-rc.3",
38
- "@carbon/icons": "10.4.0-rc.3",
39
- "browserslist-config-carbon": "10.4.0-rc.3",
37
+ "@carbon/cli-reporter": "10.3.0",
38
+ "@carbon/icons": "10.4.0",
39
+ "browserslist-config-carbon": "10.4.0",
40
40
  "change-case": "^3.1.0",
41
41
  "core-js": "^3.1.3",
42
42
  "fs-extra": "^7.0.0",
@@ -50,5 +50,5 @@
50
50
  "rollup-plugin-strip-banner": "^0.2.0"
51
51
  },
52
52
  "sideEffects": false,
53
- "gitHead": "8ff9500b61ec590a2a66f395f227b58cff690849"
53
+ "gitHead": "1a786efd8ef95572699cc00a03bc2858c794ca08"
54
54
  }