From d9b26e45b768c8e671e4f4beb768e82f9b5e7e12 Mon Sep 17 00:00:00 2001 From: Damien Vitrac Date: Wed, 5 Apr 2023 15:30:20 +0200 Subject: [PATCH 1/2] Customize search --- src/css/header.css | 15 ++-- src/css/vendor/docsearch.css | 118 ++++++------------------------ src/js/vendor/docsearch.bundle.js | 4 +- src/partials/footer-scripts.hbs | 2 + src/partials/head-styles.hbs | 2 +- 5 files changed, 32 insertions(+), 109 deletions(-) diff --git a/src/css/header.css b/src/css/header.css index 1f6e1adb..57bc4cab 100644 --- a/src/css/header.css +++ b/src/css/header.css @@ -293,27 +293,26 @@ body { .search { align-items: center; border-left: 1px solid var(--toolbar-border-color); - display: flex; + display: block; height: 100%; - padding: 8px 10px; position: relative; width: 192px; } -.search .field { +/* .search .field { align-items: center; border: 1px solid var(--kbd-border-color); border-radius: 0.1em; display: flex; flex: auto; height: inherit; -} +} */ -.search .field * { +/* .search .field * { color: var(--body-font-dark-color); -} +} */ -.search .query { +/* .search .query { background: transparent; border: none; flex: auto; @@ -330,7 +329,7 @@ body { .search .query:focus { outline: none; -} +} */ .edit-this-page { height: 40px; diff --git a/src/css/vendor/docsearch.css b/src/css/vendor/docsearch.css index 04a99c5d..c3ae2e03 100644 --- a/src/css/vendor/docsearch.css +++ b/src/css/vendor/docsearch.css @@ -1,110 +1,34 @@ -/*! docsearch 2.6.x | © Algolia | github.com/algolia/docsearch */ -@import "https://cdn.jsdelivr.net/npm/@docsearch/css@3"; -.algolia-autocomplete-results { - position: relative; - top: 14px; - right: -1px; -} +@import "https://cdn.jsdelivr.net/npm/@docsearch/css@3"; -.algolia-autocomplete { - left: auto !important; - top: auto !important; +.DocSearch-Button { + margin:0; + width: 100%; + border-radius: 0; + height: 40px; + border: 0 none; + font-weight: normal; + line-height: 40px; } -.algolia-autocomplete .ds-dropdown-menu { - background: var(--panel-background); - border: 1px solid var(--codetools-border-color); - border-radius: 4px; +.DocSearch-Button:hover { + border: 0 none; box-shadow: none; - display: flex !important; - flex-direction: column; - max-height: calc(var(--nav-height) - 8px); - max-width: none; - min-width: auto; - position: absolute; - top: 0; - right: 0; - width: 35vw; -} - -.algolia-autocomplete .ds-dropdown-menu::before { - content: none; -} - -.algolia-autocomplete .ds-dropdown-menu .ds-dataset-1 { - background: none; - border: none; - border-radius: inherit; - overscroll-behavior: none; - padding: 0 8px; -} - -.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { - margin: 8px 0; -} - -.algolia-autocomplete .algolia-docsearch-suggestion { - background: none; -} - -.algolia-autocomplete .algolia-docsearch-suggestion--category-header, -.algolia-autocomplete .algolia-docsearch-suggestion--title { - color: inherit; } -.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { - color: var(--color-gray-50); +.DocSearch-Button .DocSearch-Search-Icon { + color: var(--docsearch-muted-color); } -.algolia-autocomplete .algolia-docsearch-suggestion--highlight { - color: var(--link-font-color); +.DocSearch-Button:hover .DocSearch-Search-Icon { + color:var(--docsearch-text-color); } -.algolia-autocomplete .ds-footer { - align-items: center; - display: flex; - justify-content: space-between; - background-color: var(--body-background-color); - border-top: 1px solid var(--codetools-border-color); - padding: 10px 8px 8px; - border-radius: 0 0 4px 4px; +.DocSearch-Button-Placeholder { + font-size: 14px; } -.algolia-autocomplete .ds-pagination { - display: flex; - align-items: center; - font-size: 0.9em; - line-height: 1; -} - -.algolia-autocomplete .ds-pagination > :not(:first-child) { - margin-left: 0.5em; -} - -.algolia-autocomplete .ds-pagination a { - color: var(--link-font-color); -} - -.algolia-autocomplete .ds-pagination--prev::before, -.algolia-autocomplete .ds-pagination--next::after { - display: inline-block; - width: 0.5em; - font-size: 1.2em; - line-height: 0; -} - -.algolia-autocomplete .ds-pagination--prev::before { - content: "\2039"; -} - -.algolia-autocomplete .ds-pagination--next::after { - content: "\203a"; - text-align: right; -} - -.algolia-autocomplete .algolia-docsearch-footer { - margin-top: 0; - width: 112px; - height: 16px; -} +.DocSearch-Button .DocSearch-Search-Icon { + width: 18px; + margin: 0 3px; +} \ No newline at end of file diff --git a/src/js/vendor/docsearch.bundle.js b/src/js/vendor/docsearch.bundle.js index 81ce3503..ce45e80c 100644 --- a/src/js/vendor/docsearch.bundle.js +++ b/src/js/vendor/docsearch.bundle.js @@ -10,9 +10,7 @@ appId: config.appId, indexName: config.indexName, apiKey: config.apiKey, - // searchParameters: { - // facetFilters: ['version:6.0.2'], - // }, + searchParameters: { facetFilters: [`version:${config.pageVersion}`] }, }) } })() diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index f97c9a4d..2a7164f6 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -2,5 +2,7 @@ {{#if env.ALGOLIA_API_KEY}} +{{#if (and page.latest (eq page.url page.latest.url))}} {{/if}} +{{/if}} diff --git a/src/partials/head-styles.hbs b/src/partials/head-styles.hbs index ced69a8f..be8a751d 100644 --- a/src/partials/head-styles.hbs +++ b/src/partials/head-styles.hbs @@ -4,6 +4,6 @@ }(localStorage && localStorage.getItem('theme') || (matchMedia('(prefers-color-scheme: dark)') && 'dark')) + - From a8deb00e830eddd7d0d7bfd137a1d912494b7a37 Mon Sep 17 00:00:00 2001 From: Damien Vitrac Date: Wed, 5 Apr 2023 15:52:39 +0200 Subject: [PATCH 2/2] Fix lint --- src/css/vendor/docsearch.css | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/css/vendor/docsearch.css b/src/css/vendor/docsearch.css index c3ae2e03..bb4d8c92 100644 --- a/src/css/vendor/docsearch.css +++ b/src/css/vendor/docsearch.css @@ -2,7 +2,7 @@ @import "https://cdn.jsdelivr.net/npm/@docsearch/css@3"; .DocSearch-Button { - margin:0; + margin: 0; width: 100%; border-radius: 0; height: 40px; @@ -18,17 +18,14 @@ .DocSearch-Button .DocSearch-Search-Icon { color: var(--docsearch-muted-color); + width: 18px; + margin: 0 3px; } .DocSearch-Button:hover .DocSearch-Search-Icon { - color:var(--docsearch-text-color); + color: var(--docsearch-text-color); } .DocSearch-Button-Placeholder { font-size: 14px; } - -.DocSearch-Button .DocSearch-Search-Icon { - width: 18px; - margin: 0 3px; -} \ No newline at end of file