mario-education 2.4.173-level → 2.4.175-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: "Manageable levels of stress allowing me to perform at my best."
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,61 @@ 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(false),
31242
+ isInfoTooltip = _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 10px";
31269
+ dummyElement.innerHTML = text;
31270
+ document.body.appendChild(dummyElement);
31271
+ var height = dummyElement.offsetHeight;
31272
+ document.body.removeChild(dummyElement);
31273
+ return height;
31274
+ };
31251
31275
 
31252
31276
  var handleDotHover = function handleDotHover(students, x, y, label, color) {
31253
31277
  setTooltipStudents(Array.from(new Set(students)));
31254
- setTooltipX(isMobileScreen && label == "BURNOUT" ? x - 45 : x);
31278
+ setTooltipX(isMobileScreen && label == "OVERWHELMED" ? x - 45 : x);
31255
31279
  setTooltipY(y);
31256
31280
  setTooltipVisible(label);
31257
31281
  setColorTooltip(color);
31258
31282
  };
31259
31283
 
31284
+ var handleEnterInfoIcon = function handleEnterInfoIcon(x, y, tip) {
31285
+ setTooltipVisible(tip);
31286
+ setInfoTooltip(true);
31287
+ setTooltipX(x);
31288
+ setTooltipY(y);
31289
+ };
31290
+
31291
+ var handleLeaveInfoIcon = function handleLeaveInfoIcon() {
31292
+ setTooltipVisible("");
31293
+ setInfoTooltip(false);
31294
+ };
31295
+
31260
31296
  var handleDotLeave = function handleDotLeave() {
31261
31297
  setTooltipVisible("");
31262
31298
  };
@@ -31269,7 +31305,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31269
31305
  try {
31270
31306
  var _ret = function () {
31271
31307
  var styleElement = document.createElementNS("http://www.w3.org/2000/svg", "style");
31272
- styleElement.textContent = "\n text {\n font-size: 12px;\n }";
31308
+ 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
31309
  svg.appendChild(styleElement);
31274
31310
  var xAxis = document.createElementNS("http://www.w3.org/2000/svg", "line");
31275
31311
  xAxis.setAttribute("x1", "50");
@@ -31330,7 +31366,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31330
31366
  var circleY = !isMobileScreen ? chartHeight - 30 : chartHeight - 24;
31331
31367
 
31332
31368
  var _loop = function _loop(i) {
31333
- var _data3, _data3$value, _data3$value$length, _data6;
31369
+ var _data3, _data3$value, _data3$value$length, _data6, _data7;
31334
31370
 
31335
31371
  var circleX = circleSpacing * i + alignment;
31336
31372
  var radius = !isMobileScreen ? 15 : 12;
@@ -31362,6 +31398,18 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31362
31398
  });
31363
31399
  svg.appendChild(text);
31364
31400
  var label = (_data6 = data[i - 1]) === null || _data6 === void 0 ? void 0 : _data6.label;
31401
+ var tooltip = (_data7 = data[i - 1]) === null || _data7 === void 0 ? void 0 : _data7.tooltip;
31402
+ var infoIconContainer = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
31403
+ var infoIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
31404
+ 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>";
31405
+ infoIcon.setAttribute("width", "16");
31406
+ infoIcon.setAttribute("height", "16");
31407
+ infoIcon.setAttribute("viewBox", "0 0 256 256");
31408
+ infoIconContainer.setAttribute("width", "16");
31409
+ infoIconContainer.setAttribute("height", "20");
31410
+ infoIconContainer.style.cursor = "pointer";
31411
+ infoIconContainer.classList.add("info-stress-icon");
31412
+ infoIconContainer.appendChild(infoIcon);
31365
31413
  var labelText = document.createElementNS("http://www.w3.org/2000/svg", "text");
31366
31414
  labelText.setAttribute("x", "" + circleX);
31367
31415
  labelText.setAttribute("y", "" + (circleY - radius - 12));
@@ -31376,6 +31424,14 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31376
31424
 
31377
31425
  labelText.textContent = label;
31378
31426
  svg.appendChild(labelText);
31427
+ infoIconContainer.setAttribute("x", "" + (circleX + 8 + labelText.getBoundingClientRect().width / 2));
31428
+ infoIconContainer.setAttribute("y", "" + (circleY - radius - 20 - labelText.getBoundingClientRect().height / 2));
31429
+ infoIconContainer.addEventListener("mouseenter", function () {
31430
+ return handleEnterInfoIcon(circleX + 8 + labelText.getBoundingClientRect().width / 2, circleY - radius - 16 - labelText.getBoundingClientRect().height / 2, tooltip);
31431
+ });
31432
+ infoIconContainer.addEventListener("mouseleave", handleLeaveInfoIcon);
31433
+ labelText.getBoundingClientRect();
31434
+ svg.appendChild(infoIconContainer);
31379
31435
  };
