|
1 | 1 | // /* global window */ |
2 | 2 | import React, { useEffect, useRef, useState } from "react"; |
3 | | -import { |
4 | | - Wrapper, |
5 | | - CanvasContainer, |
6 | | - OutputBox, |
7 | | - StyledSVG, |
8 | | - CopyButton, |
9 | | -} from "./shapeBuilder.styles"; |
| 3 | +import { Wrapper, CanvasContainer, OutputBox, StyledSVG, CopyButton } from "./shapeBuilder.styles"; |
10 | 4 | import { Button, Typography, Box, CopyIcon } from "@sistent/sistent"; |
11 | 5 | import { SVG, extend as SVGextend } from "@svgdotjs/svg.js"; |
12 | 6 | import draw from "@svgdotjs/svg.draw.js"; |
@@ -66,16 +60,13 @@ const ShapeBuilder = () => { |
66 | 60 |
|
67 | 61 | const points = getPlottedPoints(poly); |
68 | 62 | if (!points) return; |
69 | | - const xs = points.map((p) => p[0]); |
70 | | - const ys = points.map((p) => p[1]); |
| 63 | + const xs = points.map(p => p[0]); |
| 64 | + const ys = points.map(p => p[1]); |
71 | 65 |
|
72 | 66 | const width = Math.abs(Math.max(...xs) - Math.min(...xs)); |
73 | 67 | const height = Math.abs(Math.max(...ys) - Math.min(...ys)); |
74 | 68 |
|
75 | | - poly.size( |
76 | | - width > height ? 520 : undefined, |
77 | | - height >= width ? 520 : undefined, |
78 | | - ); |
| 69 | + poly.size(width > height ? 520 : undefined, height >= width ? 520 : undefined); |
79 | 70 | poly.move(0, 0); |
80 | 71 | showCytoArray(); |
81 | 72 | }; |
@@ -188,59 +179,32 @@ const ShapeBuilder = () => { |
188 | 179 | onDoubleClick={closeShape} |
189 | 180 | > |
190 | 181 | <defs> |
191 | | - <pattern |
192 | | - id="grid" |
193 | | - width="16" |
194 | | - height="16" |
195 | | - patternUnits="userSpaceOnUse" |
196 | | - > |
197 | | - <path |
198 | | - d="M 16 0 L 0 0 0 16" |
199 | | - fill="none" |
200 | | - stroke="#797d7a" |
201 | | - strokeWidth="1" |
202 | | - /> |
| 182 | + <pattern id="grid" width="16" height="16" patternUnits="userSpaceOnUse"> |
| 183 | + <path d="M 16 0 L 0 0 0 16" fill="none" stroke="#797d7a" strokeWidth="1" /> |
203 | 184 | </pattern> |
204 | 185 | </defs> |
205 | 186 | <rect className="grid" width="100%" height="100%" fill="url(#grid)" /> |
206 | 187 | </StyledSVG> |
207 | 188 | {error && ( |
208 | | - <div |
209 | | - style={{ |
210 | | - position: "absolute", |
211 | | - top: "50%", |
212 | | - left: "50%", |
213 | | - transform: "translate(-50%, -50%)", |
214 | | - color: "red", |
215 | | - backgroundColor: "white", |
216 | | - padding: "10px", |
217 | | - borderRadius: "5px", |
218 | | - }} |
219 | | - > |
| 189 | + <div style={{ |
| 190 | + position: "absolute", |
| 191 | + top: "50%", |
| 192 | + left: "50%", |
| 193 | + transform: "translate(-50%, -50%)", |
| 194 | + color: "red", |
| 195 | + backgroundColor: "white", |
| 196 | + padding: "10px", |
| 197 | + borderRadius: "5px" |
| 198 | + }}> |
220 | 199 | {error} |
221 | 200 | </div> |
222 | 201 | )} |
223 | 202 | </CanvasContainer> |
224 | 203 |
|
225 | | - <Box |
226 | | - sx={{ |
227 | | - display: "flex", |
228 | | - justifyContent: "center", |
229 | | - gap: 2, |
230 | | - mt: 3, |
231 | | - mb: 3, |
232 | | - flexWrap: "wrap", |
233 | | - }} |
234 | | - > |
235 | | - <Button variant="contained" onClick={clearShape}> |
236 | | - Clear |
237 | | - </Button> |
238 | | - <Button variant="contained" onClick={closeShape}> |
239 | | - Close Shape |
240 | | - </Button> |
241 | | - <Button variant="contained" onClick={handleMaximize}> |
242 | | - Maximize |
243 | | - </Button> |
| 204 | + <Box sx={{ display: "flex", justifyContent: "center", gap: 2, mt: 3, mb: 3, flexWrap: "wrap" }}> |
| 205 | + <Button variant="contained" onClick={clearShape}>Clear</Button> |
| 206 | + <Button variant="contained" onClick={closeShape}>Close Shape</Button> |
| 207 | + <Button variant="contained" onClick={handleMaximize}>Maximize</Button> |
244 | 208 | </Box> |
245 | 209 |
|
246 | 210 | <OutputBox> |
|
0 commit comments