Skip to content

Commit

Permalink
feat(header-cta): add a cta button in the header
Browse files Browse the repository at this point in the history
  • Loading branch information
bsahitya committed Jun 14, 2024
1 parent 44b0708 commit e00bdbf
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 16 deletions.
3 changes: 3 additions & 0 deletions i18n/en/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"header.getting_started": {
"message": "Getting started"
},
"header.actions.free_demo": {
"message": "Start free demo"
},
"header.docs": {
"message": "Docs"
},
Expand Down
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@docusaurus/preset-classic": "3.2.0",
"@docusaurus/theme-mermaid": "3.2.0",
"@mdx-js/react": "^3.0.0",
"@teradata-web/react-components": "^1.0.4",
"@teradata-web/react-components": "^1.3.0",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
Expand Down
30 changes: 26 additions & 4 deletions src/theme/Navbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import React, { useEffect, useState } from 'react';
import { Header, Language, NavListItem } from '@teradata-web/react-components';
import React, { ReactElement, useEffect, useState } from 'react';
import {
Button,
Header,
HeaderAction,
Language,
NavListItem,
} from '@teradata-web/react-components';
import { useThemeConfig } from '@docusaurus/theme-common';
import { useNavbarSecondaryMenu } from '@docusaurus/theme-common/internal';
import { translate } from '@docusaurus/Translate';
import SearchBar from '../SearchBar';
import { ThemeConfig } from '@docusaurus/types';

import Link from '@docusaurus/Link';

function translateNavItems(navItems: NavListItem[]): NavListItem[] {
return navItems.map((item) => {
Expand All @@ -32,6 +38,22 @@ export default function Navbar() {
const translatedTitle = translate({ message: title });
const translatedNavItems = translateNavItems(nestedNavItems);

const headerActions: HeaderAction[] = [
{ actionElement: <SearchBar />, type: 'search' },
{
actionElement: (
<Link to="https://www.teradata.com/getting-started/demos/clearscape-analytics">
<Button
label={translate({ message: 'header.actions.free_demo' })}
icon="fa-solid fa-arrow-right-long"
trailingIcon={true}
/>
</Link>
),
type: 'button',
},
];

const secondaryMenuDetails = {
menuElement: useNavbarSecondaryMenu().content as JSX.Element,
title: translate({
Expand Down Expand Up @@ -92,7 +114,7 @@ export default function Navbar() {
key={defaultLang}
navItems={translatedNavItems}
title={translatedTitle}
headerActions={[{ actionElement: <SearchBar />, type: 'search' }]}
headerActions={headerActions}
languages={languages}
onLanguageChange={handleLanguageChange}
selectedLanguage={defaultLang}
Expand Down

0 comments on commit e00bdbf

Please sign in to comment.