• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zooniverse / front-end-monorepo / 13547957436

26 Feb 2025 03:52PM UTC coverage: 75.487% (-0.1%) from 75.625%
13547957436

Pull #6574

github

web-flow
Merge 45c6d0a81 into 1c40c2a2c
Pull Request #6574: [HOLD] lib-classifier: Refactor survey task Choices, ChoiceButton, Choice, Questions, and Filter styling

10908 of 16652 branches covered (65.51%)

Branch coverage included in aggregate %.

228 of 248 new or added lines in 24 files covered. (91.94%)

235 existing lines in 26 files now uncovered.

17008 of 20329 relevant lines covered (83.66%)

397.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.43
/packages/lib-classifier/src/plugins/drawingTools/components/Rectangle/Rectangle.js
1
import { observer } from 'mobx-react'
1✔
2
import PropTypes from 'prop-types'
1✔
3
import DragHandle from '../DragHandle'
3✔
4

5
const GRAB_STROKE_WIDTH = 6
1✔
6

7
function Rectangle({ active, mark, onFinish }) {
4✔
8
  const { x_center, y_center, width, height } = mark
4✔
9

10
  function onHandleDrag(coords) {
11
    mark.setCoordinates(coords)
1✔
12
  }
13

14
  const x_left = x_center - width / 2
4✔
15
  const x_right = x_center + width / 2
4✔
16
  const y_top = y_center - height / 2
4✔
17
  const y_bottom = y_center + height / 2
4✔
18

19
  const _onFinish =
20
    onFinish ||
4✔
21
    function () {
22
      return true
1✔
23
    }
24

25
  return (
4✔
26
    <g onPointerUp={active ? _onFinish : undefined}>
4✔
27
      <rect
28
        x={x_left}
29
        y={y_top}
30
        width={width}
31
        height={height}
32
        data-testid='rectangle-element'
33
        vectorEffect={'non-scaling-stroke'}
34
      />
35
      <rect
36
        x={x_left}
37
        y={y_top}
38
        width={width}
39
        height={height}
40
        strokeWidth={GRAB_STROKE_WIDTH}
41
        strokeOpacity='0'
42
        vectorEffect={'non-scaling-stroke'}
43
      />
44
      {active && (
7✔
45
        <DragHandle
46
          x={x_left}
47
          y={y_top}
48
          data-testid='rect-dragHandle1'
UNCOV
49
          dragMove={(e, d) =>
×
50
            onHandleDrag({
51
              x_left: x_left + d.x,
52
              x_right: x_right,
53
              y_top: y_top + d.y,
54
              y_bottom: y_bottom
55
            })
56
          }
57
        />
58
      )}
59
      {active && (
7✔
60
        <DragHandle
61
          x={x_right}
62
          y={y_bottom}
63
          data-testid='rect-dragHandle2'
64
          dragMove={(e, d) =>
×
65
            onHandleDrag({
66
              x_left: x_left,
67
              x_right: x_right + d.x,
68
              y_top: y_top,
69
              y_bottom: y_bottom + d.y
70
            })
71
          }
72
        />
73
      )}
74
      {active && (
7✔
75
        <DragHandle
76
          x={x_left}
77
          y={y_bottom}
78
          data-testid='rect-dragHandle3'
79
          dragMove={(e, d) =>
1✔
80
            onHandleDrag({
81
              x_left: x_left + d.x,
82
              x_right: x_right,
83
              y_top: y_top,
84
              y_bottom: y_bottom + d.y
85
            })
86
          }
87
        />
88
      )}
89
      {active && (
7✔
90
        <DragHandle
91
          x={x_right}
92
          y={y_top}
93
          data-testid='rect-dragHandle4'
UNCOV
94
          dragMove={(e, d) =>
×
95
            onHandleDrag({
96
              x_left: x_left,
97
              x_right: x_right + d.x,
98
              y_top: y_top + d.y,
99
              y_bottom: y_bottom
100
            })
101
          }
102
        />
103
      )}
104
    </g>
105
  )
106
}
107

108
Rectangle.propTypes = {
1✔
109
  active: PropTypes.bool
110
}
111

112
Rectangle.defaultProps = {
1✔
113
  active: false
114
}
1✔
115

116
export default observer(Rectangle)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc