-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFolderContainer.tsx
73 lines (64 loc) · 1.46 KB
/
FolderContainer.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import React from 'react';
import styled from 'styled-components';
import { useDispatch } from 'react-redux';
import { traverseIntoFolder } from 'src/packages/dashboard/state/folders/actions';
import Renamable from './Renamable';
import FolderIcon from '@mui/icons-material/Folder';
interface Props {
name: string;
id: string;
selectedFile: string | null;
setSelectedFile: (id: string) => void;
}
const IconContainer = styled.div`
display: flex;
flex-direction: column;
align-items: center;
margin: 20px;
text-align: center;
cursor: pointer;
`;
interface HighlightProps {
active: boolean;
}
const Folder = styled.div<HighlightProps>`
width: 100px;
height: 100px;
background: #999999;
${(props) =>
props.active &&
`
border: 5px solid lightblue;
border-radius: 3px;
`}
`;
export default function FolderContainer({
name,
id,
selectedFile,
setSelectedFile,
}: Props) {
const dispatch = useDispatch();
const handleClick = () => {
console.log(id);
setSelectedFile(id);
};
const handleDoubleClick = () => {
console.log(id);
dispatch(traverseIntoFolder(id));
};
return (
<IconContainer>
<FolderIcon
onClick={handleClick}
onDoubleClick={handleDoubleClick}
sx={{
color: selectedFile == id ? '#f590a1' : '#e3e3e3',
fontSize: '100px',
}}
/>
{/* <Folder active={false} /> */}
<Renamable name={name} id={id} />
</IconContainer>
);
}