This repository was archived by the owner on Dec 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathProjectNode.tsx
More file actions
71 lines (61 loc) · 1.53 KB
/
Copy pathProjectNode.tsx
File metadata and controls
71 lines (61 loc) · 1.53 KB
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
import React, { SyntheticEvent } from 'react';
import { EditOutlined } from '@ant-design/icons';
import { observer } from 'mobx-react';
import { createUseStyles } from 'react-jss';
import clsx from 'clsx';
import ProjectModel from '../../../../modules/projects/models/ProjectModel';
import rootStore from '../../../../modules/RootStore';
const { projectStore } = rootStore;
interface ProjectNodeProps {
project: ProjectModel;
active: boolean;
}
const ProjectNode = observer(({ project, active }: ProjectNodeProps) => {
const classes = useStyle();
function onClick() {
projectStore.setActiveProject(project.key);
}
function onEditClick(e: SyntheticEvent) {
e.stopPropagation();
projectStore.setEditableProject(project);
}
return (
<div
className={clsx(classes.projectNode, active && classes.active)}
onClick={onClick}
>
<div
className={classes.projectColor}
style={{ backgroundColor: project.color }}
/>
<div className={classes.title}>{project.title}</div>
<EditOutlined className={classes.editButton} onClick={onEditClick} />
</div>
);
});
export default ProjectNode;
const useStyle = createUseStyles({
projectNode: {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
'&:hover $editButton': {
display: 'inline',
},
},
active: {
fontWeight: 500,
},
projectColor: {
width: 16,
height: 16,
borderRadius: 4,
marginRight: 8,
},
title: {
flex: 1,
},
editButton: {
display: 'none',
},
});