Skip to content

Commit

Permalink
add: sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
ah-rahimi committed Apr 9, 2023
1 parent 99b1c81 commit cb4b71d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions resources/views/form/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
@endforeach
</div>

<button type="submit" class="btn btn-{{ $form->submit_color ?? 'primary' }}">
<button type="submit" class="btn btn-{{ $form->submit_color ?? 'primary' }} btn-{{ $form->submit_size }}">
{{ $form->submit ?? 'ثبت فرم' }}
</button>

@if (isset($form->reset))
<button type="reset" class="btn btn-{{ $form->reset_color }}">{{ $form->reset }}</button>
<button type="reset" class="btn btn-{{ $form->reset_color }} btn-{{ $form->reset_size }}">
{{ $form->reset }}
</button>
@endif
</form>
13 changes: 9 additions & 4 deletions src/Controllers/Makers/FormMaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use T0team\LaravelPanel\Controllers\Form\Group;
use T0team\LaravelPanel\Enums\Color;
use T0team\LaravelPanel\Enums\Size;

class FormMaker extends Maker
{
Expand Down Expand Up @@ -33,25 +34,29 @@ public function addGroup(Group $group): FormMaker
return $this;
}

public function submit(string $label, string $color = 'primary'): FormMaker
public function submit(string $label, string $color = 'primary', string $size = 'md'): FormMaker
{
$this->form['submit'] = $label;

Color::is_available_color($color) || throw new \Exception("Submit Color not available In [" . Color::class . "]");

$this->form['submit_color'] = $color;

Size::available_sizes($size) || throw new \Exception("Submit Size not available In [" . Size::class . "]");
$this->form['submit_size'] = $size;

return $this;
}

public function reset(string $label = 'شروع دوباره', string $color = 'secondary'): FormMaker
public function reset(string $label = 'شروع دوباره', string $color = 'secondary', string $size = 'md'): FormMaker
{
$this->form['reset'] = $label;

Color::is_available_color($color) || throw new \Exception("Reset Color not available In [" . Color::class . "]");

$this->form['reset_color'] = $color;

Size::available_sizes($size) || throw new \Exception("Reset Size not available In [" . Size::class . "]");
$this->form['reset_size'] = $size;

return $this;
}

Expand Down

0 comments on commit cb4b71d

Please sign in to comment.