Skip to content

Commit e7ec083

Browse files
committed
feat: add user experience survey banner
1 parent b05b157 commit e7ec083

4 files changed

Lines changed: 120 additions & 0 deletions

File tree

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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&apos;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+
};

apps/frontend/src/modules/browse/components/HomePageComponent.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import LoadMoreButton from './client/LoadMoreButton';
2727
import { TimespanButtonGroup } from './client/TimespanButton';
2828
import SongCard from './SongCard';
2929
import SongCardGroup from './SongCardGroup';
30+
import { SurveyBanner } from '../SurveyBanner';
3031

3132
export const HomePageComponent = () => {
3233
// Initialize sync hooks for proper effect handling
@@ -39,6 +40,7 @@ export const HomePageComponent = () => {
3940
{/* Welcome banner/Hero */}
4041
<WelcomeBanner />
4142
{/* <EventBanner /> */}
43+
<SurveyBanner />
4244

4345
{/* FEATURED SONGS */}
4446
{featuredSongsPage.length > 0 && (

apps/frontend/src/modules/shared/components/layout/NavbarLayout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { MiniSurveyBanner } from '@web/modules/browse/SurveyBanner';
2+
13
import { SideRailAdSlot } from '../client/ads/AdSlots';
24
import { CookieBanner } from '../client/CookieBanner';
35

@@ -18,6 +20,7 @@ async function Layout({ children }: TNavbarLayoutProps) {
1820
<div className='flex flex-row justify-around w-full pt-24 pb-10'>
1921
<SideRailAdSlot />
2022
<main className='flex-1 w-full max-w-(--breakpoint-xl) px-6 sm:px-10 mb-8'>
23+
<MiniSurveyBanner permanent={false} />
2124
{children}
2225
</main>
2326
<SideRailAdSlot />

apps/frontend/src/modules/song-upload/components/client/UploadCompleteModal.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import JSConfetti from 'js-confetti';
22
import Link from 'next/link';
33
import { useEffect, useState } from 'react';
44

5+
import { MiniSurveyBanner } from '@web/modules/browse/SurveyBanner';
56
import GenericModal from '@web/modules/shared/components/client/GenericModal';
67

78
export default function UploadCompleteModal({
@@ -71,6 +72,8 @@ export default function UploadCompleteModal({
7172
</button>
7273
</div>
7374

75+
<MiniSurveyBanner permanent={true} />
76+
7477
<div className='flex items-center justify-between gap-4 mt-6'>
7578
<button
7679
type='button'

0 commit comments

Comments
 (0)