diff --git a/README.md b/README.md index aa66878..719b510 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ php artisan laravel-template-components:install ### Input Component ```html - + ``` He accept all normal attributes of input tag and add some new attributes: - div-class: add class to div tag @@ -34,7 +34,7 @@ He accept all normal attributes of input tag and add some new attributes: ### Button Component ```html - + ``` He accept all normal attributes of button tag and add some new attributes: - div-class: add class to div tag @@ -46,15 +46,15 @@ He accept all normal attributes of button tag and add some new attributes: we support livewire loading state, so if you use livewire you can use loading state like this: ```html - + ``` ### Select Component ```html - + - + ``` He accept all normal attributes of select tag and add some new attributes: - div-class: add class to div tag @@ -63,7 +63,7 @@ He accept all normal attributes of select tag and add some new attributes: ### Textarea Component ```html - + ``` He accept all normal attributes of textarea tag and add some new attributes: - div-class: add class to div tag @@ -72,14 +72,30 @@ He accept all normal attributes of textarea tag and add some new attributes: ### Form Component ```html - + - + ``` he accept all normal attributes of form tag and add some new attributes: - route: route name that will be used in form action - other attributes will be added to form tag +### Card Component +```html + + + Heading + + Content + + Footer + + +``` +he accept all normal attributes of div tag and add some new attributes: +- div-class: add class to div tag (contener div) +- other attributes will be added to div tag (content div) + ## Supported Templates - [Vuexy](https://demos.pixinvent.com/vuexy-html-admin-template/landing/) @@ -90,6 +106,7 @@ he accept all normal attributes of form tag and add some new attributes: | Vuexy | :white_check_mark: | | Metronic | :white_check_mark: | | Html Standards | :white_check_mark: | +| Bootstrap Classes | :white_check_mark: | ## Testing diff --git a/config/template-components.php b/config/template-components.php index d9099be..118f79f 100644 --- a/config/template-components.php +++ b/config/template-components.php @@ -4,9 +4,9 @@ return [ 'defult_classes' => [ 'input' => [ - 'div' => '', + 'div' => 'form-group', 'label' => 'form-label', - 'input' => 'form-control ', + 'input' => 'form-control', 'error-div' => 'invalid-feedback', 'input-error' => 'is-invalid', ], @@ -22,5 +22,18 @@ 'error-div' => 'invalid-feedback', 'select-error' => 'is-invalid', ], + 'textarea' => [ + 'div' => 'form-group', + 'label' => 'form-label', + 'textarea' => 'form-control', + 'error-div' => 'invalid-feedback', + 'textarea-error' => 'is-invalid', + ], + 'card' => [ + 'div' => 'card', + 'header' => 'card-header', + 'body' => 'card-body', + 'footer' => 'card-footer', + ], ], ]; diff --git a/resources/views/components/button.blade.php b/resources/views/components/button.blade.php index 9f7c98d..e997fcd 100644 --- a/resources/views/components/button.blade.php +++ b/resources/views/components/button.blade.php @@ -1,12 +1,12 @@ - + diff --git a/resources/views/components/card.blade.php b/resources/views/components/card.blade.php new file mode 100644 index 0000000..63b593d --- /dev/null +++ b/resources/views/components/card.blade.php @@ -0,0 +1,17 @@ +@props(['header', 'footer']) + +
+ @isset($header) +
attributes->class([config('template-components.defult_classes.card.header')]) }}> + {{ $header }} +
+ @endisset +
class([config('template-components.defult_classes.card.body')]) }}> + {{ $slot }} +
+ @isset($footer) +
attributes->class([config('template-components.defult_classes.card.footer')]) }}> + {{ $footer }} +
+ @endisset +
diff --git a/resources/views/components/form.blade.php b/resources/views/components/form.blade.php index 496ce53..3254821 100644 --- a/resources/views/components/form.blade.php +++ b/resources/views/components/form.blade.php @@ -1,4 +1,4 @@ -
- @csrf - {{ $slot }} -
\ No newline at end of file +
+ @csrf + {{ $slot }} +
diff --git a/resources/views/components/textarea.blade.php b/resources/views/components/textarea.blade.php index c903d3c..b851dcf 100644 --- a/resources/views/components/textarea.blade.php +++ b/resources/views/components/textarea.blade.php @@ -1,20 +1,20 @@ -
- - - - - - @error($attributes->get('name') ?? $attributes->whereStartsWith('wire:model')->first()) -
- {{ $message }} -
- @enderror -
+
+ + + + + + @error($attributes->get('name') ?? $attributes->whereStartsWith('wire:model')->first()) +
+ {{ $message }} +
+ @enderror +
diff --git a/src/LaravelTemplateComponentsServiceProvider.php b/src/LaravelTemplateComponentsServiceProvider.php index 515191d..3b25da5 100644 --- a/src/LaravelTemplateComponentsServiceProvider.php +++ b/src/LaravelTemplateComponentsServiceProvider.php @@ -18,12 +18,20 @@ public function configurePackage(Package $package): void $package ->name('laravel-template-components') ->hasConfigFile() + ->hasViews() ->hasInstallCommand(function (InstallCommand $command) { $command ->publishConfigFile() ->askToStarRepoOnGitHub('salahhusa9/laravel-template-components'); }); - $this->loadViewsFrom(__DIR__.'/../resources/views/components', 'template-components'); + $this->loadViewComponentsAs('template-components', [ + 'card' => 'template-components::components.card', + 'button' => 'template-components::components.button', + 'input' => 'template-components::components.input', + 'select' => 'template-components::components.select', + 'textarea' => 'template-components::components.textarea', + 'form' => 'template-components::components.form', + ]); } } diff --git a/tests/components/ButtonComponentTest.php b/tests/components/ButtonComponentTest.php index f5c5d84..c8fbee0 100644 --- a/tests/components/ButtonComponentTest.php +++ b/tests/components/ButtonComponentTest.php @@ -5,5 +5,5 @@ use Illuminate\Support\Facades\View; it('can render button component', function () { - $this->assertTrue(View::exists('template-components::button')); + $this->assertTrue(View::exists('template-components::components.button')); }); diff --git a/tests/components/CardComponentTest.php b/tests/components/CardComponentTest.php new file mode 100644 index 0000000..d1a34e6 --- /dev/null +++ b/tests/components/CardComponentTest.php @@ -0,0 +1,9 @@ +assertTrue(View::exists('template-components::components.card')); +}); diff --git a/tests/components/FormComponentTest.php b/tests/components/FormComponentTest.php index 61db1df..d818cd2 100644 --- a/tests/components/FormComponentTest.php +++ b/tests/components/FormComponentTest.php @@ -5,5 +5,5 @@ use Illuminate\Support\Facades\View; it('can render form component', function () { - $this->assertTrue(View::exists('template-components::form')); + $this->assertTrue(View::exists('template-components::components.form')); }); diff --git a/tests/components/InputComponentTest.php b/tests/components/InputComponentTest.php index 69bb0a0..99bd662 100644 --- a/tests/components/InputComponentTest.php +++ b/tests/components/InputComponentTest.php @@ -5,5 +5,5 @@ use Illuminate\Support\Facades\View; it('can render input component', function () { - $this->assertTrue(View::exists('template-components::input')); + $this->assertTrue(View::exists('template-components::components.input')); }); diff --git a/tests/components/SelectComponentTest.php b/tests/components/SelectComponentTest.php index 0e522c5..2101ede 100644 --- a/tests/components/SelectComponentTest.php +++ b/tests/components/SelectComponentTest.php @@ -5,5 +5,5 @@ use Illuminate\Support\Facades\View; it('can render select component', function () { - $this->assertTrue(View::exists('template-components::select')); + $this->assertTrue(View::exists('template-components::components.select')); }); diff --git a/tests/components/TextareaComponentTest.php b/tests/components/TextareaComponentTest.php index 5f60e4c..5748c03 100644 --- a/tests/components/TextareaComponentTest.php +++ b/tests/components/TextareaComponentTest.php @@ -5,5 +5,5 @@ use Illuminate\Support\Facades\View; it('can render textarea component', function () { - $this->assertTrue(View::exists('template-components::textarea')); + $this->assertTrue(View::exists('template-components::components.textarea')); });