31380
31436
 
31381
31437
  for (var i = 1; i <= data.length; i++) {
@@ -31403,15 +31459,19 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31403
31459
  var lineHeight = 20;
31404
31460
  var tooltipHeight = tooltipStudents.length * lineHeight;
31405
31461
  var maxHeightTooltip = tooltipHeight + 30 > chartHeight - 50 ? chartHeight - 50 : tooltipHeight + 30;
31462
+ var heightInfoTooltip = React.useMemo(function () {
31463
+ if (isInfoTooltip && tooltipVisible) return getHeightFromText(tooltipVisible, "12px");
31464
+ return 0;
31465
+ }, [isInfoTooltip, tooltipVisible]);
31406
31466
  return React__default.createElement("svg", {
31407
31467
  ref: svgRef,
31408
31468
  width: chartWidth,
31409
31469
  height: chartHeight + 50
31410
31470
  }, !!tooltipVisible && React__default.createElement("g", {
31411
- transform: "translate(" + (tooltipX - 100) + "," + Math.max(0, tooltipY - tooltipHeight - 80) + ")"
31471
+ transform: "translate(" + (isInfoTooltip ? tooltipX - 81 : tooltipX - 100) + "," + Math.max(0, isInfoTooltip ? tooltipY - heightInfoTooltip - 30 : tooltipY - tooltipHeight - 100) + ")"
31412
31472
  }, React__default.createElement("rect", {
31413
- width: "200",
31414
- height: maxHeightTooltip + 10,
31473
+ width: isInfoTooltip ? 162 : 200,
31474
+ height: isInfoTooltip ? heightInfoTooltip + 10 : maxHeightTooltip + 10,
31415
31475
  fill: "rgba(36, 36, 36, 0.8)",
31416
31476
  rx: "5"
31417
31477
  }), React__default.createElement("text", {
@@ -31420,7 +31480,18 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31420
31480
  fill: "#fff",
31421
31481
  fontSize: "12px",
31422
31482
  textAnchor: "start"
31423
- }, tooltipStudents.length + " students are " + tooltipVisible), React__default.createElement("foreignObject", {
31483
+ }, !isInfoTooltip && tooltipStudents.length + " students are " + tooltipVisible), isInfoTooltip && React__default.createElement("foreignObject", {
31484
+ x: "0",
31485
+ y: "10",
31486
+ width: isInfoTooltip ? 162 : 200,
31487
+ height: heightInfoTooltip
31488
+ }, React__default.createElement("div", {
31489
+ style: {
31490
+ padding: "0px 5px 5px 10px",
31491
+ color: "#fff",
31492
+ fontSize: "12px"
31493
+ }
31494
+ }, tooltipVisible)), !isInfoTooltip && React__default.createElement("foreignObject", {
31424
31495
  x: "0",
31425
31496
  y: "30",
31426
31497
  width: "200",
@@ -31446,7 +31517,14 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
31446
31517
  marginRight: "10px"
31447
31518
  }
31448
31519
  }), React__default.createElement("span", null, label));
31449
- })))));
31520
+ }))), React__default.createElement("foreignObject", {
31521
+ y: isInfoTooltip ? heightInfoTooltip + 10 : tooltipHeight + 40,
31522
+ x: isInfoTooltip ? 82 : 94,
31523
+ width: 10,
31524
+ height: 10
31525
+ }, React__default.createElement("div", {
31526
+ className: "tooltip-chart"
31527
+ }))));
31450
31528
  };
31451
31529
 
31452
31530
  var headerLogo = "../images/main-logo-blue.png";