diff --git a/config/blade-svg.php b/config/blade-svg.php
index b8e3d5c..e433eca 100644
--- a/config/blade-svg.php
+++ b/config/blade-svg.php
@@ -4,24 +4,24 @@
/*
|--------------------------------------------------------------------------
- | Icon Path
+ | SVG Path
|--------------------------------------------------------------------------
|
- | This value is the path to the directory of individual SVG icons. This
+ | This value is the path to the directory of individual SVG files. This
| path is then resolved internally. Please ensure that this value is
| set relative to the root directory and not the public directory.
|
*/
- 'icon_path' => 'path/to/icons',
+ 'svg_path' => 'path/to/svgs',
/*
|--------------------------------------------------------------------------
| Spritesheet Path
|--------------------------------------------------------------------------
|
- | If you would rather have one spritesheet than a lot of individual svg
- | files, you may specify a path to a spritesheet. The icons are then
+ | If you would rather have one spritesheet than a lot of individual SVG
+ | files, you may specify a path to a spritesheet. The SVG images are
| extracted from this spritesheet to be rendered out individually.
|
*/
@@ -46,9 +46,9 @@
| Inline Rendering
|--------------------------------------------------------------------------
|
- | This value will determine whether or not the icon must be rendered as
- | an SVG element or if it must be referenced on the spritesheet. The
- | icon, if this value is false, will be rendered with a 'use' tag.
+ | This value will determine whether or not the image should be rendered
+ | as an SVG element or if it must be referenced on the spritesheet. The
+ | SVG, if this value is false, will be rendered with a 'use' tag.
|
| Default: false
|
@@ -61,7 +61,7 @@
| Optional Class
|--------------------------------------------------------------------------
|
- | If you would like to have CSS classes applied to your icons, you must
+ | If you would like to have CSS classes applied to your SVGs, you must
| specify them here. Much like how you would define multiple classes
| in an HTML attribute, you may separate each class using a space.
|
diff --git a/readme.md b/readme.md
index a5a3ff7..1882ce4 100644
--- a/readme.md
+++ b/readme.md
@@ -1,6 +1,6 @@
# Blade SVG
-Easily use SVG icons in your Blade templates, either as inline SVG or using SVG sprites.
+Easily use SVG images in your Blade templates, either as inline SVG or using SVG sprites.
## Installation
@@ -34,7 +34,7 @@ Publish the Blade SVG config file:
php artisan vendor:publish --provider="BladeSvg\BladeSvgServiceProvider"
```
-If you want to use the sprite sheet instead of rendering every icon inline, make sure you render the hidden sprite sheet somewhere at the end of any layouts that are going to use icons using the `svg_spritesheet()` helper:
+If you want to use the sprite sheet instead of rendering every image inline, make sure you render the hidden sprite sheet somewhere at the end of any layouts that are going to use SVGs using the `svg_spritesheet()` helper:
```
@@ -52,42 +52,42 @@ If you want to use the sprite sheet instead of rendering every icon inline, make
### Configuration
-Inside `config/blade-svg.php` specify the location of your spritesheet and the path to your individual icons:
+Inside `config/blade-svg.php` specify the location of your spritesheet and the path to your individual SVG images:
```php
'resources/assets/svg/sprite.svg',
- 'icon_path' => 'resources/assets/svg/icons',
+ 'svg_path' => 'resources/assets/svg/icons',
// ...
];
```
> These paths are resolved internally using the `base_path()` helper, so specify them relative to the root of your project.
-You can also specify whether you'd like icons to be rendered inline by default, or to reference the icon from the sprite sheet:
+You can also specify whether you'd like SVGs to be rendered inline by default, or to reference the SVG from the sprite sheet:
```php
true, // Render the full icon SVG inline by default
+ 'inline' => true, // Render the full SVG inline by default
// or...
- 'inline' => false, // Reference the sprite sheet and render the icon with a `use` tag
+ 'inline' => false, // Reference the sprite sheet and render the image with a `use` tag
// ...
];
```
-You can specify any default CSS classes you'd like to be applied to your icons using the `class` option:
+You can specify any default CSS classes you'd like to be applied to your SVG images using the `class` option:
```php
'icon', // Add the `icon` class to every SVG icon when rendered
+ 'class' => 'icon', // Add the `icon` class to every SVG when rendered
// ...
];
```
@@ -104,7 +104,7 @@ return [
];
```
-If the ID attributes of the icons in your spritesheet have a prefix, you can configure that using the `sprite_prefix` option:
+If the ID attributes of the SVGs in your spritesheet have a prefix, you can configure that using the `sprite_prefix` option:
```php
- @icon('cog', 'icon-lg') Settings
+ @svg('cog', 'icon-lg') Settings
@@ -138,7 +138,7 @@ To add additional attributes to the rendered SVG tag, pass an associative array
```html
- @icon('cog', 'icon-lg', ['alt' => 'Gear icon']) Settings
+ @svg('cog', 'icon-lg', ['alt' => 'Gear icon']) Settings
@@ -154,7 +154,7 @@ If you have attributes to declare but no additional class, you can pass an assoc
```html
- @icon('cog', ['alt' => 'Gear icon']) Settings
+ @svg('cog', ['alt' => 'Gear icon']) Settings
@@ -170,7 +170,7 @@ If you'd like to _override_ the default class name, specify a class in the attri
```html
- @icon('cog', ['class' => 'overridden']) Settings
+ @svg('cog', ['class' => 'overridden']) Settings
@@ -186,7 +186,7 @@ If you'd like to add an attribute that needs no value, just specify it without a
```html
- @icon('cog', ['data-foo']) Settings
+ @svg('cog', ['data-foo']) Settings
@@ -198,11 +198,11 @@ If you'd like to add an attribute that needs no value, just specify it without a
```
-If you'd like, you can use the `svg_icon` helper directly to expose a fluent syntax for setting icon attributes:
+If you'd like, you can use the `svg_image` helper directly to expose a fluent syntax for setting SVG attributes:
```html
- {{ svg_icon('cog')->alt('Alt text')->dataFoo('bar')->dataBaz() }} Settings
+ {{ svg_image('cog')->alt('Alt text')->dataFoo('bar')->dataBaz() }} Settings
@@ -214,11 +214,11 @@ If you'd like, you can use the `svg_icon` helper directly to expose a fluent syn
```
-You can force an icon to reference the sprite sheet even if you are rendering inline by default by using the fluent syntax and chaining the `sprite` method:
+You can force an SVG to reference the sprite sheet even if you are rendering inline by default by using the fluent syntax and chaining the `sprite` method:
```html
- {{ svg_icon('cog', 'icon-lg')->sprite() }} Settings
+ {{ svg_image('cog', 'icon-lg')->sprite() }} Settings
@@ -230,11 +230,11 @@ You can force an icon to reference the sprite sheet even if you are rendering in
```
-Similarly, you can force an icon to render inline even if you are using sprites by default by chaining the `inline` method:
+Similarly, you can force an SVG to render inline even if you are using sprites by default by chaining the `inline` method:
```html
- {{ svg_icon('cog', 'icon-lg')->inline() }} Settings
+ {{ svg_image('cog', 'icon-lg')->inline() }} Settings
diff --git a/src/BladeSvgServiceProvider.php b/src/BladeSvgServiceProvider.php
index bf1a23e..b1277c2 100644
--- a/src/BladeSvgServiceProvider.php
+++ b/src/BladeSvgServiceProvider.php
@@ -2,14 +2,15 @@
namespace BladeSvg;
-use BladeSvg\IconFactory;
+use BladeSvg\SvgFactory;
+use Illuminate\Support\Collection;
use Illuminate\Support\ServiceProvider;
class BladeSvgServiceProvider extends ServiceProvider
{
public function boot()
{
- app(IconFactory::class)->registerBladeTag();
+ app(SvgFactory::class)->registerBladeTag();
$this->publishes([
__DIR__.'/../config/blade-svg.php' => config_path('blade-svg.php'),
@@ -18,12 +19,13 @@ public function boot()
public function register()
{
- $this->app->singleton(IconFactory::class, function () {
- $config = array_merge(config('blade-svg', []), [
- 'spritesheet_path' => config('blade-svg.spritesheet_path') ? base_path(config('blade-svg.spritesheet_path')) : null,
- 'icon_path' => config('blade-svg.icon_path') ? base_path(config('blade-svg.icon_path')) : null,
- ]);
- return new IconFactory($config);
+ $this->app->singleton(SvgFactory::class, function () {
+ $config = Collection::make(config('blade-svg', []))->merge([
+ 'spritesheet_path' => config('blade-svg.spritesheet_path'),
+ 'svg_path' => config('blade-svg.svg_path', config('blade-svg.icon_path')),
+ ])->map('base_path')->all();
+
+ return new SvgFactory($config);
});
}
}
diff --git a/src/Icon.php b/src/Svg.php
similarity index 86%
rename from src/Icon.php
rename to src/Svg.php
index f545d51..dc1ed0e 100644
--- a/src/Icon.php
+++ b/src/Svg.php
@@ -6,16 +6,16 @@
use Illuminate\Support\HtmlString;
use Illuminate\Contracts\Support\Htmlable;
-class Icon implements Htmlable
+class Svg implements Htmlable
{
- private $icon;
+ private $imageName;
private $renderMode;
private $factory;
private $attrs = [];
- public function __construct($icon, $renderMode, $factory, $attrs = [])
+ public function __construct($imageName, $renderMode, $factory, $attrs = [])
{
- $this->icon = $icon;
+ $this->imageName = $imageName;
$this->renderMode = $renderMode;
$this->factory = $factory;
$this->attrs = $attrs;
@@ -56,7 +56,7 @@ public function renderInline()
return str_replace(
'