diff --git a/src/components/Callout/Callout.tsx b/src/components/Callout/Callout.tsx index 0d40770c0e2..b1b785ea002 100644 --- a/src/components/Callout/Callout.tsx +++ b/src/components/Callout/Callout.tsx @@ -3,12 +3,21 @@ import { Message, View } from '@aws-amplify/ui-react'; interface CalloutProps { info?: boolean; warning?: boolean; + backgroundColor?: string; children?: React.ReactNode; } -export const Callout = ({ warning, children }: CalloutProps) => { +export const Callout = ({ + warning, + backgroundColor, + children +}: CalloutProps) => { return ( - + {children} ); diff --git a/src/components/Callout/__tests__/Callout.test.tsx b/src/components/Callout/__tests__/Callout.test.tsx index 260069dc805..6b5b32f5d73 100644 --- a/src/components/Callout/__tests__/Callout.test.tsx +++ b/src/components/Callout/__tests__/Callout.test.tsx @@ -19,4 +19,17 @@ describe('Callout', () => { consoleErrorFn.mockRestore(); }); + + it('should pass the backgroundColor through to the Message component', async () => { + const child =
Callout Child
; + const ele = render( + + {child} + + ); + + const styles = getComputedStyle(ele.container.children[0]); + console.log(styles); + expect(styles.backgroundColor).toBe('red'); + }); }); diff --git a/src/components/Gen1Banner/Gen1Banner.tsx b/src/components/Gen1Banner/Gen1Banner.tsx new file mode 100644 index 00000000000..c39fff78707 --- /dev/null +++ b/src/components/Gen1Banner/Gen1Banner.tsx @@ -0,0 +1,20 @@ +import { Callout } from '@/components/Callout'; +import Link from 'next/link'; +import classNames from 'classnames'; + +export const Gen1Banner = ({ currentPlatform }) => { + return ( + + For new Amplify apps, we recommend using Amplify Gen 2. You can learn more + in our{' '} + + Gen 2 Docs + + . + + ); +}; diff --git a/src/components/Gen1Banner/index.ts b/src/components/Gen1Banner/index.ts new file mode 100644 index 00000000000..36949bf086f --- /dev/null +++ b/src/components/Gen1Banner/index.ts @@ -0,0 +1 @@ +export { Gen1Banner } from './Gen1Banner'; diff --git a/src/components/Layout/Layout.tsx b/src/components/Layout/Layout.tsx index b4404b201aa..4b73cc128cc 100644 --- a/src/components/Layout/Layout.tsx +++ b/src/components/Layout/Layout.tsx @@ -35,6 +35,7 @@ import { NEXT_PREVIOUS_SECTIONS } from '@/components/NextPrevious'; import { Modal } from '@/components/Modal'; +import { Gen1Banner } from '@/components/Gen1Banner'; export const Layout = ({ children, @@ -127,6 +128,13 @@ export const Layout = ({ } }, 20); + const isGen1GettingStarted = /\/gen1\/\w+\/start\/getting-started\//.test( + asPathWithNoHash + ); + const isGen1HowAmplifyWorks = /\/gen1\/\w+\/how-amplify-works\//.test( + asPathWithNoHash + ); + useEffect(() => { const headings: HeadingInterface[] = []; @@ -254,6 +262,9 @@ export const Layout = ({ {useCustomTitle ? null : ( {pageTitle} )} + {(isGen1GettingStarted || isGen1HowAmplifyWorks) && ( + + )} {children} {showNextPrev && }