Skip to content

Commit

Permalink
buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaneGlee committed Mar 20, 2019
1 parent 26f250d commit 11c8a68
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/Buttons/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class Button implements Renderable, ReceivesData
{
protected $text;
protected $icon;
protected $action_type;
protected $url_template;
protected $data_attributes = [];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/Buttons/ButtonGroupDropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/Buttons/ImageButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/Buttons/PostButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 15 additions & 0 deletions src/views/button.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@if($button->isButton())
<button {!! $button->attributes() !!}>
@if($button->getIcon() != '')
<span class="fa fa-{{ $button->getIcon() }}"></span>
@endif
{{ $button->getText() }}
</button>
@else
<a {!! $button->attributes() !!}>
@if($button->getIcon() != '')
<span class="fa fa-{{ $button->getIcon() }}"></span>
@endif
{{ $button->getText() }}
</a>
@endif
18 changes: 18 additions & 0 deletions src/views/button_group_dropdown.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="btn-group">
@if($button->isButton())
<button {!! $button->attributes() !!}>{{ $button->getText() }}</button>
@else
<a {!! $button->attributes() !!}>{{ $button->getText() }}</a>
@endif
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu dropdown-menu-right">
@foreach($button->buttons as $btn)
<li>
{!! $btn->render() !!}
</li>
@endforeach
</ul>
</div>
6 changes: 6 additions & 0 deletions src/views/image_button.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@if($button->isButton())
<button {!! $button->attributes() !!}><img height="20" src="{{ $button->getImage() }}" /></button>
@else
<a {!! $button->attributes() !!}><img height="20" src="{{ $button->getImage() }}" /></a>
@endif

6 changes: 6 additions & 0 deletions src/views/post_button.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{ Form::open(['url' => $button->getRoute(),'style' => 'display:inline-block;']) }}
@foreach($button->data() as $key => $value)
{{ Form::hidden($key, $value) }}
@endforeach
<button type="submit" {!! $button->attributes() !!}>{{ $button->getText() }}</button>
{{ Form::close() }}

0 comments on commit 11c8a68

Please sign in to comment.