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