From ee2759518e29bbb6ec483681cba4d70c6f2d0a01 Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Mon, 18 Mar 2024 19:16:12 +0100 Subject: [PATCH] wip(search): surface explorer views in search results --- site/search/Search.scss | 21 ++++++++++++-- site/search/SearchPanel.tsx | 55 +++++++++++++++++++++++++++++++++++++ site/search/searchTypes.ts | 8 ++++++ 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/site/search/Search.scss b/site/search/Search.scss index 798fb183c9c..ff80e269aea 100644 --- a/site/search/Search.scss +++ b/site/search/Search.scss @@ -194,6 +194,7 @@ .search-results__pages-list, .search-results__explorers-list, +.search-results__explorer-views-list, .search-results__charts-list { gap: var(--grid-gap); @include sm-only { @@ -228,7 +229,8 @@ display: block; } -.search-results__explorer-hit a { +.search-results__explorer-hit a, +.search-results__explorer-view-hit a { background-color: $blue-10; height: 100%; padding: 24px; @@ -290,6 +292,7 @@ .search-results__pages, .search-results__explorers, +.search-results__explorer-views, .search-results__charts { display: none; } @@ -297,6 +300,7 @@ .search-results[data-active-filter="all"] { .search-results__pages, .search-results__explorers, + .search-results__explorer-views, .search-results__charts { // both needed for .search-results__show-more-container absolute-positioning display: inline-block; @@ -341,10 +345,21 @@ } } -.search-results[data-active-filter="explorers"] .search-results__explorers { +.search-results__explorer-view-hit { + display: none; + + &:nth-child(-n + 4) { + display: inline; + } +} + +.search-results[data-active-filter="explorers"] .search-results__explorers, +.search-results[data-active-filter="explorers"] + .search-results__explorer-views { display: inline; - .search-results__explorer-hit { + .search-results__explorer-hit, + .search-results__explorer-view-hit { display: inline; } } diff --git a/site/search/SearchPanel.tsx b/site/search/SearchPanel.tsx index 1056721a26b..532f1c274ed 100644 --- a/site/search/SearchPanel.tsx +++ b/site/search/SearchPanel.tsx @@ -35,6 +35,7 @@ import { searchCategoryFilters, IPageHit, pageTypeDisplayNames, + IExplorerViewHit, } from "./searchTypes.js" import { EXPLORERS_ROUTE_FOLDER } from "../../explorer/ExplorerConstants.js" import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js" @@ -103,6 +104,23 @@ function ChartHit({ hit }: { hit: IChartHit }) { ) } +function ExplorerViewHit({ hit }: { hit: IExplorerViewHit }) { + return ( + +

{hit.viewTitle}

+ + in {hit.explorerTitle} Data Explorer + + {/* Explorer subtitles are mostly useless at the moment, so we're only showing titles */} +
+ ) +} + function ExplorerHit({ hit }: { hit: IExplorerHit }) { return ( get(results, ["results", "hits", "length"], 0) ) + hitsLengthByIndexName[getIndexName("all")] = Object.values( hitsLengthByIndexName ).reduce((a: number, b: number) => a + b, 0) + hitsLengthByIndexName[getIndexName(SearchIndexName.Explorers)] = + hitsLengthByIndexName[getIndexName(SearchIndexName.Explorers)] + + hitsLengthByIndexName[getIndexName(SearchIndexName.ExplorerViews)] + return (
    { + + + +
    +
    +

    + Data Explorer views +

    + +
    + +
    +
    +
    +export type IExplorerViewHit = Hit & { + objectID: string + explorerSlug: string + viewTitle: string + explorerTitle: string + viewQueryParams: string +} + export type IExplorerHit = Hit & { objectID: string slug: string