Skip to content

Commit

Permalink
feat(components) cria componentes de date, time e datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
irineujunior committed Feb 20, 2024
1 parent 0a89ca0 commit 8cd7795
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/form.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@
<div class="mb-3">
<x-form.input name="name" label="Input com hint" hint="Preencha com seu nome completo"/>
</div>
<div class="mb-3">
<x-form.datetime name="published_at" label="Data e hora de publicação"/>
</div>
<div class="mb-3">
<x-form.date name="published_at" label="Data de publicação"/>
</div>
<div class="mb-3">
<x-form.time name="published_at" label="Hora de publicação"/>
</div>
<div class="mb-3">
<x-form.password name="password" label="Senha"/>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/Providers/BladeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ public function bootComponents(): void
Blade::component($prefix . 'form.hint', Components\Forms\Hint::class);
Blade::component($prefix . 'form.label', Components\Forms\Label::class);
Blade::component($prefix . 'form.checkbox', Components\Forms\Inputs\Checkbox::class);
Blade::component($prefix . 'form.date', Components\Forms\Inputs\Date::class);
Blade::component($prefix . 'form.datetime', Components\Forms\Inputs\Datetime::class);
Blade::component($prefix . 'form.input', Components\Forms\Inputs\Input::class);
Blade::component($prefix . 'form.password', Components\Forms\Inputs\Password::class);
Blade::component($prefix . 'form.plaintext', Components\Forms\Inputs\Plaintext::class);
Blade::component($prefix . 'form.radio', Components\Forms\Inputs\Radio::class);
Blade::component($prefix . 'form.select', Components\Forms\Inputs\Select::class);
Blade::component($prefix . 'form.textarea', Components\Forms\Inputs\Textarea::class);
Blade::component($prefix . 'form.time', Components\Forms\Inputs\Time::class);
Blade::component($prefix . 'form.toggle', Components\Forms\Inputs\Toggle::class);
Blade::component($prefix . 'form.toggle-notification', Components\Forms\Inputs\ToggleNotification::class);
Blade::component($prefix . 'page.body', Components\Pages\Body::class);
Expand Down
20 changes: 20 additions & 0 deletions src/View/Components/Forms/Inputs/Date.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Agenciafmd\Ui\View\Components\Forms\Inputs;

class Date extends Input
{
public function __construct(
public string $name = '',
public string $label = '',
public string $hint = '',
public string $type = 'date',
) {
parent::__construct(
$name,
$label,
$hint,
$type,
);
}
}
20 changes: 20 additions & 0 deletions src/View/Components/Forms/Inputs/Datetime.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Agenciafmd\Ui\View\Components\Forms\Inputs;

class Datetime extends Input
{
public function __construct(
public string $name = '',
public string $label = '',
public string $hint = '',
public string $type = 'datetime-local',
) {
parent::__construct(
$name,
$label,
$hint,
$type,
);
}
}
3 changes: 2 additions & 1 deletion src/View/Components/Forms/Inputs/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function __construct(
public string $name = '',
public string $label = '',
public string $hint = '',
public string $type = 'text',
) {
$this->uuid = '-' . str(serialize($this))
->pipe('md5')
Expand All @@ -29,7 +30,7 @@ public function render(): string|View
</x-form.label>
@endif
<input wire:model="{{ $name }}" {{ $attributes->merge([
'type' => 'text',
'type' => $type,
'id' => $name . $uuid,
])->class([
'form-control',
Expand Down
20 changes: 20 additions & 0 deletions src/View/Components/Forms/Inputs/Time.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Agenciafmd\Ui\View\Components\Forms\Inputs;

class Time extends Input
{
public function __construct(
public string $name = '',
public string $label = '',
public string $hint = '',
public string $type = 'time',
) {
parent::__construct(
$name,
$label,
$hint,
$type,
);
}
}

0 comments on commit 8cd7795

Please sign in to comment.