1
+ import CloseIcon from '@mui/icons-material/Close' ;
1
2
import QuestionMarkIcon from '@mui/icons-material/QuestionMark' ;
2
3
import ShareIcon from '@mui/icons-material/Share' ;
3
4
import { IconButton , Snackbar , Tooltip } from '@mui/material' ;
4
5
import Image from 'next/image' ;
5
6
import Link from 'next/link' ;
6
7
import { useRouter } from 'next/router' ;
7
- import React , { useCallback , useState } from 'react' ;
8
+ import React , { useCallback , useEffect , useState } from 'react' ;
8
9
9
10
import Background from '@/../public/background.png' ;
10
11
import Tutorial from '@/components/dashboard/Tutorial/tutorial' ;
@@ -54,6 +55,22 @@ export function TopMenu({ resultsLoading, setResultsLoading }: TopMenuProps) {
54
55
55
56
const [ openTutorial , setOpenTutorial ] = useState ( false ) ;
56
57
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
57
74
58
75
return (
59
76
< >
@@ -78,11 +95,49 @@ export function TopMenu({ resultsLoading, setResultsLoading }: TopMenuProps) {
78
95
input_className = "[&>.MuiInputBase-root]:bg-white [&>.MuiInputBase-root]:dark:bg-haiti"
79
96
/>
80
97
< 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
+ >
82
129
< IconButton
83
130
className = "w-12 h-12"
84
131
size = "medium"
85
132
onClick = { ( ) => {
133
+ setOpenTutorialHint ( false ) ;
134
+ localStorage . setItem (
135
+ 'tutorialHint' ,
136
+ JSON . stringify ( {
137
+ value : 'closed' ,
138
+ cacheIndex : cacheIndex ,
139
+ } ) ,
140
+ ) ;
86
141
setOpenTutorial ( true ) ;
87
142
} }
88
143
>
0 commit comments