Skip to content

Commit

Permalink
Merge pull request #6 from salahhusa9/component/select
Browse files Browse the repository at this point in the history
Component Select
  • Loading branch information
salahhusa9 authored Aug 6, 2023
2 parents 85ac1af + ee6274a commit fe1fa9a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ we support livewire loading state, so if you use livewire you can use loading st
<x-template-components::button wire:target="save" />
```

### Select component
```html
<x-template-components::select />
```
He accept all normal attributes of select tag and add some new attributes:
- div-class: add class to div tag
- label-class: add class to label tag
- other attributes will be added to select tag

## Supported Templates

- [Vuexy](https://pixinvent.com/demo/vuexy-html-bootstrap-admin-template/html/ltr/vertical-menu-template/dashboard-ecommerce.html)
Expand Down
9 changes: 8 additions & 1 deletion config/template-components.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
'button' => 'btn',
'indicator-progress' => 'd-block',
'spinner-class' => 'spinner-border spinner-border-sm',
]
],
'select' => [
'div' => '',
'label' => 'form-label',
'select' => 'form-select',
'error-div' => 'invalid-feedback',
'select-error' => 'is-invalid',
],
],
];
20 changes: 20 additions & 0 deletions resources/views/components/select.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="{{ config('template-components.defult_classes.select.div') }} {{ $attributes->get('div-class') }}">

<label class="{{ config('template-components.defult_classes.select.label') }} {{ $attributes->get('label-class') }}">
{{ $attributes->get('label') }}
</label>

<select class="{{ config('template-components.defult_classes.select.select') }} {{ $attributes->get('class') }}
@error($attributes->get('name') ?? $attributes->whereStartsWith('wire:model')->first())
{{ config('template-components.defult_classes.select.select-error') }}
@enderror"
{{ $attributes }} >
{{ $slot }}
</select>

@error($attributes->get('name') ?? $attributes->whereStartsWith('wire:model')->first())
<div class="{{ config('template-components.defult_classes.select.error-div') }}">
{{ $message }}
</div>
@enderror
</div>
9 changes: 9 additions & 0 deletions tests/components/SelectComponentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

// test select component

use Illuminate\Support\Facades\View;

it('can render select component', function () {
$this->assertTrue(View::exists('template-components::select'));
});

0 comments on commit fe1fa9a

Please sign in to comment.