Skip to content

Commit

Permalink
fix naming components
Browse files Browse the repository at this point in the history
  • Loading branch information
mozex committed May 17, 2024
1 parent 0b0bfc8 commit b6a0717
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ModulesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,13 @@ protected function getViewName(array $asset, AssetType $type): string

protected function lowerDashedName(string $name): string
{
return str($name)
$str = str($name);

if ($name === $str->upper()->toString()) {
return $str->lower()->toString();
}

return $str
->replaceMatches('/(?<! )[A-Z]/', '-$0')
->replaceFirst('-', '')
->lower()
Expand Down
5 changes: 5 additions & 0 deletions tests/Feature/LivewireComponentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
deleteCachedView: true
))
->toContain('List Users Livewire Component')
->and(Blade::render(
string: '<livewire:pwa::icons/>',
deleteCachedView: true
))
->toContain('PWA Icons Livewire Component')
->and(Blade::render(
string: '<livewire:first::nested.nested-users/>',
deleteCachedView: true
Expand Down
7 changes: 7 additions & 0 deletions tests/Feature/ViewsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@
->toContain('Second Page')
->and(view('second::pages.page')->render())
->toContain('Nested Page')
->and(view('pwa::head')->render())
->toContain('PWA Head')
->and(Blade::render(
string: '<x-pwa::manifest/>',
deleteCachedView: true
))
->toContain('Manifest Component')
->and(Blade::render(
string: '<x-first::input/>',
deleteCachedView: true
Expand Down
16 changes: 16 additions & 0 deletions workbench/Modules/PWA/Livewire/Icons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Modules\PWA\Livewire;

use Illuminate\View\View;
use Livewire\Component;

class Icons extends Component
{
public function render(): View
{
return view('pwa::livewire.icons', [
'name' => 'PWA Icons Livewire Component',
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Manifest Component
1 change: 1 addition & 0 deletions workbench/Modules/PWA/Resources/views/head.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PWA Head
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
{{ $name }}
</div>

0 comments on commit b6a0717

Please sign in to comment.