Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #29 from nebulapackage/fixes-&-features
Browse files Browse the repository at this point in the history
Fixes & features
  • Loading branch information
Larsklopstra authored Oct 1, 2020
2 parents fd79a37 + e57b858 commit de4d2c0
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 18 deletions.
2 changes: 1 addition & 1 deletion resources/views/components/error.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@props(['for'])

@error($for)
@error($for->getName())
<p class="text-sm font-medium text-danger-600">{{ $message }}</p>
@enderror
2 changes: 1 addition & 1 deletion resources/views/components/fields/forms/boolean.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{ old($field->getName()) ?? (Arr::get($item, $field->getName()) ?? $field->getValue()) ? 'checked' : '' }}
name="{{ $field->getName() }}" type="checkbox">

<x-nebula::error :for="$field->getName()" />
<x-nebula::error :for="$field" />

</div>

Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/fields/forms/color.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@endforeach
</div>

<x-nebula::error :for="$field->getName()" />
<x-nebula::error :for="$field" />

</div>

Expand Down
6 changes: 4 additions & 2 deletions resources/views/components/fields/forms/date.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
<div class="space-y-2">

<input class="block w-full max-w-lg border border-gray-300 rounded-lg shadow-sm form-input sm:text-sm"
id="{{ $field->getName() }}" value="{{ old($field->getName()) ?? (Arr::get($item, $field->getName()) ?? $field->getValue()) }}"
id="{{ $field->getName() }}"
value="{{ old($field->getName()) ?? (Arr::get($item, $field->getName()) ?? $field->getValue()) }}"
{{ $field->getRequired() ? 'required' : '' }} name="{{ $field->getName() }}" type="date">

<x-nebula::error :for="$field->getName()" />
<x-nebula::error :for="$field" />
<x-nebula::helper-text :for="$field" />

</div>

Expand Down
3 changes: 2 additions & 1 deletion resources/views/components/fields/forms/input.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
value="{{ old($field->getName()) ?? (Arr::get($item, $field->getName()) ?? $field->getValue()) }}"
{{ $field->getRequired() ? 'required' : '' }} name="{{ $field->getName() }}" type="{{ $field->getType() }}">

<x-nebula::error :for="$field->getName()" />
<x-nebula::error :for="$field" />
<x-nebula::helper-text :for="$field" />

</div>

Expand Down
3 changes: 2 additions & 1 deletion resources/views/components/fields/forms/select.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

</select>

<x-nebula::error :for="$field->getName()" />
<x-nebula::error :for="$field" />
<x-nebula::helper-text :for="$field" />

</div>

Expand Down
3 changes: 2 additions & 1 deletion resources/views/components/fields/forms/textarea.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
id="{{ $field->getName() }}"
name="{{ $field->getName() }}">{{ old($field->getName()) ?? (Arr::get($item, $field->getName()) ?? $field->getValue()) }}</textarea>

<x-nebula::error :for="$field->getName()" />
<x-nebula::error :for="$field" />
<x-nebula::helper-text :for="$field" />

</div>

Expand Down
5 changes: 5 additions & 0 deletions resources/views/components/helper-text.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@props(['for'])

@if($for->getHelperText())
<p class="text-sm font-medium text-gray-600">{{ $for->getHelperText() }}</p>
@enderror
4 changes: 2 additions & 2 deletions src/Contracts/NebulaField.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function value($value): self
* Set the required property.
*
* @param bool $required
* @return NebulaField
* @return $this
*/
public function required(bool $required = true): self
{
Expand All @@ -95,7 +95,7 @@ public function required(bool $required = true): self
* Set the rules.
*
* @param mixed $rules
* @return NebulaField
* @return $this
*/
public function rules($rules): self
{
Expand Down
4 changes: 2 additions & 2 deletions src/Fields/BooleanField.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BooleanField extends NebulaField
protected string $false = 'False';

/**
* Set the true label
* Set the true label.
*
* @param string $label
* @return $this
Expand All @@ -23,7 +23,7 @@ public function true(string $label): self
}

/**
* Set the false label
* Set the false label.
*
* @param string $label
* @return $this
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/ColorField.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ColorField extends NebulaField
* Sets the colors.
*
* @param array $colors
* @return ColorField
* @return $this
*/
public function colors(array $colors): self
{
Expand Down
31 changes: 31 additions & 0 deletions src/Fields/Concerns/HasHelperText.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Larsklopstra\Nebula\Fields\Concerns;

trait HasHelperText
{
protected string $helperText = '';

/**
* Sets the helper text property.
*
* @param string $helperText
* @return $this
*/
public function helperText(string $helperText): self
{
$this->helperText = $helperText;

return $this;
}

/**
* Returns the helper text.
*
* @return string
*/
public function getHelperText(): string
{
return $this->helperText;
}
}
2 changes: 1 addition & 1 deletion src/Fields/Concerns/HasPlaceholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait HasPlaceholder
* Sets the placeholder property.
*
* @param string $placeholder
* @return HasPlaceholder
* @return $this
*/
public function placeholder(string $placeholder): self
{
Expand Down
5 changes: 4 additions & 1 deletion src/Fields/DateField.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
use Carbon\Carbon;
use Carbon\Exceptions\InvalidFormatException;
use Larsklopstra\Nebula\Contracts\NebulaField;
use Larsklopstra\Nebula\Fields\Concerns\HasHelperText;

class DateField extends NebulaField
{
use HasHelperText;

protected string $format = 'Y-m-d';

/**
Expand All @@ -26,7 +29,7 @@ public function applyFormat($date)
* Applies the date format in the front-end.
*
* @param string $format
* @return DateField
* @return $this
*/
public function format(string $format): self
{
Expand Down
5 changes: 3 additions & 2 deletions src/Fields/InputField.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
namespace Larsklopstra\Nebula\Fields;

use Larsklopstra\Nebula\Contracts\NebulaField;
use Larsklopstra\Nebula\Fields\Concerns\HasHelperText;
use Larsklopstra\Nebula\Fields\Concerns\HasPlaceholder;

class InputField extends NebulaField
{
use HasPlaceholder;
use HasPlaceholder, HasHelperText;

protected string $type = 'text';

/**
* Sets the HTML input type.
*
* @param mixed $type
* @return InputField
* @return $this
*/
public function type($type): self
{
Expand Down
3 changes: 3 additions & 0 deletions src/Fields/SelectField.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
namespace Larsklopstra\Nebula\Fields;

use Larsklopstra\Nebula\Contracts\NebulaField;
use Larsklopstra\Nebula\Fields\Concerns\HasHelperText;

class SelectField extends NebulaField
{
use HasHelperText;

protected array $options = [];

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Fields/TextareaField.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace Larsklopstra\Nebula\Fields;

use Larsklopstra\Nebula\Contracts\NebulaField;
use Larsklopstra\Nebula\Fields\Concerns\HasHelperText;
use Larsklopstra\Nebula\Fields\Concerns\HasPlaceholder;

class TextareaField extends NebulaField
{
use HasPlaceholder;
use HasPlaceholder, HasHelperText;
}

0 comments on commit de4d2c0

Please sign in to comment.