File tree Expand file tree Collapse file tree 2 files changed +26
-20
lines changed Expand file tree Collapse file tree 2 files changed +26
-20
lines changed Original file line number Diff line number Diff line change
1
+ 'use client' ;
2
+
3
+ import Cookies from 'js-cookie' ;
4
+ import { useRouter } from 'next/navigation' ;
5
+
6
+ export default function DismissButton ( ) {
7
+ const router = useRouter ( ) ;
8
+
9
+ return (
10
+ < button
11
+ className = "contents underline text-blue-600"
12
+ onClick = { ( ) => {
13
+ Cookies . set ( 'template-banner-hidden' , 'true' ) ;
14
+ router . refresh ( ) ;
15
+ } }
16
+ >
17
+ Dismiss →
18
+ </ button >
19
+ ) ;
20
+ }
Original file line number Diff line number Diff line change 1
- 'use client' ;
2
-
3
- import { useState , useEffect } from 'react' ;
4
- import Cookies from 'js-cookie' ;
1
+ import { cookies } from 'next/headers' ;
2
+ import DismissButton from './dismiss-button' ;
5
3
6
4
export default function Toast ( ) {
7
- const [ bannerHidden , setBannerHidden ] = useState ( true ) ;
8
-
9
- useEffect ( ( ) => {
10
- setBannerHidden ( Cookies . get ( 'template-banner-hidden' ) === 'true' ) ;
11
- } , [ ] ) ;
5
+ const cookieStore = cookies ( ) ;
6
+ const isHidden = cookieStore . get ( 'template-banner-hidden' ) ;
12
7
13
- return bannerHidden ? null : (
8
+ return isHidden ? null : (
14
9
< div className = "sticky rounded-2xl w-11/12 sm:w-[581px] h-40 sm:h-[80px] p-0.5 z-10 bottom-10 left-0 right-0 mx-auto" >
15
10
< div className = "rounded-[14px] w-full h-full bg-gray-50 border border-gray-200 flex flex-col sm:flex-row items-center justify-center sm:justify-between space-y-3 sm:space-y-0 px-5" >
16
11
< p className = "text-black text-[13px] font-mono w-[304px] h-10 flex items-center justify-center p-3" >
17
- Get started with Next.js and Vercel instantly.{ ' ' }
18
- < button
19
- className = "contents underline text-blue-600"
20
- onClick = { ( ) => {
21
- setBannerHidden ( true ) ;
22
- Cookies . set ( 'template-banner-hidden' , 'true' ) ;
23
- } }
24
- >
25
- Dismiss →
26
- </ button >
12
+ Get started with Next.js and Vercel instantly. < DismissButton />
27
13
</ p >
28
14
< a
29
15
className = "text-white text-[13px] font-mono bg-black hover:bg-gray-700 transition-all rounded-md w-[220px] h-10 flex items-center justify-center whitespace-nowrap"
You can’t perform that action at this time.
0 commit comments