Skip to content
This repository was archived by the owner on Jul 7, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ typings/
.fusebox/

composer.phar
/vendor/
/vendor/
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $icons->get('feather', array('class' => 'fooclass', 'stroke-width' => 1, 'aria-l
// <svg ... class="feather feather-feather fooclass", stroke-width="1", aria-label="Battery icon" ... >...</svg>
```

You can also change the default attributes in the `Icons` class if you want some attributes consistent across multiple `get` calls. The passed attributes are merged over the current default attributes in the class by default.
You can also change the default attributes in the `Icons` class if you want some attributes consistent across multiple `get` calls. The passed attributes are merged over the current attributes in the class by default.
```php
$icons->setAttributes(array(
'color' => 'red',
Expand Down Expand Up @@ -94,7 +94,7 @@ doStuffWith($cloud_icon);
<br>

### `Feather\Icons->setAttributes($attributes, $merge = true)`
Sets default attributes of the class. These are used as default attributes for the `get` method. By default, the `$attributes` argument is merged over the current default attributes in the class. You can disable this by setting the `$merge` argument to false, but only do it if you know what you are doing.
Sets default attributes of the class. These are used as default attributes for the `get` method. By default, the `$attributes` argument is merged over the current attributes in the class. You can disable this by setting the `$merge` argument to false, but only do it if you know what you are doing.
```php
$icons = new Feather\Icons;

Expand All @@ -114,7 +114,7 @@ $icons->get('delete');
<br>

### `Feather\Icons->getAttributes()`
Get the current default attributes for the class. To set it, use the `setAttributes()` method;
Get the current attributes for the class. To set it, use the `setAttributes()` method;
```php
$icons = new Feather\Icons;

Expand Down
2 changes: 1 addition & 1 deletion bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let defaultAttrs = null;
Object.keys(feather.icons)
.forEach(key => {
const { name, contents, attrs } = feather.icons[key];

if (defaultAttrs === null) {
defaultAttrs = attrs;
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"phpunit/phpunit": "7"
},
"require": {
"php": ">=5.3.0"
"php": ">=5.6.0"
}
}
8 changes: 3 additions & 5 deletions src/Icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

require __DIR__ . '/defaultAttributes.php';

use Feather\DEFAULT_ATTRIBUTES;

class Icons {
private $attributes = DEFAULT_ATTRIBUTES;

Expand All @@ -25,10 +23,10 @@ public function get($name, $attributes = array(), $echo = true) {
array_keys($attributes),
function($final, $current) use ($attributes) {
$attribute_value = $attributes[$current];

if (is_bool($attribute_value))
$attribute_value = $attribute_value ? 'true' : 'false';

return $final . $current . '="' . (string)$attribute_value . '" ';
}, ''
);
Expand All @@ -43,7 +41,7 @@ function($final, $current) use ($attributes) {
}

public function setAttributes($attributes, $merge = true) {
if ($merge) $this->attributes = array_merge(DEFAULT_ATTRIBUTES, $attributes);
if ($merge) $this->attributes = array_merge($this->attributes, $attributes);
else $this->attributes = $attributes;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/FeatherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public function setUp() {
$this->icons = new Feather\Icons;

// Data from JS

$this->XMLTestData = json_decode(
file_get_contents(__DIR__ . '/XMLTestData.json'),
true
Expand Down Expand Up @@ -59,4 +59,4 @@ public function testIconXMLWithAttributesFromClass() {

$this->icons->setAttributes(Feather\DEFAULT_ATTRIBUTES);
}
}
}
2 changes: 1 addition & 1 deletion tests/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ const testAttributeData = {
fs.writeFileSync(
path.resolve(__dirname, 'AttributeTestData.json'),
JSON.stringify(testAttributeData)
);
);