From 264f3b6969a642c4f093a9ca36315632fbd788ba Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 17:23:05 +0100 Subject: [PATCH 01/13] first test --- README.md | 1 + config/template-components.php | 4 ++-- resources/views/components/card.blade.php | 13 +++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 resources/views/components/card.blade.php diff --git a/README.md b/README.md index aa66878..4047b7f 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,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..3ff8827 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', ], diff --git a/resources/views/components/card.blade.php b/resources/views/components/card.blade.php new file mode 100644 index 0000000..5a1c166 --- /dev/null +++ b/resources/views/components/card.blade.php @@ -0,0 +1,13 @@ +@props(['heading', 'footer']) + +
attributes->class(['card', 'mb-4']) }}> +
attributes->class(['card-header']) }}> + {{ $heading }} +
+
class(['card-body']) }}> + {{ $slot }} +
+
attributes->class(['card-footer']) }}> + {{ $footer }} +
+
From b0196c30ef4153def0c79a1fd1ac3a3ab1715218 Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 17:36:35 +0100 Subject: [PATCH 02/13] wip --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4047b7f..095e35b 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,12 +46,12 @@ 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 - + @@ -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,7 +72,7 @@ He accept all normal attributes of textarea tag and add some new attributes: ### Form Component ```html - + ``` From eeafea4d082be63c42744bb1fe03a24235b64d02 Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 18:07:53 +0100 Subject: [PATCH 03/13] wip --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 095e35b..1559db2 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,9 +72,9 @@ 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 From bf44ec02bb46d488607e952a130737854b058257 Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 18:08:15 +0100 Subject: [PATCH 04/13] load View and Components --- src/LaravelTemplateComponentsServiceProvider.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/LaravelTemplateComponentsServiceProvider.php b/src/LaravelTemplateComponentsServiceProvider.php index 515191d..01d386e 100644 --- a/src/LaravelTemplateComponentsServiceProvider.php +++ b/src/LaravelTemplateComponentsServiceProvider.php @@ -18,12 +18,19 @@ 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', + ]); } } From ce25bae933fb604dad5f62c60be09459491636c0 Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 18:13:12 +0100 Subject: [PATCH 05/13] wip, textarea set defclass config --- resources/views/components/textarea.blade.php | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) 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 +
From 7fa6311f41eae75f9302e55eb675b7069915da68 Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 18:13:23 +0100 Subject: [PATCH 06/13] configs --- config/template-components.php | 13 +++++++++++++ resources/views/components/card.blade.php | 12 ++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/config/template-components.php b/config/template-components.php index 3ff8827..167847c 100644 --- a/config/template-components.php +++ b/config/template-components.php @@ -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/card.blade.php b/resources/views/components/card.blade.php index 5a1c166..84c5c30 100644 --- a/resources/views/components/card.blade.php +++ b/resources/views/components/card.blade.php @@ -1,13 +1,13 @@ -@props(['heading', 'footer']) +@props(['header', 'footer']) -
attributes->class(['card', 'mb-4']) }}> -
attributes->class(['card-header']) }}> - {{ $heading }} +
attributes->class([config('template-components.defult_classes.card.div')]) }}> +
attributes->class([config('template-components.defult_classes.card.header')]) }}> + {{ $header }}
-
class(['card-body']) }}> +
class([config('template-components.defult_classes.card.body')]) }}> {{ $slot }}
-
attributes->class(['card-footer']) }}> +
attributes->class([config('template-components.defult_classes.card.footer')]) }}> {{ $footer }}
From 49b7bd339a12b7dce7306009dd768727c101230f Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 17:13:56 +0000 Subject: [PATCH 07/13] Fix styling --- config/template-components.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/template-components.php b/config/template-components.php index 167847c..118f79f 100644 --- a/config/template-components.php +++ b/config/template-components.php @@ -34,6 +34,6 @@ 'header' => 'card-header', 'body' => 'card-body', 'footer' => 'card-footer', - ] + ], ], ]; From e7077fbb3d07a6b7c173691d194b7e70b15ee5ad Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 18:20:23 +0100 Subject: [PATCH 08/13] docs --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 1559db2..01d3ea8 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,19 @@ 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 + + +``` + ## Supported Templates - [Vuexy](https://demos.pixinvent.com/vuexy-html-admin-template/landing/) From 7389b07935e5429cdaed89f4b4d853413d105e33 Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 18:25:22 +0100 Subject: [PATCH 09/13] isset --- README.md | 3 +++ resources/views/components/card.blade.php | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 01d3ea8..8c7d701 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,9 @@ he accept all normal attributes of form tag and add some new attributes: ``` +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 form tag ## Supported Templates diff --git a/resources/views/components/card.blade.php b/resources/views/components/card.blade.php index 84c5c30..63b593d 100644 --- a/resources/views/components/card.blade.php +++ b/resources/views/components/card.blade.php @@ -1,13 +1,17 @@ @props(['header', 'footer']) -
attributes->class([config('template-components.defult_classes.card.div')]) }}> +
+ @isset($header)
attributes->class([config('template-components.defult_classes.card.header')]) }}> {{ $header }}
+ @endisset
class([config('template-components.defult_classes.card.body')]) }}> {{ $slot }}
-
attributes->class([config('template-components.defult_classes.card.footer')]) }}> - {{ $footer }} -
+ @isset($footer) +
attributes->class([config('template-components.defult_classes.card.footer')]) }}> + {{ $footer }} +
+ @endisset
From 97871c36f57f0bd3e462a5b603677ead722a490c Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 18:27:54 +0100 Subject: [PATCH 10/13] docs wip --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c7d701..719b510 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ he accept all normal attributes of form tag and add some new attributes: ``` 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 form tag +- other attributes will be added to div tag (content div) ## Supported Templates From 4e2cd5af6fc80b08d55ae65cf380a917ee147cc4 Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 18:36:25 +0100 Subject: [PATCH 11/13] done --- resources/views/components/button.blade.php | 24 +++++++++---------- resources/views/components/form.blade.php | 8 +++---- ...ravelTemplateComponentsServiceProvider.php | 1 + 3 files changed, 17 insertions(+), 16 deletions(-) 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/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/src/LaravelTemplateComponentsServiceProvider.php b/src/LaravelTemplateComponentsServiceProvider.php index 01d386e..3b25da5 100644 --- a/src/LaravelTemplateComponentsServiceProvider.php +++ b/src/LaravelTemplateComponentsServiceProvider.php @@ -31,6 +31,7 @@ public function configurePackage(Package $package): void 'input' => 'template-components::components.input', 'select' => 'template-components::components.select', 'textarea' => 'template-components::components.textarea', + 'form' => 'template-components::components.form', ]); } } From f3deb2220a09eaf1d5c2d487bdabec3fc08f3fe2 Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 18:49:24 +0100 Subject: [PATCH 12/13] Tests --- tests/components/ButtonComponentTest.php | 2 +- tests/components/FormComponentTest.php | 2 +- tests/components/InputComponentTest.php | 2 +- tests/components/SelectComponentTest.php | 2 +- tests/components/TextareaComponentTest.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) 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/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')); }); From ad8fbddfe06069b7c8c72936febf191b472c5be9 Mon Sep 17 00:00:00 2001 From: salahhusa9 Date: Thu, 31 Aug 2023 18:49:52 +0100 Subject: [PATCH 13/13] Test card --- tests/components/CardComponentTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/components/CardComponentTest.php 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')); +});