Skip to content

Commit 4a8ce41

Browse files
jacobloganJacob Logan
andauthored
Add Gen1 banner to getting started pages (#7839)
* add Gen1 Banner to all gen 1 getting started pages * update link location and add banner to how amplify works --------- Co-authored-by: Jacob Logan <[email protected]>
1 parent 0863c08 commit 4a8ce41

File tree

5 files changed

+56
-2
lines changed

5 files changed

+56
-2
lines changed

src/components/Callout/Callout.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@ import { Message, View } from '@aws-amplify/ui-react';
33
interface CalloutProps {
44
info?: boolean;
55
warning?: boolean;
6+
backgroundColor?: string;
67
children?: React.ReactNode;
78
}
89

9-
export const Callout = ({ warning, children }: CalloutProps) => {
10+
export const Callout = ({
11+
warning,
12+
backgroundColor,
13+
children
14+
}: CalloutProps) => {
1015
return (
11-
<Message variation="filled" colorTheme={warning ? 'warning' : 'info'}>
16+
<Message
17+
variation="filled"
18+
colorTheme={warning ? 'warning' : 'info'}
19+
backgroundColor={backgroundColor}
20+
>
1221
<View>{children}</View>
1322
</Message>
1423
);

src/components/Callout/__tests__/Callout.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,17 @@ describe('Callout', () => {
1919

2020
consoleErrorFn.mockRestore();
2121
});
22+
23+
it('should pass the backgroundColor through to the Message component', async () => {
24+
const child = <div>Callout Child</div>;
25+
const ele = render(
26+
<Callout info={true} backgroundColor={'red'}>
27+
{child}
28+
</Callout>
29+
);
30+
31+
const styles = getComputedStyle(ele.container.children[0]);
32+
console.log(styles);
33+
expect(styles.backgroundColor).toBe('red');
34+
});
2235
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Callout } from '@/components/Callout';
2+
import Link from 'next/link';
3+
import classNames from 'classnames';
4+
5+
export const Gen1Banner = ({ currentPlatform }) => {
6+
return (
7+
<Callout backgroundColor="background.error">
8+
For new Amplify apps, we recommend using Amplify Gen 2. You can learn more
9+
in our{' '}
10+
<Link
11+
href={`/${currentPlatform}/start/quickstart`}
12+
passHref
13+
className={classNames('amplify-link')}
14+
>
15+
Gen 2 Docs
16+
</Link>
17+
.
18+
</Callout>
19+
);
20+
};

src/components/Gen1Banner/index.ts

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

src/components/Layout/Layout.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
NEXT_PREVIOUS_SECTIONS
3636
} from '@/components/NextPrevious';
3737
import { Modal } from '@/components/Modal';
38+
import { Gen1Banner } from '@/components/Gen1Banner';
3839

3940
export const Layout = ({
4041
children,
@@ -127,6 +128,13 @@ export const Layout = ({
127128
}
128129
}, 20);
129130

131+
const isGen1GettingStarted = /\/gen1\/\w+\/start\/getting-started\//.test(
132+
asPathWithNoHash
133+
);
134+
const isGen1HowAmplifyWorks = /\/gen1\/\w+\/how-amplify-works\//.test(
135+
asPathWithNoHash
136+
);
137+
130138
useEffect(() => {
131139
const headings: HeadingInterface[] = [];
132140

@@ -254,6 +262,9 @@ export const Layout = ({
254262
{useCustomTitle ? null : (
255263
<Heading level={1}>{pageTitle}</Heading>
256264
)}
265+
{(isGen1GettingStarted || isGen1HowAmplifyWorks) && (
266+
<Gen1Banner currentPlatform={currentPlatform} />
267+
)}
257268
{children}
258269
{showNextPrev && <NextPrevious />}
259270
</Flex>

0 commit comments

Comments
 (0)