Skip to content

Commit 417543a

Browse files
Merge pull request #79 from strapi/feat/ai-announcement-banner
Feat/ai announcement banner
2 parents 73b1a97 + 40ccc8f commit 417543a

File tree

4 files changed

+100
-1
lines changed

4 files changed

+100
-1
lines changed

next/app/[locale]/layout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { draftMode } from 'next/headers';
21
import { Metadata } from 'next';
32
import { ViewTransitions } from 'next-view-transitions';
43
import { Inter } from 'next/font/google';
4+
import { draftMode } from 'next/headers';
55
import React from 'react';
66

77
import { DraftModeBanner } from '@/components/draft-mode-banner';
88
import { Footer } from '@/components/footer';
99
import { Navbar } from '@/components/navbar';
10+
import { AIToast } from '@/components/toast';
1011
import { CartProvider } from '@/context/cart-context';
1112
import { generateMetadataObject } from '@/lib/shared/metadata';
1213
import fetchContentType from '@/lib/strapi/fetchContentType';
@@ -66,6 +67,7 @@ export default async function LocaleLayout(props: {
6667
<Navbar data={pageData.navbar} locale={locale} />
6768
{children}
6869
<Footer data={pageData.footer} locale={locale} />
70+
<AIToast />
6971
{isDraftMode && <DraftModeBanner />}
7072
</div>
7173
</CartProvider>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { ComponentPropsWithoutRef } from 'react';
2+
3+
export const ExternalLinkIcon = (props: ComponentPropsWithoutRef<'svg'>) => (
4+
<svg
5+
xmlns="http://www.w3.org/2000/svg"
6+
width="24"
7+
height="24"
8+
viewBox="0 0 24 24"
9+
fill="none"
10+
stroke="currentColor"
11+
strokeWidth="2"
12+
strokeLinecap="round"
13+
strokeLinejoin="round"
14+
{...props}
15+
>
16+
<path d="M15 3h6v6" />
17+
<path d="M10 14 21 3" />
18+
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
19+
</svg>
20+
);

next/components/icons/x.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { ComponentPropsWithoutRef } from 'react';
2+
3+
export const XIcon = (props: ComponentPropsWithoutRef<'svg'>) => (
4+
<svg
5+
xmlns="http://www.w3.org/2000/svg"
6+
width="24"
7+
height="24"
8+
viewBox="0 0 24 24"
9+
fill="none"
10+
stroke="currentColor"
11+
strokeWidth="2"
12+
strokeLinecap="round"
13+
strokeLinejoin="round"
14+
{...props}
15+
>
16+
<path d="M18 6 6 18" />
17+
<path d="m6 6 12 12" />
18+
</svg>
19+
);

next/components/toast.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'use client';
2+
3+
import clsx from 'clsx';
4+
import { useEffect, useState } from 'react';
5+
6+
import { ExternalLinkIcon } from '@/components/icons/external-link';
7+
import { XIcon } from '@/components/icons/x';
8+
9+
export const AIToast = () => {
10+
const [isOpen, setIsOpen] = useState(false);
11+
12+
useEffect(() => {
13+
setTimeout(() => {
14+
setIsOpen(true);
15+
}, 2000);
16+
}, []);
17+
18+
return (
19+
<div
20+
className={clsx(
21+
'fixed bottom-4 left-4 z-50 bg-secondary text-black px-6 py-3 rounded-lg shadow-lg flex items-center gap-4 opacity-0 transition-all',
22+
isOpen && 'opacity-100'
23+
)}
24+
>
25+
<div className="flex items-start">
26+
<div className="flex-1">
27+
<p className="text-sm font-medium text-gray-900">Strapi AI</p>
28+
<p className="mt-1 text-sm text-gray-500">
29+
You can now try Strapi AI for yourself!
30+
</p>
31+
<div className="mt-3">
32+
<a
33+
href={
34+
'https://docs.strapi.io/cms/configurations/admin-panel#strapi-ai'
35+
}
36+
target="_blank"
37+
rel="noopener noreferrer"
38+
className="inline-flex items-center gap-1.5 text-sm font-medium text-gray-900 hover:text-gray-700 transition-colors"
39+
>
40+
Go to docs
41+
<ExternalLinkIcon className="h-3.5 w-3.5" />
42+
</a>
43+
</div>
44+
</div>
45+
<div className="ml-4 flex flex-shrink-0">
46+
<button
47+
type="button"
48+
onClick={() => setIsOpen(false)}
49+
className="inline-flex rounded-md text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors"
50+
>
51+
<span className="sr-only">Close</span>
52+
<XIcon className="h-5 w-5" />
53+
</button>
54+
</div>
55+
</div>
56+
</div>
57+
);
58+
};

0 commit comments

Comments
 (0)