Skip to content

Commit

Permalink
Merge pull request #7 from chkilel/dev
Browse files Browse the repository at this point in the history
Plugin Version 2
  • Loading branch information
chkilel committed May 12, 2022
2 parents d04f3b7 + c6efdb7 commit 45eea9b
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 12 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Access thousands of SVG icons as a backend form widget.

One library, over **100,000** vector icons, Modern replacement for icon fonts. Fast, easy to use.

- **108+** icon sets powered by [Iconify](https://iconify.design/)
- **128+** icon sets powered by [Iconify](https://iconify.design/)
- Browse the icons on [Iconify](https://icon-sets.iconify.design/) or on [Icônes](https://icones.netlify.app/)

![Icônes FormWidget](https://res.cloudinary.com/chkilel/image/upload/v1629852348/icones-plugin/README/IconesFinder-demo_kyztau.gif)
Expand All @@ -26,6 +26,7 @@ You can use Font Awesome, Material Design Icons, Unicons, Dashicons, Emoji, ...
- [Icônes Form Widget 🪄 🎉 🎊](#icônes-form-widget----)
- [Advantages of this form widget](#advantages-of-this-form-widget)
- [TOC](#toc)
- [Upgrading from version 1.* 🚨](#upgrading-from-version-1-)
- [Installation](#installation)
- [Composer](#composer)
- [How to use](#how-to-use)
Expand All @@ -43,6 +44,22 @@ You can use Font Awesome, Material Design Icons, Unicons, Dashicons, Emoji, ...
- [Usage in Backend List](#usage-in-backend-list)


## Upgrading from version 1.* 🚨

Icônes Form Widget 2.0 depend on version 2 of [Iconify Icon Sets](https://github.com/iconify/icon-sets).
If you are upgrading from version 1.* , you need to upgrade your Iconify Icon Sets to version 2.* also.
For that, run the following command in the root of your project:

```bash
composer require chkilel/icones-plugin:dev-next --with-all-dependencies
# --with-all-dependencies will upgrade all dependencies also
```
then migrate the database:

```bash
php artisan october:up
```

## Installation
Simply install the plugin from the marketplace, if you run into problems because of composer dependencies, please use composer.

Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@
"require": {
"php": ">=7.0",
"composer/installers": "~1.0",
"iconify/json": "^1.1.461",
"iconify/json": "^2.1.41",
"iconify/json-tools": "^1.0"
},
"require-dev": {
"roave/security-advisories": "dev-latest"
},
"config": {
"allow-plugins": {
"composer/installers": true
}
}
}
16 changes: 10 additions & 6 deletions controllers/settings/_icon-sets_list_item.htm
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,30 @@

<div class="layout-cell min-height theme-description">
<h3><?= e($iconSet->name) ?></h3>
<?php if (strlen($iconSet->author)): ?>
<?php if (strlen($iconSet->url)): ?>
<p class="author">
<?= trans('chkilel.icones::lang.settings.by_author', ['name' => '<a href="' . e($iconSet->url) . '">' . e($iconSet->author) . '</a>']) ?>
<?= trans('chkilel.icones::lang.settings.by_author', ['name' => '<a href="' . e($iconSet->url) . '" target="_blank">' . e($iconSet->author) . '</a>']) ?>
</p>
<?php else: ?>
<p class="author">
<?= trans('chkilel.icones::lang.settings.by_author', ['name' => '<span>' . e($iconSet->author) . '</span>']) ?>
</p>
<?php endif ?>

<div class="scoreboard">

<div class="scoreboard-item title-value">
<h4 class=""><?= $iconSet->category; ?></h4>
<h4 class=""><?= $iconSet->category ?? 'Uncategorized'; ?></h4>
<p class="svg-container">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="36" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24">
<path d="M18.514 2.23l3.448 3.447a2 2 0 0 1 .463 2.103l-1.763 4.812a1 1 0 0 1-.232.363l-8.323 8.323a2 2 0 0 1-2.829 0l-6.364-6.364a2 2 0 0 1 0-2.828l8.333-8.333a1 1 0 0 1 .364-.232l4.802-1.755a2 2 0 0 1 2.101.464zM15.29 8.904a1.5 1.5 0 1 0 2.12-2.122a1.5 1.5 0 0 0-2.12 2.122z" fill="#34495e" />
</svg>
</p>
</div>
<div class="scoreboard-item title-value">
<h4 class=""><?= $iconSet->palette; ?></h4>
<h4 class=""><?= $iconSet->palette? 'Colourful' : 'Colorless'; ?></h4>
<p class="svg-container">
<?php if (strtolower($iconSet->palette) == 'colorless'): ?>
<?php if ($iconSet->palette == 0): ?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="36" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 48 48">
<path fill="#8CBCD6" d="M40 41H8c-2.2 0-4-1.8-4-4V11c0-2.2 1.8-4 4-4h32c2.2 0 4 1.8 4 4v26c0 2.2-1.8 4-4 4z" />
<circle fill="#B3DDF5" cx="35" cy="16" r="3" />
Expand Down Expand Up @@ -108,7 +112,7 @@ <h4>Total icons</h4>
<h4>License</h4>
<p class="license">
<?php if ($iconSet->license_url): ?>
<a href="<?= $iconSet->license_url; ?>">
<a href="<?= $iconSet->license_url; ?>" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" style="vertical-align: -0.125em;" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 512 512">
<path d="M432 320h-32a16 16 0 0 0-16 16v112H64V128h144a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16H48a48 48 0 0 0-48 48v352a48 48 0 0 0 48 48h352a48 48 0 0 0 48-48V336a16 16 0 0 0-16-16zM488 0H360c-21.37 0-32.05 25.91-17 41l35.73 35.73L135 320.37a24 24 0 0 0 0 34L157.67 377a24 24 0 0 0 34 0l243.61-243.68L471 169c15 15 41 4.5 41-17V24a24 24 0 0 0-24-24z" fill="#0f86e4" />
</svg>
Expand Down
1 change: 1 addition & 0 deletions models/IconSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class IconSet extends Model
protected $casts = [
'is_enabled' => 'boolean',
'is_installed' => 'boolean',
'palette' => 'boolean',
];

/**
Expand Down
10 changes: 6 additions & 4 deletions updates/seed_icon_sets_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ public function createIconSets(): void
$model->id = $prefix;
$model->name = $iconSet['name'];
$model->total = $iconSet['total'];
$model->author = $iconSet['author'];
$model->url = $iconSet['url'] ?? null;
$model->license = $iconSet['license'];
$model->license_url = $iconSet['licenseURL'] ?? null;


$model->author = $iconSet['author']['name'];
$model->url = $iconSet['author']['url'] ?? null;
$model->license = $iconSet['license']['title'];
$model->license_url = $iconSet['license']['url'] ?? null;
$model->version = $iconSet['version'] ?? null;
$model->samples = $iconSet['samples'] ?? null;
$model->palette = $iconSet['palette'] ?? null;
Expand Down
36 changes: 36 additions & 0 deletions updates/upgrade_icon_sets_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Chkilel\Icones\Updates;

use Schema;
use Illuminate\Support\Facades\DB;
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;

class UpgradeIconSetsTable extends Migration
{
public function up()
{
//move the value to the new datatype
//Colourful => 1, Colorless => 0
DB::table('chkilel_icones_icon_sets')->where('palette', 'Colorless')->update(['palette' => false]);
DB::table('chkilel_icones_icon_sets')->where('palette', 'Colorful')->update(['palette' => true]);

// Change the datatype of the column
Schema::table('chkilel_icones_icon_sets', function (Blueprint $table) {
$table->boolean('palette')->change();
});

}

public function down()
{
Schema::table('chkilel_icones_icon_sets', function (Blueprint $table) {
$table->string('palette')->change();
});
//Roll back the value to the old datatype
// 1 => Colourful , 0 => Colorless
DB::table('chkilel_icones_icon_sets')->where('palette', '0')->update(['palette' => 'Colorless']);
DB::table('chkilel_icones_icon_sets')->where('palette', '1')->update(['palette' => 'Colorful']);
}
}
3 changes: 3 additions & 0 deletions updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
- change_body_datatype_in_icons_table.php
1.0.5:
- Fix error "php artisan optimize" cached Route
2.0.0:
- 'Upgrade `iconify/icon-sets` to version 2'
- upgrade_icon_sets_table.php

0 comments on commit 45eea9b

Please sign in to comment.