1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Xetaravel\View\Components; |
4
|
|
|
|
5
|
|
|
use Closure; |
6
|
|
|
use Illuminate\Contracts\View\View; |
7
|
|
|
use Illuminate\View\Component; |
8
|
|
|
|
9
|
|
|
class Button extends Component |
10
|
|
|
{ |
11
|
|
|
public string $uuid; |
12
|
|
|
|
13
|
|
|
public string $tooltipPosition = 'lg:tooltip-top'; |
14
|
|
|
|
15
|
|
|
public function __construct( |
16
|
|
|
public ?string $label = null, |
17
|
|
|
public ?string $icon = null, |
18
|
|
|
public ?string $iconRight = null, |
19
|
|
|
public ?string $spinner = null, |
20
|
|
|
public ?string $link = null, |
21
|
|
|
public ?bool $external = false, |
22
|
|
|
public ?bool $noWireNavigate = false, |
23
|
|
|
public ?bool $responsive = false, |
24
|
|
|
public ?string $badge = null, |
25
|
|
|
public ?string $badgeClasses = null, |
26
|
|
|
public ?string $tooltip = null, |
27
|
|
|
public ?string $tooltipLeft = null, |
28
|
|
|
public ?string $tooltipRight = null, |
29
|
|
|
public ?string $tooltipBottom = null, |
30
|
|
|
) { |
31
|
|
|
$this->uuid = md5(serialize($this)); |
32
|
|
|
$this->tooltip = $this->tooltip ?? $this->tooltipLeft ?? $this->tooltipRight ?? $this->tooltipBottom; |
33
|
|
|
$this->tooltipPosition = $this->tooltipLeft ? 'lg:tooltip-left' : ($this->tooltipRight ? 'lg:tooltip-right' : ($this->tooltipBottom ? 'lg:tooltip-bottom' : 'lg:tooltip-top')); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function spinnerTarget(): ?string |
37
|
|
|
{ |
38
|
|
|
if ($this->spinner == 1) { |
39
|
|
|
return $this->attributes->whereStartsWith('wire:click')->first(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
return $this->spinner; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Get the view / contents that represent the component. |
47
|
|
|
*/ |
48
|
|
|
public function render(): View|Closure|string |
49
|
|
|
{ |
50
|
|
|
return view('components.button'); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|