Skip to content

Commit d7444ab

Browse files
committed
popover
1 parent 18684f4 commit d7444ab

File tree

8 files changed

+90
-39
lines changed

8 files changed

+90
-39
lines changed

composer.json

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"require": {
2020
"php": "^8.2",
2121
"blade-ui-kit/blade-icons": "^1.7",
22-
"illuminate/contracts": "^10.0||^11.0",
22+
"illuminate/contracts": "^10.0||^11.0||^12.0",
2323
"spatie/laravel-package-tools": "^1.16"
2424
},
2525
"require-dev": {
@@ -43,17 +43,20 @@
4343
"autoload-dev": {
4444
"psr-4": {
4545
"Elegantly\\Kit\\Tests\\": "tests/",
46-
"Workbench\\App\\": "workbench/app/"
46+
"Workbench\\App\\": "workbench/app/",
47+
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
48+
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
4749
}
4850
},
4951
"scripts": {
50-
"post-autoload-dump": "@composer run prepare",
51-
"clear": "@php vendor/bin/testbench package:purge-blade-kit --ansi",
52-
"prepare": "@php vendor/bin/testbench package:discover --ansi",
53-
"build": [
54-
"@composer run prepare",
55-
"@php vendor/bin/testbench workbench:build --ansi"
52+
"post-autoload-dump": [
53+
"@clear",
54+
"@prepare",
55+
"@composer run prepare"
5656
],
57+
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
58+
"prepare": "@php vendor/bin/testbench package:discover --ansi",
59+
"build": "@php vendor/bin/testbench workbench:build --ansi",
5760
"start": [
5861
"Composer\\Config::disableProcessTimeout",
5962
"@composer run build",
@@ -62,7 +65,16 @@
6265
"analyse": "vendor/bin/phpstan analyse",
6366
"test": "vendor/bin/pest",
6467
"test-coverage": "vendor/bin/pest --coverage",
65-
"format": "vendor/bin/pint"
68+
"format": "vendor/bin/pint",
69+
"serve": [
70+
"Composer\\Config::disableProcessTimeout",
71+
"@build",
72+
"@php vendor/bin/testbench serve --ansi"
73+
],
74+
"lint": [
75+
"@php vendor/bin/pint --ansi",
76+
"@php vendor/bin/phpstan analyse --verbose --ansi"
77+
]
6678
},
6779
"config": {
6880
"sort-packages": true,
@@ -83,4 +95,4 @@
8395
},
8496
"minimum-stability": "dev",
8597
"prefer-stable": true
86-
}
98+
}

resources/views/components/button/index.blade.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
'loader' => null,
88
'loading' => false,
99
'badge' => null,
10-
'extra' => null,
10+
'before' => null,
11+
'after' => null,
1112
])
1213

1314
@php
14-
$target = $attributes->wire('target')->value;
15+
$target = $attributes->get('wire:target');
1516
@endphp
1617

1718
<x-kit::button.base :attributes="$attributes->when(
@@ -21,6 +22,7 @@
2122
'wire:loading.class' => 'pointer-events-none',
2223
]),
2324
)" :size="$size">
25+
{!! $before !!}
2426

2527
@if ($icon)
2628
@php
@@ -31,13 +33,18 @@
3133
@endif
3234

3335
@if ($slot->hasActualContent() || $content)
34-
<span @class([
35-
'relative',
36-
'inline-flex min-w-0',
37-
'ml-2' => $icon && $offset,
38-
'mr-2' => $iconRight && $offset,
39-
$content?->attributes->get('class'),
40-
])>
36+
@php
37+
$contentAttributes = is_object($content)
38+
? $content->attributes
39+
: new \Illuminate\View\ComponentAttributeBag();
40+
@endphp
41+
<span
42+
{{ $contentAttributes->class([
43+
'relative',
44+
'inline-flex min-w-0',
45+
'ml-2' => $icon && $offset,
46+
'mr-2' => $iconRight && $offset,
47+
]) }}>
4148
{{ $content ?? $slot }}
4249

4350
@if (!$icon && $badge)
@@ -61,5 +68,5 @@
6168
wire:target="{{ $target }}">{{ $loader }}</x-kit::buttons.loader>
6269
@endif
6370

64-
{!! $extra !!}
71+
{!! $after !!}
6572
</x-kit::button.base>

resources/views/components/button/radio.blade.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,35 @@
33
'disabled' => false,
44
'colorChecked' => 'black',
55
'type' => 'radio',
6+
'icon' => null,
7+
'iconRight' => null,
68
])
79

810
@php
911
$input = $attributes->filter(function ($value, $key) {
1012
return in_array($key, ['name', 'value']) || Str::startsWith($key, ['x-model', 'wire:model']);
1113
});
12-
$label = $attributes
13-
->except(array_keys($input->all()))
14-
->class([\Elegantly\Kit\Facades\Kit::button()->color($colorChecked)->checked()]);
14+
$label = $attributes->except(array_keys($input->all()))->class([
15+
//
16+
// 'has-[:focus-visible]:outline has-[:active]:outline',
17+
\Elegantly\Kit\Facades\Kit::button()->color($colorChecked)->checked(),
18+
]);
1519
@endphp
1620

