Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 committed Jul 7, 2024
1 parent 667a6cb commit d7d7953
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 54 deletions.
29 changes: 0 additions & 29 deletions src/Support/Html/Elements/Attributes/Livewire.php

This file was deleted.

15 changes: 0 additions & 15 deletions src/Support/Html/Elements/Form.php

This file was deleted.

14 changes: 9 additions & 5 deletions src/Support/Html/HtmlExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@

namespace Foxws\WireUse\Support\Html;

use Foxws\WireUse\Support\Html\Elements\Form as FormElement;
use Livewire\Form;
use Spatie\Html\Elements\Element;
use Spatie\Html\Html;

class HtmlExtended extends Html
{
protected ?Form $form = null;

public function wireForm(Form $value, ?string $action = null): FormElement
public function wireForm(Form $value): static
{
$this->form = $value;

$form = FormElement::create();
return $this;
}

return $form
->wireSubmit($action);
public function icon(string $name): Element
{
return $this
->element('x-icon')
->attribute('name', $name);
}
}
28 changes: 23 additions & 5 deletions src/Support/Html/Mixins/BaseElementMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

class BaseElementMixin
{
public function wireKey()
public function wireKey(): mixed
{
return function (string $value) {
return function (?string $value = null) {
/** @var BaseElement $this */

return $this->attribute('wire:key', $value);
};
}

public function wireIgnore()
public function wireIgnore(): mixed
{
return function (bool $self = false) {
return function (?bool $self = null) {
/** @var BaseElement $this */

return $self
Expand All @@ -27,7 +27,25 @@ public function wireIgnore()
};
}

public function wireModel()
public function wireNavigate(): mixed
{
return function () {
/** @var BaseElement $this */

return $this->attribute('wire:navigate');
};
}

public function wireSubmit(): mixed
{
return function (?string $action = null) {
/** @var BaseElement $this */

return $this->attributeIfNotNull($action, 'wire:submit', $action);
};
}

public function wireModel(): mixed
{
return function (string $key, ?string $modifiers = null) {
/** @var BaseElement $this */
Expand Down
17 changes: 17 additions & 0 deletions src/Support/Html/Mixins/LinkElementMixin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Foxws\WireUse\Support\Html\Mixins;

use Spatie\Html\Elements\A;

class LinkElementMixin
{
public function route(): mixed
{
return function (string $route, mixed $parameters = null, bool $absolute = true) {
/** @var A $this */

return $this->href(route($route, $parameters, $absolute));
};
}
}
3 changes: 3 additions & 0 deletions src/WireUseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
use Foxws\WireUse\Support\Blade\Bladeable;
use Foxws\WireUse\Support\Html\HtmlExtended;
use Foxws\WireUse\Support\Html\Mixins\BaseElementMixin;
use Foxws\WireUse\Support\Html\HtmlExtended;

Check failure on line 8 in src/WireUseServiceProvider.php

View workflow job for this annotation

GitHub Actions / P8.3 - L11.* - prefer-lowest - ubuntu-latest

Cannot use Foxws\WireUse\Support\Html\HtmlExtended as HtmlExtended because the name is already in use

Check failure on line 8 in src/WireUseServiceProvider.php

View workflow job for this annotation

GitHub Actions / P8.3 - L11.* - prefer-stable - ubuntu-latest

Cannot use Foxws\WireUse\Support\Html\HtmlExtended as HtmlExtended because the name is already in use

Check failure on line 8 in src/WireUseServiceProvider.php

View workflow job for this annotation

GitHub Actions / P8.2 - L11.* - prefer-lowest - ubuntu-latest

Cannot use Foxws\WireUse\Support\Html\HtmlExtended as HtmlExtended because the name is already in use

Check failure on line 8 in src/WireUseServiceProvider.php

View workflow job for this annotation

GitHub Actions / P8.2 - L11.* - prefer-stable - ubuntu-latest

Cannot use Foxws\WireUse\Support\Html\HtmlExtended as HtmlExtended because the name is already in use
use Illuminate\Support\Facades\Blade;
use Illuminate\View\ComponentAttributeBag;
use Spatie\Html\BaseElement;
use Spatie\Html\Elements\A;
use Spatie\Html\Html;
use Spatie\LaravelPackageTools\Commands\InstallCommand;
use Spatie\LaravelPackageTools\Package;
Expand Down Expand Up @@ -176,6 +178,7 @@ protected function registerHtml(): static
$this->app->singleton(Html::class, HtmlExtended::class);

BaseElement::mixin(new BaseElementMixin);
A::mixin(new LinkElementMixin);

return $this;
}
Expand Down

0 comments on commit d7d7953

Please sign in to comment.