@sis-cc/dotstatsuite-visions 7.11.0 → 7.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ import React, { useState } from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import * as R from 'ramda';
8
8
  import cx from 'classnames';
9
+ import useSize from '@react-hook/size';
9
10
  import { makeStyles } from '@material-ui/core/styles';
10
11
  import Typography from '@material-ui/core/Typography';
11
12
  import Collapse from '@material-ui/core/Collapse';
@@ -86,20 +87,17 @@ var useStyles = makeStyles(function (theme) {
86
87
  margin: theme.spacing(0.5, 0.5)
87
88
  },
88
89
  fadeContent: {
89
- maxHeight: 70,
90
90
  color: theme.palette.grey['A200'],
91
91
  position: 'relative',
92
92
  overflow: 'hidden'
93
93
  },
94
94
  fading: {
95
95
  position: 'absolute',
96
- bottom: 0,
97
96
  left: 0,
98
- width: '100%',
97
+ right: 0,
99
98
  height: 15,
100
- textAlign: 'center',
101
99
  margin: 0,
102
- padding: theme.spacing(0, 0.5, 0.5, 0.5),
100
+ padding: 0,
103
101
  backgroundImage: 'linear-gradient(to bottom, transparent, white)'
104
102
  },
105
103
  wrapper: {
@@ -161,6 +159,20 @@ var Dataflow = function Dataflow(_ref2) {
161
159
 
162
160
  var description = R.propOr('', 'description', body);
163
161
 
162
+ var target = React.useRef();
163
+
164
+ var _useSize = useSize(target),
165
+ height = _useSize[1];
166
+
167
+ var handleExpand = function handleExpand() {
168
+ setExpand(function (prev) {
169
+ return !prev;
170
+ });
171
+ };
172
+
173
+ //const collapsedSize = R.min(!isExpanded ? height : !collapsedSize ? height : collapsedSize, 70);
174
+ var collapsedSize = R.min(height, 70);
175
+
164
176
  return React.createElement(
165
177
  Card,
166
178
  { elevation: 0, square: true, className: classes.card, 'data-testid': '' + testId },
@@ -196,12 +208,13 @@ var Dataflow = function Dataflow(_ref2) {
196
208
  Collapse,
197
209
  {
198
210
  'in': isExpanded,
199
- collapsedSize: 70,
211
+ collapsedSize: collapsedSize,
200
212
  classes: isExpanded ? undefined : { wrapper: classes.wrapper }
201
213
  },
202
214
  React.createElement(
203
215
  CardContent,
204
216
  {
217
+ ref: target,
205
218
  className: cx(classes.cardContent, (_cx = {}, _cx[classes.fadeContent] = !isExpanded, _cx))
206
219
  },
207
220
  React.createElement(
@@ -213,7 +226,7 @@ var Dataflow = function Dataflow(_ref2) {
213
226
  },
214
227
  React.createElement(HTMLRenderer, { html: description })
215
228
  ),
216
- !isExpanded && React.createElement('div', { className: classes.fading })
229
+ !isExpanded && React.createElement('div', { className: classes.fading, style: { top: collapsedSize - 15 } })
217
230
  )
218
231
  ),
219
232
  R.not(R.empty(R.propOr('', 'highlightDescription')(body))) && React.createElement(
@@ -346,9 +359,7 @@ var Dataflow = function Dataflow(_ref2) {
346
359
  'data-testid': 'dataflow-expand-button-test-id',
347
360
  'aria-label': 'expand',
348
361
  onClick: function onClick() {
349
- return setExpand(function (prev) {
350
- return !prev;
351
- });
362
+ return handleExpand();
352
363
  },
353
364
  color: 'primary',
354
365
  size: 'small'
@@ -1,6 +1,4 @@
1
1
  /**
2
- * Dataflow
3
- *
4
2
  * Without onDownload the button download will disappear
5
3
  *
6
4
  * @demoReady
@@ -20,6 +20,10 @@ var _classnames = require('classnames');
20
20
 
21
21
  var _classnames2 = _interopRequireDefault(_classnames);
22
22
 
23
+ var _size = require('@react-hook/size');
24
+
25
+ var _size2 = _interopRequireDefault(_size);
26
+
23
27
  var _styles = require('@material-ui/core/styles');
24
28
 
25
29
  var _Typography = require('@material-ui/core/Typography');
@@ -140,20 +144,17 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
140
144
  margin: theme.spacing(0.5, 0.5)
141
145
  },
142
146
  fadeContent: {
143
- maxHeight: 70,
144
147
  color: theme.palette.grey['A200'],
145
148
  position: 'relative',
146
149
  overflow: 'hidden'
147
150
  },
148
151
  fading: {
149
152
  position: 'absolute',
150
- bottom: 0,
151
153
  left: 0,
152
- width: '100%',
154
+ right: 0,
153
155
  height: 15,
154
- textAlign: 'center',
155
156
  margin: 0,
156
- padding: theme.spacing(0, 0.5, 0.5, 0.5),
157
+ padding: 0,
157
158
  backgroundImage: 'linear-gradient(to bottom, transparent, white)'
158
159
  },
159
160
  wrapper: {
@@ -215,6 +216,20 @@ var Dataflow = function Dataflow(_ref2) {
215
216
 
216
217
  var description = R.propOr('', 'description', body);
217
218
 
219
+ var target = _react2.default.useRef();
220
+
221
+ var _useSize = (0, _size2.default)(target),
222
+ height = _useSize[1];
223
+
224
+ var handleExpand = function handleExpand() {
225
+ setExpand(function (prev) {
226
+ return !prev;
227
+ });
228
+ };
229
+
230
+ //const collapsedSize = R.min(!isExpanded ? height : !collapsedSize ? height : collapsedSize, 70);
231
+ var collapsedSize = R.min(height, 70);
232
+
218
233
  return _react2.default.createElement(
219
234
  _Card2.default,
220
235
  { elevation: 0, square: true, className: classes.card, 'data-testid': '' + testId },
@@ -250,12 +265,13 @@ var Dataflow = function Dataflow(_ref2) {
250
265
  _Collapse2.default,
251
266
  {
252
267
  'in': isExpanded,
253
- collapsedSize: 70,
268
+ collapsedSize: collapsedSize,
254
269
  classes: isExpanded ? undefined : { wrapper: classes.wrapper }
255
270
  },
256
271
  _react2.default.createElement(
257
272
  _CardContent2.default,
258
273
  {
274
+ ref: target,
259
275
  className: (0, _classnames2.default)(classes.cardContent, (_cx = {}, _cx[classes.fadeContent] = !isExpanded, _cx))
260
276
  },
261
277
  _react2.default.createElement(
@@ -267,7 +283,7 @@ var Dataflow = function Dataflow(_ref2) {
267
283
  },
268
284
  _react2.default.createElement(HTMLRenderer, { html: description })
269
285
  ),
270
- !isExpanded && _react2.default.createElement('div', { className: classes.fading })
286
+ !isExpanded && _react2.default.createElement('div', { className: classes.fading, style: { top: collapsedSize - 15 } })
271
287
  )
272
288
  ),
273
289
  R.not(R.empty(R.propOr('', 'highlightDescription')(body))) && _react2.default.createElement(
@@ -400,9 +416,7 @@ var Dataflow = function Dataflow(_ref2) {
400
416
  'data-testid': 'dataflow-expand-button-test-id',
401
417
  'aria-label': 'expand',
402
418
  onClick: function onClick() {
403
- return setExpand(function (prev) {
404
- return !prev;
405
- });
419
+ return handleExpand();
406
420
  },
407
421
  color: 'primary',
408
422
  size: 'small'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sis-cc/dotstatsuite-visions",
3
- "version": "7.11.0",
3
+ "version": "7.11.1",
4
4
  "description": "Library of visual components",
5
5
  "author": "OECD",
6
6
  "homepage": "https://visions-qa.siscc.org/#o",