Skip to content

Commit 46508de

Browse files
Update readme.md
1 parent 6f9516c commit 46508de

File tree

1 file changed

+88
-19
lines changed

1 file changed

+88
-19
lines changed

readme.md

Lines changed: 88 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ composer require husseinalhammad/fontawesome-svg
1212

1313
Or you can download the `FontAwesomeSVG.php` file and include it manually.
1414

15-
1615
## Usage
1716

1817
### Files
1918

20-
* Download Font Awesome (Free or Pro)
21-
* Get the folder `advanced-options/raw-svg` and place it in your project
22-
* Add `svg-with-js/css/fa-svg-with-js` to your document (or write your own CSS)
19+
- Download Font Awesome (Free or Pro)
20+
- Get the folder `advanced-options/raw-svg` and place it in your project
21+
- Add `svg-with-js/css/fa-svg-with-js` to your document (or write your own CSS)
2322

2423
### Examples
2524

@@ -66,15 +65,89 @@ echo $FA->get_svg('fas fa-file', [
6665
]);
6766
```
6867

69-
| Option | What it means |
70-
|-----------------------|--------------------------------------------------------------------------|
71-
| class | Adds classes to the SVG tag |
72-
| default_class | If set to `false`, the default CSS class won't be added to the SVG tag. Deafult: `true`. |
73-
| title | Adds a `<title>` inside the SVG tag for semantic icons |
74-
| title_id | Adds an `id` attribute to `<title>` and adds `aria-labelledby` on the SVG tag with the same value |
75-
| role | The value of the `role` attribute in the SVG tag. Default: `img` |
76-
| fill | The value of the `fill` attribute in the `<path>` inside the SVG. Default: `currentColor` |
68+
Customise duotone icons:
69+
70+
```php
71+
echo $FA->get_svg('fad fa-laugh-wink', [
72+
'primary' => [
73+
'fill' => '#e64980',
74+
],
75+
'secondary' => [
76+
'fill' => '#fcc417',
77+
'opacity' => '1',
78+
],
79+
]);
80+
```
81+
82+
| Option | What it means |
83+
| ------------- | ------------------------------------------------------------------------------------------------- |
84+
| class | Adds classes to the SVG tag |
85+
| default_class | If set to `false`, the default CSS class won't be added to the SVG tag. Deafult: `true`. |
86+
| inline_style | Whether to add duotone styles as inline style to the `<svg>` tag. Deafult: `true`. |
87+
| title | Adds a `<title>` inside the SVG tag for semantic icons |
88+
| title_id | Adds an `id` attribute to `<title>` and adds `aria-labelledby` on the SVG tag with the same value |
89+
| role | The value of the `role` attribute in the SVG tag. Default: `img` |
90+
| fill | The value of the `fill` attribute in the `<path>` inside the SVG. Default: `currentColor` |
91+
| primary | Duotone primary options (see table below) |
92+
| secondary | Duotone secondary options (see table below) |
93+
94+
## Duotone
95+
96+
> Requires **v5.10.0** or greater, and a FontAwesome Pro license
97+
98+
### options
99+
100+
If `inline_style` is enabled, the value of `fill` and `opacity` are also used in the inline style on `<svg>` tag.
101+
102+
| Option | What it means |
103+
| ------- | ----------------------------------------------------------------------------------------- |
104+
| fill | The value of the `fill` attribute in the `<path>` inside the SVG. Default: `currentColor` |
105+
| opacity | The value of the `opacity` attribute in the `<path>` inside the SVG. |
106+
107+
### Examples:
108+
109+
Single colour:
110+
111+
```php
112+
echo $FA->get_svg('fad fa-laugh-wink', [
113+
'fill' => '#e64980',
114+
]);
115+
```
116+
117+
Swapping Layer Opacity:
77118

119+
```php
120+
echo $FA->get_svg('fad fa-laugh-wink', [
121+
'fill' => '#e64980',
122+
'class' => 'fa-swap-opacity',
123+
]);
124+
```
125+
126+
Single colour with custom opacity:
127+
128+
```php
129+
echo $FA->get_svg('fad fa-laugh-wink', [
130+
'fill' => '#e64980',
131+
'secondary' => [
132+
'opacity' => '0.2',
133+
],
134+
]);
135+
```
136+
137+
Custom colours and opacity:
138+
139+
```php
140+
echo $FA->get_svg('fad fa-laugh-wink', [
141+
'primary' => [
142+
'fill' => '#e64980',
143+
'opacity' => '0.5',
144+
],
145+
'secondary' => [
146+
'fill' => '#fcc417',
147+
'opacity' => '1',
148+
],
149+
]);
150+
```
78151

79152
## Accessibility
80153

@@ -83,7 +156,6 @@ The below is implemented based on:
83156
- Font Awesome's [Accessibility docs](https://fontawesome.com/how-to-use/on-the-web/other-topics/accessibility)
84157
- Heather Migliorisi's article on CSS-Tricks [Accessible SVGs](https://css-tricks.com/accessible-svgs/)
85158

86-
87159
### `role` attribute
88160

89161
`role="img"` is added to the SVG tag by default:
@@ -92,7 +164,6 @@ The below is implemented based on:
92164
<svg role="img"></svg>
93165
```
94166

95-
96167
### `<title>`, `aria-labelledby`
97168

98169
You can set a `<title>`, an `id` for the `<title>` and the `aria-labelledby` attribute will be added automatically:
@@ -106,14 +177,13 @@ echo $FA->get_svg('fas fa-file', [
106177

107178
```html
108179
<svg aria-labelledby="file-id">
109-
<title id="file-id">File</title>
180+
<title id="file-id">File</title>
110181
</svg>
111182
```
112183

113-
114184
### `aria-*` attributes
115185

116-
You can add any aria-* attribute to the SVG tag:
186+
You can add any aria-\* attribute to the SVG tag:
117187

118188
```php
119189
echo $FA->get_svg('fas fa-file', [
@@ -125,7 +195,6 @@ echo $FA->get_svg('fas fa-file', [
125195
<svg aria-label="File"></svg>
126196
```
127197

128-
129198
### `aria-hidden` attribute
130199

131200
`aria-hidden="true"` is added to the SVG tag by default unless `<title id="">` (and `aria-labelledby`) or `aria-label` is set.
@@ -136,4 +205,4 @@ echo $FA->get_svg('fas fa-file');
136205

137206
```html
138207
<svg aria-hidden="true"></svg>
139-
```
208+
```

0 commit comments

Comments
 (0)