Skip to content

Commit

Permalink
Added customSelected Slot.
Browse files Browse the repository at this point in the history
  • Loading branch information
victorybiz committed Jun 26, 2021
1 parent 59b954b commit a50d810
Show file tree
Hide file tree
Showing 3 changed files with 314 additions and 252 deletions.
39 changes: 34 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Laravel Simple Select inputs component for Blade and Livewire.
- [Usage](#usage)
- [Simple Select](#simple-select)
- [Custom Option Slot](#custom-option-slot)
- [Custom Selected Slot](#custom-selected-slot)
- [Custom Icon Slots](#custom-icon-slots)
- [Dependent Selects](#dependent-selects)
- [Event Listener](#event-listener)
Expand Down Expand Up @@ -187,6 +188,33 @@ $options = [
</x-simple-select>
```

<a name="custom-selected-slot"></a>

#### Custom Selected Slot
```html
<x-simple-select
name="country"
id="country"
:options="$options"
value-field='code'
text-field='name'
placeholder="Select Country"
search-input-placeholder="Search Country"
:searchable="true"
class="form-select"
>
<x-slot name="customSelected">
<img class="float-left mr-2" :src="`https://www.countryflags.io/${option.code?.toLowerCase()}/shiny/24.png`">
<span x-text="option.name"></span>
</x-slot>
<x-slot name="customOption">
<img class="float-left mr-2 -mt-1" :src="`https://www.countryflags.io/${option.code?.toLowerCase()}/shiny/32.png`">
<span x-text="option.name"></span>
</x-slot>
</x-simple-select>
```


<a name="custom-icon-slot"></a>

#### Custom Icon Slots
Expand Down Expand Up @@ -392,18 +420,19 @@ The simple-select component makes use of `Popper.js` for positioning the select

| Name | Description |
| --- | --- |
| **customOption** | Slot for custom option text template. See [example](custom-option-slot) above. |
| **customDeselectOptionIcon**| Slot for custom deselect option icon markup. See [example](custom-icon-slot) above. |
| **customCaretDownIcon**| Slot for custom caret down icon markup. See [example](custom-icon-slot) above. |
| **customCaretUpIcon**| Slot for custom caret up icon markup. See [example](custom-icon-slot) above. |
| **customOption** | Slot for custom option text template. See [example](#custom-option-slot) above. |
| **customSelected** | Slot for custom selected template. See [example](#custom-selected-slot) above. |
| **customDeselectOptionIcon**| Slot for custom deselect option icon markup. See [example](#custom-icon-slot) above. |
| **customCaretDownIcon**| Slot for custom caret down icon markup. See [example](#custom-icon-slot) above. |
| **customCaretUpIcon**| Slot for custom caret up icon markup. See [example](#custom-icon-slot) above. |

<a name="events"></a>

## Events

| Name | Listen to | Description |
| --- | --- | --- |
| **Select** | `select` | Emitted after selecting an option. See [example](event-listener) above. |
| **Select** | `select` | Emitted after selecting an option. See [example](#event-listener) above. |


## Testing
Expand Down
Loading

0 comments on commit a50d810

Please sign in to comment.