Skip to content

Commit 99bf446

Browse files
committed
Add tutorial hint
1 parent 61ee164 commit 99bf446

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

Diff for: src/components/navigation/topMenu/topMenu.tsx

+57-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import CloseIcon from '@mui/icons-material/Close';
12
import QuestionMarkIcon from '@mui/icons-material/QuestionMark';
23
import ShareIcon from '@mui/icons-material/Share';
34
import { IconButton, Snackbar, Tooltip } from '@mui/material';
45
import Image from 'next/image';
56
import Link from 'next/link';
67
import { useRouter } from 'next/router';
7-
import React, { useCallback, useState } from 'react';
8+
import React, { useCallback, useEffect, useState } from 'react';
89

910
import Background from '@/../public/background.png';
1011
import Tutorial from '@/components/dashboard/Tutorial/tutorial';
@@ -54,6 +55,22 @@ export function TopMenu({ resultsLoading, setResultsLoading }: TopMenuProps) {
5455

5556
const [openTutorial, setOpenTutorial] = useState(false);
5657
const closeTutorial = useCallback(() => setOpenTutorial(false), []);
58+
const [openTutorialHint, setOpenTutorialHint] = useState(false);
59+
//Open if not already closed (based on localStorage)
60+
useEffect(() => {
61+
const previous = localStorage.getItem('tutorialHint');
62+
let ask = previous === null;
63+
if (previous !== null) {
64+
const parsed = JSON.parse(previous);
65+
if (parsed !== null && parsed.value !== 'closed') {
66+
ask = true;
67+
}
68+
}
69+
if (ask) {
70+
setOpenTutorialHint(true);
71+
}
72+
}, []);
73+
const cacheIndex = 0; //Increment this to open the popup for all users on next deployment
5774

5875
return (
5976
<>
@@ -78,11 +95,49 @@ export function TopMenu({ resultsLoading, setResultsLoading }: TopMenuProps) {
7895
input_className="[&>.MuiInputBase-root]:bg-white [&>.MuiInputBase-root]:dark:bg-haiti"
7996
/>
8097
<div className="flex gap-4 ml-auto">
81-
<Tooltip title="Open tutorial">
98+
<Tooltip
99+
open={openTutorialHint}
100+
arrow
101+
slotProps={{ tooltip: { className: 'animate-bounce' } }}
102+
title={
103+
<div
104+
className="p-2 flex flex-col items-start min-w-32 max-w-96"
105+
role="dialog"
106+
aria-modal="true"
107+
>
108+
<div className="flex w-full items-center gap-2 pl-2">
109+
<p className="text-lg font-bold">Quick tutorial</p>
110+
<IconButton
111+
onClick={() => {
112+
setOpenTutorialHint(false);
113+
localStorage.setItem(
114+
'tutorialHint',
115+
JSON.stringify({
116+
value: 'closed',
117+
cacheIndex: cacheIndex,
118+
}),
119+
);
120+
}}
121+
className="ml-auto"
122+
>
123+
<CloseIcon />
124+
</IconButton>
125+
</div>
126+
</div>
127+
}
128+
>
82129
<IconButton
83130
className="w-12 h-12"
84131
size="medium"
85132
onClick={() => {
133+
setOpenTutorialHint(false);
134+
localStorage.setItem(
135+
'tutorialHint',
136+
JSON.stringify({
137+
value: 'closed',
138+
cacheIndex: cacheIndex,
139+
}),
140+
);
86141
setOpenTutorial(true);
87142
}}
88143
>

0 commit comments

Comments
 (0)