Skip to content

Commit e933e9a

Browse files
committed
Initial commit
0 parents  commit e933e9a

15 files changed

+428
-0
lines changed

.gitattributes

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
* text=auto
2+
3+
/.github export-ignore
4+
/bin export-ignore
5+
/config/generation.php export-ignore
6+
/dist export-ignore
7+
/tests export-ignore
8+
.gitattributes export-ignore
9+
.gitignore export-ignore
10+
.php_cs.dist export-ignore
11+
CHANGELOG.md export-ignore
12+
phpunit.xml.dist export-ignore
13+
README.md export-ignore
14+
UPGRADE.md export-ignore

.github/workflows/tests.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
php: [7.4, 8.0]
17+
laravel: [^8.0]
18+
19+
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v2
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
extensions: dom, curl, libxml, mbstring, zip
30+
coverage: none
31+
32+
- name: Install dependencies
33+
run: |
34+
composer require "illuminate/contracts=${{ matrix.laravel }}" --prefer-dist --no-interaction --no-update
35+
composer update --prefer-dist --no-interaction --no-progress
36+
37+
- name: Execute tests
38+
run: vendor/bin/phpunit --verbose

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
vendor/
3+
.phpunit.result.cache
4+
composer.lock
5+
phpunit.xml
6+
package-lock.json

