hoaaah/yii2-startbootstrap-sb-admin-2-asset

This extensions is library for Startbootstrap SB Admin 2 Template with Bootstrap4

v0.1.3 2021-06-04 16:32 UTC

This package is auto-updated.

Last update: 2024-12-17 11:55:49 UTC


README

This packages contans an Asset Bundle of Startbootstrap SB Admin 2 for Yii2.

Startbootstrap SB Admin 2 is a responsive Bootstrap 4 created by Start Bootstrap.

Preview

SB Admin 2 Preview

Launch Live Preview

Start Bootstrap was created by and is maintained by David Miller, Owner of Blackrock Digital.

Start Bootstrap is based on the Bootstrap framework created by Mark Otto and Jacob Thorton.

Requirement

This Asset Bundle need Bootstrap 4. Since Yii2 used Bootstrap 3 by default, you must install and change every Bootstrap 3 Asset to Bootstrap 4. You can read this tutorial to migrate to Yii2 Bootstrap 4 :

Installation

The preferred way to install this extension is through composer.

Either run

composer require hoaaah/yii2-startbootstrap-sb-admin-2-asset:dev-master

or add

"hoaaah/yii2-startbootstrap-sb-admin-2-asset": "*"

to the require section of your composer.json file.

Usage

You can see views-examples folder for example use of this library

Menu Widget

You can use Menu widget in your sidebar. This widget optimize for Startbootstrap SB-Admin 2 template. This widget, like SB-Admin 2, only support 2 level menu.

You can see example use of this widget in views-exampale/views/layout/sidebar.php.

use hoaaah\sbadmin2\widgets\Menu;
echo Menu::widget([
    'options' => [
        'ulClass' => "navbar-nav bg-gradient-primary sidebar sidebar-dark accordion",
        'ulId' => "accordionSidebar"
    ], //  optional
    'brand' => [
        'url' => ['/'],
        'content' => <<<HTML
            <div class="sidebar-brand-icon rotate-n-15">
            <i class="fas fa-laugh-wink"></i>
            </div>
            <div class="sidebar-brand-text mx-3">SB Admin <sup>2</sup></div>        
HTML
    ],
    'items' => [
        [
            'label' => 'Menu 1',
            'url' => ['/menu1'], //  Array format of Url to, will be not used if have an items
            'icon' => 'fas fa-fw fa-tachometer-alt', // optional, default to "fa fa-circle-o
            'visible' => true, // optional, default to true
            // 'options' => [
            //     'liClass' => 'nav-item',
            // ] // optional
        ],
        [
            'type' => 'divider', // divider or sidebar, if not set then link menu
            // 'label' => '', // if sidebar we will set this, if divider then no
        ],
        [
            'label' => 'Menu 2',
            // 'icon' => 'fa fa-menu', // optional, default to "fa fa-circle-o
            'visible' => true, // optional, default to true
            // 'subMenuTitle' => 'Menu 2 Item', // optional only when have submenutitle, if not exist will not have subMenuTitle
            'items' => [
                [
                    'label' => 'Menu 2 Sub 1',
                    'url' => ['/menu21'], //  Array format of Url to, will be not used if have an items
                ],
                [
                    'label' => 'Menu 2 Sub 2',
                    'url' => ['/menu22'], //  Array format of Url to, will be not used if have an items
                ],
            ]
        ],

        [
            'label' => 'Menu 3',
            'visible' => true, // optional, default to true
            // 'subMenuTitle' => 'Menu 3 Item', // optional only when have submenutitle, if not exist will not have subMenuTitle
            'items' => [
                [
                    'label' => 'Menu 3 Sub 1',
                    'url' => ['/menu21'], //  Array format of Url to, will be not used if have an items
                ],
                [
                    'label' => 'Menu 3 Sub 2',
                    'url' => ['/menu22'], //  Array format of Url to, will be not used if have an items
                    'linkOptions' => [
                       'onClick' => 'alert("This is onClick")',
                    ]
                ],
            ]
        ],
    ]
]);

As you can see in above example, this Widget consist of two primary method.

Card Widget

You can use card widget. This widget will create bootstrap card, optimize for this template

Example use of card are like below code

use hoaaah\sbadmin2\widgets\Card;
echo Card::widget([
    'type' => 'cardBorder',
    'label' => 'Label',
    'sLabel' => '1000',
    'icon' => 'fas fa-calendar',
    'options' => [
        'colSizeClass' => 'col-md-3',
        'borderColor' => 'primary',
    ]
]);

As you can see in above example, this Widget consist of some method.

TODO

Todo Widget

  • Menu
  • CardBorder
  • CardBox
  • HeaderMenu
  • HeaderColor based on Params
  • Etc

Creator

This asset wrapper was created by and is maintained by hoaaah.