Skip to content

Commit a09b2b3

Browse files
committed
Add support for Font Awesome 5
Resolves #126.
1 parent 1e1364d commit a09b2b3

16 files changed

+220
-67
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,16 @@ All node objects **must** have a unique `value`. This value is serialized into t
8686

8787
#### Changing the Default Icons
8888

89-
By default, **react-checkbox-tree** uses Font Awesome for the various icons that appear in the tree. To change the defaults, simply pass in the `icons` property and override the defaults. Note that you can override as many or as little icons as you like:
89+
By default, **react-checkbox-tree** uses Font Awesome 4 for the various icons that appear in the tree. To utilize Font Awesome 5 icons, simply pass in `iconsClass="fa5"`:
90+
91+
``` jsx
92+
<CheckboxTree
93+
...
94+
iconsClass="fa5"
95+
/>
96+
```
97+
98+
To change the rendered icons entirely, simply pass in the `icons` property and override the defaults. Note that you can override as many or as little icons as you like:
9099

91100
``` jsx
92101
<CheckboxTree
@@ -140,6 +149,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
140149
| `expandDisabled` | bool | If true, the ability to expand nodes will be disabled. | `false` |
141150
| `expandOnClick` | bool | If true, nodes will be expanded by clicking on labels. Requires a non-empty `onClick` function. | `false` |
142151
| `icons` | object | An object containing the mappings for the various icons and their components. See **Changing the Default Icons**. | `{ ... }` |
152+
| `iconsClass` | string | A string that specifies which icons class to utilize. Currently, `'fa4'` and `'fa5'` are supported. | `'fa4'` |
143153
| `id` | string | A string to be used for the HTML ID of the rendered tree and its nodes. | `null` |
144154
| `expanded` | array | An array of expanded node values. | `[]` |
145155
| `lang` | object | An object containing the language mappings for the various text elements. | `{ ... }` |

examples/src/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<meta name="theme-color" content="#3498db">
88
<meta name="description" content="React Checkbox Tree: A simple, yet elegant checkbox treeview for React.">
9-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
10-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
9+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">
10+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css">
1111
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Roboto">
1212
<link rel="stylesheet" href="style.css">
1313
</head>

examples/src/js/BasicExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class BasicExample extends React.Component {
116116
<CheckboxTree
117117
checked={checked}
118118
expanded={expanded}
119+
iconsClass="fa5"
119120
nodes={nodes}
120121
onCheck={this.onCheck}
121122
onExpand={this.onExpand}

examples/src/js/ClickableLabelsExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ class ClickExample extends React.Component {
125125
<CheckboxTree
126126
checked={checked}
127127
expanded={expanded}
128+
iconsClass="fa5"
128129
nodes={nodes}
129130
expandOnClick
130131
onCheck={this.onCheck}

examples/src/js/CustomIconsExample.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ const nodes = [
99
{
1010
value: 'Employee Evaluations.zip',
1111
label: 'Employee Evaluations.zip',
12-
icon: <i className="fa fa-file-archive-o" />,
12+
icon: <i className="far fa-file-archive" />,
1313
},
1414
{
1515
value: 'Expense Report.pdf',
1616
label: 'Expense Report.pdf',
17-
icon: <i className="fa fa-file-pdf-o" />,
17+
icon: <i className="far fa-file-pdf" />,
1818
},
1919
{
2020
value: 'notes.txt',
2121
label: 'notes.txt',
22-
icon: <i className="fa fa-file-text-o" />,
22+
icon: <i className="far fa-file-alt" />,
2323
},
2424
],
2525
},
@@ -71,6 +71,7 @@ class CustomIconsExamples extends React.Component {
7171
<CheckboxTree
7272
checked={checked}
7373
expanded={expanded}
74+
iconsClass="fa5"
7475
nodes={nodes}
7576
onCheck={this.onCheck}
7677
onExpand={this.onExpand}

examples/src/js/DisabledExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class DisabledExample extends React.Component {
117117
checked={checked}
118118
disabled
119119
expanded={expanded}
120+
iconsClass="fa5"
120121
nodes={nodes}
121122
onCheck={this.onCheck}
122123
onExpand={this.onExpand}

examples/src/js/ExpandAllExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class ExpandAllExample extends React.Component {
117117
<CheckboxTree
118118
checked={checked}
119119
expanded={expanded}
120+
iconsClass="fa5"
120121
nodes={nodes}
121122
showExpandAll
122123
onCheck={this.onCheck}

examples/src/js/HiddenCheckboxesExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class HiddenCheckboxesExample extends React.Component {
122122
<CheckboxTree
123123
checked={checked}
124124
expanded={expanded}
125+
iconsClass="fa5"
125126
nodes={nodes}
126127
onlyLeafCheckboxes
127128
onCheck={this.onCheck}

examples/src/js/LargeDataExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class LargeDataExample extends React.Component {
5454
<CheckboxTree
5555
checked={checked}
5656
expanded={expanded}
57+
iconsClass="fa5"
5758
nodes={nodes}
5859
onCheck={this.onCheck}
5960
onExpand={this.onExpand}

examples/src/js/NoCascadeExample.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class NoCascadeExample extends React.Component {
117117
<CheckboxTree
118118
checked={checked}
119119
expanded={expanded}
120+
iconsClass="fa5"
120121
noCascade
121122
nodes={nodes}
122123
onCheck={this.onCheck}

0 commit comments

Comments
 (0)