sag_components 1.0.80 → 1.0.81

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.
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = exports.TotalDoughnutChart = void 0;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
8
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
9
- var _react = _interopRequireDefault(require("react"));
11
+ var _react = _interopRequireWildcard(require("react"));
10
12
  var _CommonFunctions = require("./CommonFunctions");
11
13
  var _recharts = require("recharts");
12
14
  var _TotalDoughnutChartStyle = require("./TotalDoughnutChart.style.js");
@@ -25,18 +27,36 @@ var TotalDoughnutChart = function TotalDoughnutChart(_ref) {
25
27
  currencyType = _ref$currencyType === void 0 ? "USD" : _ref$currencyType,
26
28
  legendData = _ref.legendData,
27
29
  _ref$width = _ref.width,
28
- width = _ref$width === void 0 ? "100%" : _ref$width,
30
+ width = _ref$width === void 0 ? "250px" : _ref$width,
29
31
  _ref$height = _ref.height,
30
- height = _ref$height === void 0 ? "100%" : _ref$height,
32
+ height = _ref$height === void 0 ? "280px" : _ref$height,
31
33
  _ref$textColor = _ref.textColor,
32
34
  textColor = _ref$textColor === void 0 ? "black" : _ref$textColor,
33
35
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
36
+ var DEFAULT_ROOT_FONT = 16;
37
+ var DEFAULT_COMPONENT_WIDTH = 250;
38
+ var _useState = (0, _react.useState)(DEFAULT_ROOT_FONT.toString().concat("", "px")),
39
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
40
+ rootFont = _useState2[0],
41
+ setRootFont = _useState2[1];
42
+ var controlsContainerRef = (0, _react.useRef)();
43
+ (0, _react.useEffect)(function () {
44
+ var offsetWidth = controlsContainerRef.current.offsetWidth;
45
+ setRootFont(getRootFont(offsetWidth));
46
+ }, [width]);
47
+ var getRootFont = function getRootFont(width) {
48
+ var relation = width.toString().replace("px", "").replace("%", "") / DEFAULT_COMPONENT_WIDTH;
49
+ var fontRoot = (DEFAULT_ROOT_FONT * relation).toString().concat("", "px");
50
+ return fontRoot;
51
+ };
34
52
  var onPieEnterHandler = function onPieEnterHandler() {};
35
53
  return /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.ControlsContainer, {
36
54
  id: "ControlsContainer",
37
55
  height: height,
38
56
  width: width,
39
- textColor: textColor
57
+ textColor: textColor,
58
+ ref: controlsContainerRef,
59
+ rootFont: rootFont
40
60
  }, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.Controls, {
41
61
  id: "Controls",
42
62
  height: height,
@@ -63,8 +83,8 @@ var TotalDoughnutChart = function TotalDoughnutChart(_ref) {
63
83
  onMouseEnter: onPieEnterHandler
64
84
  }, /*#__PURE__*/_react.default.createElement(_recharts.Pie, {
65
85
  data: legendData,
66
- innerRadius: 23,
67
- outerRadius: 33,
86
+ outerRadius: 33 * (rootFont.toString().replace("px", "") / DEFAULT_ROOT_FONT),
87
+ innerRadius: 23 * (rootFont.toString().replace("px", "") / DEFAULT_ROOT_FONT),
68
88
  fill: "#8884d8",
69
89
  dataKey: "value"
70
90
  }, legendData.map(function (row, index) {
@@ -8,7 +8,9 @@ exports.TitleAndValueContainer = exports.Title = exports.LegendTitleAndFormatedV
8
8
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
9
9
  var _styledComponents = _interopRequireDefault(require("styled-components"));
10
10
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17;
11
- var ControlsContainer = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n position: relative;\n margin: 0px 0 0px;\n font-family: \"Lato\", sans-serif;\n font-style: normal;\n color: ", ";\n width: ", ";\n height: ", ";\n //box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);\n border-radius: 12px; \n align-content: center;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n //border: 1px solid blue;\n"])), function (props) {
11
+ var ControlsContainer = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n position: relative;\n font-family: \"Lato\", sans-serif;\n font-style: normal; \n font-size: ", ";\n color: ", ";\n width: ", ";\n height: ", ";\n //box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);\n border-radius: 12px; \n align-content: center;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n"])), function (props) {
12
+ return props.rootFont;
13
+ }, function (props) {
12
14
  return props.textColor;
13
15
  }, function (props) {
14
16
  return props.width;
@@ -16,37 +18,37 @@ var ControlsContainer = _styledComponents.default.div(_templateObject || (_templ
16
18
  return props.height;
17
19
  });
18
20
  exports.ControlsContainer = ControlsContainer;
19
- var Controls = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n border-radius: 12px;\n width:100%;\n height:100%;\n background: #ffffff;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n //border: 1px solid blue;\n"])));
21
+ var Controls = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n border-radius: 12px;\n width:100%;\n height:100%;\n background: #ffffff;\n justify-content: center;\n align-items: center;\n flex-direction: column; \n"])));
20
22
  exports.Controls = Controls;
21
- var TitleAndValueContainer = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n width: 80%;\n margin-top: 35px;\n"])));
23
+ var TitleAndValueContainer = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n width: 90%;\n margin-top: 35px;\n"])));
22
24
  exports.TitleAndValueContainer = TitleAndValueContainer;
23
- var Title = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%; \n height: 30px;\n font-weight: 600;\n font-size: 1.125rem;\n line-height: 22px;\n"])));
25
+ var Title = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%; \n height: 100%; \n font-weight: 600;\n font-size: 1em;\n"])));
24
26
  exports.Title = Title;
25
27
  var CurrencySignAndFormattedValueContainer = _styledComponents.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: row;\n align-items: baseline;\n"])));
26
28
  exports.CurrencySignAndFormattedValueContainer = CurrencySignAndFormattedValueContainer;
27
- var CurrencySign = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 500;\n font-size: 18px;\n line-height: 22px;\n //border: 1px solid red;\n"])));
29
+ var CurrencySign = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 500;\n font-size: 1em;\n"])));
28
30
  exports.CurrencySign = CurrencySign;
29
- var FormattedValue = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 500;\n font-size: 2.5rem;\n line-height: 48px;\n \n //border: 1px solid red;\n"])));
31
+ var FormattedValue = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 500;\n font-size: 2.22em; \n"])));
30
32
  exports.FormattedValue = FormattedValue;
31
- var DoughnutChartAndLegendContainer = _styledComponents.default.div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: row;\n width: 80%;\n height: 27%;\n margin-top: 35px;\n margin-bottom: 35px;\n"])));
33
+ var DoughnutChartAndLegendContainer = _styledComponents.default.div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: row;\n width: 90%;\n height: 27%;\n margin-top: 2.18em; // 35px;\n margin-bottom: 2.18em; // 35px;\n"])));
32
34
  exports.DoughnutChartAndLegendContainer = DoughnutChartAndLegendContainer;
33
- var DoughnutChart = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n width: 34%;\n height: 100%;\n //border: 1px solid red;\n"])));
35
+ var DoughnutChart = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n width: 34%;\n height: 100%;\n"])));
34
36
  exports.DoughnutChart = DoughnutChart;
35
- var LegendContainer = _styledComponents.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n width: 66%;\n padding-left: 10px;\n flex-direction: column;\n align-items: left;\n justify-content: space-between;\n\n //border: 1px solid blue;\n"])));
37
+ var LegendContainer = _styledComponents.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n width: 66%;\n padding-left: 10px;\n flex-direction: column;\n align-items: left;\n justify-content: space-between;\n"])));
36
38
  exports.LegendContainer = LegendContainer;
37
- var LegendControlsContainer = _styledComponents.default.div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: row;\n align-items: center;\n height: 50%;\n width: 100%;\n //border: 1px solid blue;\n"])));
39
+ var LegendControlsContainer = _styledComponents.default.div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: row;\n align-items: center;\n height: 50%;\n width: 100%;\n"])));
38
40
  exports.LegendControlsContainer = LegendControlsContainer;
39
- var LegendTitleAndFormatedValueContainer = _styledComponents.default.div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n width: 80%;\n margin-left: 5px;\n flex-direction: column;\n //border: 1px solid blue;\n"])));
41
+ var LegendTitleAndFormatedValueContainer = _styledComponents.default.div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n width: 100%;\n height: 100%;\n margin-left: 0.1em; \n flex-direction: column;\n"])));
40
42
  exports.LegendTitleAndFormatedValueContainer = LegendTitleAndFormatedValueContainer;
41
- var LegendFormatedValueContainer = _styledComponents.default.div(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: row;\n \n //border: 1px solid blue;\n"])));
43
+ var LegendFormatedValueContainer = _styledComponents.default.div(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: row;\n width: 100%;\n height: 50%;\n"])));
42
44
  exports.LegendFormatedValueContainer = LegendFormatedValueContainer;
43
- var LegendColorRectangle = _styledComponents.default.div(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2.default)(["\n width: 10px;\n height: 10px;\n background: ", ";\n"])), function (props) {
45
+ var LegendColorRectangle = _styledComponents.default.div(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2.default)(["\n width: 0.8em;\n height: 0.7em;\n margin-right:0.3em;\n background: ", ";\n"])), function (props) {
44
46
  return props.color;
45
47
  });
46
48
  exports.LegendColorRectangle = LegendColorRectangle;
47
- var LegendTitle = _styledComponents.default.div(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 400;\n font-size: 0.6vw;\n width: 90%;\n height: 50%;\n //border: 1px solid red;\n"])));
49
+ var LegendTitle = _styledComponents.default.div(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 400;\n font-size: 0.8em; \n width: 100%;\n height: 50%;\n"])));
48
50
  exports.LegendTitle = LegendTitle;
49
- var LegendCurrencySign = _styledComponents.default.div(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 600;\n font-size: 0.6vw;\n height: 50%;\n //border: 1px solid red;\n"])));
51
+ var LegendCurrencySign = _styledComponents.default.div(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 600;\n font-size: 0.8em; \n"])));
50
52
  exports.LegendCurrencySign = LegendCurrencySign;
51
- var LegendFormattedValue = _styledComponents.default.div(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 600;\n font-size:0.6vw;\n height: 50%;\n //border: 1px solid red;\n"])));
53
+ var LegendFormattedValue = _styledComponents.default.div(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 600;\n font-size: 0.8em; \n"])));
52
54
  exports.LegendFormattedValue = LegendFormattedValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sag_components",
3
- "version": "1.0.80",
3
+ "version": "1.0.81",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {