Skip to content

Commit 40cf359

Browse files
authored
Merge pull request #8 from ouun/master
* enhance(sagesvg): Allow setting default SVG 'attributes' via config file * chore(deps): Bump dependencies * chore(license): Bump license year * chore(deps): Bump minimum PHP version to match Acorn
2 parents 074f8e1 + 7946b74 commit 40cf359

File tree

7 files changed

+37
-11
lines changed

7 files changed

+37
-11
lines changed

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Brandon Nifong
3+
Copyright (c) 2020 Brandon Nifong
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
![CircleCI](https://img.shields.io/circleci/build/gh/Log1x/sage-svg.svg?style=flat-square)
55
[![Total Downloads](https://poser.pugx.org/log1x/sage-svg/downloads)](https://packagist.org/packages/log1x/sage-svg)
66

7-
Sage SVG is a simple package for using inline SVGs in your Sage 10 projects.
7+
Sage SVG is a simple package for using inline SVGs in your Sage 10 projects.
88

99
## Requirements
1010

1111
- [Sage](https://github.com/roots/sage) >= 10.0
12-
- [PHP](https://secure.php.net/manual/en/install.php) >= 7.2
12+
- [PHP](https://secure.php.net/manual/en/install.php) >= 7.2.5
1313
- [Composer](https://getcomposer.org/download/)
1414

1515
## Installation
@@ -56,7 +56,7 @@ $image = get_svg('app/uploads/2019/07/logo.svg', 'w-32 h-auto');
5656
$image = get_svg(
5757
get_field('logo_svg'),
5858
'my-logo'
59-
);
59+
);
6060
```
6161

6262
### App Container

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
]
2727
},
2828
"require": {
29-
"php": ">=7.2"
29+
"php": ">=7.2.5"
3030
},
3131
"require-dev": {
3232
"squizlabs/php_codesniffer": "^3.5"

composer.lock

+7-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/svg.php

+14
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@
3030

3131
'class' => '',
3232

33+
/*
34+
|--------------------------------------------------------------------------
35+
| Attributes
36+
|--------------------------------------------------------------------------
37+
|
38+
| Here you can specify default attributes to be added on all inlined SVGs.
39+
| ↪ <https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute>
40+
|
41+
*/
42+
43+
'attributes' => [
44+
// 'stroke-width' => '1.5',
45+
],
46+
3347
/*
3448
|--------------------------------------------------------------------------
3549
| Directives

src/SageSvg.php

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class SageSvg
2626
'path' => '',
2727
'class' => '',
2828
'directives' => '',
29+
'attributes' => [],
2930
];
3031

3132
/**
@@ -161,6 +162,11 @@ protected function buildClass($class)
161162
*/
162163
protected function buildAttributes($attrs = [])
163164
{
165+
$attrs = array_merge(
166+
$this->config->get('attributes', []),
167+
$attrs
168+
);
169+
164170
if (empty($attrs)) {
165171
return '';
166172
}

src/helpers.php

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
/**
4+
* Sage SVG Helpers
5+
*/
6+
37
use Log1x\SageSvg\SageSvg;
48

59
use function Roots\app;
@@ -12,6 +16,7 @@
1216
* @param array $attrs
1317
* @return string
1418
*/
19+
1520
if (! function_exists('get_svg')) {
1621
function get_svg($image, $class = '', $attrs = [])
1722
{

0 commit comments

Comments
 (0)