From 11c8a68d5769efae2ff75d0890eab734518c2661 Mon Sep 17 00:00:00 2001 From: Shane Glee Date: Wed, 20 Mar 2019 12:18:03 +0000 Subject: [PATCH] buttons --- src/Buttons/Button.php | 13 ++++++++++++- src/Buttons/ButtonGroupDropdown.php | 2 +- src/Buttons/ImageButton.php | 2 +- src/Buttons/PostButton.php | 2 +- src/views/button.blade.php | 15 +++++++++++++++ src/views/button_group_dropdown.blade.php | 18 ++++++++++++++++++ src/views/image_button.blade.php | 6 ++++++ src/views/post_button.blade.php | 6 ++++++ 8 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 src/views/button.blade.php create mode 100644 src/views/button_group_dropdown.blade.php create mode 100644 src/views/image_button.blade.php create mode 100644 src/views/post_button.blade.php diff --git a/src/Buttons/Button.php b/src/Buttons/Button.php index 4759c19..f67f10a 100644 --- a/src/Buttons/Button.php +++ b/src/Buttons/Button.php @@ -10,6 +10,7 @@ class Button implements Renderable, ReceivesData { protected $text; + protected $icon; protected $action_type; protected $url_template; protected $data_attributes = []; @@ -47,6 +48,16 @@ public function mergeAttributes(array $attributes) : Button return $this; } + public function getIcon() + { + return $this->icon; + } + + public function setIcon(string $icon) + { + $this->icon = $icon; + } + public function getText() : string { return $this->text; @@ -126,6 +137,6 @@ public function hasAttribute($key) public function render() { - return view('_components.button')->with('button', $this); + return view('core::button')->with('button', $this); } } diff --git a/src/Buttons/ButtonGroupDropdown.php b/src/Buttons/ButtonGroupDropdown.php index 9cab767..a082983 100644 --- a/src/Buttons/ButtonGroupDropdown.php +++ b/src/Buttons/ButtonGroupDropdown.php @@ -68,6 +68,6 @@ public function setTarget($target) public function render() { - return view('_components.button_group_dropdown')->with('button', $this); + return view('core::button_group_dropdown')->with('button', $this); } } diff --git a/src/Buttons/ImageButton.php b/src/Buttons/ImageButton.php index 90d2cc2..745ea24 100644 --- a/src/Buttons/ImageButton.php +++ b/src/Buttons/ImageButton.php @@ -16,7 +16,7 @@ public function __construct($img_url, $route) public function render() { - return view('_components.image_button')->with('button', $this); + return view('core::image_button')->with('button', $this); } public function getImage() diff --git a/src/Buttons/PostButton.php b/src/Buttons/PostButton.php index 3ed610c..7216189 100644 --- a/src/Buttons/PostButton.php +++ b/src/Buttons/PostButton.php @@ -16,7 +16,7 @@ public function __construct($text, $action, $data, BaseBtnType $btn_type) public function render() { - return view('_components.post_button')->with('button', $this); + return view('core::post_button')->with('button', $this); } public function data() diff --git a/src/views/button.blade.php b/src/views/button.blade.php new file mode 100644 index 0000000..1389502 --- /dev/null +++ b/src/views/button.blade.php @@ -0,0 +1,15 @@ +@if($button->isButton()) + +@else + attributes() !!}> + @if($button->getIcon() != '') + + @endif + {{ $button->getText() }} + +@endif \ No newline at end of file diff --git a/src/views/button_group_dropdown.blade.php b/src/views/button_group_dropdown.blade.php new file mode 100644 index 0000000..a115e1b --- /dev/null +++ b/src/views/button_group_dropdown.blade.php @@ -0,0 +1,18 @@ +
+ @if($button->isButton()) + + @else + attributes() !!}>{{ $button->getText() }} + @endif + + +
diff --git a/src/views/image_button.blade.php b/src/views/image_button.blade.php new file mode 100644 index 0000000..6d7f176 --- /dev/null +++ b/src/views/image_button.blade.php @@ -0,0 +1,6 @@ +@if($button->isButton()) + +@else + attributes() !!}> +@endif + diff --git a/src/views/post_button.blade.php b/src/views/post_button.blade.php new file mode 100644 index 0000000..6b77d02 --- /dev/null +++ b/src/views/post_button.blade.php @@ -0,0 +1,6 @@ +{{ Form::open(['url' => $button->getRoute(),'style' => 'display:inline-block;']) }} +@foreach($button->data() as $key => $value) + {{ Form::hidden($key, $value) }} +@endforeach + +{{ Form::close() }}