Skip to content

Commit 128509d

Browse files
committed
More configurable classes
1 parent e84d3f2 commit 128509d

File tree

5 files changed

+30
-72
lines changed

5 files changed

+30
-72
lines changed

bin/codegen/docblocks.php

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
<?php
22

3+
use Barryvdh\Reflection\DocBlock;
4+
use Galahad\Aire\Elements\Element;
5+
36
echo "/**\n";
47

58
$classes = [
69
\Galahad\Aire\Aire::class,
7-
\Galahad\Aire\Elements\Form::class,
10+
// \Galahad\Aire\Elements\Form::class,
11+
\Galahad\Aire\Elements\Concerns\CreatesElements::class,
12+
\Galahad\Aire\Elements\Concerns\CreatesInputTypes::class,
813
];
914

15+
$element_reflect = new ReflectionClass(Element::class);
16+
1017
foreach ($classes as $class) {
1118
$reflect = new ReflectionClass($class);
1219
$methods = $reflect->getMethods();
@@ -23,11 +30,21 @@
2330
continue;
2431
}
2532

33+
if ($element_reflect->hasMethod($name)) {
34+
continue;
35+
}
36+
37+
$phpdoc = new DocBlock($method, new DocBlock\Context($reflect->getNamespaceName()));
38+
2639
$return = $method->hasReturnType()
2740
? (string) $method->getReturnType()
2841
: 'mixed';
2942