.styleci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
preset: laravel
2+
enabled:
3+
- heredoc_indentation
4+
- trailing_comma_in_multiline_call

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
3+
This changelog follows [the Keep a Changelog standard](https://keepachangelog.com).
4+
5+
6+
## [Unreleased](https://github.com/blade-organization/blade-heroicons/compare/1.0.0...main)
7+
8+
9+
## 1.0.0 (20??-??-??)
10+
11+
Initial release.

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Blade Developer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Blade Icons Template
2+
3+
<a href="https://github.com/blade-organization/blade-heroicons/actions?query=workflow%3ATests">
4+
<img src="https://github.com/blade-ui-kit/blade-heroicons/workflows/Tests/badge.svg" alt="Tests">
5+
</a>
6+
<a href="https://packagist.org/packages/blade-organization/blade-heroicons">
7+
<img src="https://img.shields.io/packagist/v/blade-organization/blade-heroicons" alt="Latest Stable Version">
8+
</a>
9+
<a href="https://packagist.org/packages/blade-organization/blade-heroicons">
10+
<img src="https://img.shields.io/packagist/dt/blade-organization/blade-heroicons" alt="Total Downloads">
11+
</a>
12+
13+
> This is a template repository for new icon packages for [Blade Icons](https://github.com/blade-ui-kit/blade-icons). Start a new repo with this and replace the relevant things below:
14+
>
15+
> 1. `blade-organization` with your GitHub organization
16+
> 2. `blade-heroicons` with your repository name
17+
> 3. `Blade Heroicons` & `Blade Icons Template` with your icon set name
18+
> 4. Any other reference to `Heroicons` with your icon set name
19+
> 5. `Blade Developer` with your name
20+
>
21+
> Then, make sure [the implementation](./src) is correct, that you set up [icon generation](https://github.com/blade-ui-kit/blade-icons#generating-icons) and that [your tests](./tests) pass. And remove this quote block from your readme. When you've published your package on Packagist, make sure to send it in to [the Blade Icons package list](https://github.com/blade-ui-kit/blade-icons#icon-packages).
22+
23+
A package to easily make use of [Heroicons](https://github.com/refactoringui/heroicons) in your Laravel Blade views.
24+
25+
For a full list of available icons see [the SVG directory](resources/svg) or preview them at [heroicons.com](https://heroicons.com/).
26+
27+
## Requirements
28+
29+
- PHP 7.4 or higher
30+
- Laravel 8.0 or higher
31+
32+
## Installation
33+
34+
```bash
35+
composer require blade-organization/blade-heroicons
36+
```
37+
38+
## Updating
39+
40+
Please refer to [`the upgrade guide`](UPGRADE.md) when updating the library.
41+
42+
## Blade Icons
43+
44+
Blade Heroicons uses Blade Icons under the hood. Please refer to [the Blade Icons readme](https://github.com/blade-ui-kit/blade-icons) for additional functionality. We also recommend to [enable icon caching](https://github.com/blade-ui-kit/blade-icons#caching) with this library.
45+
46+
## Configuration
47+
48+
Blade Heroicons also offers the ability to use features from Blade Icons like default classes, default attributes, etc. If you'd like to configure these, publish the `blade-heroicons.php` config file:
49+
50+
```bash
51+
php artisan vendor:publish --tag=blade-heroicons-config
52+
```
53+
54+
## Usage
55+
56+
Icons can be used as self-closing Blade components which will be compiled to SVG icons:
57+
58+
```blade
59+
<x-heroicon-o-adjustments/>
60+
```
61+
62+
You can also pass classes to your icon components:
63+
64+
```blade
65+
<x-heroicon-o-adjustments class="w-6 h-6 text-gray-500"/>
66+
```
67+
68+
And even use inline styles:
69+
70+
```blade
71+
<x-heroicon-o-adjustments style="color: #555"/>
72+
```
73+
74+
The solid icons can be referenced like this:
75+
76+
```blade
77+
<x-heroicon-s-adjustments/>
78+
```
79+
80+
### Raw SVG Icons
81+
82+
If you want to use the raw SVG icons as assets, you can publish them using:
83+
84+
```bash
85+
php artisan vendor:publish --tag=blade-heroicons --force
86+
```
87+
88+
Then use them in your views like:
89+
90+
```blade
91+
<img src="{{ asset('vendor/blade-heroicons/o-adjustments.svg') }}" width="10" height="10"/>
92+
```
93+
94+
## Changelog
95+
96+
Check out the [CHANGELOG](CHANGELOG.md) in this repository for all the recent changes.
97+
98+
## Maintainers
99+
100+
Blade Heroicons is developed and maintained by Blade Developer.
101+
102+
## License
103+
104+
Blade Heroicons is open-sourced software licensed under [the MIT license](LICENSE.md).

composer.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "blade-organization/blade-heroicons",
3+
"description": "A package to easily make use of Heroicons in your Laravel Blade views.",
4+
"keywords": ["Blade", "Heroicons", "Laravel"],
5+
"homepage": "https://github.com/blade-organization/blade-heroicons",
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Blade Developer"
10+
}
11+
],
12+
"require": {
13+
"php": "^7.4|^8.0",
14+
"blade-ui-kit/blade-icons": "^1.1",
15+
"illuminate/support": "^8.0"
16+
},
17+
"require-dev": {
18+
"orchestra/testbench": "^6.0",
19+
"phpunit/phpunit": "^9.0"
20+
},
21+
"autoload": {
22+
"psr-4": {
23+
"BladeUI\\Heroicons\\": "src"
24+
}
25+
},
26+
"autoload-dev": {
27+
"psr-4": {
28+
"Tests\\": "tests"
29+
}
30+
},
31+
"extra": {
32+
"laravel": {
33+
"providers": [
34+
"BladeUI\\Heroicons\\BladeHeroiconsServiceProvider"
35+
]
36+
}
37+
},
38+
"config": {
39+
"sort-packages": true
40+
},
41+
"minimum-stability": "dev",
42+
"prefer-stable": true
43+
}

config/blade-heroicons.php

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|-----------------------------------------------------------------
7+
| Default Prefix
8+
|-----------------------------------------------------------------
9+
|
10+
| This config option allows you to define a default prefix for
11+
| your icons. The dash separator will be applied automatically
12+
| to every icon name. It's required and needs to be unique.
13+
|
14+
*/
15+
16+
'prefix' => 'heroicon',
17+
18+
/*
19+
|-----------------------------------------------------------------
20+
| Fallback Icon
21+
|-----------------------------------------------------------------
22+
|
23+
| This config option allows you to define a fallback
24+
| icon when an icon in this set cannot be found.
25+
|
26+
*/
27+
28+
'fallback' => '',
29+
30+
/*
31+
|-----------------------------------------------------------------
32+
| Default Set Classes
33+
|-----------------------------------------------------------------
34+
|
35+
| This config option allows you to define some classes which
36+
| will be applied by default to all icons within this set.
37+
|
38+
*/
39+
40+
'class' => '',
41+
42+
/*
43+
|-----------------------------------------------------------------
44+
| Default Set Attributes
45+
|-----------------------------------------------------------------
46+
|
47+
| This config option allows you to define some attributes which
48+
| will be applied by default to all icons within this set.
49+
|
50+
*/
51+
52+
'attributes' => [
53+
// 'width' => 50,
54+
// 'height' => 50,
55+
],
56+
57+
];

config/generation.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
return [
4+
[
5+
'source' => __DIR__.'/../node_modules/heroicons',
6+
'destination' => __DIR__.'/../resources/svg',
7+
],
8+
];

package.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"private": true,
3+
"dependencies": {
4+
"heroicons": "^1.0.1"
5+
}
6+
}

phpunit.xml.dist

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
>
7+
<testsuites>
8+
<testsuite name="Icons Test Suite">
9+
<directory>tests</directory>
10+
</testsuite>
11+
</testsuites>
12+
</phpunit>

resources/svg/.gitkeep

Whitespace-only changes.

src/BladeHeroiconsServiceProvider.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace BladeUI\Heroicons;
6+
7+
use BladeUI\Icons\Factory;
8+
use Illuminate\Contracts\Container\Container;
9+
use Illuminate\Support\ServiceProvider;
10+
11+
final class BladeHeroiconsServiceProvider extends ServiceProvider
12+
{
13+
public function register(): void
14+
{
15+
$this->registerConfig();
16+
17+
$this->callAfterResolving(Factory::class, function (Factory $factory, Container $container) {
18+
$config = $container->make('config')->get('blade-heroicons', []);
19+
20+
$factory->add('heroicons', array_merge(['path' => __DIR__.'/../resources/svg'], $config));
21+
});
22+
}
23+
24+
private function registerConfig(): void
25+
{
26+
$this->mergeConfigFrom(__DIR__.'/../config/blade-heroicons.php', 'blade-heroicons');
27+
}
28+
29+
public function boot(): void
30+
{
31+
if ($this->app->runningInConsole()) {
32+
$this->publishes([
33+
__DIR__.'/../resources/svg' => public_path('vendor/blade-heroicons'),
34+
], 'blade-heroicons');
35+
36+
$this->publishes([
37+
__DIR__.'/../config/blade-heroicons.php' => $this->app->configPath('blade-heroicons.php'),
38+
], 'blade-heroicons-config');
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)