Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit 5ec69ec

Browse files
committed
Add custom "after" addon slot
1 parent 1e5863c commit 5ec69ec

File tree

9 files changed

+42
-1
lines changed

9 files changed

+42
-1
lines changed

resources/views/partials/trailing-addons.blade.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
@if ($trailingAddon)
1+
@if ($after ?? null)
2+
{{ $after }}
3+
@elseif ($trailingAddon)
24
<div class="trailing-addon absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
35
<span class="text-blue-gray-500 sm:text-sm sm:leading-5">{!! $trailingAddon !!}</span>
46
</div>

src/Components/Inputs/CustomSelect.php

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function __construct(
4444
public bool $convertValuesToString = false,
4545
public null|string $containerClass = null,
4646
public $extraAttributes = '',
47+
public $after = null,
4748
) {
4849
parent::__construct(
4950
name: $name,

src/Components/Inputs/DatePicker.php

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function __construct(
3434
public null|string $clearIcon = null,
3535
public null|string $containerClass = null,
3636
public $extraAttributes = '',
37+
public $after = null,
3738
) {
3839
parent::__construct(
3940
name: $name,

src/Components/Inputs/Input.php

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function __construct(
3636
$trailingAddonPadding = self::DEFAULT_TRAILING_ADDON_PADDING,
3737
$trailingIcon = false,
3838
public $extraAttributes = '',
39+
public $after = null,
3940
) {
4041
$this->id = $this->id ?? $this->name;
4142
$this->value = $this->name ? old($this->name, $this->value) : $this->value;

src/Components/Inputs/Password.php

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function __construct(
2424
public null|string $hidePasswordIcon = null,
2525
public null|string $containerClass = null,
2626
public $extraAttributes = '',
27+
public $after = null,
2728
) {
2829
parent::__construct(
2930
name: $name,

src/Components/Inputs/Select.php

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function __construct(
2828
$trailingIcon = false,
2929
public null|string $containerClass = null,
3030
public $extraAttributes = '',
31+
public $after = null,
3132
) {
3233
parent::__construct(
3334
name: $name,

src/Components/Inputs/TimezoneSelect.php

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function __construct(
2929
null|string $placeholder = 'form-components::messages.timezone_select_placeholder',
3030
public null|string $containerClass = null,
3131
public $extraAttributes = '',
32+
public $after = null,
3233
) {
3334
parent::__construct(
3435
name: $name,

tests/Components/Inputs/InputTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,22 @@ public function can_have_extra_attributes(): void
246246

247247
$this->assertMatchesSnapshot((string) $view);
248248
}
249+
250+
/** @test */
251+
public function can_have_custom_trailing_addon_markup(): void
252+
{
253+
$template = <<<HTML
254+
<x-input name="foo">
255+
<x-slot name="after">
256+
<div class="my-custom-trailing-addon">
257+
My custom addon content...
258+
</div>
259+
</x-slot>
260+
</x-input>
261+
HTML;
262+
263+
$this->assertMatchesSnapshot(
264+
(string) $this->blade($template)
265+
);
266+
}
249267
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div class="form-text-container flex rounded-sm shadow-sm relative">
2+
3+
<input
4+
class="form-input form-text flex-1 block w-full px-3 py-2 border-blue-gray-300 placeholder-blue-gray-400 sm:text-sm focus:border-blue-300 focus:ring-opacity-50 focus:ring-4 focus:ring-blue-400 rounded-md"
5+
6+
7+
name="foo" id="foo" type="text"
8+
9+
10+
/>
11+
12+
<div class="my-custom-trailing-addon">
13+
My custom addon content...
14+
</div>
15+
</div>

0 commit comments

Comments
 (0)