Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
agentphoenix authored Aug 22, 2023
0 parents commit 437ba1c
Show file tree
Hide file tree
Showing 15 changed files with 430 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
* text=auto

/.github export-ignore
/bin export-ignore
/config/generation.php export-ignore
/dist export-ignore
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
CHANGELOG.md export-ignore
phpunit.xml.dist export-ignore
README.md export-ignore
UPGRADE.md export-ignore
7 changes: 7 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Coding Standards

on: [push]

jobs:
lint:
uses: laravel/.github/.github/workflows/coding-standards.yml@main
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Tests

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
tests:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [8.1, 8.2]
laravel: [9, 10]

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip
coverage: none

- name: Install dependencies
run: |
composer require "illuminate/contracts=^${{ matrix.laravel }}" --prefer-dist --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-progress
- name: Execute tests
run: vendor/bin/phpunit --verbose
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
vendor/
.phpunit.result.cache
composer.lock
phpunit.xml
package-lock.json
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog

This changelog follows [the Keep a Changelog standard](https://keepachangelog.com).


## [Unreleased](https://github.com/blade-organization/blade-heroicons/compare/1.0.0...main)


## 1.0.0 (20??-??-??)

Initial release.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Blade Developer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
104 changes: 104 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Blade Icons Template

<a href="https://github.com/blade-organization/blade-heroicons/actions?query=workflow%3ATests">
<img src="https://github.com/blade-ui-kit/blade-heroicons/workflows/Tests/badge.svg" alt="Tests">
</a>
<a href="https://packagist.org/packages/blade-organization/blade-heroicons">
<img src="https://img.shields.io/packagist/v/blade-organization/blade-heroicons" alt="Latest Stable Version">
</a>
<a href="https://packagist.org/packages/blade-organization/blade-heroicons">
<img src="https://img.shields.io/packagist/dt/blade-organization/blade-heroicons" alt="Total Downloads">
</a>

> 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:
>
> 1. `blade-organization` with your GitHub organization
> 2. `blade-heroicons` with your repository name
> 3. `Blade Heroicons` & `Blade Icons Template` with your icon set name
> 4. Any other reference to `Heroicons` with your icon set name
> 5. `Blade Developer` with your name
>
> 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).
A package to easily make use of [Heroicons](https://github.com/refactoringui/heroicons) in your Laravel Blade views.

For a full list of available icons see [the SVG directory](resources/svg) or preview them at [heroicons.com](https://heroicons.com/).

## Requirements

- PHP 8.1 or higher
- Laravel 9.0 or higher

## Installation

```bash
composer require blade-organization/blade-heroicons
```

## Updating

Please refer to [`the upgrade guide`](UPGRADE.md) when updating the library.

## Blade Icons

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.

## Configuration

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:

```bash
php artisan vendor:publish --tag=blade-heroicons-config
```

## Usage

Icons can be used as self-closing Blade components which will be compiled to SVG icons:

```blade
<x-heroicon-o-adjustments/>
```

You can also pass classes to your icon components:

```blade
<x-heroicon-o-adjustments class="w-6 h-6 text-gray-500"/>
```

And even use inline styles:

```blade
<x-heroicon-o-adjustments style="color: #555"/>
```

The solid icons can be referenced like this:

```blade
<x-heroicon-s-adjustments/>
```

### Raw SVG Icons

If you want to use the raw SVG icons as assets, you can publish them using:

```bash
php artisan vendor:publish --tag=blade-heroicons --force
```

Then use them in your views like:

```blade
<img src="{{ asset('vendor/blade-heroicons/o-adjustments.svg') }}" width="10" height="10"/>
```

## Changelog

Check out the [CHANGELOG](CHANGELOG.md) in this repository for all the recent changes.

## Maintainers

Blade Heroicons is developed and maintained by Blade Developer.

## License

Blade Heroicons is open-sourced software licensed under [the MIT license](LICENSE.md).
43 changes: 43 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "blade-organization/blade-heroicons",
"description": "A package to easily make use of Heroicons in your Laravel Blade views.",
"keywords": ["Blade", "Heroicons", "Laravel"],
"homepage": "https://github.com/blade-organization/blade-heroicons",
"license": "MIT",
"authors": [
{
"name": "Blade Developer"
}
],
"require": {
"php": "~8.1.0|~8.2.0",
"blade-ui-kit/blade-icons": "^1.4",
"illuminate/support": "^9.0|^10.0"
},
"require-dev": {
"orchestra/testbench": "^7.0|^8.0",
"phpunit/phpunit": "^9.0"
},
"autoload": {
"psr-4": {
"BladeUI\\Heroicons\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
"BladeUI\\Heroicons\\BladeHeroiconsServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
57 changes: 57 additions & 0 deletions config/blade-heroicons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

return [

/*
|-----------------------------------------------------------------
| Default Prefix
|-----------------------------------------------------------------
|
| This config option allows you to define a default prefix for
| your icons. The dash separator will be applied automatically
| to every icon name. It's required and needs to be unique.
|
*/

'prefix' => 'heroicon',

/*
|-----------------------------------------------------------------
| Fallback Icon
|-----------------------------------------------------------------
|
| This config option allows you to define a fallback
| icon when an icon in this set cannot be found.
|
*/

'fallback' => '',

/*
|-----------------------------------------------------------------
| Default Set Classes
|-----------------------------------------------------------------
|
| This config option allows you to define some classes which
| will be applied by default to all icons within this set.
|
*/

'class' => '',

/*
|-----------------------------------------------------------------
| Default Set Attributes
|-----------------------------------------------------------------
|
| This config option allows you to define some attributes which
| will be applied by default to all icons within this set.
|
*/

'attributes' => [
// 'width' => 50,
// 'height' => 50,
],

];
8 changes: 8 additions & 0 deletions config/generation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
[
'source' => __DIR__.'/../node_modules/heroicons',
'destination' => __DIR__.'/../resources/svg',
],
];
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"heroicons": "^1.0.1"
}
}
12 changes: 12 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Icons Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
Empty file added resources/svg/.gitkeep
Empty file.
41 changes: 41 additions & 0 deletions src/BladeHeroiconsServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace BladeUI\Heroicons;

use BladeUI\Icons\Factory;
use Illuminate\Contracts\Container\Container;
use Illuminate\Support\ServiceProvider;

final class BladeHeroiconsServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->registerConfig();

$this->callAfterResolving(Factory::class, function (Factory $factory, Container $container) {
$config = $container->make('config')->get('blade-heroicons', []);

$factory->add('heroicons', array_merge(['path' => __DIR__.'/../resources/svg'], $config));
});
}

private function registerConfig(): void
{
$this->mergeConfigFrom(__DIR__.'/../config/blade-heroicons.php', 'blade-heroicons');
}

public function boot(): void
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/../resources/svg' => public_path('vendor/blade-heroicons'),
], 'blade-heroicons');

$this->publishes([
__DIR__.'/../config/blade-heroicons.php' => $this->app->configPath('blade-heroicons.php'),
], 'blade-heroicons-config');
}
}
}
Loading

0 comments on commit 437ba1c

Please sign in to comment.