scadini/nova-icon 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

scadini/nova-icon

最新稳定版本:v0.2.1

Composer 安装命令:

composer require scadini/nova-icon

包简介

A Laravel Nova icon field.

README 文档

README

Latest Stable Version License

This package allows you to render a SVG icon as a custom field.

Available Icons | Examples | Roadmap

Installation

composer require scadini/nova-icon

Usage

use NovaIcon\Icon;
public function fields()
{
    return [
        ID::make()->sortable(),

        Text::make('Name'),

        Icon::make('Approved')
            ->icon('entypo:check'),
    ];
}

Example 1

The simplest way to add an icon is by using the icon() method. This method accepts either a string or a closure containing the vendor name and the icon name separated by a colon:

    Icon::make('Approved')->icon('entypo:check');
    Icon::make('Approved')->icon(function () {
        return 'entypo:check';
    });

To apply css classes, you can chain the css() method. This method accepts a string, an array, or a closure:

    Icon::make('Approved')->icon('entypo:check')->css('text-info h-12 w-12');

    Icon::make('Approved')->icon('entypo:check')->css(['text-info', 'h-12', 'w-12']);

    Icon::make('Approved')
        ->icon('entypo:check')
        ->css(function () {
            return 'text-info h-12 w-12'; // or ['text-info', 'h-12', 'w-12']
        }
    );

To hide an icon for a specific row, you can use the hide() method. This method accepts a closure:

    Icon::make('Approved')
        ->icon('entypo:check')
        ->hide(function () {
            return $this->role === 'admin';
        });

Example

Here's an example about using this component. Let's say a user has a preferred internet platform:

    Icon::make('Platform')
        ->icon(function () {
            return 'entypo:' . $this->platform;
        })
        ->css(function () {
            $options = [
                'youtube' => 'text-danger',
                'vimeo'   => 'text-success'
            ];

            return $options[$this->platform];
        })

Example 2

Available Icons

The icons available are organized by their vendor name.

Currently, the only vendor available is Entypo, but there are plans to include Zondicons library.

For the icon names you can use this reference table

Roadmap

  • Add all icons from Entypo
  • Add all icons from Zondicons
  • Make icons clickable to perform actions or view resources

统计信息

  • 总下载量: 23.48k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-21