mario-education 2.4.174-level → 2.4.176-level

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.
@@ -31209,20 +31209,25 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31209
31209
  var chartHeight = isMobileScreen ? chartWidth / 1.5 : chartWidth / 3.12;
31210
31210
  var colors = ["#C44140", "#81C935", "#0F9655", "#FFB04F", "#C44140"];
31211
31211
  var data = [{
31212
- label: "BOREOUT",
31213
- value: studentPressure.boreOutStudent
31212
+ label: "UNMOTIVATED",
31213
+ value: studentPressure.boreOutStudent,
31214
+ tooltip: "Not enough challenge, leading to boredom and lack of interest."
31214
31215
  }, {
31215
31216
  label: "COMFORT",
31216
- value: studentPressure.comfortStudent
31217
+ value: studentPressure.comfortStudent,
31218
+ tooltip: "Calm and relaxed but not enough motivation to perform at my best."
31217
31219
  }, {
31218
31220
  label: "STRETCH",
31219
- value: studentPressure.stretchStudent
31221
+ value: studentPressure.stretchStudent,
31222
+ tooltip: "Manageable levels of stress allowing me to perform at my best."
31220
31223
  }, {
31221
31224
  label: "STRAIN",
31222
- value: studentPressure.strainStudent
31225
+ value: studentPressure.strainStudent,
31226
+ tooltip: "Still in control but starting to feel the pressure."
31223
31227
  }, {
31224
- label: "BURNOUT",
31225
- value: studentPressure.burnoutStudent
31228
+ label: "OVERWHELMED",
31229
+ value: studentPressure.burnoutStudent,
31230
+ tooltip: "Too much pressure and really struggling to manage my workload."
31226
31231
  }];
31227
31232
  var xAxistLabels = ["Low", "Moderate", "High", "Very High"];
31228
31233
 
@@ -31230,30 +31235,75 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31230
31235
  tooltipVisible = _useState[0],
31231
31236
  setTooltipVisible = _useState[1];
31232
31237
 
31233
- var _useState2 = useState(0),
31234
- tooltipX = _useState2[0],
31235
- setTooltipX = _useState2[1];
31238
+ var _useState2 = useState(""),
31239
+ infoTooltip = _useState2[0],
31240
+ setInfoTooltip = _useState2[1];
31236
31241
 
31237
31242
  var _useState3 = useState(0),
31238
- tooltipY = _useState3[0],
31239
- setTooltipY = _useState3[1];
31243
+ tooltipX = _useState3[0],
31244
+ setTooltipX = _useState3[1];
31240
31245
 
31241
- var _useState4 = useState([]),
31242
- tooltipStudents = _useState4[0],
31243
- setTooltipStudents = _useState4[1];
31246
+ var _useState4 = useState(0),
31247
+ tooltipY = _useState4[0],
31248
+ setTooltipY = _useState4[1];
31244
31249
 
31245
- var _useState5 = useState(""),
31246
- colorTooltip = _useState5[0],
31247
- setColorTooltip = _useState5[1];
31250
+ var _useState5 = useState([]),
31251
+ tooltipStudents = _useState5[0],
31252
+ setTooltipStudents = _useState5[1];
31253
+
31254
+ var _useState6 = useState(""),
31255
+ colorTooltip = _useState6[0],
31256
+ setColorTooltip = _useState6[1];
31257
+
31258
+ var getHeightFromText = function getHeightFromText(text, fontSize) {
31259
+ var dummyElement = document.createElement("span");
31260
+ dummyElement.style.visibility = "hidden";
31261
+ dummyElement.style.position = "absolute";
31262
+ dummyElement.style.whiteSpace = "wrap";
31263
+ dummyElement.style.fontSize = fontSize;
31264
+ dummyElement.style.width = "162px";
31265
+ dummyElement.style.padding = "5px 5px 5px 8px";
31266
+ dummyElement.innerHTML = text;
31267
+ document.body.appendChild(dummyElement);
31268
+ var height = dummyElement.offsetHeight;
31269
+ document.body.removeChild(dummyElement);
31270
+ return height;
31271
+ };
31272
+
31273
+ var getWidthFromText = function getWidthFromText(text, fontSize, fontWeight) {
31274
+ var dummyElement = document.createElement("span");
31275
+ dummyElement.style.visibility = "hidden";
31276
+ dummyElement.style.position = "absolute";
31277
+ dummyElement.style.whiteSpace = "nowrap";
31278
+ dummyElement.style.fontSize = fontSize;
31279
+ dummyElement.style.fontWeight = fontWeight;
31280
+ dummyElement.innerHTML = text;
31281
+ document.body.appendChild(dummyElement);
31282
+ var width = dummyElement.offsetWidth;
31283
+ document.body.removeChild(dummyElement);
31284
+ return width;
31285
+ };
31248
31286
 
