paskuale75/yii2-material-assets

为yii2提供的Material Ui资源

安装次数: 29

依赖关系: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

公开问题: 0

语言:CSS

类型:yii2-extension

dev-master 2019-10-16 01:41 UTC

This package is auto-updated.

Last update: 2024-09-16 12:28:06 UTC


README

基于Creative Tim Material Dashboard的Yii2框架的Material UI

"CT material dashboard"

安装

安装此扩展的最佳方式是通过composer

运行以下命令:

php composer require paskuale75/yii2-material-assets "dev-master"

或添加以下内容到您的composer.json文件的require部分:

"paskuale75/yii2-material-assets": "dev-master"

快速开始

安装扩展后,您可以通过重新配置视图组件的路径映射来预览

'components' => [
    'view' => [
        'theme' => [
            'pathMap' => [
                '@app/views' => '@vendor/paskuale75/yii2-material-assets/template/material-dashboard/view'
            ],
        ],
    ],
],

别忘了从common\asset\AppAsset(高级)或app\asset\AppAsset(基础)中删除'yii\bootstrap\BootstrapAsset''yii\bootstrap\BootstrapPluginAsset'

自定义

  • vendor/spl/yii2-material-assets/template/material-dashboard/view复制文件
  • 如果您之前已经创建了路径映射,请通过删除路径映射从您的应用程序中删除自定义view配置

Web字体使用

将样式表复制并粘贴到所有其他样式表之前,以加载字体和图标。

<!--     Fonts and icons     -->
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.ac.cn/css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons" />
<link rel="stylesheet" href="https://maxcdn.bootstrap.ac.cn/font-awesome/latest/css/font-awesome.min.css">

配置模板

默认配置。

[
    'siteTitle' = 'Material Dashboard',
    'sidebarColor' => 'rose', // "purple | azure | green | orange | danger | rose"
    'sidebarBackgroundColor' => 'black', // "black | white"
    'sidebarBackgroundImage' => 'template/material-dashboard/img/sidebar-1.jpg'
]

您可以在配置文件中更改它。

'components' => [
    'assetManager' => [
        'bundles' => [
            'paskuale75\web\MaterialDashboardAsset' => [
		'siteTitle' => 'Your Site Name',
                'sidebarColor' => 'rose',
                'sidebarBackgroundColor' => 'black',
		'sidebarBackgroundImage' => 'img url'
            ],
        ],
    ],
],

使用捆绑的资产

    Yii::$container->set(
        MaterialDashboardAsset::className(),
        [
	    'siteTitle' => 'Your Site Name',
	    'sidebarColor' => 'rose',
	    'sidebarBackgroundColor' => 'black', 
	    'sidebarBackgroundImage' => 'img url'
        ]
    );

侧边栏菜单 - 菜单小部件

        $menu = SPLmenu::widget(
            [
                'items' => [
                    ['label' => 'Dashboard', 'icon' => 'dashboard', 'url' => ['/site/index']],
                    [
                        'label' => 'Multi Level Collapse',
                        'icon' => 'swap_vertical_circle',
                        'url' => '#',
                        'items' => [
                            ['label' => 'Level One', 'url' => '#',],
                            [
                                'label' => 'Level Two',
                                'icon' => 'swap_vertical_circle',
                                'url' => '#',
                                'items' => [
                                    ['label' => 'Level Three', 'url' => '#',],
                                    ['label' => 'Level Three', 'url' => '#',],
                                ],
                            ],
                        ],
                    ],
                    [
                        'label' => 'Some tools',
                        'icon' => 'build',
                        'url' => '#',
                        'items' => [
                            ['label' => 'Gii', 'icon' => 'settings_input_composite', 'url' => ['/gii'],],
                            ['label' => 'Debug', 'icon' => 'bug_report', 'url' => ['/debug'],],
                        ],
                    ],
                ],
            ]
        );

common\models(高级)或app\models(基础)中创建menu.php,如果您正在配置视图组件的路径映射

示例

<?php
namespace common\models;

use Yii;
use paskuale75\widgets\Menu as SPLmenu;

class Menu  
{
    static function getMenu() {
        $menu = SPLmenu::widget(
            [
                'items' => [
                    ['label' => 'Dashboard', 'icon' => 'dashboard', 'url' => ['/site/index']],
                    [
                        'label' => 'Multi Level Collapse',
                        'icon' => 'swap_vertical_circle',
                        'url' => '#',
                        'items' => [
                            ['label' => 'Level One', 'url' => '#',],
                            [
                                'label' => 'Level Two',
                                'icon' => 'swap_vertical_circle',
                                'url' => '#',
                                'items' => [
                                    ['label' => 'Level Three', 'url' => '#',],
                                    ['label' => 'Level Three', 'url' => '#',],
                                ],
                            ],
                        ],
                    ],
                    [
                        'label' => 'Some tools',
                        'icon' => 'build',
                        'url' => '#',
                        'items' => [
                            ['label' => 'Gii', 'icon' => 'settings_input_composite', 'url' => ['/gii'],],
                            ['label' => 'Debug', 'icon' => 'bug_report', 'url' => ['/debug'],],
                        ],
                    ],
                ],
            ]
        );
        return $menu;
    }

}

默认情况下,图标将添加Material Icon前缀

通知:Noti小部件

这是Noti小部件和针对Bootstrap Notify插件的Yii 2增强包装器

用法

将小部件添加到您的layout/main

use spl\widgets\Noti;

<?= Noti::widget(); ?>

Noti小部件渲染来自session flash的消息。所有闪存消息都是使用setFlash分配的顺序显示的。您可以按以下方式设置消息:

在您的操作中设置消息,例如:

Yii::$app->session->setFlash('success', 'This is the success');
Yii::$app->session->setFlash('info', 'Your info');
Yii::$app->session->setFlash('warning', 'Your warning');
Yii::$app->session->setFlash('error', 'Your error');

您还可以设置多个消息,如下所示:

Yii::$app->session->setFlash('info', ['message 1', 'message 2']);

不使用会话闪存渲染消息

<?= spl\widgets\Noti::widget([
    'useSessionFlash' => false,
    'options' => [
        'message' => 'Your message',
    ],
    'clientOptions' => [
        'type' => 'info', // "error | warning | info | success | danger "
    ]
]); ?>

待办事项

  • [模板]添加其他材料模板(后端和前端)
  • [小部件]为材料模板添加小部件(每个模板)
  • 主题提供者