Skip to content

Commit 0f9f70f

Browse files
committed
Tweaks
1 parent d0431c3 commit 0f9f70f

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

config/aire.php

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
'default_classes' => [
7171
'input' => 'text-grey-darkest bg-white border rounded-sm',
7272
'summary' => 'border border-red bg-red-lightest text-red font-bold rounded p-4 my-4',
73+
'button' => 'inline-block font-normal text-center whitespace-no-wrap align-middle select-none border
74+
rounded font-normal leading-normal text-white bg-blue-dark border-blue-darker hover:bg-blue-darker
75+
hover:border-blue-darkest p-2 px-4',
7376
],
7477

7578
/*

src/Elements/Attributes/ClassNames.php

+15-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ public function __toString()
103103
*/
104104
protected function defaults() : ?string
105105
{
106-
return Arr::get(static::$default_classes, $this->element->name);
106+
$key = $this->element->name;
107+
108+
if ('textarea' === $key && !Arr::has(static::$default_classes, 'textarea')) {
109+
$key = 'input';
110+
}
111+
112+
return Arr::get(static::$default_classes, $key);
107113
}
108114

109115
/**
@@ -113,13 +119,19 @@ protected function defaults() : ?string
113119
*/
114120
protected function validation() : ?string
115121
{
122+
$element_key = $this->element->name;
123+
124+
if ('textarea' === $element_key && !Arr::has(static::$validation_classes, 'textarea')) {
125+
$element_key = 'input';
126+
}
127+
116128
if ($this->element->group) {
117-
$key = "{$this->element->group->validation_state}.{$this->element->name}";
129+
$key = "{$this->element->group->validation_state}.{$element_key}";
118130
return Arr::get(static::$validation_classes, $key);
119131
}
120132

121133
if ($this->element instanceof Group) {
122-
$key = "{$this->element->validation_state}.{$this->element->name}";
134+
$key = "{$this->element->validation_state}.{$element_key}";
123135
return Arr::get(static::$validation_classes, $key);
124136
}
125137

src/Elements/Form.php

+9
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ public function delete() : self
276276
return $this;
277277
}
278278

279+
public function method($method = null)
280+
{
281+
if (method_exists($this, strtolower($method))) {
282+
return $this->$method();
283+
}
284+
285+
return parent::method($method);
286+
}
287+
279288
/**
280289
* Enable client-side validation
281290
*

views/button.blade.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

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

118
{{ $slot }}

views/textarea.blade.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php /** @var \Galahad\Aire\Elements\Attributes\Attributes $attributes */ ?>
22

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

0 commit comments

Comments
 (0)