From 94e0a1b73c5dbc2904afe3d7c2e6b23d7f5796d8 Mon Sep 17 00:00:00 2001 From: Irineu Junior Date: Tue, 5 Mar 2024 18:03:51 -0300 Subject: [PATCH] =?UTF-8?q?feat(btn)=20criar=20o=20bot=C3=A3o=20submit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Providers/BladeServiceProvider.php | 1 + src/View/Components/Buttons/Submit.php | 42 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/View/Components/Buttons/Submit.php diff --git a/src/Providers/BladeServiceProvider.php b/src/Providers/BladeServiceProvider.php index d054379..017d8b0 100644 --- a/src/Providers/BladeServiceProvider.php +++ b/src/Providers/BladeServiceProvider.php @@ -70,6 +70,7 @@ public function bootComponents(): void Blade::component($prefix . 'btn', Components\Buttons\Button::class); Blade::component($prefix . 'btn.link', Components\Buttons\Link::class); Blade::component($prefix . 'btn.primary', Components\Buttons\Primary::class); + Blade::component($prefix . 'btn.submit', Components\Buttons\Submit::class); Blade::component($prefix . 'card.body', Components\Card\Body::class); Blade::component($prefix . 'card', Components\Card\Card::class); Blade::component($prefix . 'card.footer', Components\Card\Footer::class); diff --git a/src/View/Components/Buttons/Submit.php b/src/View/Components/Buttons/Submit.php new file mode 100644 index 0000000..53badc9 --- /dev/null +++ b/src/View/Components/Buttons/Submit.php @@ -0,0 +1,42 @@ +label = $label ?: __('Send'); + $this->method = strtoupper($method); + } + + public function render(): string|View + { + return <<<'HTML' +
+ @csrf + @method($method) + + +
+ HTML; + } + + public function fallback(): string + { + return str($this->label) + ->stripTags() + ->squish() + ->lower() + ->ucfirst(); + } +}