定制 reedware/nova-treeview 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

reedware/nova-treeview

最新稳定版本:v1.0.0

Composer 安装命令:

composer require reedware/nova-treeview

包简介

A treeview component to use with the Nova sidebar.

README 文档

README

Installation

Require this package with composer.

composer require reedware/nova-treeview

This package uses auto-discovery, so doesn't require you to manually add the service provider. Should you choose to do this manually, you can include the following class in your list of service providers:

\Reedware\NovaTreeview\TreeviewServiceProvider::class

Usage

This packages creates a new <treeview> Vue component that can be used within your views. The <treeview> component at its core can be used to optionally toggle the display of some sort of menu by clicking its corresponding label. In practice, is recommend to be used by the sidebar in Nova.

Basic Syntax

Here's the basic syntax:

<treeview tag="div" class="" toggle-tag="h3" toggle-class="flex items-center cursor-pointer">
  <template slot="label">
    <!-- Some label -->
  </template>

  <template slot="menu">
    <!-- Something to optionally display -->
  <template>
</treeview>

Example: Resource Navigation

Here's what the treeview would look like if applied to resource navigation:

@if(count(Nova::availableResources(request())))
    <treeview tag="div" toggle-tag="h3" toggle-class="cursor-pointer flex items-center font-normal dim text-white mb-6 text-base no-underline">
        <template slot="label">
            <svg class="sidebar-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                <!-- Resources Label -->
            </svg>
            <span class="sidebar-label flex-1">{{ __('Resources') }}</span>
        </template>

        <template slot="menu">
            @foreach($navigation as $group => $resources)
                @if(count($groups) > 1)
                    <h4 class="ml-8 mb-4 text-xs text-white-50% uppercase tracking-wide">{{ $group }}</h4>
                @endif

                <ul class="list-reset mb-8">
                    @foreach($resources as $resource)
                        <li class="leading-tight mb-4 ml-8 text-sm">
                            <!-- Link to each Resource -->
                        </li>
                    @endforeach
                </ul>
            @endforeach
        </template>
    </treeview>
@endif

Which will result in the following:

Resource Example

By clicking the "Resources" label, you will expand the resources portion of the sidebar. Just remember, you can use the treeview anywhere in the sidebar (it doesn't have to be specifically for resources).

Example: Resource Groups

Additionally, you can nest treeviews within treeviews. Here's an example using treeviews to collapse Resource Groups:

@if(count(Nova::availableResources(request())))
    <treeview tag="div" toggle-tag="h3" toggle-class="cursor-pointer flex items-center font-normal dim text-white mb-6 text-base no-underline">
        <template slot="label">
            <svg class="sidebar-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
                <!-- Resources Label -->
            </svg>
            <span class="sidebar-label flex-1">{{ __('Resources') }}</span>
        </template>

        <template slot="menu">
            @foreach($navigation as $group => $resources)
                @if(count($groups) > 1)
                    <treeview tag="div" toggle-tag="h4" toggle-class="cursor-pointer flex items-center ml-8 mb-4 text-xs text-white-50% dim uppercase tracking-wide">
                        <template slot="label">
                            <span class="flex-1">{{ $group }}</span>
                        </template>

                        <template slot="menu">
                @endif

                <ul class="list-reset mb-8">
                    @foreach($resources as $resource)
                        <li class="leading-tight mb-4 ml-8 text-sm">
                            <!-- Link to each Resource -->
                        </li>
                    @endforeach
                </ul>

                @if(count($groups) > 1)
                        </template>
                    </treeview>
                @endif

            @endforeach
        </template>
    </treeview>
@endif

This will result in the following:

Resource Group Example

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-26