Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Commit 991bed4

Browse files
committed
Apply Blade Include, Directive and Component
1 parent 4d1c5f0 commit 991bed4

File tree

8 files changed

+127
-13
lines changed

8 files changed

+127
-13
lines changed

app/Blade/Components.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace App\Blade;
4+
5+
use Illuminate\Support\Facades\Blade;
6+
7+
class Components
8+
{
9+
public static function make()
10+
{
11+
return new self();
12+
}
13+
14+
public function register()
15+
{
16+
$this->cards();
17+
$this->collapse();
18+
$this->modals();
19+
$this->pages();
20+
$this->tabs();
21+
}
22+
23+
private function cards()
24+
{
25+
Blade::component('components.card');
26+
Blade::component('components.cards.figure', 'card-figure');
27+
}
28+
29+
private function collapse()
30+
{
31+
Blade::component('components.collapse.container', 'collapseContainer');
32+
Blade::component('components.collapse.content', 'collapseContent');
33+
}
34+
35+
private function modals()
36+
{
37+
Blade::component('components.modals.base', 'modalBase');
38+
Blade::component('components.modals.button', 'modalButton');
39+
}
40+
41+
private function pages()
42+
{
43+
Blade::component('components.modals.pages', 'pageTitle');
44+
}
45+
46+
private function tabs()
47+
{
48+
Blade::component('components.tab.content', 'tabContent');
49+
Blade::component('components.tab.navigation', 'tabNavigation');
50+
}
51+
}

app/Blade/Directives/Icon.php renamed to app/Blade/Directives.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
<?php
22

3-
namespace App\Blade\Directives;
3+
namespace App\Blade;
44

55
use Illuminate\Support\Facades\Blade;
66

7-
class Icon
7+
class Directives
88
{
9-
public static function register()
9+
public static function make()
10+
{
11+
return new self();
12+
}
13+
14+
public function register()
1015
{
1116
Blade::directive('icon', function ($icon) {
1217
$icon = str_replace('\'', '"', $icon);

app/Blade/Includes.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace App\Blade;
4+
5+
use Illuminate\Support\Facades\Blade;
6+
7+
class Includes
8+
{
9+
public static function make()
10+
{
11+
return new self();
12+
}
13+
14+
public function register()
15+
{
16+
$this->forms();
17+
$this->miscs();
18+
}
19+
20+
private function forms()
21+
{
22+
Blade::include('components.forms.assets.datetimepicker', 'assetDatetimepicker');
23+
Blade::include('components.forms.assets.dropzone', 'assetDropzone');
24+
Blade::include('components.forms.assets.select2', 'assetSelect2');
25+
Blade::include('components.forms.assets.textarea', 'assetTextarea');
26+
Blade::include('components.forms.checkbox');
27+
Blade::include('components.forms.datetimepicker');
28+
Blade::include('components.forms.file');
29+
Blade::include('components.forms.hidden');
30+
Blade::include('components.forms.input');
31+
Blade::include('components.forms.radio');
32+
Blade::include('components.forms.selectmultiple');
33+
Blade::include('components.forms.select');
34+
Blade::include('components.forms.checkbox');
35+
Blade::include('components.forms.submit');
36+
Blade::include('components.forms.switch');
37+
Blade::include('components.forms.textarea');
38+
}
39+
40+
private function miscs()
41+
{
42+
Blade::include('components.app-name', 'appName');
43+
Blade::include('components.logo');
44+
Blade::include('components.actions');
45+
Blade::include('components.avatar');
46+
Blade::include('components.datatable');
47+
Blade::include('components.popover');
48+
Blade::include('components.table');
49+
Blade::include('components.tooltip');
50+
}
51+
}

app/Providers/BladeServiceProvider.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ class BladeServiceProvider extends ServiceProvider
1515
*/
1616
public function boot()
1717
{
18-
\App\Blade\Directives\Icon::register();
19-
20-
// @todo to figure out, how to pass data to the custom component
21-
Blade::component('components.cards.figure', 'figure');
18+
\App\Blade\Components::make()->register();
19+
\App\Blade\Directives::make()->register();
20+
\App\Blade\Includes::make()->register();
2221
}
2322

2423
/**
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ config('app.name') }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<i class="{{ $icon }}"></i>
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
<img height="{{ $height ?? '32px' }}" src="{{ asset('images/logo.svg') }}" class="pr-2" alt="{{ config('app.name') }}">
2-
{{-- <div>
3-
Icons made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a>
4-
</div> --}}
1+
<img height="{{ $height ?? '32px' }}"
2+
src="{{ $src ?? asset('images/logo.svg') }}"
3+
class="pr-2"
4+
alt="{{ $alt ?? config('app.name') }}">
5+
6+
@if(!isset($src))
7+
{{-- <div>
8+
Icons made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a>
9+
</div> --}}
10+
@endif

resources/views/welcome.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<div class="row justify-content-md-center mt-5">
66
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
77
<h1 class="text-center">
8-
@include('components.logo', ['height' => '128px'])
8+
@logo(['height' => '128px'])
99
<br>
10-
{{ config('app.name') }}
10+
@appName()
1111
</h1>
1212
<hr>
1313
<h5 class="text-center">Ready with Bootstrap 4, Font Awesome 5, Select2, Datatable and many more!</h5>

0 commit comments

Comments
 (0)