-
Notifications
You must be signed in to change notification settings - Fork 2
/
editContigOverlay.tsx
187 lines (180 loc) · 7.77 KB
/
editContigOverlay.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import * as React from "react";
import {SketchPicker, ColorResult, RGBColor} from "react-color";
import {CircularFigure, Contig} from "../../../../circularFigure/circularFigure";
import {GridWrapper} from "../../../../containers/gridWrapper";
import {Grid} from "../../../../components/grid";
import {IconButton} from "../../../../components/iconButton";
import {blue} from "../../../../styles/colours";
import {ChevronLeft} from "../../../../components/icons/chevronLeft";
import {OutlinedInput} from "../../../../components/outlinedInput";
import {Button} from "../../../../components/button";
import {Typography} from "../../../../components/typography";
export interface EditContigOverlayProps {
onClose: () => void;
onSave: (opts: {
contigUuid: string,
newName?: string,
newTextColour?: string,
newBodyColour?: string,
}) => void;
figure: CircularFigure;
contig: Contig;
allowMovingSelectContig: boolean;
}
export interface EditContigOverlayState {
}
export function EditContigOverlay(props: EditContigOverlayProps): JSX.Element
{
let endteredName = "";
let enteredTextColour: ColorResult | undefined;
let enteredBodyColour: ColorResult | undefined;
return (
<div>
<div style={{marginLeft: "2vh"}}>
<Grid container spacing={4} justify="flex-start">
<IconButton
edge="start"
color="primary"
classes={{colorPrimary: blue}}
onClick={props.onClose}
>
<ChevronLeft />
</IconButton>
</Grid>
</div>
<div style={{marginLeft: "2.5vh"}}>
<Grid container spacing={4} justify="flex-start">
<Typography>Name in reference:</Typography>
</Grid>
</div>
<GridWrapper>
<div style={{marginRight: "1vh", marginLeft: "1vh", marginBottom: "1vh", marginTop: "1vh"}}>
<Grid container spacing={4} justify="center">
<Grid item>
<Typography>{props.contig.name}</Typography>
</Grid>
</Grid>
</div>
</GridWrapper>
<div style={{marginLeft: "2.5vh"}}>
<Grid container spacing={4} justify="flex-start">
<Typography>Name to display:</Typography>
</Grid>
</div>
<GridWrapper>
<div style={{marginRight: "1vh", marginLeft: "1vh", marginBottom: "1vh", marginTop: "1vh"}}>
<Grid container spacing={4} justify="center">
<Grid item>
<OutlinedInput
label={props.contig.alias}
inputProps={{
onChange: (event) =>
{
endteredName = event.target.value;
}
}}
/>
</Grid>
</Grid>
</div>
</GridWrapper>
<div style={{marginLeft: "2.5vh"}}>
<Grid container spacing={4} justify="flex-start">
<Typography>Text opacity:</Typography>
</Grid>
</div>
<GridWrapper>
<div style={{marginRight: "1vh", marginLeft: "1vh", marginBottom: "1vh", marginTop: "1vh"}}>
<Grid container spacing={4} justify="center">
<Grid item>
<OutlinedInput
label={props.contig.opacity ? props.contig.opacity.toString() : ""}
inputProps={{
onChange: (event) =>
{
if(event.target.value)
{
console.log(parseFloat(event.target.value));
if(parseFloat(event.target.value) == NaN)
{
alert("Opacity must be a number");
}
}
}
}}
/>
</Grid>
</Grid>
</div>
</GridWrapper>
<div style={{marginLeft: "2.5vh"}}>
<Grid container spacing={4} justify="flex-start">
<Typography>Text colour:</Typography>
</Grid>
</div>
<GridWrapper>
<div style={{marginRight: "1vh", marginLeft: "1vh", marginBottom: "1vh", marginTop: "1vh"}}>
<Grid container spacing={4} justify="center">
<Grid item>
<SketchPicker
color={props.contig.fontFill}
onChange={(color: ColorResult) =>
{
enteredTextColour = color;
}}
/>
</Grid>
</Grid>
</div>
</GridWrapper>
<div style={{marginLeft: "2.5vh"}}>
<Grid container spacing={4} justify="flex-start">
<Typography>Body colour:</Typography>
</Grid>
</div>
<GridWrapper>
<div style={{marginRight: "1vh", marginLeft: "1vh", marginBottom: "1vh", marginTop: "1vh"}}>
<Grid container spacing={4} justify="center">
<Grid item>
<SketchPicker
color={props.contig.color}
onChange={(color: ColorResult) =>
{
enteredBodyColour = color;
}}
/>
</Grid>
</Grid>
</div>
</GridWrapper>
<GridWrapper>
<div style={{marginRight: "1vh", marginLeft: "1vh", marginBottom: "1vh", marginTop: "1vh"}}>
<Grid container spacing={4} justify="center">
<Grid item>
<Button
label="Cancel"
onClick={props.onClose}
type="retreat"
/>
</Grid>
<Grid item>
<Button
label="Save"
onClick={() =>
{
props.onSave({
contigUuid: props.contig.uuid,
newName: endteredName,
newBodyColour: enteredBodyColour ? enteredBodyColour.hex : "",
newTextColour : enteredTextColour ? enteredTextColour.hex : "",
});
}}
type="advance"
/>
</Grid>
</Grid>
</div>
</GridWrapper>
</div>
);
}