Guest User

shopify help 2

a guest
Jun 30th, 2026
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.22 KB | None | 0 0
  1. {%- doc -%}
  2. Renders the search action button or custom search bar.
  3. @param {string} [style] - The style of the search action.
  4. @param {string} [class] - Additional classes for the search action.
  5. @param {string} [display_style] - The display style ('icon' or 'text').
  6. {%- enddoc -%}
  7.  
  8. {% unless style == 'none' %}
  9. <div class="mgr-custom-search-wrapper" id="mgr-main-search-container">
  10.  
  11. <search-button
  12. class="search-action mobile-only-search {% if class != blank %} {{ class | strip }}{% endif %}"
  13. >
  14. <button
  15. on:click="#search-modal/showDialog"
  16. class="button-unstyled header-actions__action"
  17. aria-label="{{ 'content.search_input_label' | t }}"
  18. aria-haspopup="dialog"
  19. >
  20. <span class="svg-wrapper">
  21. {{ 'icon-search.svg' | inline_asset_content }}
  22. </span>
  23. </button>
  24. </search-button>
  25.  
  26. <predictive-search-component
  27. class="desktop-only-search predictive-search color-{{ settings.popover_color_scheme }}{% if class != blank %} {{ class | strip }}{% endif %}"
  28. style="--product-corner-radius: {{ settings.product_corner_radius | default: 8 | append: 'px' }}; --card-corner-radius: {{ settings.card_corner_radius | default: 8 | append: 'px' }};{% if settings.card_title_case == 'uppercase' %} --title-case: uppercase;{% endif %}"
  29. data-section-id="predictive-search"
  30. data-testid="{{ 'search-component--modal' }}"
  31. role="search"
  32. aria-label="{{ 'content.search_input_label' | t }}"
  33. >
  34. <form
  35. action="{{ routes.search_url }}"
  36. method="get"
  37. role="search"
  38. class="predictive-search-form"
  39. ref="form"
  40. on:keydown="/onSearchKeyDown"
  41. >
  42. <div class="predictive-search-form__header">
  43. <div class="predictive-search-form__header-inner">
  44. <label
  45. for="{{ 'cmdk-input' | default: 'Search' }}"
  46. class="visually-hidden"
  47. >
  48. {{- 'content.search_input_label' | t -}}
  49. </label>
  50. <input
  51. class="search-input"
  52. id="{{ 'cmdk-input' | default: 'Search' }}"
  53. type="search"
  54. name="q"
  55. role="combobox"
  56. aria-expanded="false"
  57. aria-owns="predictive-search-results"
  58. aria-controls="predictive-search-results"
  59. aria-haspopup="listbox"
  60. aria-autocomplete="list"
  61. autocomplete="off"
  62. placeholder="Buscar producto, o número de parte..."
  63. ref="searchInput"
  64. on:input="/search"
  65. on:keydown="/onSearchKeyDown"
  66. >
  67. <input
  68. name="options[prefix]"
  69. type="hidden"
  70. value="last"
  71. >
  72. <span class="svg-wrapper predictive-search__icon search-icon-custom">
  73. {{ 'icon-search.svg' | inline_asset_content }}
  74. </span>
  75. </div>
  76. </div>
  77.  
  78. <div class="predictive-search-form__content-wrapper">
  79. <div
  80. class="predictive-search-form__content"
  81. ref="predictiveSearchResults"
  82. on:click="/handleModalClick"
  83. >
  84. {% render 'predictive-search-empty-state',
  85. load_empty_state: true,
  86. shadow_opacity: 0.1,
  87. products_test_id: 'products-list-default--modal'
  88. %}
  89. </div>
  90.  
  91. <div class="predictive-search-form__footer">
  92. <button
  93. class="button predictive-search__search-button"
  94. ref="viewAllButton"
  95. >
  96. {{ 'content.search_results_view_all' | t }}
  97. </button>
  98. </div>
  99. </div>
  100. </form>
  101. </predictive-search-component>
  102. </div>
  103. {% endunless %}
  104.  
  105. <style>
  106. .header__column--left .mgr-custom-search-wrapper {
  107. display: none !important;
  108. }
  109.  
  110. .mgr-custom-search-wrapper {
  111. position: relative !important;
  112. display: flex !important;
  113. align-items: left !important;
  114. width: 100%;
  115. }
  116.  
  117. @media screen and (max-width: 749px) {
  118. .desktop-only-search {
  119. display: none !important;
  120. }
  121. .mobile-only-search {
  122. display: flex !important;
  123. }
  124. }
  125.  
  126. @media screen and (min-width: 750px) {
  127. .mobile-only-search {
  128. display: none !important;
  129. }
  130.  
  131. .desktop-only-search.predictive-search {
  132. display: block !important;
  133. flex: 1 1 auto !important;
  134. min-width: 250px !important;
  135. max-width: 100% !important;
  136. margin: 0 !important;
  137. }
  138.  
  139. .mgr-custom-search-wrapper {
  140. flex: 1 1 auto !important;
  141. justify-content: center !important;
  142. }
  143. }
  144.  
  145. .predictive-search-form {
  146. width: 100% !important;
  147. }
  148.  
  149. .predictive-search-form__header-inner {
  150. position: relative !important;
  151. background: rgba(88, 89, 91, 1) !important;
  152. border: 2px solid #c2c2c2ff !important;
  153. border-radius: var(--product-corner-radius, 8px) !important;
  154. display: flex !important;
  155. align-items: center !important;
  156. width: 100% !important;
  157. }
  158.  
  159. input.search-input {
  160. width: 100% !important;
  161. padding: 12px 15px 12px 40px !important;
  162. border: none !important;
  163. background: transparent !important;
  164. outline: none !important;
  165. font-size: 14px !important;
  166. color: #FAF9F6 !important;
  167. }
  168.  
  169. input.search-input::placeholder {
  170. color: rgba(250, 249, 246, 0.7);
  171. }
  172.  
  173. .search-icon-custom {
  174. position: absolute !important;
  175. left: 15px !important;
  176. top: 50% !important;
  177. transform: translateY(-50%) !important;
  178. color: #FAF9F6 !important;
  179. pointer-events: none;
  180. }
  181.  
  182. .predictive-search-form__content.custom-active {
  183. display: block !important;
  184. opacity: 1 !important;
  185. max-height: 50dvh !important;
  186. }
  187.  
  188. .predictive-search-form__content {
  189. max-height: 0dvh !important;
  190. overflow: hidden;
  191. transition: max-height 0.2s ease;
  192. }
  193. </style>
  194.  
  195. <script>
  196. document.addEventListener('input', function (e) {
  197. if (e.target.matches('.search-input')) {
  198. const wrapper = e.target.closest('.predictive-search');
  199. const content = wrapper?.querySelector('.predictive-search-form__content');
  200. if (!content) return;
  201. const value = e.target.value.trim();
  202. content.classList.toggle('custom-active', value.length > 0);
  203. }
  204. });
  205. </script>
Advertisement
Add Comment
Please, Sign In to add comment