From b7b9e5ef05eff2be9627f314460d9962f29bfcb0 Mon Sep 17 00:00:00 2001 From: isaacclad Date: Sun, 7 Jun 2026 15:38:29 +0000 Subject: [PATCH] Add a mobile search page for Hosting. Return an HTML search screen from /search for browser visits and point the bottom nav Search tab at it instead of the dashboard. Co-authored-by: Cursor --- .../Controllers/Hosting/SearchController.php | 13 ++- resources/js/app.js | 12 ++- .../components/mobile-page-header.blade.php | 28 +++++ resources/views/layouts/hosting.blade.php | 4 +- .../views/partials/search-screen.blade.php | 100 ++++++++++++++++++ resources/views/search.blade.php | 15 +++ 6 files changed, 162 insertions(+), 10 deletions(-) create mode 100644 resources/views/components/mobile-page-header.blade.php create mode 100644 resources/views/partials/search-screen.blade.php create mode 100644 resources/views/search.blade.php diff --git a/app/Http/Controllers/Hosting/SearchController.php b/app/Http/Controllers/Hosting/SearchController.php index 44eab55..5877cbf 100644 --- a/app/Http/Controllers/Hosting/SearchController.php +++ b/app/Http/Controllers/Hosting/SearchController.php @@ -9,19 +9,22 @@ use App\Models\HostingAccountMember; use App\Models\HostingProduct; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Illuminate\View\View; class SearchController extends Controller { - public function __invoke(Request $request): JsonResponse + public function __invoke(Request $request): JsonResponse|View { $q = trim((string) $request->query('q', '')); + $results = mb_strlen($q) >= 2 ? $this->resultsForUser($request->user(), $q) : []; - if (mb_strlen($q) < 2) { - return response()->json(['results' => []]); + if ($request->expectsJson() || $request->ajax() || $request->wantsJson()) { + return response()->json(['results' => $results]); } - return response()->json([ - 'results' => $this->resultsForUser($request->user(), $q), + return view('search', [ + 'query' => $q, + 'results' => $results, ]); } diff --git a/resources/js/app.js b/resources/js/app.js index c63c6c1..b920e01 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -136,14 +136,20 @@ Alpine.data('afia', (config = {}) => ({ })); Alpine.data('topbarSearch', (config = {}) => ({ - query: '', - results: [], - open: false, + query: config.initialQuery || '', + results: Array.isArray(config.initialResults) ? config.initialResults : [], + open: !!config.openOnInit, loading: false, active: 0, _abort: null, searchUrl: config.searchUrl || '/search', + init() { + if (config.autoFocus) { + this.$nextTick(() => this.$refs.input?.focus()); + } + }, + onFocus() { if (this.results.length > 0 || this.query.trim().length >= 2) this.open = true; }, diff --git a/resources/views/components/mobile-page-header.blade.php b/resources/views/components/mobile-page-header.blade.php new file mode 100644 index 0000000..acd3927 --- /dev/null +++ b/resources/views/components/mobile-page-header.blade.php @@ -0,0 +1,28 @@ +@props([ + 'title', + 'subtitle' => null, + 'backUrl' => null, + 'badge' => null, +]) + +
+
+ @if ($backUrl) + + + + @endif +
+ @if ($subtitle) +

{{ $subtitle }}

+ @endif +

{{ $title }}

+
+ @if ($badge) + {{ $badge }} + @endif + {{ $actions ?? '' }} +
+ {{ $slot }} +
diff --git a/resources/views/layouts/hosting.blade.php b/resources/views/layouts/hosting.blade.php index 7d71fd4..d09d6b4 100644 --- a/resources/views/layouts/hosting.blade.php +++ b/resources/views/layouts/hosting.blade.php @@ -37,8 +37,8 @@ @include('partials.mobile-bottom-nav', [ 'homeUrl' => route('hosting.dashboard'), 'homeActive' => request()->routeIs('hosting.dashboard') || request()->routeIs('hosting.index'), - 'searchUrl' => route('hosting.dashboard'), - 'searchActive' => request()->routeIs('hosting.*'), + 'searchUrl' => route('hosting.search'), + 'searchActive' => request()->routeIs('hosting.search'), 'notificationsUrl' => route('notifications.index'), 'notificationsActive' => request()->routeIs('notifications.*'), 'unreadUrl' => route('notifications.unread'), diff --git a/resources/views/partials/search-screen.blade.php b/resources/views/partials/search-screen.blade.php new file mode 100644 index 0000000..ee04c30 --- /dev/null +++ b/resources/views/partials/search-screen.blade.php @@ -0,0 +1,100 @@ +@php + $searchUrl = $searchUrl ?? url('/search'); +@endphp + +
+ +
+
+ + +
+
+
+ + + +
+ + + + + + + +
+
diff --git a/resources/views/search.blade.php b/resources/views/search.blade.php new file mode 100644 index 0000000..61d6e4c --- /dev/null +++ b/resources/views/search.blade.php @@ -0,0 +1,15 @@ +@extends('layouts.hosting') + +@section('title', 'Search') + +@section('content') + @include('partials.search-screen', [ + 'query' => $query, + 'results' => $results, + 'backUrl' => route('hosting.dashboard'), + 'searchUrl' => route('hosting.search'), + 'heading' => 'Find hosting accounts and orders', + 'placeholder' => 'Search domains, usernames, orders…', + 'emptyHint' => 'Use at least 2 characters to search hosting accounts, linked domains, or orders.', + ]) +@endsection