Skip to content

Commit fe1fa9a

Browse files
authored
Merge pull request #6 from salahhusa9/component/select
Component Select
2 parents 85ac1af + ee6274a commit fe1fa9a

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ we support livewire loading state, so if you use livewire you can use loading st
4949
<x-template-components::button wire:target="save" />
5050
```
5151

52+
### Select component
53+
```html
54+
<x-template-components::select />
55+
```
56+
He accept all normal attributes of select tag and add some new attributes:
57+
- div-class: add class to div tag
58+
- label-class: add class to label tag
59+
- other attributes will be added to select tag
60+
5261
## Supported Templates
5362

5463
- [Vuexy](https://pixinvent.com/demo/vuexy-html-bootstrap-admin-template/html/ltr/vertical-menu-template/dashboard-ecommerce.html)

config/template-components.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
'button' => 'btn',
1515
'indicator-progress' => 'd-block',
1616
'spinner-class' => 'spinner-border spinner-border-sm',
17-
]
17+
],
18+
'select' => [
19+
'div' => '',
20+
'label' => 'form-label',
21+
'select' => 'form-select',
22+
'error-div' => 'invalid-feedback',
23+
'select-error' => 'is-invalid',
24+
],
1825
],
1926
];
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<div class="{{ config('template-components.defult_classes.select.div') }} {{ $attributes->get('div-class') }}">
2+
3+
<label class="{{ config('template-components.defult_classes.select.label') }} {{ $attributes->get('label-class') }}">
4+
{{ $attributes->get('label') }}
5+
</label>
6+
7+
<select class="{{ config('template-components.defult_classes.select.select') }} {{ $attributes->get('class') }}
8+
@error($attributes->get('name') ?? $attributes->whereStartsWith('wire:model')->first())
9+
{{ config('template-components.defult_classes.select.select-error') }}
10+
@enderror"
11+
{{ $attributes }} >
12+
{{ $slot }}
13+
</select>
14+
15+
@error($attributes->get('name') ?? $attributes->whereStartsWith('wire:model')->first())
16+
<div class="{{ config('template-components.defult_classes.select.error-div') }}">
17+
{{ $message }}
18+
</div>
19+
@enderror
20+
</div>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
// test select component
4+
5+
use Illuminate\Support\Facades\View;
6+
7+
it('can render select component', function () {
8+
$this->assertTrue(View::exists('template-components::select'));
9+
});

0 commit comments

Comments
 (0)