-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdock.tsx
59 lines (51 loc) · 2.36 KB
/
dock.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import React from 'react';
import { Context } from "../../lib/store";
const Dock = () => {
const [ clicked , setClick ] = React.useState(false);
const [ window , setWindow ] = React.useState<string>('');
const {state, dispatch} = React.useContext(Context) as AppStoreContextType;
const [name, setName] = React.useState('');
const getName = () => {
if ( window === 'TERMINAL' ) {
return 'Terminal';
}
if ( window === 'MAIL') {
return 'Mail';
}
return 'Hello';
}
React.useEffect(() => {
var timeout: NodeJS.Timeout;
if ( clicked ){
timeout = setTimeout(() => {
setClick(false);
if ( window){
dispatch({ type: "NEW_WINDOW", payload: { id: window, header: true, title: getName() } })
}
}, 1500);
}
return () => clearTimeout(timeout);
}, [clicked]);
return (
<div className="absolute bottom-0 w-full flex flex-row justify-center" >
<div className="flex flex-row rounded-tl-xl rounded-tr-xl pl-2 pr-2" style={{ backgroundColor: "rgb(227 , 230 , 252, 0.3)" }}>
<img src='/assets/bigsur.png' onClick={ () => {
setClick(true); setWindow('PROFILE'); setName('finder'); } }
className={ "h-16 w-16 " + ( clicked && name === 'finder' ? "animate-bounce" :"") } ></img>
<img src='/assets/launchpad.png' onClick={() => {
setClick(true); setWindow(''); setName('launchpad')
}}
className={"h-16 w-16 " + (clicked && name === 'launchpad' ? "animate-bounce" : "")}></img>
<img src='/assets/mail.png' onClick={() => {
setClick(true); setWindow('MAIL'); setName('mail');
}}
className={"h-14 w-14 mt-1 " + (clicked && name === 'mail' ? "animate-bounce" : "")}></img>
<img src='/assets/terminal.png' onClick={() => {
setClick(true); setWindow('TERMINAL'); setName('terminal')
}}
className={"h-16 w-16 " + (clicked && name === 'terminal' ? "animate-bounce" : "")} ></img>
</div>
</div>
)
}
export default Dock;