Skip to content

Commit

Permalink
add simple components
Browse files Browse the repository at this point in the history
  • Loading branch information
MimisK13 committed Nov 5, 2023
1 parent 051b230 commit 13e07c7
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 392 deletions.
5 changes: 5 additions & 0 deletions src/LaravelTablerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ protected function bootForConsole(): void
__DIR__.'/../resources/views/errors' => base_path('resources/views/vendor/mimisk13'),
], 'tabler.views');

// Components
$this->publishes([
__DIR__.'/../resources/views/components' => base_path('resources/views/vendor/mimisk13'),
], 'tabler.components');

$this->publishes([
__DIR__.'/../vite.config.js' => base_path(),
], 'tabler.vite-config');
Expand Down
25 changes: 25 additions & 0 deletions stubs/default/resources/views/components/alert.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@props([
// TODO: WIP
])

@if (session('success'))
<div class="alert alert-success alert-dismissible" role="alert">
<h3 class="mb-1">Success</h3>
<p>{{ session('success') }}</p>

<a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
</div>
@endif

@if ($errors->any())
<div class="alert alert-danger alert-dismissible" role="alert">
<h3 class="mb-1">Oops...</h3>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>

<a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
</div>
@endif
18 changes: 18 additions & 0 deletions stubs/default/resources/views/components/button.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@props([
'type' => null ?? 'button',
'route'
])


@isset($route)

<a href="{{ $route }}" {{ $attributes->class(['btn btn-primary w-100']) }}>
{{ $slot }}
</a>

@else
<button type="{{ $type }}" {{ $attributes->class(['btn btn-primary w-100']) }}>
{{ $slot }}
</button>
@endisset
29 changes: 29 additions & 0 deletions stubs/default/resources/views/components/card.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@props([
'header',
'content',
'footer'
])

<div {{ $attributes->class(['card']) }}>

@isset($header)
<div {{ $header->attributes->class(['card-header']) }}>
<h3 class="card-title">
{{ $header }}
</h3>
</div>
@endisset

@isset($content)
<div {{ $content->attributes->class(['card-body']) }}>
{{ $content }}
</div>
@endisset

@isset($footer)
<div {{ $footer->attributes->class(['card-footer']) }}>
{{ $footer }}
</div>
@endisset

</div>
12 changes: 12 additions & 0 deletions stubs/default/resources/views/components/form.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@props([
'action',
'method'
])

<form action="{{ $action }}" method="{{ $method }}">
@method($method)
@csrf

{{ $slot }}
</form>
39 changes: 39 additions & 0 deletions stubs/default/resources/views/components/input.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@props([
'label' => null ?? ucfirst($name),
'type' => null ?? 'text',
'name',
'id' => null ?? $name,
'placeholder' => null,
'autocomplete' => null ?? 'off',
'readonly' => false,
'disabled' => false,
'required' => false,
'value' => null ?? old($name)
])

<div class="mb-3">
<label for="{{ $id }}"
class="form-label @error($name) text-danger @enderror {{ $required ? 'required' : '' }}"
>
{{ __($label) }}
</label>

<input type="{{ $type }}"
name="{{ $name }}"
id="{{ $id }}"
class="form-control rounded-0 @error($name) is-invalid @enderror"
placeholder="{{ $placeholder }}"
autocomplete="{{ $autocomplete }}"
{{ $readonly ? 'readonly' : '' }}
{{ $disabled ? 'disabled' : '' }}
{{ $required ? 'required' : '' }}
{{-- value="{{ old($name, $model->name ) }}"--}}
value="{{ $value }}"
>

@error($name)
<div class="invalid-feedback">
{{ $message }}
</div>
@enderror
</div>
17 changes: 17 additions & 0 deletions stubs/default/resources/views/components/table.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@props([
'thead',
])

<div class="table-responsive">
<table class="table card-table table-vcenter text-nowrap datatable">
<thead>
<tr>
{{ $thead }}
</tr>
</thead>

<tbody>
{{ $slot }}
</tbody>
</table>
</div>
5 changes: 5 additions & 0 deletions stubs/default/resources/views/components/table/td.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@props([
])

<td>{{ $slot }}</td>
423 changes: 31 additions & 392 deletions stubs/default/resources/views/layouts/tabler.blade.php

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions stubs/default/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
return view('dashboard');
});

Route::get('empty/', function () {
return view('empty');
})->name('empty');

Route::get('license', function () {
return view('license');
})->name('license');

0 comments on commit 13e07c7

Please sign in to comment.