|
| 1 | +'use client'; |
| 2 | + |
| 3 | +import { |
| 4 | + faChartSimple, |
| 5 | + faExclamationCircle, |
| 6 | + faExternalLink, |
| 7 | + faTimes, |
| 8 | +} from '@fortawesome/free-solid-svg-icons'; |
| 9 | +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; |
| 10 | +import Link from 'next/link'; |
| 11 | +import { usePathname } from 'next/navigation'; |
| 12 | +import { useEffect, useState } from 'react'; |
| 13 | + |
| 14 | +const SURVEY_LINK = 'https://forms.gle/3eY4Lktd1tQkZ2mt8'; |
| 15 | +const STORAGE_KEY = 'surveyBannerClosed'; |
| 16 | + |
| 17 | +export const SurveyBanner = () => { |
| 18 | + return ( |
| 19 | + <div className='flex flex-row mx-auto w-fit min-h-32 justify-between items-center text-pretty gap-6 p-4 sm:px-8 text-md rounded-xl mb-10 bg-top backdrop-filter backdrop-blur-lg bg-linear-to-br from-15% from-green-300/50 via-green-400/50 to-85% to-emerald-600/50 relative'> |
| 20 | + <div |
| 21 | + className='absolute h-full w-full top-0 left-0 z-[-1] rounded-xl opacity-50 brightness-[0.3]' |
| 22 | + style={{ |
| 23 | + backgroundImage: "url('/background-tile-flat.png')", |
| 24 | + backgroundSize: 'auto', |
| 25 | + //backgroundAttachment: 'fixed', |
| 26 | + backgroundRepeat: 'repeat', |
| 27 | + backgroundPosition: '0% 100%', |
| 28 | + }} |
| 29 | + ></div> |
| 30 | + <FontAwesomeIcon |
| 31 | + icon={faChartSimple} |
| 32 | + className='text-green-300 text-4xl' |
| 33 | + /> |
| 34 | + |
| 35 | + <div className='flex-1 leading-tight max-w-(--breakpoint-md) w-fit'> |
| 36 | + <p className='uppercase text-md font-bold tracking-wider text-yellow-300 mb-1 w-fit'> |
| 37 | + <FontAwesomeIcon icon={faExclamationCircle} /> Help us in research! |
| 38 | + </p> |
| 39 | + <p> |
| 40 | + We're doing <span className='font-bold'>original research</span>{' '} |
| 41 | + on the note block community! Answer our{' '} |
| 42 | + <span className='font-bold'>10-minute survey</span> and help us build |
| 43 | + the future of Note Block World.{' '} |
| 44 | + <Link |
| 45 | + href={SURVEY_LINK} |
| 46 | + target='_blank' |
| 47 | + className='text-blue-300 hover:text-blue-200 font-bold underline' |
| 48 | + > |
| 49 | + Click here to start |
| 50 | + </Link> |
| 51 | + </p> |
| 52 | + </div> |
| 53 | + </div> |
| 54 | + ); |
| 55 | +}; |
| 56 | + |
| 57 | +export const MiniSurveyBanner = ({ |
| 58 | + permanent = false, |
| 59 | +}: { |
| 60 | + permanent?: boolean; |
| 61 | +}) => { |
| 62 | + const pathname = usePathname(); |
| 63 | + const canDismiss = !permanent; |
| 64 | + // Start closed to avoid a dismiss flash; open after mount if eligible. |
| 65 | + const [isOpen, setIsOpen] = useState(false); |
| 66 | + |
| 67 | + useEffect(() => { |
| 68 | + if (pathname === '/') return; |
| 69 | + if (!canDismiss || localStorage.getItem(STORAGE_KEY) !== 'true') { |
| 70 | + setIsOpen(true); |
| 71 | + } |
| 72 | + }, [canDismiss, pathname]); |
| 73 | + |
| 74 | + const handleClose = () => { |
| 75 | + setIsOpen(false); |
| 76 | + localStorage.setItem(STORAGE_KEY, 'true'); |
| 77 | + }; |
| 78 | + |
| 79 | + if (!isOpen || pathname === '/') return null; |
| 80 | + |
| 81 | + return ( |
| 82 | + <div className='relative flex items-center justify-center gap-2 mt-4 mb-5 bg-emerald-800 border-emerald-400 text-emerald-300 border-2 rounded-lg px-3 py-1.5 text-sm'> |
| 83 | + {canDismiss && ( |
| 84 | + <button |
| 85 | + type='button' |
| 86 | + onClick={handleClose} |
| 87 | + aria-label='Dismiss survey banner' |
| 88 | + className='absolute top-1 right-1.5 text-emerald-400 hover:text-emerald-200' |
| 89 | + > |
| 90 | + <FontAwesomeIcon icon={faTimes} /> |
| 91 | + </button> |
| 92 | + )} |
| 93 | + <FontAwesomeIcon icon={faChartSimple} className='h-5' /> |
| 94 | + <p className={`leading-4.5 ${canDismiss ? 'pr-4' : ''}`}> |
| 95 | + Answer our{' '} |
| 96 | + <Link |
| 97 | + href={SURVEY_LINK} |
| 98 | + target='_blank' |
| 99 | + className='text-blue-400 hover:text-blue-300 hover:underline' |
| 100 | + > |
| 101 | + 10-minute survey |
| 102 | + </Link> |
| 103 | + <FontAwesomeIcon |
| 104 | + className='text-blue-400 font-bold ml-1 mr-1' |
| 105 | + size='xs' |
| 106 | + icon={faExternalLink} |
| 107 | + />{' '} |
| 108 | + and help us improve your experience! |
| 109 | + </p> |
| 110 | + </div> |
| 111 | + ); |
| 112 | +}; |
0 commit comments