1721
<x-kit::button tag="label" :attributes="$label">
18-
<x-slot:extra>
22+
<x-slot:before>
1923
<input type="{{ $type }}" {{ $input }}
20-
class="size-full pointer-events-none absolute left-0 top-0 appearance-none opacity-0"
24+
class="peer/input pointer-events-none absolute left-0 top-0 size-full appearance-none opacity-0"
2125
@checked($checked) @disabled($disabled)>
22-
</x-slot:extra>
26+
</x-slot:before>
27+
28+
@if ($icon?->hasActualContent())
29+
<x-slot:icon :attributes="$iconRight?->icon"> {{ $icon }} </x-slot:icon>
30+
@endif
2331

2432
{{ $slot }}
33+
34+
@if ($iconRight?->hasActualContent())
35+
<x-slot:icon-right :attributes="$iconRight?->attributes"> {{ $iconRight }} </x-slot:icon-right>
36+
@endif
2537
</x-kit::button>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@props([
2+
'position' => 'bottom-start',
3+
'offset' => 5,
4+
])
5+
6+
<div {{ $attributes }} x-show="open" x-trap="open"
7+
x-anchor.{!! $position !!}.offset.{!! $offset !!}="$refs.trigger" x-on:click.outside="open = false"
8+
x-on:keyup.escape.prevent="open = false">
9+
{{ $slot }}
10+
</div>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@props([
2+
'xData' => '{}',
3+
])
4+
5+
<div {{ $attributes->class(['']) }} x-data="{
6+
open: true,
7+
...{!! $xData !!}
8+
}">
9+
{{ $slot }}
10+
</div>

src/Ui/Button.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public function icon(): static
3535
{
3636
return $this->append(match ($this->size) {
3737
'2xs' => 'size-4 p-px',
38-
'xs' => 'size-4',
39-
'sm' => 'size-5 p-0.5',
40-
'base', 'md' => 'size-5 p-0.5',
38+
'xs' => 'size-4 text-base',
39+
'sm' => 'size-5 p-0.5 text-base',
40+
'base', 'md' => 'size-5 p-0.5 text-base',
4141
'lg' => 'size-6 p-0.5',
4242
'xl' => 'size-7 p-0.5',
4343
default => ''
@@ -46,13 +46,13 @@ public function icon(): static
4646

4747
public function checked(): string
4848
{
49-
return match ($this->color) {
49+
return $this->append(match ($this->color) {
5050
'white' => 'has-[:checked]:bg-white has-[:checked]:text-black',
5151
'black' => 'has-[:checked]:bg-black has-[:checked]:text-white',
5252
'emerald' => 'has-[:checked]:bg-emerald-500 has-[:checked]:text-white',
5353
'rose' => 'has-[:checked]:bg-rose-500 has-[:checked]:text-white',
5454
'amber' => 'has-[:checked]:bg-amber-500 has-[:checked]:text-white',
5555
default => ''
56-
};
56+
});
5757
}
5858
}

src/Ui/Input.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Input extends Base
1010
public function text(): static
1111
{
1212
return $this->append(match ($this->color) {
13-
'white' => 'text-black placeholder:text-gray-400',
13+
'white' => 'text-black placeholder:text-black/40',
1414
default => ''
1515
});
1616
}
@@ -22,9 +22,9 @@ public function icon(): static
2222
{
2323
$this->append(match ($this->size) {
2424
'2xs' => 'size-4 p-px my-2 mx-2',
25-
'xs' => 'size-4 my-2 mx-2',
26-
'sm' => 'size-5 p-0.5 my-2 mx-2',
27-
'base', 'md' => 'size-5 p-0.5 my-2 mx-2',
25+
'xs' => 'size-4 my-1.5 mx-1.5 text-base',
26+
'sm' => 'size-5 p-0.5 my-1.5 mx-1.5',
27+
'base', 'md' => 'size-5 p-0.5 my-2 mx-2 text-base',
2828
'lg' => 'size-6 p-0.5 my-2 mx-2',
2929
'xl' => 'size-7 p-0.5 my-2 mx-2',
3030
default => ''
@@ -62,8 +62,8 @@ public function spacingIconLeft(): static
6262
{
6363
return $this->append(match ($this->size) {
6464
'2xs' => '',
65-
'xs' => '',
66-
'sm' => '',
65+
'xs' => 'pl-7',
66+
'sm' => 'pl-8',
6767
'base', 'md', 'lg', 'xl' => 'pl-8',
6868
default => ''
6969
});

src/Ui/Tag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public function icon(): static
99
$this->append(match ($this->size) {
1010
'2xs' => 'size-4 p-px',
1111
'xs' => 'size-4',
12-
'sm' => 'size-5 p-0.5',
13-
'base', 'md' => 'size-5 p-0.5',
12+
'sm' => 'size-5 p-0.5 text-base',
13+
'base', 'md' => 'size-5 p-0.5 text-base',
1414
'lg' => 'size-6 p-0.5',
1515
'xl' => 'size-6 p-0.5',
1616
default => ''

0 commit comments

Comments
 (0)