-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DIGG-482: Fixing types in entryscape blocks, small code improvements
- Loading branch information
Showing
11 changed files
with
164 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,71 @@ | ||
/** | ||
* @fileoverview Search page selector component that provides navigation tabs | ||
* for different search categories (datasets, concepts, specifications, content). | ||
*/ | ||
|
||
import { useRouter } from "next/router"; | ||
import useTranslation from "next-translate/useTranslation"; | ||
import React from "react"; | ||
|
||
import { ButtonLink } from "@/components/button"; | ||
|
||
/** | ||
* Props for the SearchPageSelector component | ||
* @interface | ||
*/ | ||
interface SearchTabsProps { | ||
/** The current search query string */ | ||
query?: string; | ||
} | ||
|
||
//Navigation between data & Api:s, concepts, specifications. | ||
export const SearchPageSelector: React.FC<SearchTabsProps> = ({ query }) => { | ||
/** | ||
* Configuration for search tabs defining their paths and translation keys | ||
* @constant | ||
*/ | ||
const SEARCH_TABS = [ | ||
{ path: "/datasets", translationKey: "search$datasets" }, | ||
{ path: "/concepts", translationKey: "search$concepts" }, | ||
{ path: "/specifications", translationKey: "search$specifications" }, | ||
{ path: "/search", translationKey: "search$content" }, | ||
] as const; | ||
|
||
/** | ||
* Navigation component that displays tabs for different search categories. | ||
* Highlights the currently active tab and maintains the search query across navigation. | ||
* | ||
* @component | ||
* @param {SearchTabsProps} props - The component props | ||
* @param {string} [props.query] - The current search query string | ||
* @returns {JSX.Element} A navigation component with search category tabs | ||
*/ | ||
export function SearchPageSelector({ query }: SearchTabsProps) { | ||
const { t, lang } = useTranslation("pages"); | ||
const { pathname } = useRouter() || {}; | ||
|
||
return ( | ||
<nav aria-label={t("search$search-type-navigation")}> | ||
<div | ||
className="mb-lg flex gap-md overflow-x-scroll md:overflow-x-visible" | ||
className="mb-lg flex gap-md overflow-x-scroll md:overflow-x-visible" | ||
role="tablist" | ||
aria-label={t("search$search-tabs")} | ||
> | ||
<ButtonLink | ||
variant={"plain"} | ||
href={`/datasets?q=${query ? query : ""}&f=`} | ||
label={t("search$datasets")} | ||
locale={lang} | ||
className={`focus--in whitespace-nowrap ${ | ||
pathname === "/datasets" | ||
? "bg-pink-200 font-strong text-textPrimary" | ||
: "" | ||
}`} | ||
role="tab" | ||
aria-selected={pathname === "/datasets"} | ||
/> | ||
|
||
<ButtonLink | ||
variant={"plain"} | ||
href={`/concepts?q=${query ? query : ""}&f=`} | ||
label={t("search$concepts")} | ||
locale={lang} | ||
className={`focus--in whitespace-nowrap ${ | ||
pathname === "/concepts" | ||
? "bg-pink-200 font-strong text-textPrimary" | ||
: "" | ||
}`} | ||
role="tab" | ||
aria-selected={pathname === "/concepts"} | ||
/> | ||
|
||
<ButtonLink | ||
variant={"plain"} | ||
href={`/specifications?q=${query ? query : ""}&f=`} | ||
label={t("search$specifications")} | ||
locale={lang} | ||
className={`focus--in whitespace-nowrap ${ | ||
pathname === "/specifications" | ||
? "bg-pink-200 font-strong text-textPrimary" | ||
: "" | ||
}`} | ||
role="tab" | ||
aria-selected={pathname === "/specifications"} | ||
/> | ||
|
||
<ButtonLink | ||
variant={"plain"} | ||
href={`/search?q=${query ? query : ""}&f=`} | ||
label={t("search$content")} | ||
locale={lang} | ||
className={`focus--in whitespace-nowrap ${ | ||
pathname === "/search" | ||
? "bg-pink-200 font-strong text-textPrimary" | ||
: "" | ||
}`} | ||
role="tab" | ||
aria-selected={pathname === "/search"} | ||
/> | ||
{SEARCH_TABS.map(({ path, translationKey }) => ( | ||
<ButtonLink | ||
key={path} | ||
variant="plain" | ||
href={`${path}?q=${query || ""}&f=`} | ||
label={t(translationKey)} | ||
locale={lang} | ||
className={`focus--in whitespace-nowrap ${ | ||
pathname === path | ||
? "bg-pink-200 font-strong text-textPrimary" | ||
: "" | ||
}`} | ||
role="tab" | ||
aria-selected={pathname === path} | ||
/> | ||
))} | ||
</div> | ||
</nav> | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { customIndicators } from "./global"; | ||
import { Translate } from "next-translate"; | ||
|
||
import { customIndicators } from "./global"; | ||
|
||
export const apiexploreBlocks = (t: Translate, iconSize: number) => { | ||
return [...customIndicators(t, iconSize)]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.