templates.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. const prefix = 'algolia-docsearch';
  2. const suggestionPrefix = `${prefix}-suggestion`;
  3. const footerPrefix = `${prefix}-footer`;
  4. /* eslint-disable max-len */
  5. const templates = {
  6. suggestion: `
  7. <a class="${suggestionPrefix}
  8. {{#isCategoryHeader}}${suggestionPrefix}__main{{/isCategoryHeader}}
  9. {{#isSubCategoryHeader}}${suggestionPrefix}__secondary{{/isSubCategoryHeader}}
  10. "
  11. aria-label="Link to the result"
  12. href="{{{url}}}"
  13. >
  14. <div class="${suggestionPrefix}--category-header">
  15. <span class="${suggestionPrefix}--category-header-lvl0">{{{category}}}</span>
  16. </div>
  17. <div class="${suggestionPrefix}--wrapper">
  18. <div class="${suggestionPrefix}--subcategory-column">
  19. <span class="${suggestionPrefix}--subcategory-column-text">{{{subcategory}}}</span>
  20. </div>
  21. {{#isTextOrSubcategoryNonEmpty}}
  22. <div class="${suggestionPrefix}--content">
  23. <div class="${suggestionPrefix}--subcategory-inline">{{{subcategory}}}</div>
  24. <div class="${suggestionPrefix}--title">{{{title}}}</div>
  25. {{#text}}<div class="${suggestionPrefix}--text">{{{text}}}</div>{{/text}}
  26. </div>
  27. {{/isTextOrSubcategoryNonEmpty}}
  28. </div>
  29. </a>
  30. `,
  31. suggestionSimple: `
  32. <div class="${suggestionPrefix}
  33. {{#isCategoryHeader}}${suggestionPrefix}__main{{/isCategoryHeader}}
  34. {{#isSubCategoryHeader}}${suggestionPrefix}__secondary{{/isSubCategoryHeader}}
  35. suggestion-layout-simple
  36. ">
  37. <div class="${suggestionPrefix}--category-header">
  38. {{^isLvl0}}
  39. <span class="${suggestionPrefix}--category-header-lvl0 ${suggestionPrefix}--category-header-item">{{{category}}}</span>
  40. {{^isLvl1}}
  41. {{^isLvl1EmptyOrDuplicate}}
  42. <span class="${suggestionPrefix}--category-header-lvl1 ${suggestionPrefix}--category-header-item">
  43. {{{subcategory}}}
  44. </span>
  45. {{/isLvl1EmptyOrDuplicate}}
  46. {{/isLvl1}}
  47. {{/isLvl0}}
  48. <div class="${suggestionPrefix}--title ${suggestionPrefix}--category-header-item">
  49. {{#isLvl2}}
  50. {{{title}}}
  51. {{/isLvl2}}
  52. {{#isLvl1}}
  53. {{{subcategory}}}
  54. {{/isLvl1}}
  55. {{#isLvl0}}
  56. {{{category}}}
  57. {{/isLvl0}}
  58. </div>
  59. </div>
  60. <div class="${suggestionPrefix}--wrapper">
  61. {{#text}}
  62. <div class="${suggestionPrefix}--content">
  63. <div class="${suggestionPrefix}--text">{{{text}}}</div>
  64. </div>
  65. {{/text}}
  66. </div>
  67. </div>
  68. `,
  69. footer: `
  70. <div class="${footerPrefix}">
  71. </div>
  72. `,
  73. empty: `
  74. <div class="${suggestionPrefix}">
  75. <div class="${suggestionPrefix}--wrapper">
  76. <div class="${suggestionPrefix}--content ${suggestionPrefix}--no-results">
  77. <div class="${suggestionPrefix}--title">
  78. <div class="${suggestionPrefix}--text">
  79. No results found for query <b>"{{query}}"</b>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. `,
  86. searchBox: `
  87. <form novalidate="novalidate" onsubmit="return false;" class="searchbox">
  88. <div role="search" class="searchbox__wrapper">
  89. <input id="docsearch" type="search" name="search" placeholder="Search the docs" autocomplete="off" required="required" class="searchbox__input"/>
  90. <button type="submit" title="Submit your search query." class="searchbox__submit" >
  91. <svg width=12 height=12 role="img" aria-label="Search">
  92. <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sbx-icon-search-13"></use>
  93. </svg>
  94. </button>
  95. <button type="reset" title="Clear the search query." class="searchbox__reset hide">
  96. <svg width=12 height=12 role="img" aria-label="Reset">
  97. <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sbx-icon-clear-3"></use>
  98. </svg>
  99. </button>
  100. </div>
  101. </form>
  102. <div class="svg-icons" style="height: 0; width: 0; position: absolute; visibility: hidden">
  103. <svg xmlns="http://www.w3.org/2000/svg">
  104. <symbol id="sbx-icon-clear-3" viewBox="0 0 40 40"><path d="M16.228 20L1.886 5.657 0 3.772 3.772 0l1.885 1.886L20 16.228 34.343 1.886 36.228 0 40 3.772l-1.886 1.885L23.772 20l14.342 14.343L40 36.228 36.228 40l-1.885-1.886L20 23.772 5.657 38.114 3.772 40 0 36.228l1.886-1.885L16.228 20z" fill-rule="evenodd"></symbol>
  105. <symbol id="sbx-icon-search-13" viewBox="0 0 40 40"><path d="M26.806 29.012a16.312 16.312 0 0 1-10.427 3.746C7.332 32.758 0 25.425 0 16.378 0 7.334 7.333 0 16.38 0c9.045 0 16.378 7.333 16.378 16.38 0 3.96-1.406 7.593-3.746 10.426L39.547 37.34c.607.608.61 1.59-.004 2.203a1.56 1.56 0 0 1-2.202.004L26.807 29.012zm-10.427.627c7.322 0 13.26-5.938 13.26-13.26 0-7.324-5.938-13.26-13.26-13.26-7.324 0-13.26 5.936-13.26 13.26 0 7.322 5.936 13.26 13.26 13.26z" fill-rule="evenodd"></symbol>
  106. </svg>
  107. </div>
  108. `,
  109. };
  110. export default templates;