@@ -31,6 +31,8 @@ var _Constants = require("./Constants");
31
31
32
32
var _Generators = require ( "./Generators" ) ;
33
33
34
+ var _reactUseMeasure = _interopRequireDefault ( require ( "react-use-measure" ) ) ;
35
+
34
36
var TipContent = function TipContent ( _ref ) {
35
37
var message = _ref . message ;
36
38
return /*#__PURE__*/ _react . default . createElement ( _grommet . Box , {
@@ -56,13 +58,24 @@ var TipContent = function TipContent(_ref) {
56
58
} ;
57
59
58
60
var Drawer = function Drawer ( _ref2 ) {
59
- var highlightColor = _ref2 . highlightColor ;
61
+ var highlightColor = _ref2 . highlightColor ,
62
+ drawerWidth = _ref2 . drawerWidth ;
60
63
61
64
var _useState = ( 0 , _react . useState ) ( '' ) ,
62
65
_useState2 = ( 0 , _slicedToArray2 . default ) ( _useState , 2 ) ,
63
66
searchTerm = _useState2 [ 0 ] ,
64
67
setSearchTerm = _useState2 [ 1 ] ;
65
68
69
+ var _useMeasure = ( 0 , _reactUseMeasure . default ) ( ) ,
70
+ _useMeasure2 = ( 0 , _slicedToArray2 . default ) ( _useMeasure , 2 ) ,
71
+ drawerRef = _useMeasure2 [ 0 ] ,
72
+ drawerBounds = _useMeasure2 [ 1 ] ;
73
+
74
+ var _useMeasure3 = ( 0 , _reactUseMeasure . default ) ( ) ,
75
+ _useMeasure4 = ( 0 , _slicedToArray2 . default ) ( _useMeasure3 , 2 ) ,
76
+ headerRef = _useMeasure4 [ 0 ] ,
77
+ headerBounds = _useMeasure4 [ 1 ] ;
78
+
66
79
var blocks = ( 0 , _ProgrammingContext . useProgrammingStore ) ( function ( store ) {
67
80
var blocks = [ ] ;
68
81
@@ -103,11 +116,11 @@ var Drawer = function Drawer(_ref2) {
103
116
return store . setActiveDrawer ;
104
117
} ) ;
105
118
var drawerStyle = ( 0 , _web . useSpring ) ( {
106
- width : activeDrawer !== null ? 235 : 0 ,
119
+ width : activeDrawer !== null ? drawerWidth : 0 ,
107
120
config : _reactSpring . config . stiff
108
121
} ) ;
109
122
var sidebarStyle = ( 0 , _web . useSpring ) ( {
110
- width : activeDrawer !== null ? 285 : 50 ,
123
+ width : activeDrawer !== null ? drawerWidth + 50 : 50 ,
111
124
config : _reactSpring . config . stiff
112
125
} ) ;
113
126
return /*#__PURE__*/ _react . default . createElement ( _web . animated . div , {
@@ -163,12 +176,14 @@ var Drawer = function Drawer(_ref2) {
163
176
icon : /*#__PURE__*/ _react . default . createElement ( Icon , null )
164
177
} ) ;
165
178
} ) ) , /*#__PURE__*/ _react . default . createElement ( _web . animated . div , {
179
+ ref : drawerRef ,
166
180
style : ( 0 , _objectSpread2 . default ) ( {
167
181
height : '100%' ,
168
182
backgroundColor : '#2f2f2f' ,
169
183
overflow : 'hidden'
170
184
} , drawerStyle )
171
185
} , activeDrawer !== null && /*#__PURE__*/ _react . default . createElement ( _react . default . Fragment , null , /*#__PURE__*/ _react . default . createElement ( _grommet . Box , {
186
+ ref : headerRef ,
172
187
background : "#444444" ,
173
188
direction : "column" ,
174
189
pad : "small" ,
@@ -195,24 +210,29 @@ var Drawer = function Drawer(_ref2) {
195
210
onChange : function onChange ( e ) {
196
211
return setSearchTerm ( e . target . value ) ;
197
212
}
198
- } ) ) , /*#__PURE__*/ _react . default . createElement ( _grommet . List , {
213
+ } ) ) , /*#__PURE__*/ _react . default . createElement ( _grommet . Box , {
214
+ style : {
215
+ height : drawerBounds . height - headerBounds . height ,
216
+ overflowY : 'scroll'
217
+ }
218
+ } , /*#__PURE__*/ _react . default . createElement ( _grommet . List , {
199
219
data : blocks ,
200
220
border : false ,
201
221
style : {
202
- padding : 5 ,
203
- width : 235
222
+ padding : 5
204
223
} ,
205
224
margin : "none" ,
206
225
pad : "none"
207
226
} , function ( block , idx ) {
208
227
return /*#__PURE__*/ _react . default . createElement ( _grommet . Box , {
228
+ key : idx ,
209
229
animation : {
210
230
type : 'fadeIn' ,
211
231
delay : idx * 100
212
232
} ,
213
233
style : {
214
234
marginBottom : 5 ,
215
- width : 225
235
+ width : drawerWidth - 10
216
236
}
217
237
} , /*#__PURE__*/ _react . default . createElement ( _Block . Block , {
218
238
staticData : block ,
@@ -228,7 +248,7 @@ var Drawer = function Drawer(_ref2) {
228
248
isSpawner : true
229
249
}
230
250
} ) ) ;
231
- } ) ) ) ) ;
251
+ } ) ) ) ) ) ;
232
252
} ;
233
253
234
254
exports . Drawer = Drawer ;
0 commit comments