Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro committed Dec 6, 2018
1 parent d0431c3 commit 0f9f70f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
3 changes: 3 additions & 0 deletions config/aire.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
'default_classes' => [
'input' => 'text-grey-darkest bg-white border rounded-sm',
'summary' => 'border border-red bg-red-lightest text-red font-bold rounded p-4 my-4',
'button' => 'inline-block font-normal text-center whitespace-no-wrap align-middle select-none border
rounded font-normal leading-normal text-white bg-blue-dark border-blue-darker hover:bg-blue-darker
hover:border-blue-darkest p-2 px-4',
],

/*
Expand Down
18 changes: 15 additions & 3 deletions src/Elements/Attributes/ClassNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ public function __toString()
*/
protected function defaults() : ?string
{
return Arr::get(static::$default_classes, $this->element->name);
$key = $this->element->name;

if ('textarea' === $key && !Arr::has(static::$default_classes, 'textarea')) {
$key = 'input';
}

return Arr::get(static::$default_classes, $key);
}

/**
Expand All @@ -113,13 +119,19 @@ protected function defaults() : ?string
*/
protected function validation() : ?string
{
$element_key = $this->element->name;

if ('textarea' === $element_key && !Arr::has(static::$validation_classes, 'textarea')) {
$element_key = 'input';
}

if ($this->element->group) {
$key = "{$this->element->group->validation_state}.{$this->element->name}";
$key = "{$this->element->group->validation_state}.{$element_key}";
return Arr::get(static::$validation_classes, $key);
}

if ($this->element instanceof Group) {
$key = "{$this->element->validation_state}.{$this->element->name}";
$key = "{$this->element->validation_state}.{$element_key}";
return Arr::get(static::$validation_classes, $key);
}

Expand Down
9 changes: 9 additions & 0 deletions src/Elements/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ public function delete() : self
return $this;
}

public function method($method = null)
{
if (method_exists($this, strtolower($method))) {
return $this->$method();
}

return parent::method($method);
}

/**
* Enable client-side validation
*
Expand Down
5 changes: 1 addition & 4 deletions views/button.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

<button
{{ $attributes->except('class') }}
class="inline-block font-normal text-center whitespace-no-wrap align-middle select-none border
rounded font-normal leading-normal text-white bg-blue-dark border-blue-darker
hover:bg-blue-darker hover:border-blue-darkest
p-2 px-4 {{ $class }}"
class="{{ $class }}"
>

{{ $slot }}
Expand Down
6 changes: 3 additions & 3 deletions views/textarea.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php /** @var \Galahad\Aire\Elements\Attributes\Attributes $attributes */ ?>

<textarea {{ $attributes->except('class', 'value') }}
class="h-auto block w-full p-2 text-base leading-normal text-grey-darkest
bg-white border rounded-sm {{ $class }}">{{ $value ?? null }}</textarea>
<textarea
{{ $attributes->except('class', 'value') }}
class="h-auto w-full p-2 text-base leading-normal {{ $class }}">{{ $value ?? null }}</textarea>

0 comments on commit 0f9f70f

Please sign in to comment.