search-box.blade.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. {{-- resources/views/components/wiki/search-box.blade.php (Tabler 增强版) --}}
  2. @props([
  3. 'action' => '/library/search',
  4. 'method' => 'GET',
  5. 'placeholder' => '搜索佛法词条、经典、人物...',
  6. 'buttonText' => '搜索',
  7. 'queryParam' => 'q',
  8. 'typeParam' => 'type',
  9. 'typeValue' => 'wiki',
  10. 'autoFocus' => false,
  11. 'size' => 'md', // sm, md, lg
  12. 'class' => '',
  13. ])
  14. <div {{ $attributes->merge(['class' => $class]) }}>
  15. <form action="{{ $action }}" method="{{ $method }}" role="search">
  16. <div class="row g-2 align-items-center">
  17. <div class="col">
  18. <div class="input-icon">
  19. <span class="input-icon-addon">
  20. <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  21. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  22. <circle cx="10" cy="10" r="7" />
  23. <line x1="21" y1="21" x2="15" y2="15" />
  24. </svg>
  25. </span>
  26. <input
  27. type="text"
  28. name="{{ $queryParam }}"
  29. class="form-control"
  30. placeholder="{{ $placeholder }}"
  31. value="{{ request($queryParam) }}"
  32. {{ $autoFocus ? 'autofocus' : '' }}
  33. aria-label="{{ $placeholder }}">
  34. </div>
  35. </div>
  36. <div class="col-auto">
  37. <button type="submit" class="btn btn-primary">
  38. <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  39. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  40. <circle cx="10" cy="10" r="7" />
  41. <line x1="21" y1="21" x2="15" y2="15" />
  42. </svg>
  43. <span class="d-none d-sm-inline ms-2">{{ $buttonText }}</span>
  44. </button>
  45. </div>
  46. </div>
  47. @if($typeParam && $typeValue)
  48. <input type="hidden" name="{{ $typeParam }}" value="{{ $typeValue }}">
  49. @endif
  50. {{ $slot }}
  51. </form>
  52. </div>