31249
31287
  var handleDotHover = function handleDotHover(students, x, y, label, color) {
31250
31288
  setTooltipStudents(Array.from(new Set(students)));
31251
- setTooltipX(isMobileScreen && label == "BURNOUT" ? x - 45 : x);
31289
+ setTooltipX(isMobileScreen && label == data[data.length - 1].label ? x - 45 : x);
31252
31290
  setTooltipY(y);
31253
31291
  setTooltipVisible(label);
31254
31292
  setColorTooltip(color);
31255
31293
  };
31256
31294
 
31295
+ var handleEnterInfoIcon = function handleEnterInfoIcon(x, y, tip, label) {
31296
+ setTooltipVisible(label);
31297
+ setInfoTooltip(tip);
31298
+ setTooltipX(isMobileScreen && label == data[data.length - 1].label ? x - 15 : x);
31299
+ setTooltipY(y);
31300
+ };
31301
+
31302
+ var handleLeaveInfoIcon = function handleLeaveInfoIcon() {
31303
+ setTooltipVisible("");
31304
+ setInfoTooltip("");
31305
+ };
31306
+
31257
31307
  var handleDotLeave = function handleDotLeave() {
31258
31308
  setTooltipVisible("");
31259
31309
  };
@@ -31266,7 +31316,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31266
31316
  try {
31267
31317
  var _ret = function () {
31268
31318
  var styleElement = document.createElementNS("http://www.w3.org/2000/svg", "style");
31269
- styleElement.textContent = "\n text {\n font-size: 12px;\n }";
31319
+ styleElement.textContent = "\n text {\n font-size: 12px;\n }\n .info-stress-icon:hover circle{\n stroke: #316CD9\n }\n .info-stress-icon:hover polyline{\n stroke: #316CD9\n }\n .tooltip-chart{\n content: \"\";\n display: block;\n width: 0; \n height: 0; \n border-left: 5px solid transparent;\n border-right: 5px solid transparent;\n border-top: 5px solid #242424CC;\n }\n ";
31270
31320
  svg.appendChild(styleElement);
31271
31321
  var xAxis = document.createElementNS("http://www.w3.org/2000/svg", "line");
31272
31322
  xAxis.setAttribute("x1", "50");
@@ -31327,7 +31377,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31327
31377
  var circleY = !isMobileScreen ? chartHeight - 30 : chartHeight - 24;
31328
31378
 
31329
31379
  var _loop = function _loop(i) {
31330
- var _data3, _data3$value, _data3$value$length, _data6;
31380
+ var _data3, _data4, _data5, _data5$value, _data5$value$length, _data8, _data9;
31331
31381
 
31332
31382
  var circleX = circleSpacing * i + alignment;
31333
31383
  var radius = !isMobileScreen ? 15 : 12;
@@ -31336,12 +31386,17 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31336
31386
  circle.setAttribute("cy", "" + circleY);
31337
31387
  circle.setAttribute("r", "" + radius);
31338
31388
  circle.setAttribute("fill", colors[i - 1]);
31389
+ circle.style.cursor = "pointer";
31339
31390
  circle.addEventListener("mouseenter", function () {
31340
31391
  var _data, _data2;
31341
31392
 
31342
31393
  handleDotHover((_data = data[i - 1]) === null || _data === void 0 ? void 0 : _data.value, circleX, circleY, (_data2 = data[i - 1]) === null || _data2 === void 0 ? void 0 : _data2.label, colors[i - 1]);
31343
31394
  });
31344
- circle.addEventListener("mouseleave", handleDotLeave);
31395
+ var lineHeight = 20;
31396
+ var tooltipHeight = ((_data3 = data[i - 1]) === null || _data3 === void 0 ? void 0 : _data3.value.length) * lineHeight * 6;
31397
+ var widthLabel = getWidthFromText((_data4 = data[i - 1]) === null || _data4 === void 0 ? void 0 : _data4.label, "9px", "bold");
31398
+ var isScrollStudents = tooltipHeight + 30 > chartHeight - 100 - (isMobileScreen ? widthLabel : 0);
31399
+ if (isScrollStudents) circle.addEventListener("click", handleDotLeave);else circle.addEventListener("mouseleave", handleDotLeave);
31345
31400
  svg.appendChild(circle);
31346
31401
  var text = document.createElementNS("http://www.w3.org/2000/svg", "text");
31347
31402
  text.setAttribute("x", "" + circleX);
@@ -31351,14 +31406,28 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31351
31406
  text.setAttribute("text-anchor", "middle");
31352
31407
  text.setAttribute("dominant-baseline", "middle");
31353
31408
  text.setAttribute("style", "cursor: default");
31354
- text.textContent = (_data3 = data[i - 1]) === null || _data3 === void 0 ? void 0 : (_data3$value = _data3.value) === null || _data3$value === void 0 ? void 0 : (_data3$value$length = _data3$value.length) === null || _data3$value$length === void 0 ? void 0 : _data3$value$length.toString();
31409
+ text.textContent = (_data5 = data[i - 1]) === null || _data5 === void 0 ? void 0 : (_data5$value = _data5.value) === null || _data5$value === void 0 ? void 0 : (_data5$value$length = _data5$value.length) === null || _data5$value$length === void 0 ? void 0 : _data5$value$length.toString();
31410
+ text.style.cursor = "pointer";
31355
31411
  text.addEventListener("mouseenter", function () {
31356
- var _data4, _data5;
31412
+ var _data6, _data7;
31357
31413
 
31358
- handleDotHover((_data4 = data[i - 1]) === null || _data4 === void 0 ? void 0 : _data4.value, circleX, circleY, (_data5 = data[i - 1]) === null || _data5 === void 0 ? void 0 : _data5.label, colors[i - 1]);
31414
+ handleDotHover((_data6 = data[i - 1]) === null || _data6 === void 0 ? void 0 : _data6.value, circleX, circleY, (_data7 = data[i - 1]) === null || _data7 === void 0 ? void 0 : _data7.label, colors[i - 1]);
31359
31415
  });
31416
+ if (isScrollStudents) text.addEventListener("click", handleDotLeave);else text.addEventListener("mouseleave", handleDotLeave);
31360
31417
  svg.appendChild(text);
31361
- var label = (_data6 = data[i - 1]) === null || _data6 === void 0 ? void 0 : _data6.label;
31418
+ var label = (_data8 = data[i - 1]) === null || _data8 === void 0 ? void 0 : _data8.label;
31419
+ var tooltip = (_data9 = data[i - 1]) === null || _data9 === void 0 ? void 0 : _data9.tooltip;
31420
+ var infoIconContainer = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
31421
+ var infoIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
31422
+ infoIcon.innerHTML = "<rect width=\"256\" height=\"256\" fill=\"none\"></rect><circle cx=\"128\" cy=\"128\" r=\"96\" fill=\"none\" stroke=\"#000\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"16\"></circle><polyline fill=\"none\" stroke=\"#000\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"16\" points=\"120 120 128 120 128 176 136 176\"></polyline><circle cx=\"128\" cy=\"84\" r=\"12\"></circle>";
31423
+ infoIcon.setAttribute("width", "16");
31424
+ infoIcon.setAttribute("height", "16");
31425
+ infoIcon.setAttribute("viewBox", "0 0 256 256");
31426
+ infoIconContainer.setAttribute("width", "16");
31427
+ infoIconContainer.setAttribute("height", "20");
31428
+ infoIconContainer.style.cursor = "pointer";
31429
+ infoIconContainer.classList.add("info-stress-icon");
31430
+ infoIconContainer.appendChild(infoIcon);
31362
31431
  var labelText = document.createElementNS("http://www.w3.org/2000/svg", "text");
31363
31432
  labelText.setAttribute("x", "" + circleX);
31364
31433
  labelText.setAttribute("y", "" + (circleY - radius - 12));
@@ -31373,6 +31442,15 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31373
31442
 
31374
31443
  labelText.textContent = label;
31375
31444
  svg.appendChild(labelText);
31445
+ var infoX = isMobileScreen ? circleX - 8 : circleX + 8 + labelText.getBoundingClientRect().width / 2;
31446
+ var infoY = isMobileScreen ? circleY - radius - 32 - labelText.getBoundingClientRect().height : circleY - radius - 20 - labelText.getBoundingClientRect().height / 2;
31447
+ infoIconContainer.setAttribute("x", "" + infoX);
31448
+ infoIconContainer.setAttribute("y", "" + infoY);
31449
+ infoIconContainer.addEventListener("mouseenter", function () {
31450
+ return handleEnterInfoIcon(infoX, infoY + 4, tooltip, label);
31451
+ });
31452
+ infoIconContainer.addEventListener("mouseleave", handleLeaveInfoIcon);
31453
+ svg.appendChild(infoIconContainer);
31376
31454
  };
31377
31455
 
31378
31456
  for (var i = 1; i <= data.length; i++) {
@@ -31390,25 +31468,42 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31390
31468
  }
31391
31469
  };
31392
31470
 
31393
- while (svg.firstChild) {
31394
- svg.firstChild.remove();
31395
- }
31471
+ try {
31472
+ while (svg.firstChild) {
31473
+ while (svg.firstChild.firstChild) {
31474
+ svg.firstChild.firstChild.remove();
31475
+ }
31476
+
31477
+ svg.firstChild.remove();
31478
+ }
31396
31479
 
31397
- drawChart();
31480
+ drawChart();
31481
+ } catch (err) {
31482
+ console.log("err: ", err);
31483
+ }
31398
31484
  }
