From ea69c6524bda88ff1042233106cc296f5928154f Mon Sep 17 00:00:00 2001 From: LRLJoe Date: Wed, 27 Nov 2024 23:55:11 +0000 Subject: [PATCH 1/2] Split Search into individal blades --- .../views/components/tools/toolbar.blade.php | 2 +- .../toolbar/items/search-field.blade.php | 57 +++---------------- .../tools/toolbar/items/search/icon.blade.php | 8 +++ .../toolbar/items/search/input.blade.php | 20 +++++++ .../toolbar/items/search/remove.blade.php | 21 +++++++ src/Traits/Helpers/SearchHelpers.php | 5 ++ 6 files changed, 62 insertions(+), 51 deletions(-) create mode 100644 resources/views/components/tools/toolbar/items/search/icon.blade.php create mode 100644 resources/views/components/tools/toolbar/items/search/input.blade.php create mode 100644 resources/views/components/tools/toolbar/items/search/remove.blade.php diff --git a/resources/views/components/tools/toolbar.blade.php b/resources/views/components/tools/toolbar.blade.php index 65e8c086b..a9ae046de 100644 --- a/resources/views/components/tools/toolbar.blade.php +++ b/resources/views/components/tools/toolbar.blade.php @@ -28,7 +28,7 @@ @endif - @if ($this->searchIsEnabled() && $this->searchVisibilityIsEnabled()) + @if ($this->searchIsEnabled && $this->searchVisibilityIsEnabled) @endif diff --git a/resources/views/components/tools/toolbar/items/search-field.blade.php b/resources/views/components/tools/toolbar/items/search-field.blade.php index a52f06427..406b8e9ce 100644 --- a/resources/views/components/tools/toolbar/items/search-field.blade.php +++ b/resources/views/components/tools/toolbar/items/search-field.blade.php @@ -1,63 +1,20 @@ -@aware(['component', 'tableName','isTailwind', 'isBootstrap']) +@aware(['isTailwind', 'isBootstrap'])
$this->isBootstrap, - 'rounded-md shadow-sm' => $this->isTailwind, + 'mb-3 mb-md-0 input-group' => $isBootstrap, + 'rounded-md shadow-sm' => $isTailwind, 'flex' => !$this->hasSearchIcon, 'relative inline-flex flex-row' => $this->hasSearchIcon, ])> @if($this->hasSearchIcon) -
- - @svg($this->getSearchIcon, $this->getSearchIconClasses, $this->getSearchIconOtherAttributes()) - -
+ @endif - getSearchOptions() }}="search" - placeholder="{{ $this->getSearchPlaceholder() }}" - type="text" - {{ - $attributes->merge($this->getSearchFieldAttributes()) - ->class([ - 'rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 rounded-none rounded-l-md focus:ring-0 focus:border-gray-300' => $this->isTailwind && $this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-styling'] ?? true)), - 'rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 rounded-md focus:ring focus:ring-opacity-50' => $this->isTailwind && !$this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-styling'] ?? true)), - 'border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-gray-300' => $this->isTailwind && $this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-colors'] ?? true)), - 'border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-indigo-300 focus:ring-indigo-200' => $this->isTailwind && !$this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-colors'] ?? true)), - 'block w-full' => !$this->hasSearchIcon, - 'pl-8 pr-4' => $this->hasSearchIcon, - 'form-control' => $this->isBootstrap && $this->getSearchFieldAttributes()['default'] ?? true, - ]) - ->except(['default','default-styling','default-colors']) - }} - - /> + - @if ($this->hasSearch()) -
$this->isBootstrap, - ])> -
$this->isBootstrap, - 'inline-flex h-full items-center px-3 text-gray-500 bg-gray-50 rounded-r-md border border-l-0 border-gray-300 cursor-pointer sm:text-sm dark:bg-gray-700 dark:text-white dark:border-gray-600 dark:hover:bg-gray-600' => $this->isTailwind, - ]) - > - @if($this->isTailwind) - - @else - - @endif -
-
+ @if ($this->hasSearch) + @endif - -
diff --git a/resources/views/components/tools/toolbar/items/search/icon.blade.php b/resources/views/components/tools/toolbar/items/search/icon.blade.php new file mode 100644 index 000000000..f90022b50 --- /dev/null +++ b/resources/views/components/tools/toolbar/items/search/icon.blade.php @@ -0,0 +1,8 @@ +@props(['searchIcon','searchIconClasses','searchIconOtherAttributes']) +
+ + @svg($searchIcon, $searchIconClasses, $searchIconOtherAttributes) + +
diff --git a/resources/views/components/tools/toolbar/items/search/input.blade.php b/resources/views/components/tools/toolbar/items/search/input.blade.php new file mode 100644 index 000000000..d3331cd14 --- /dev/null +++ b/resources/views/components/tools/toolbar/items/search/input.blade.php @@ -0,0 +1,20 @@ +@aware(['isTailwind', 'isBootstrap']) +getSearchOptions() }}="search" + placeholder="{{ $this->getSearchPlaceholder() }}" + type="text" + {{ + $attributes->merge($this->getSearchFieldAttributes()) + ->class([ + 'rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 rounded-none rounded-l-md focus:ring-0 focus:border-gray-300' => $isTailwind && $this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-styling'] ?? true)), + 'rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 rounded-md focus:ring focus:ring-opacity-50' => $isTailwind && !$this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-styling'] ?? true)), + 'border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-gray-300' => $isTailwind && $this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-colors'] ?? true)), + 'border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-indigo-300 focus:ring-indigo-200' => $isTailwind && !$this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-colors'] ?? true)), + 'block w-full' => !$this->hasSearchIcon, + 'pl-8 pr-4' => $this->hasSearchIcon, + 'form-control' => $isBootstrap && $this->getSearchFieldAttributes()['default'] ?? true, + ]) + ->except(['default','default-styling','default-colors']) + }} + +/> \ No newline at end of file diff --git a/resources/views/components/tools/toolbar/items/search/remove.blade.php b/resources/views/components/tools/toolbar/items/search/remove.blade.php new file mode 100644 index 000000000..40ef7d8fe --- /dev/null +++ b/resources/views/components/tools/toolbar/items/search/remove.blade.php @@ -0,0 +1,21 @@ + +@aware(['isTailwind', 'isBootstrap']) + +
$isBootstrap, + ])> +
$isBootstrap, + 'inline-flex h-full items-center px-3 text-gray-500 bg-gray-50 rounded-r-md border border-l-0 border-gray-300 cursor-pointer sm:text-sm dark:bg-gray-700 dark:text-white dark:border-gray-600 dark:hover:bg-gray-600' => $isTailwind, + ]) + > + @if($isTailwind) + + @else + + @endif +
+
diff --git a/src/Traits/Helpers/SearchHelpers.php b/src/Traits/Helpers/SearchHelpers.php index 387155271..859332d40 100644 --- a/src/Traits/Helpers/SearchHelpers.php +++ b/src/Traits/Helpers/SearchHelpers.php @@ -1,14 +1,17 @@ search != ''; } + #[Computed] public function getSearch(): string { return $this->search ?? ''; @@ -27,6 +30,7 @@ public function getSearchStatus(): bool return $this->searchStatus; } + #[Computed] public function searchIsEnabled(): bool { return $this->getSearchStatus() === true; @@ -42,6 +46,7 @@ public function getSearchVisibilityStatus(): bool return $this->searchVisibilityStatus; } + #[Computed] public function searchVisibilityIsEnabled(): bool { return $this->getSearchVisibilityStatus() === true; From 2afc3f9d74240cfc7dc74c53297cedf8b8f7556f Mon Sep 17 00:00:00 2001 From: lrljoe Date: Wed, 27 Nov 2024 23:55:38 +0000 Subject: [PATCH 2/2] Fix styling --- src/Traits/Helpers/SearchHelpers.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Traits/Helpers/SearchHelpers.php b/src/Traits/Helpers/SearchHelpers.php index 859332d40..9b96ec8dc 100644 --- a/src/Traits/Helpers/SearchHelpers.php +++ b/src/Traits/Helpers/SearchHelpers.php @@ -1,6 +1,7 @@