From b6a0717835e1c8efa68ff28fa217bb1b3f07cfbc Mon Sep 17 00:00:00 2001 From: Mozex Date: Fri, 17 May 2024 12:17:28 +0300 Subject: [PATCH] fix naming components --- src/ModulesServiceProvider.php | 8 +++++++- tests/Feature/LivewireComponentsTest.php | 5 +++++ tests/Feature/ViewsTest.php | 7 +++++++ workbench/Modules/PWA/Livewire/Icons.php | 16 ++++++++++++++++ .../views/components/manifest.blade.php | 1 + .../Modules/PWA/Resources/views/head.blade.php | 1 + .../PWA/Resources/views/livewire/icons.blade.php | 3 +++ 7 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 workbench/Modules/PWA/Livewire/Icons.php create mode 100644 workbench/Modules/PWA/Resources/views/components/manifest.blade.php create mode 100644 workbench/Modules/PWA/Resources/views/head.blade.php create mode 100644 workbench/Modules/PWA/Resources/views/livewire/icons.blade.php diff --git a/src/ModulesServiceProvider.php b/src/ModulesServiceProvider.php index 56f4815..af7a85e 100644 --- a/src/ModulesServiceProvider.php +++ b/src/ModulesServiceProvider.php @@ -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('/(?replaceFirst('-', '') ->lower() diff --git a/tests/Feature/LivewireComponentsTest.php b/tests/Feature/LivewireComponentsTest.php index 8ec97e7..e2b7758 100644 --- a/tests/Feature/LivewireComponentsTest.php +++ b/tests/Feature/LivewireComponentsTest.php @@ -72,6 +72,11 @@ deleteCachedView: true )) ->toContain('List Users Livewire Component') + ->and(Blade::render( + string: '', + deleteCachedView: true + )) + ->toContain('PWA Icons Livewire Component') ->and(Blade::render( string: '', deleteCachedView: true diff --git a/tests/Feature/ViewsTest.php b/tests/Feature/ViewsTest.php index 3b77e26..a79cbd7 100644 --- a/tests/Feature/ViewsTest.php +++ b/tests/Feature/ViewsTest.php @@ -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: '', + deleteCachedView: true + )) + ->toContain('Manifest Component') ->and(Blade::render( string: '', deleteCachedView: true diff --git a/workbench/Modules/PWA/Livewire/Icons.php b/workbench/Modules/PWA/Livewire/Icons.php new file mode 100644 index 0000000..9478c6e --- /dev/null +++ b/workbench/Modules/PWA/Livewire/Icons.php @@ -0,0 +1,16 @@ + 'PWA Icons Livewire Component', + ]); + } +} diff --git a/workbench/Modules/PWA/Resources/views/components/manifest.blade.php b/workbench/Modules/PWA/Resources/views/components/manifest.blade.php new file mode 100644 index 0000000..cd8a978 --- /dev/null +++ b/workbench/Modules/PWA/Resources/views/components/manifest.blade.php @@ -0,0 +1 @@ +Manifest Component diff --git a/workbench/Modules/PWA/Resources/views/head.blade.php b/workbench/Modules/PWA/Resources/views/head.blade.php new file mode 100644 index 0000000..eb27588 --- /dev/null +++ b/workbench/Modules/PWA/Resources/views/head.blade.php @@ -0,0 +1 @@ +PWA Head diff --git a/workbench/Modules/PWA/Resources/views/livewire/icons.blade.php b/workbench/Modules/PWA/Resources/views/livewire/icons.blade.php new file mode 100644 index 0000000..84b7cbe --- /dev/null +++ b/workbench/Modules/PWA/Resources/views/livewire/icons.blade.php @@ -0,0 +1,3 @@ +
+ {{ $name }} +