atomescrochus / laravel-bulma-starter
使用 Bulma 构建的 Laravel 基本模板的快速替代品
Requires
- php: ~5.6|~7.0
- illuminate/support: ~5.4
Requires (Dev)
- phpunit/phpunit: ~4.0||~5.0
- squizlabs/php_codesniffer: ^2.3
README
使用 Bulma 构建的 Laravel 基本模板的快速替代品。它需要 Laravel >= 5.4。
安装
通过 Composer
$ composer require atomescrochus/laravel-bulma-starter
然后您需要安装包的服务提供者,除非您正在运行 Laravel >=5.5(它将使用包自动发现)。
// config/app.php 'providers' => [ ... Atomescrochus\LaravelBulmaStarter\LaravelBulmaStarterServiceProvider::class, ];
然后,按照以下简单步骤操作
- 将
"bulma": "^0.3.1"
添加到您的package.json
文件中; - 运行
npm update
- (如果您不想再使用 Bootstrap)从您的
resources/assets/sass/app.scss
文件和resources/assets/js/bootstrap.js
中删除或注释对sass_bootstrap
和variables
的引用。 - 将
@import "node_modules/bulma/bulma";
添加到resources/assets/sass/app.scss
文件中 - 运行
npm run [your-choice-of-env]
(模板文件最大使用mix()
辅助函数)
使用方法
发布包的视图文件
如果您想查看代码,可以使用以下方式发布包的文件
php artisan vendor:publish --provider="Atomescrochus\LaravelBulmaStarter\LaravelBulmaStarterServiceProvider" --tag="views"
您可以在 resources/views/vendor/laravel-bulma-starter
中找到它们。
替换 Laravel 默认文件
如果您想替换 welcome.blade.php
为包中提供的版本,只需打开 Laravel 提供的版本,并用 @include('laravel-bulma-starter::welcome')
替换其内容。对于 auth.login
视图,我会使用 @include('laravel-bulma-starter::auth.login')
,依此类推。
自行使用包默认模板
只需创建一个新的 blade 文件,并用 @extends('laravel-bulma-starter::layouts.bulma')
扩展它。
您可以使用以下方式向此布局文件传递内容
@section('content')
Some content.
@endsection
您可以将元素添加到右上角菜单中,如下所示
@push('right-nav-menu')
<a class="nav-item is-tab" href="{{ url('/some-link') }}">A menu item</a>
<a class="nav-item is-tab" href="{{ url('/some-other-link') }}">Another menu item</a>
@endpush
如果您需要添加其他脚本或样式表,可以使用一些附加堆栈(例如 scripts-before
、scripts-after
、styles-before
和 styles-after
)
@push('scripts-before')
<!-- This will be added right before the inclusion of app.js -->
<!-- You still have to use the <script> tags here. -->
@endpush
@push('styles-before')
<!-- This will be added right before the inclusion of app.css -->
<!-- You still have to use the <link> tags here. -->
@endpush
错误显示组件
除了使用 Bulma 之外,此包的视图与 Laravel 的默认视图之间唯一的真正区别是我使用了一个自定义的错误组件。它可以这样使用
// if using it in a "horizontal form" @include('laravel-bulma-starter::components.forms-errors', ['field' => 'nameOfField', 'type' => 'horizontal']) // or if in a regular form, just omit the type @include('laravel-bulma-starter::components.forms-errors', ['field' => 'nameOfField'])
当然,您不必在这个包的视图之外使用这些组件,但我发现它非常有用,所以不妨试试!
变更日志
请参阅 CHANGELOG 了解最近更改的更多信息。
贡献
请参阅CONTRIBUTING和CONDUCT获取详细信息。
安全
如果您发现任何与安全相关的问题,请发送电子邮件至jp@atomescroch.us,而不是使用问题跟踪器。
致谢
- [Jean-Philippe Murray][https://github.com/jpmurray]
- 所有贡献者
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。