1
0
Fork 0
docsearch/packages/docsearch-react/src/Footer.tsx
Dylan Tientcheu 19c1ef9192
feat(v4): release v4 (#2555) (#2666)
* feat(v4): add new UI (#2555)

* feat: add new footer ui

* feat: add new search box ui

* feat: add searchbox actions

* feat: add start screen

* feat: add no results screen

* feat: add new card ui

* feat: add new icons

* feat: add new key press class

* fix: cypress tests

* fix: circleci

* fix: circleci

* fix: close aria label

* fix: circleci

* fix: remove unused classes

* fix: circleci

* feat: update version

* feat: add new dark mode ui

* fix: colors

* fix: design review

* fix: hit title length

* fix: improve accessibility

* fix: ci

* chore: increase bundle size threshold

* fix: css

* feat(v4): ask-ai foundations  (#2574)

* feat(v4): docsearch askAI context (#2587)

* fix(v4): ask ai updates (#2654)

* feat(v4): update beta documentation (#2659)

* chore: release v4.0.0-beta.0 (#2660)

* fix: make release run on branches like v4

* chore: release v4.0.0-beta.0

* hotfix: closing on askai error

* chore: release v4.0.0-beta.1 (#2661)

* fix: add a section on models

* fix: update to `<package>@beta`

* feat(docsearch-website): Updated docs (#2662)

* feat(v4): update the landing page (#2665)

* fix: beta in readme

* feat: added glow around the search bar and a little copy above the keyboard

* feat: add glow around the search bar and copy above the keyboard

* fix: Add more styling

* fix: polishing v4 (#2667)

* chore: release v4.0.0-beta.2 (#2668)

* fix: update docusaurus tarballs

* fix(website): update docusaurus tarballs

* fix: mobile search bar

---------

Co-authored-by: Vasco Bettencourt <32492444+vascobettencourt@users.noreply.github.com>
Co-authored-by: Natan Yagudayev <natanyagudayev@gmail.com>
2025-07-17 15:53:46 +02:00

93 lines
2.8 KiB
TypeScript

import React, { type JSX } from 'react';
import { AlgoliaLogo } from './AlgoliaLogo';
export type FooterTranslations = Partial<{
selectText: string;
submitQuestionText: string;
selectKeyAriaLabel: string;
navigateText: string;
navigateUpKeyAriaLabel: string;
navigateDownKeyAriaLabel: string;
closeText: string;
backToSearchText: string;
closeKeyAriaLabel: string;
poweredByText: string;
}>;
type FooterProps = Partial<{
translations: FooterTranslations;
isAskAiActive: boolean;
}>;
interface CommandIconProps {
children: React.ReactNode;
ariaLabel: string;
}
function CommandIcon(props: CommandIconProps): JSX.Element {
return (
<svg width="20" height="20" aria-label={props.ariaLabel} viewBox="0 0 24 24" role="img">
<g fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.4">
{props.children}
</g>
</svg>
);
}
export function Footer({ translations = {}, isAskAiActive = false }: FooterProps): JSX.Element {
const {
selectText = 'Select',
selectKeyAriaLabel = 'Enter key',
submitQuestionText = 'Submit question',
navigateText = 'Navigate',
navigateUpKeyAriaLabel = 'Arrow up',
navigateDownKeyAriaLabel = 'Arrow down',
closeText = 'Close',
backToSearchText = 'Back to search',
closeKeyAriaLabel = 'Escape key',
poweredByText = 'Powered by',
} = translations;
return (
<>
<div className="DocSearch-Logo">
<AlgoliaLogo translations={{ poweredByText }} />
</div>
<ul className="DocSearch-Commands">
<li>
<kbd className="DocSearch-Commands-Key">
<CommandIcon ariaLabel={navigateDownKeyAriaLabel}>
<path d="M12 5v14" />
<path d="m19 12-7 7-7-7" />
</CommandIcon>
</kbd>
<kbd className="DocSearch-Commands-Key">
<CommandIcon ariaLabel={navigateUpKeyAriaLabel}>
<path d="m5 12 7-7 7 7" />
<path d="M12 19V5" />
</CommandIcon>
</kbd>
<span className="DocSearch-Label">{navigateText}</span>
</li>
<li>
<kbd className="DocSearch-Commands-Key">
<CommandIcon ariaLabel={selectKeyAriaLabel}>
<polyline points="9 10 4 15 9 20" />
<path d="M20 4v7a4 4 0 0 1-4 4H4" />
</CommandIcon>
</kbd>
<span className="DocSearch-Label">{isAskAiActive ? submitQuestionText : selectText}</span>
</li>
<li>
<kbd className="DocSearch-Commands-Key">
<span className="DocSearch-Escape-Key">ESC</span>
</kbd>
<span className="DocSearch-Label" aria-label={closeKeyAriaLabel}>
{isAskAiActive ? backToSearchText : closeText}
</span>
</li>
</ul>
</>
);
}