-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathconnectors.tsx
More file actions
56 lines (50 loc) · 1.33 KB
/
connectors.tsx
File metadata and controls
56 lines (50 loc) · 1.33 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
import React from 'react';
import Connector from 'Components/connector';
import { getCalculatedStyles } from '../settings';
import { calculatePositionOfMatch } from './calculate-match-position';
const Connectors = ({
bracketSnippet,
rowIndex,
columnIndex,
style,
offsetY = 0,
}) => {
const {
columnWidth,
rowHeight,
canvasPadding,
} = getCalculatedStyles(style);
const currentMatchPosition = calculatePositionOfMatch(rowIndex, columnIndex, {
canvasPadding,
rowHeight,
columnWidth,
offsetY,
});
const previousBottomPosition = (rowIndex + 1) * 2 - 1;
const previousTopMatchPosition =
bracketSnippet.previousTopMatch &&
calculatePositionOfMatch(previousBottomPosition - 1, columnIndex - 1, {
canvasPadding,
rowHeight,
columnWidth,
offsetY,
});
const previousBottomMatchPosition =
bracketSnippet.previousBottomMatch &&
calculatePositionOfMatch(previousBottomPosition, columnIndex - 1, {
canvasPadding,
rowHeight,
columnWidth,
offsetY,
});
return (
<Connector
bracketSnippet={bracketSnippet}
previousBottomMatchPosition={previousBottomMatchPosition}
previousTopMatchPosition={previousTopMatchPosition}
currentMatchPosition={currentMatchPosition}
style={style}
/>
);
};
export default Connectors;