Skip to content

Commit

Permalink
Prepare help texts
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbaljet committed Aug 24, 2022
1 parent d4053ab commit 8693afc
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 26 deletions.
5 changes: 3 additions & 2 deletions resources/views/form/checkbox.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div {{ $attributes->only(['v-if', 'v-show', 'class']) }}>
<label class="flex items-center">
<input {{ $attributes->except(['v-if', 'v-show', 'class'])->class([
<input {{ $attributes->except(['v-if', 'v-show', 'class'])->class(
'rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 disabled:opacity-50'
])->merge([
)->merge([
'name' => $name,
'value' => $value,
'type' => 'checkbox',
Expand All @@ -19,6 +19,7 @@
</span>
</label>

@includeWhen($help, 'splade::form.help', ['help' => $help])
@includeWhen($showErrors, 'splade::form.error', ['name' => $validationKey()])
</div>

Expand Down
6 changes: 4 additions & 2 deletions resources/views/form/file.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
>
<template #default="{!! $scope !!}">
<label class="block">
@include('splade::form.label', ['label' => $label])
@includeWhen($label, 'splade::form.label', ['label' => $label])

<div class="@if($label) mt-1 @endif">
<div>
<a @submit.prevent
class="inline-block px-3 py-1 rounded-md border border-gray-300 shadow-sm bg-gray-100 hover:bg-gray-300 relative cursor-pointer">

Expand All @@ -28,6 +28,8 @@ class="inline-block px-3 py-1 rounded-md border border-gray-300 shadow-sm bg-gra
/>
</a>

@includeWhen($help, 'splade::form.help', ['help' => $help])

<div class="mt-2 text-sm italic">
<p v-for="(filename, key) in file.filenames" v-bind:key="key" v-text="filename" />
</div>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/form/group.blade.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<div {{ $attributes->only(['v-if', 'v-show']) }}>
@include('splade::form.label', ['label' => $label])
@includeWhen($label, 'splade::form.label', ['label' => $label])

<div {{ $attributes->except(['v-if', 'v-show'])->class([
'mt-2' => $label,
'flex flex-wrap space-x-6' => $inline,
'space-y-1' => !$inline,
]) }}
>
{{ $slot }}
</div>

@includeWhen($help, 'splade::form.help', ['help' => $help])
@includeWhen($showErrors, 'splade::form.error', ['name' => $validationKey()])
</div>
1 change: 1 addition & 0 deletions resources/views/form/help.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p class="text-gray-500 text-sm mt-2">{{ $help }}</p>
5 changes: 3 additions & 2 deletions resources/views/form/input.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
v-model="{{ $vueModel() }}"
>
<label class="block">
@include('splade::form.label', ['label' => $label])
@includeWhen($label, 'splade::form.label', ['label' => $label])

<div class="@if($label) mt-1 @endif flex rounded-md shadow-sm">
<div class="flex rounded-md shadow-sm">
@if($prepend)
<span class="inline-flex items-center px-3 rounded-l-md border border-r-0 border-gray-300 bg-gray-50 text-gray-500">
{!! $prepend !!}
Expand Down Expand Up @@ -35,5 +35,6 @@
</div>
</label>

@include('splade::form.help', ['help' => $help])
@includeWhen($showErrors, 'splade::form.error', ['name' => $validationKey()])
</SpladeInput>
2 changes: 1 addition & 1 deletion resources/views/form/label.blade.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@if($label) <span class="text-gray-700">{{ $label }}</span> @endif
<span class="block mb-1 text-gray-700">{{ $label }}</span>
5 changes: 3 additions & 2 deletions resources/views/form/radio.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div {{ $attributes->only(['v-if', 'v-show', 'class']) }}>
<label class="flex items-center">
<input {{ $attributes->except(['v-if', 'v-show', 'class'])->class([
<input {{ $attributes->except(['v-if', 'v-show', 'class'])->class(
'rounded-full border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 disabled:opacity-50'
])->merge([
)->merge([
'name' => $name,
'value' => $value,
'type' => 'radio',
Expand All @@ -19,6 +19,7 @@
</span>
</label>

@includeWhen($help, 'splade::form.help', ['help' => $help])
@includeWhen($showErrors, 'splade::form.error', ['name' => $validationKey()])
</div>

Expand Down
4 changes: 2 additions & 2 deletions resources/views/form/select.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
v-model="{{ $vueModel() }}"
>
<label class="block">
@include('splade::form.label', ['label' => $label])
@includeWhen($label, 'splade::form.label', ['label' => $label])

<select {{ $attributes->except(['v-if', 'v-show', 'class'])->class([
'block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 disabled:opacity-50',
'mt-1' => $label,
])->merge([
'multiple' => $multiple,
'name' => $name,
Expand All @@ -28,5 +27,6 @@
</select>
</label>

@includeWhen($help, 'splade::form.help', ['help' => $help])
@includeWhen($showErrors, 'splade::form.error', ['name' => $validationKey()])
</SpladeSelect>
4 changes: 2 additions & 2 deletions resources/views/form/submit.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<button {{ $attributes->class([
<button {{ $attributes->class(
'rounded-md shadow-sm bg-indigo-500 hover:bg-indigo-700 text-white font-bold py-2 px-4 focus:outline-none focus:shadow-outline'
])->merge([
)->merge([
'type' => $type
]) }}
>
Expand Down
10 changes: 5 additions & 5 deletions resources/views/form/textarea.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
v-model="{{ $vueModel() }}"
>
<label class="block">
@include('splade::form.label', ['label' => $label])
@includeWhen($label, 'splade::form.label', ['label' => $label])

<textarea {{ $attributes->except(['v-if', 'v-show', 'class', 'autosize'])->class([
'block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 disabled:opacity-50',
'mt-1' => $label,
])->merge([
<textarea {{ $attributes->except(['v-if', 'v-show', 'class', 'autosize'])->class(
'block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 disabled:opacity-50'
)->merge([
'name' => $name,
'v-model' => $vueModel()
]) }}
/>
</label>

@includeWhen($help, 'splade::form.help', ['help' => $help])
@includeWhen($showErrors, 'splade::form.error', ['name' => $validationKey()])
</SpladeTextarea>
1 change: 1 addition & 0 deletions src/Components/Form/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function __construct(
public string $label = '',
public string $validationKey = '',
public bool $showErrors = true,
public string $help = '',
) {
Form::allowAttribute($name);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Form/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public function __construct(
public string $validationKey = '',
public bool $showErrors = true,
public bool $multiple = false,
public string $scope = 'file'
public string $scope = 'file',
public string $help = '',
) {
Form::allowAttribute($name);

Expand Down
3 changes: 2 additions & 1 deletion src/Components/Form/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public function __construct(
public string $label = '',
public bool $inline = false,
public string $validationKey = '',
public bool $showErrors = true
public bool $showErrors = true,
public string $help = '',
) {
}

Expand Down
3 changes: 2 additions & 1 deletion src/Components/Form/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public function __construct(
public bool $showErrors = true,
private bool $range = false,
public string $prepend = '',
public string $append = ''
public string $append = '',
public string $help = '',
) {
if ($date === false && $this->type === 'date' && static::$defaultFlatpickrOptions !== false) {
$this->date = $date = true;
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Form/Radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public function __construct(
public $value = 1,
public string $label = '',
public string $validationKey = '',
public bool $showErrors = false
public bool $showErrors = false,
public string $help = '',
) {
Form::allowAttribute($name);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Form/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public function __construct(
public bool|array|string $choices = false,
public string $validationKey = '',
public bool $showErrors = true,
public bool $relation = false
public bool $relation = false,
public string $help = '',
) {
if (is_bool($placeholder) && $placeholder) {
$this->placeholder = __('Search') . '...';
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Form/Textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public function __construct(
public string $name = '',
public string $label = '',
public string $validationKey = '',
public bool $showErrors = true
public bool $showErrors = true,
public string $help = '',
) {
Form::allowAttribute($name);
}
Expand Down

0 comments on commit 8693afc

Please sign in to comment.