From 3435762cb1a99431996c56abc8f15b1cdb24a66b Mon Sep 17 00:00:00 2001 From: Bogdan Kharchenko Date: Wed, 19 Feb 2020 10:15:22 -0500 Subject: [PATCH 1/4] Remove improper label add a test for the future --- src/AireBootstrapServiceProvider.php | 7 ++----- tests/BootstrapMarkupTest.php | 9 +++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/AireBootstrapServiceProvider.php b/src/AireBootstrapServiceProvider.php index 3f05098..2909234 100644 --- a/src/AireBootstrapServiceProvider.php +++ b/src/AireBootstrapServiceProvider.php @@ -137,9 +137,6 @@ public function boot() }); Input::registerElementMutator(function (Input $input) { - - // Apply a label by default - $input->group->label('Choose file'); $input->attributes->registerMutator('class', function (ClassNames $classNames) use ($input) { @@ -147,11 +144,11 @@ public function boot() $classNames ->remove('form-control') ->add('custom-file-input'); - + $input ->groupAddClass('custom-file') ->groupRemoveClass('form-group'); - + $input->group->label ->addClass('custom-file-label') ->removeClass('cursor-pointer'); diff --git a/tests/BootstrapMarkupTest.php b/tests/BootstrapMarkupTest.php index 4604a54..984d314 100644 --- a/tests/BootstrapMarkupTest.php +++ b/tests/BootstrapMarkupTest.php @@ -74,4 +74,13 @@ public function test_radio_group_form() : void $this->assertSelectorAttribute($html, 'div.form-check > input.form-check-input', 'value', 'radio-1'); $this->assertSelectorContainsText($html,'div.form-check > label.form-check-label','Radio 1'); } + + public function test_when_no_label_given_a_label_is_not_generated() : void + { + $html = $this->aire() + ->form() + ->input('text-input'); + + $this->assertSelectorDoesNotExist($html, 'label'); + } } From 24950f4513c84c357db834c2faab7b383cc92331 Mon Sep 17 00:00:00 2001 From: Bogdan Kharchenko Date: Wed, 19 Feb 2020 10:26:32 -0500 Subject: [PATCH 2/4] fix a few tests --- tests/BootstrapMarkupTest.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/BootstrapMarkupTest.php b/tests/BootstrapMarkupTest.php index 984d314..27c11c0 100644 --- a/tests/BootstrapMarkupTest.php +++ b/tests/BootstrapMarkupTest.php @@ -24,10 +24,10 @@ public function test_an_ungrouped_checkbox(): void ->id('foo-box') ->withoutGroup(); - $this->assertSelectorExists($html, 'div.form-check'); - $this->assertSelectorAttribute($html, 'div.form-check > input.form-check-input', 'name', 'demo'); - $this->assertSelectorAttribute($html, 'div.form-check > label.form-check-label', 'for', 'foo-box'); - $this->assertSelectorContainsText($html, 'div.form-check > label.form-check-label', 'Demo checkbox'); + $this->assertSelectorDoesNotExist($html,'.form-group'); + $this->assertSelectorAttribute($html, 'input.custom-control-input', 'name', 'demo'); + $this->assertSelectorAttribute($html, 'label.custom-control-label', 'for', 'foo-box'); + $this->assertSelectorContainsText($html, 'label.custom-control-label', 'Demo checkbox'); } public function test_a_select_form(): void @@ -61,7 +61,7 @@ public function test_submit_button_html() ->id('foo-submit-button'); $this->assertSelectorAttribute($html, 'button', 'type', 'submit'); - $this->assertSelectorAttribute($html, 'button', 'class', 'btn btn-primary'); + $this->assertSelectorAttribute($html, 'button', 'class', 'btn btn-primary '); $this->assertSelectorAttribute($html, 'button', 'id', 'foo-submit-button'); $this->assertSelectorContainsText($html, 'button', 'Submit Awesome'); } @@ -71,8 +71,9 @@ public function test_radio_group_form() : void $html = $this->aire()->form() ->radioGroup(['radio-1'=>'Radio 1','radio-2'=>'Radio 2'],'radio_selector','Foo Radio Selector'); - $this->assertSelectorAttribute($html, 'div.form-check > input.form-check-input', 'value', 'radio-1'); - $this->assertSelectorContainsText($html,'div.form-check > label.form-check-label','Radio 1'); + $this->assertSelectorContainsText($html, 'div.form-group > label', 'Foo Radio Selector'); + $this->assertSelectorAttribute($html,'div.custom-control.custom-radio > input.custom-control-input','value', 'radio-1'); + $this->assertSelectorAttribute($html,'div.custom-control.custom-radio + div.custom-control.custom-radio > input.custom-control-input','value', 'radio-2'); } public function test_when_no_label_given_a_label_is_not_generated() : void From b2f15ef54ea42c8994b903cb3cba3d92a8c0b174 Mon Sep 17 00:00:00 2001 From: Bogdan Kharchenko Date: Wed, 19 Feb 2020 10:48:19 -0500 Subject: [PATCH 3/4] publish bootstrap specific views --- src/AireBootstrapServiceProvider.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/AireBootstrapServiceProvider.php b/src/AireBootstrapServiceProvider.php index 2909234..7a69918 100644 --- a/src/AireBootstrapServiceProvider.php +++ b/src/AireBootstrapServiceProvider.php @@ -14,6 +14,10 @@ public function boot() { $this->loadViewsFrom(dirname(__DIR__) . '/views', 'aire-bootstrap'); + $this->publishes([ + dirname(__DIR__).'/views' => $this->app->resourcePath('views/vendor/aire-bootstrap'), + ], 'aire-bootstrap-views'); + Aire::setTheme('aire-bootstrap', null, [ 'default_classes' => [ 'group' => 'form-group', From f7f371c7380e43126c95a7728a5643d4d4349345 Mon Sep 17 00:00:00 2001 From: Bogdan Kharchenko Date: Wed, 19 Feb 2020 10:53:23 -0500 Subject: [PATCH 4/4] remove d-none defaults from group errors --- src/AireBootstrapServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AireBootstrapServiceProvider.php b/src/AireBootstrapServiceProvider.php index 7a69918..0f7d9f3 100644 --- a/src/AireBootstrapServiceProvider.php +++ b/src/AireBootstrapServiceProvider.php @@ -25,7 +25,7 @@ public function boot() 'group_prepend' => 'input-group-prepend', 'group_append' => 'input-group-append', 'group_help_text' => 'form-text text-muted', - 'group_errors' => 'd-none', + 'group_errors' => '', 'label' => '', 'input' => 'form-control',