1
1
import { withStyles } from '@material-ui/core'
2
2
import React from 'react'
3
+ import { observer , PropTypes as MobxPropTypes } from 'mobx-react'
3
4
import PropTypes from 'prop-types'
4
5
import Block from '../../BasicTrack/components/Block'
5
6
@@ -14,7 +15,7 @@ const styles = (/* theme */) => ({
14
15
background : '#555' ,
15
16
// background: theme.palette.background.default,
16
17
overflow : 'hidden' ,
17
- height : '100%' ,
18
+ height : 32 ,
18
19
} ,
19
20
refLabel : {
20
21
fontSize : '16px' ,
@@ -37,48 +38,26 @@ function findBlockContainingLeftSideOfView(offsetPx, blockSet) {
37
38
return undefined
38
39
}
39
40
40
- function ScaleBar ( {
41
- classes,
42
- style,
43
- height,
44
- blocks,
45
- offsetPx,
46
- bpPerPx,
47
- horizontallyFlipped,
48
- } ) {
49
- const finalStyle = Object . assign ( { } , style , {
50
- height : `${ height } px` ,
51
- } )
52
-
41
+ function ScaleBar ( { classes, model, height } ) {
53
42
const blockContainingLeftEndOfView = findBlockContainingLeftSideOfView (
54
- offsetPx ,
55
- blocks ,
43
+ model . offsetPx ,
44
+ model . staticBlocks ,
56
45
)
57
46
58
47
return (
59
- < div style = { finalStyle } className = { classes . scaleBar } >
60
- { blocks . map ( block => {
48
+ < div className = { classes . scaleBar } >
49
+ { model . staticBlocks . map ( block => {
61
50
return (
62
- < Block
63
- leftBorder = { block . isLeftEndOfDisplayedRegion }
64
- rightBorder = { block . isRightEndOfDisplayedRegion }
65
- refName = { block . refName }
66
- start = { block . start }
67
- end = { block . end }
68
- width = { block . widthPx }
69
- key = { block . key }
70
- offset = { block . offsetPx - offsetPx }
71
- bpPerPx = { bpPerPx }
72
- >
51
+ < Block key = { block . offsetPx } block = { block } model = { model } >
73
52
< svg height = { height } width = { block . widthPx } >
74
53
< Ruler
75
54
region = { block }
76
55
showRefNameLabel = {
77
56
! ! block . isLeftEndOfDisplayedRegion &&
78
57
block !== blockContainingLeftEndOfView
79
58
}
80
- bpPerPx = { bpPerPx }
81
- flipped = { horizontallyFlipped }
59
+ bpPerPx = { model . bpPerPx }
60
+ flipped = { model . horizontallyFlipped }
82
61
/>
83
62
</ svg >
84
63
</ Block >
@@ -95,20 +74,11 @@ function ScaleBar({
95
74
}
96
75
ScaleBar . defaultProps = {
97
76
style : { } ,
98
- blocks : [ ] ,
99
- horizontallyFlipped : false ,
100
77
}
101
78
ScaleBar . propTypes = {
79
+ model : MobxPropTypes . objectOrObservableObject . isRequired ,
102
80
classes : PropTypes . objectOf ( PropTypes . string ) . isRequired ,
103
- style : PropTypes . objectOf ( PropTypes . any ) ,
104
81
height : PropTypes . number . isRequired ,
105
- blocks : PropTypes . shape ( {
106
- map : PropTypes . func . isRequired ,
107
- getBlocks : PropTypes . func . isRequired ,
108
- } ) ,
109
- bpPerPx : PropTypes . number . isRequired ,
110
- offsetPx : PropTypes . number . isRequired ,
111
- horizontallyFlipped : PropTypes . bool ,
112
82
}
113
83
114
- export default withStyles ( styles ) ( ScaleBar )
84
+ export default withStyles ( styles ) ( observer ( ScaleBar ) )
0 commit comments