Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
swapnilsarwe committed Mar 17, 2021
0 parents commit 76f2259
Show file tree
Hide file tree
Showing 297 changed files with 2,035 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
/dist export-ignore
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php_cs.dist export-ignore
CHANGELOG.md export-ignore
phpunit.xml.dist export-ignore
README.md export-ignore
UPGRADE.md export-ignore
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: [7.3, 7.4, 8.0]
laravel: [^8.0, ^7.0]

name: P${{ matrix.php }} - L${{ 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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist/
composer.lock
phpunit.xml
vendor
.phpunit.result.cache
4 changes: 4 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
preset: laravel
enabled:
- heredoc_indentation
- trailing_comma_in_multiline_call
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

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

## 0.1.0 (2021-03-17)

Initial release.
Current package support [Ikonate Icons](https://github.com/mikolajdobrucki/ikonate/releases/tag/v1.1.1)
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) Swapnil Sarwe

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.
87 changes: 87 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<p align="center">
<img src="https://banners.beyondco.de/Blade%20SIkonate.png?theme=light&packageManager=composer+require&packageName=codeat3%2Fblade-ikonate&pattern=architect&style=style_1&description=A+package+to+use+Ikonate+Icons+in+your+Laravel+Blade+views&md=1&showWatermark=1&fontSize=100px&images=https%3A%2F%2Flaravel.com%2Fimg%2Flogomark.min.svg" width="1280" title="Social Card Blade Ikonate Icons">
</p>

# Blade Simple Icons

<a href="https://github.com/codeat3/blade-ikonate/actions?query=workflow%3ATests">
<img src="https://github.com/codeat3/blade-ikonate/workflows/Tests/badge.svg" alt="Tests">
</a>
<a href="https://github.styleci.io/repos/258753939">
<img src="https://github.styleci.io/repos/258753939/shield?style=flat" alt="Code Style">
</a>
<a href="https://packagist.org/packages/codeat3/blade-ikonate">
<img src="https://img.shields.io/packagist/v/codeat3/blade-ikonate" alt="Latest Stable Version">
</a>
<a href="https://packagist.org/packages/codeat3/blade-ikonate">
<img src="https://img.shields.io/packagist/dt/codeat3/blade-ikonate" alt="Total Downloads">
</a>

A package to easily make use of [Ikonate Icons](https://github.com/mikolajdobrucki/ikonate) in your Laravel Blade views.

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

## Requirements

- PHP 7.3 or higher
- Laravel 7.14 or higher

## Installation

```bash
composer require codeat3/blade-ikonate
```

## Updating

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

## Usage

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

```blade
<x-ik-sun-cloud/>
```

You can also pass classes to your icon components:

```blade
<x-ik-sun-cloud class="w-6 h-6 text-gray-500"/>
```

And even use inline styles:

```blade
<x-ik-sun-cloud style="color: #555"/>
```

### 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-ik --force
```

Then use them in your views like:

```blade
<img src="{{ asset('vendor/blade-ik/sun-cloud.svg') }}" width="10" height="10"/>
```

### Blade Icons

Blade System UIcons uses Blade Icons under the hood. Please refer to [the Blade Icons readme](https://github.com/blade-ui-kit/blade-icons) for additional functionality.

## Changelog

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

## Maintainers

Blade Simple Icons is developed and maintained by [Swapnil Sarwe](https://swapnilsarwe.com).

## License

Blade Simple Icons is open-sourced software licensed under [the MIT license](LICENSE.md).
23 changes: 23 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Upgrade Guide

General steps for every update:

- Run `php artisan view:clear`

## Upgrading from Blade Icons

If you're upgrading from the original Blade Icons package there's very little steps you would need to take. The syntax for the Blade components has remained the same.

### Raw Icons

If you were using the raw exported icons you'll need to re-publish them with:

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

The new way to reference them is:

```blade
<img src="{{ asset('vendor/blade-ik/alarm-clock.svg') }}" width="10" height="10"/>
```
84 changes: 84 additions & 0 deletions bin/compile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

require_once "vendor/autoload.php";

use Symfony\Component\Finder\Finder;
use Symfony\Component\DomCrawler\Crawler;

class SvgIconCleaner
{
const RESOURCE_DIR = "resources/svg";

protected $attrsNotRequired = [
"id",
"class",
"width",
"height",
];

protected $replacePatterns = [
'/\s(id=\"[a-b0-9]{2}\")/' => '',
'/\s(class=\"[a-b0-9]{2}\")/' => '',
'/\s(height=\"[0-9]+\")/' => '',
'/\s(width=\"[0-9]+\")/' => '',
];

private function removeAttributes()
{
$finder = new Finder();
$finder->files()->in(self::RESOURCE_DIR);
foreach ($finder as $file) {
$text = $file->getContents();
$newtext = preg_replace(array_keys($this->replacePatterns), array_values($this->replacePatterns), $text);
if ($text !== $newtext) {
file_put_contents($file->getRealPath(), $newtext);
}
}
}

private function replaceSolidPatterns($svgText)
{

// check if exists
preg_match('/<svg.*(fill\=\"currentColor\".*?>)/', $svgText, $matches);

if (count($matches) == 2 && isset($matches[0])) {
return false;
}

// replace it

preg_match('/<svg.*?>/', $svgText, $matches);

if (count($matches) > 0 && isset($matches[0])) {
$source = $matches[0];
$replacement = str_replace('>', ' fill="currentColor">', $source);
$svgText = str_replace($source, $replacement, $svgText);
}
return $svgText;
}

private function addAttributes()
{
// for solid icons
$finder = new Finder();
$finder->files()->in(self::RESOURCE_DIR)->name('*.svg');
foreach ($finder as $file) {
$changedText = $this->replaceSolidPatterns($file->getContents());
if ($changedText !== false) {
file_put_contents($file->getRealPath(), $changedText);
} else {
echo 'no changes'.PHP_EOL;
}
}
}

public function process()
{
$this->removeAttributes();

$this->addAttributes();
}
}
$svgCleaner = new SvgIconCleaner();
$svgCleaner->process();
38 changes: 38 additions & 0 deletions bin/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

set -e

# prepare the source of icons by cloning the repo
TEMP_DIR=tmp
mkdir -p $TEMP_DIR
SOURCE=$TEMP_DIR/ikonate
git clone [email protected]:mikolajdobrucki/ikonate.git $TEMP_DIR/ikonate

DIRECTORY=$(cd `dirname $0` && pwd)
RESOURCES=$DIRECTORY/../resources/svg

echo $SOURCE
echo "Reading icons..."
for ICON_DIR in $SOURCE/icons/*; do
# Category Directory Path
# echo $ICON_DIR
# exit

# Icon Name
ICON_NAME=${ICON_DIR##*/}
# echo $ICON_NAME

CONVERTED_ICON_DESTINATION_NAME="${ICON_NAME//_/-}"

CP_COMMAND='cp '$ICON_DIR' '$RESOURCES/$CONVERTED_ICON_DESTINATION_NAME
$CP_COMMAND
# exit

done

echo "copied all svgs!"
echo "Removing "$TEMP_DIR
rm -rf $TEMP_DIR

echo "All Done!"
# echo "Run `php bin/compile.php` to update the svgs"
49 changes: 49 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "codeat3/blade-ikonate",
"description": "A package to easily make use of Ikonate Icons in your Laravel Blade views.",
"keywords": ["Blade", "ikonate", "icons", "Laravel"],
"homepage": "https://github.com/codeat3/blade-ikonate",
"license": "MIT",
"authors": [
{
"name": "Swapnil Sarwe",
"homepage": "https://swapnilsarwe.com"
},
{
"name": "Dries Vints",
"homepage": "https://driesvints.com"
}
],
"require": {
"php": "^7.3|^8.0",
"blade-ui-kit/blade-icons": "^0.5.0",
"illuminate/support": "^7.14|^8.0"
},
"require-dev": {
"orchestra/testbench": "^5.0|^6.0",
"phpunit/phpunit": "^8.0|^9.0",
"symfony/finder": "^5.2"
},
"autoload": {
"psr-4": {
"Codeat3\\BladeIkonate\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
"Codeat3\\BladeIkonate\\BladeIkonateServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
17 changes: 17 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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="Blade Google Material Design Icons Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
Loading

0 comments on commit 76f2259

Please sign in to comment.