31399
- }, [chartWidth, studentPressure]);
31485
+ }, [chartWidth, chartHeight, JSON.stringify(studentPressure)]);
31486
+ var widthLabel = useMemo(function () {
31487
+ if (!!tooltipVisible) return getWidthFromText(tooltipVisible, "9px", "bold");
31488
+ return 0;
31489
+ }, [tooltipVisible]);
31400
31490
  var lineHeight = 20;
31401
- var tooltipHeight = tooltipStudents.length * lineHeight;
31402
- var maxHeightTooltip = tooltipHeight + 30 > chartHeight - 50 ? chartHeight - 50 : tooltipHeight + 30;
31491
+ var tooltipHeight = tooltipStudents.length * lineHeight * 6;
31492
+ var isScrollStudents = tooltipHeight + 30 > chartHeight - 100 - (isMobileScreen ? widthLabel : 0);
31493
+ var maxHeightTooltip = isScrollStudents ? chartHeight - 100 - (isMobileScreen ? widthLabel : 0) : tooltipHeight + 30;
31494
+ var heightInfoTooltip = useMemo(function () {
31495
+ if (!!infoTooltip && !!tooltipVisible) return getHeightFromText(infoTooltip, "12px");
31496
+ return 0;
31497
+ }, [infoTooltip, tooltipVisible]);
31403
31498
  return React.createElement("svg", {
31404
31499
  ref: svgRef,
31405
31500
  width: chartWidth,
31406
31501
  height: chartHeight + 50
31407
31502
  }, !!tooltipVisible && React.createElement("g", {
31408
- transform: "translate(" + (tooltipX - 100) + "," + Math.max(0, tooltipY - tooltipHeight - 80) + ")"
31503
+ transform: "translate(" + (infoTooltip ? tooltipX - 81 : tooltipX - 100) + "," + Math.max(0, infoTooltip ? tooltipY - heightInfoTooltip - 30 : isMobileScreen ? tooltipY - tooltipHeight - 100 - widthLabel : tooltipY - tooltipHeight - 100) + ")"
31409
31504
  }, React.createElement("rect", {
31410
- width: "200",
31411
- height: maxHeightTooltip + 10,
31505
+ width: infoTooltip ? 162 : 200,
31506
+ height: infoTooltip ? heightInfoTooltip + 10 : maxHeightTooltip + 10,
31412
31507
  fill: "rgba(36, 36, 36, 0.8)",
31413
31508
  rx: "5"
31414
31509
  }), React.createElement("text", {
@@ -31417,7 +31512,18 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31417
31512
  fill: "#fff",
31418
31513
  fontSize: "12px",
31419
31514
  textAnchor: "start"
31420
- }, tooltipStudents.length + " students are " + tooltipVisible), React.createElement("foreignObject", {
31515
+ }, !infoTooltip && tooltipStudents.length + " students are " + tooltipVisible), !!infoTooltip && React.createElement("foreignObject", {
31516
+ x: "0",
31517
+ y: "10",
31518
+ width: infoTooltip ? 162 : 200,
31519
+ height: heightInfoTooltip
31520
+ }, React.createElement("div", {
31521
+ style: {
31522
+ padding: "0px 5px 5px 10px",
31523
+ color: "#fff",
31524
+ fontSize: "12px"
31525
+ }
31526
+ }, infoTooltip)), !infoTooltip && React.createElement("foreignObject", {
31421
31527
  x: "0",
31422
31528
  y: "30",
31423
31529
  width: "200",
@@ -31425,12 +31531,12 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31425
31531
  }, React.createElement("div", {
31426
31532
  style: {
31427
31533
  overflowY: "auto",
31428
- maxHeight: maxHeightTooltip - 20 + "px",
31534
+ maxHeight: (isScrollStudents ? maxHeightTooltip - 30 : maxHeightTooltip - 20) + "px",
31429
31535
  padding: "5px 5px 5px 10px",
31430
31536
  color: "#fff",
31431
31537
  fontSize: "12px"
31432
31538
  }
31433
- }, tooltipStudents.map(function (label, index) {
31539
+ }, [].concat(tooltipStudents, tooltipStudents, tooltipStudents, tooltipStudents, tooltipStudents, tooltipStudents).map(function (label, index) {
31434
31540
  return React.createElement("div", {
31435
31541
  key: index
31436
31542
  }, React.createElement("span", {
@@ -31443,7 +31549,14 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31443
31549
  marginRight: "10px"
31444
31550
  }
31445
31551
  }), React.createElement("span", null, label));
31446
- })))));
31552
+ }))), React.createElement("foreignObject", {
31553
+ y: infoTooltip ? heightInfoTooltip + 10 : Math.min(tooltipHeight + 40, maxHeightTooltip + 10),
31554
+ x: infoTooltip ? isMobileScreen && tooltipVisible === data[data.length - 1].label ? 99 : 84 : isMobileScreen && tooltipVisible === "OVERWHELMED" ? 139 : 94,
31555
+ width: 10,
31556
+ height: 10
31557
+ }, React.createElement("div", {
31558
+ className: "tooltip-chart"
31559
+ }))));
31447
31560
  };
31448
31561
 
31449
31562
  var headerLogo = "../images/main-logo-blue.png";