Skip to content

Commit 022988a

Browse files
ErikCHdindjarinjs
andauthored
Added new badge and message for AI kit (#8110)
Co-authored-by: dindjarinjs <[email protected]>
1 parent 0aadfcd commit 022988a

File tree

10 files changed

+93
-1
lines changed

10 files changed

+93
-1
lines changed

mdx-components.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
22
import type { MDXComponents } from 'mdx/types';
33
import ExportedImage from 'next-image-export-optimizer';
4+
import { AIBanner } from './src/components/AIBanner';
45
import InlineFilter from './src/components/InlineFilter';
56
import { YoutubeEmbed } from './src/components/YoutubeEmbed';
67
import { Accordion } from './src/components/Accordion';
@@ -64,6 +65,7 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
6465
InlineFilter,
6566
MigrationAlert,
6667
YoutubeEmbed,
68+
AIBanner,
6769
Overview,
6870
ExternalLink,
6971
ExternalLinkButton,
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { Flex, Message, IconsProvider, Text } from '@aws-amplify/ui-react';
2+
import { IconStar, IconChevron } from '../Icons';
3+
import { Button } from '@aws-amplify/ui-react';
4+
5+
export const AIBanner: React.FC = () => {
6+
const URL = '/react/ai/set-up-ai/';
7+
return (
8+
<IconsProvider
9+
icons={{
10+
message: {
11+
info: <IconStar />
12+
}
13+
}}
14+
>
15+
<Message className="message-banner" colorTheme="info">
16+
<Flex className="message-banner__inner">
17+
<Flex direction="column" gap="xxs">
18+
<Text as="span" className="message-banner__heading">
19+
Amplify AI kit is now generally available
20+
</Text>
21+
<Text className="message-banner__content">
22+
Create fullstack AI-powered apps with TypeScript, no prior
23+
experience in cloud architecture or AI needed.
24+
</Text>
25+
</Flex>
26+
27+
<Button
28+
as="a"
29+
href={URL}
30+
size="small"
31+
gap="small"
32+
colorTheme="overlay"
33+
rel="noopener noreferrer"
34+
className="message-banner__button"
35+
>
36+
Get started
37+
<IconChevron className="icon-rotate-270" fontSize=".875em" />
38+
</Button>
39+
</Flex>
40+
</Message>
41+
</IconsProvider>
42+
);
43+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import { AIBanner } from '../index';
4+
5+
describe('AIBanner', () => {
6+
it('should render the AIBanner component', async () => {
7+
const bannerText = 'Amplify AI kit is now generally available';
8+
render(<AIBanner />);
9+
10+
const component = await screen.findByText(bannerText);
11+
expect(component).toBeInTheDocument();
12+
});
13+
});

src/components/AIBanner/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { AIBanner } from './AIBanner';

src/components/Layout/Layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import type { HeadingInterface } from '@/components/TableOfContents/TableOfConte
2929
import { Breadcrumbs } from '@/components/Breadcrumbs';
3030
import { debounce } from '@/utils/debounce';
3131
import '@docsearch/css';
32+
import { AIBanner } from '@/components/AIBanner';
3233
import { usePathWithoutHash } from '@/utils/usePathWithoutHash';
3334
import {
3435
NextPrevious,
@@ -71,6 +72,7 @@ export const Layout = ({
7172
const basePath = 'docs.amplify.aws';
7273
const metaUrl = url ? url : basePath + asPathWithNoHash;
7374
const pathname = router.pathname;
75+
const shouldShowAIBanner = asPathWithNoHash === '/';
7476
const isGen1 = asPathWithNoHash.split('/')[1] === 'gen1';
7577
const isContributor = asPathWithNoHash.split('/')[1] === 'contribute';
7678
const currentGlobalNavMenuItem = isContributor ? 'Contribute' : 'Docs';
@@ -272,6 +274,7 @@ export const Layout = ({
272274
platform={currentPlatform}
273275
/>
274276
) : null}
277+
{shouldShowAIBanner ? <AIBanner /> : null}
275278
{useCustomTitle ? null : (
276279
<Heading level={1}>{pageTitle}</Heading>
277280
)}

src/components/Menu/MenuItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { usePathWithoutHash } from '@/utils/usePathWithoutHash';
22
import { ReactElement, useContext, useEffect, useState, useMemo } from 'react';
3-
import { Link as AmplifyUILink, Flex } from '@aws-amplify/ui-react';
3+
import { Link as AmplifyUILink, Flex, Badge } from '@aws-amplify/ui-react';
44
import { IconExternalLink, IconChevron } from '@/components/Icons';
55
import Link from 'next/link';
66
import { JS_PLATFORMS, Platform, JSPlatform } from '@/data/platforms';
@@ -200,6 +200,7 @@ export function MenuItem({
200200
className={`menu__list-item__link__inner ${listItemLinkInnerStyle}`}
201201
>
202202
{pageNode.title}
203+
{pageNode.isNew && <Badge backgroundColor="purple.20">New</Badge>}
203204
{children && hasVisibleChildren && level !== Levels.Category && (
204205
<IconChevron className={open ? '' : 'icon-rotate-90-reverse'} />
205206
)}

src/directory/directory.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,9 @@ export type PageNode = {
5757
* This is being used for categories like Cli - Legacy and SDK
5858
*/
5959
hideChildrenOnBase?: boolean;
60+
61+
/**
62+
* This flag indicates that the item is new and will display a "new" badge
63+
*/
64+
isNew?: boolean;
6065
};

src/pages/[platform]/ai/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getCustomStaticPath } from '@/utils/getCustomStaticPath';
44
export const meta = {
55
title: 'AI kit',
66
description: 'The quickest way for fullstack developers to build web apps with AI capabilities such as chat, conversational search, and summarization',
7+
isNew: true,
78
route: '/[platform]/ai',
89
platforms: [
910
'angular',

src/styles/banner.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.message-banner {
2+
align-items: start;
3+
/* Specificity to override Amplify UI color theme */
4+
&.amplify-message--info {
5+
border: 1px solid var(--amplify-colors-purple-20);
6+
background-color: var(--amplify-colors-purple-10);
7+
@include darkMode {
8+
background-color: var(--amplify-colors-purple-20);
9+
}
10+
}
11+
.amplify-message__icon {
12+
color: var(--amplify-colors-purple-80);
13+
}
14+
&__inner {
15+
display: flex;
16+
flex-direction: column;
17+
align-items: flex-start;
18+
}
19+
&__heading {
20+
font-weight: 700;
21+
}
22+
}

src/styles/styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@import './accordion.scss';
1010
@import './block-switcher.scss';
1111
@import './breadcrumbs.scss';
12+
@import './banner.scss';
1213
@import './callout.scss';
1314
@import './code.scss';
1415
@import './color-switcher.scss';

0 commit comments

Comments
 (0)