30-
if ('self' === $return) {
43+
if ('mixed' === $return && ($phpdoc_return = $phpdoc->getTagsByName('return'))) {
44+
$return = $phpdoc_return[0]->getContent();
45+
}
46+
47+
if ('self' === $return || '$this' === $return) {
3148
$return = $class;
3249
}
3350

config/aire.php

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
*/
7070
'default_classes' => [
7171
'group' => 'mb-6',
72+
'group_prepend' => '-mr-1 block p-2 text-base leading-normal bg-grey-100 text-grey-300 border rounded-l-sm',
73+
'group_append' => '-ml-1 block p-2 text-base leading-normal bg-grey-100 text-grey-300 border rounded-r-sm',
74+
'group_help_text' => 'block mt-1 text-grey-dark text-sm font-normal',
7275
'input' => 'text-grey-darkest bg-white border rounded-sm',
7376
'checkbox' => 'pr-2',
7477
'summary' => 'border border-red bg-red-lightest text-red font-bold rounded p-4 my-4',

src/Aire.php

+4-57
Original file line numberDiff line numberDiff line change
@@ -12,69 +12,17 @@
1212
use Illuminate\View\Factory;
1313

1414
/**
15-
* @method static \Galahad\Aire\Elements\Form bind($bound_data)
16-
* @method static mixed getBoundValue($name, $default = NULL)
17-
* @method static array getErrors(string $name)
18-
* @method static \Galahad\Aire\Elements\Form close()
19-
* @method static \Galahad\Aire\Elements\Form route(string $route_name, array $parameters = [], bool $absolute = true)
20-
* @method static \Galahad\Aire\Elements\Form get()
21-
* @method static \Galahad\Aire\Elements\Form post()
22-
* @method static \Galahad\Aire\Elements\Form put()
23-
* @method static \Galahad\Aire\Elements\Form patch()
24-
* @method static \Galahad\Aire\Elements\Form delete()
25-
* @method static mixed acceptCharset($value = NULL)
26-
* @method static mixed action($value = NULL)
27-
* @method static mixed autoComplete($value = NULL)
28-
* @method static mixed encType($value = NULL)
29-
* @method static mixed method($value = NULL)
30-
* @method static mixed name($value = NULL)
31-
* @method static mixed noValidate(bool $no_validate = true)
32-
* @method static mixed target($value = NULL)
33-
* @method static mixed getAttribute(string $attribute, $default = NULL)
34-
* @method static mixed data($key, $value)
35-
* @method static mixed toHtml()
36-
* @method static mixed accessKey($value = NULL)
37-
* @method static mixed class($value = NULL)
38-
* @method static mixed contentEditable(bool $content_editable = true)
39-
* @method static mixed contextMenu($value = NULL)
40-
* @method static mixed dir($value = NULL)
41-
* @method static mixed draggable($value = NULL)
42-
* @method static mixed dropZone($value = NULL)
43-
* @method static mixed hidden(bool $hidden = true)
44-
* @method static mixed id($value = NULL)
45-
* @method static mixed lang($value = NULL)
46-
* @method static mixed role($value = NULL)
47-
* @method static mixed spellCheck(bool $spell_check = true)
48-
* @method static mixed style($value = NULL)
49-
* @method static mixed tabIndex($value = NULL)
50-
* @method static mixed title($value = NULL)
51-
* @method static mixed ariaActiveDescendant($value = NULL)
52-
* @method static mixed ariaAtomic(bool $aria_atomic = true)
53-
* @method static mixed ariaBusy(bool $aria_busy = true)
54-
* @method static mixed ariaControls($value = NULL)
55-
* @method static mixed ariaDescribedBy($value = NULL)
56-
* @method static mixed ariaDisabled($value = NULL)
57-
* @method static mixed ariaDropEffect($value = NULL)
58-
* @method static mixed ariaFlowTo($value = NULL)
59-
* @method static mixed ariaGrabbed($value = NULL)
60-
* @method static mixed ariaHasPopup(bool $aria_has_popup = true)
61-
* @method static mixed ariaHidden(bool $aria_hidden = true)
62-
* @method static mixed ariaInvalid($value = NULL)
63-
* @method static mixed ariaLabel($value = NULL)
64-
* @method static mixed ariaLabelledBy($value = NULL)
65-
* @method static mixed ariaLive($value = NULL)
66-
* @method static mixed ariaOwns($value = NULL)
67-
* @method static mixed ariaRelevant($value = NULL)
68-
* @method static mixed grouped()
69-
* @method static mixed withoutGroup()
7015
* @method static \Galahad\Aire\Elements\Label label(string $label)
71-
* @method static \Galahad\Aire\Elements\Button button(string $label = null)
16+
* @method static \Galahad\Aire\Elements\Button button(string $label = NULL)
7217
* @method static \Galahad\Aire\Elements\Button submit(string $label = 'Submit')
7318
* @method static \Galahad\Aire\Elements\Input input($name = NULL, $label = NULL)
7419
* @method static \Galahad\Aire\Elements\Select select(array $options, $name = NULL, $label = NULL)
7520
* @method static \Galahad\Aire\Elements\Textarea textArea($name = NULL, $label = NULL)
7621
* @method static \Galahad\Aire\Elements\Summary summary()
7722
* @method static \Galahad\Aire\Elements\Checkbox checkbox($name = NULL, $label = NULL)
23+
* @method static \Galahad\Aire\Elements\CheckboxGroup checkboxGroup($name, array $options, $label = NULL)
24+
* @method static \Galahad\Aire\Elements\RadioGroup radioGroup($name, array $options, $label = NULL)
25+
* @method static \Galahad\Aire\Elements\Input hidden($name = NULL, $value = NULL)
7826
* @method static \Galahad\Aire\Elements\Input color($name = NULL, $label = NULL)
7927
* @method static \Galahad\Aire\Elements\Input date($name = NULL, $label = NULL)
8028
* @method static \Galahad\Aire\Elements\Input dateTime($name = NULL, $label = NULL)
@@ -85,7 +33,6 @@
8533
* @method static \Galahad\Aire\Elements\Input month($name = NULL, $label = NULL)
8634
* @method static \Galahad\Aire\Elements\Input number($name = NULL, $label = NULL)
8735
* @method static \Galahad\Aire\Elements\Input password($name = NULL, $label = NULL)
88-
* @method static \Galahad\Aire\Elements\Input radio($name = NULL, $label = NULL)
8936
* @method static \Galahad\Aire\Elements\Input range($name = NULL, $label = NULL, $min = 0, $max = 100)
9037
* @method static \Galahad\Aire\Elements\Input search($name = NULL, $label = NULL)
9138
* @method static \Galahad\Aire\Elements\Input tel($name = NULL, $label = NULL)

src/Support/Facades/Aire.php

+1-10
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,7 @@
99
* @method static \Galahad\Aire\Elements\Form form($action = NULL, $bound_data = NULL)
1010
* @method static \Galahad\Aire\Elements\Form open($action = NULL, $bound_data = NULL)
1111
* @method static mixed config(string $key, $default = NULL)
12-
* @method static \Galahad\Aire\Elements\Form bind($bound_data)
13-
* @method static \Galahad\Aire\Elements\Form close()
14-
* @method static \Galahad\Aire\Elements\Button openButton()
15-
* @method static \Galahad\Aire\Elements\Button closeButton()
16-
* @method static \Galahad\Aire\Elements\Form route(string $route_name, $parameters = [], bool $absolute = true)
17-
* @method static \Galahad\Aire\Elements\Form get()
18-
* @method static \Galahad\Aire\Elements\Form post()
19-
* @method static \Galahad\Aire\Elements\Form put()
20-
* @method static \Galahad\Aire\Elements\Form patch()
21-
* @method static \Galahad\Aire\Elements\Form delete()
12+
* @method static \Galahad\Aire\Elements\Label label(string $label)
2213
* @method static \Galahad\Aire\Elements\Button button(string $label = NULL)
2314
* @method static \Galahad\Aire\Elements\Button submit(string $label = 'Submit')
2415
* @method static \Galahad\Aire\Elements\Input input($name = NULL, $label = NULL)

views/group.blade.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55

66
<div class="{{ $prepend || $append ? 'flex' : '' }}">
77
@if($prepend)
8-
<div class="-mr-1 block p-2 text-base leading-normal bg-grey-100 text-grey-300 border rounded-l-sm">
8+
<div class="{{ config('aire.default_classes.group_prepend') }}">
99
{{ $prepend }}
1010
</div>
1111
@endif
1212

1313
{{ $element }}
1414

1515
@if($append)
16-
<div class="-ml-1 block p-2 text-base leading-normal bg-grey-100 text-grey-300 border rounded-r-sm">
16+
<div class="{{ config('aire.default_classes.group_append') }}">
1717
{{ $append }}
1818
</div>
1919
@endif
2020
</div>
2121

2222
@isset($help_text)
23-
<small class="block mt-1 text-grey-dark text-sm font-normal" data-aire-help-text>
23+
<small class="{{ config('aire.default_classes.group_help_text') }}" data-aire-help-text>
2424
{{ $help_text }}
2525
</small>
2626
@endisset

0 commit comments

Comments
 (0)