|
66 | 66 | } |
67 | 67 |
|
68 | 68 | .challenge-header__exerpt { |
69 | | - margin-bottom: 1.5rem; |
| 69 | + margin-bottom: 0.2rem; |
70 | 70 | line-height: 1.5; |
71 | 71 | } |
72 | 72 |
|
| 73 | + /* Hints styles */ |
| 74 | + .hints-container { |
| 75 | + margin-bottom: 1.5rem; |
| 76 | + font-size: 13px; |
| 77 | + } |
| 78 | + .hints-container #read-hints { |
| 79 | + padding: 0.2em 0.8em; |
| 80 | + font-size: 13px; |
| 81 | + } |
| 82 | + .hints-container #hints-missing { |
| 83 | + margin-top: 0.8em; |
| 84 | + /* The "secondary" style comes from https://picocss.com/docs/buttons.html */ |
| 85 | + color: var(--secondary); |
| 86 | + } |
| 87 | + .hints-container .hints-message { |
| 88 | + display: none; |
| 89 | + margin-top: 0.5em; |
| 90 | + margin-bottom: 0; |
| 91 | + padding: 0.75em 1em; |
| 92 | + font-size: 13px; |
| 93 | + } |
| 94 | + html[data-theme='light'] .hints-container .hints-message { |
| 95 | + box-shadow: none; |
| 96 | + background-color: #f4f4f4; |
| 97 | + } |
| 98 | + .hints-container .hints-message * { |
| 99 | + font-size: 13px; |
| 100 | + } |
| 101 | + |
73 | 102 | .challenge-main { |
74 | 103 | display: flex; |
75 | 104 | justify-content: space-between; |
|
243 | 272 | fail type check, while others can pass.<br> |
244 | 273 | Hit the "▶️ Run" button to see result. |
245 | 274 | </p> |
| 275 | + <div class="hints-container"> |
| 276 | + {% if hints_for_display %} |
| 277 | + <a id="read-hints" role="button" class="secondary outline" href="javascript:void(0);">💡 Read Hints</a> |
| 278 | + {% else %} |
| 279 | + <div id="hints-missing" href="javascript:void(0);">💡 No Hints Available</div> |
| 280 | + {% endif %} |
| 281 | + <article class="hints-message">{{hints_for_display | safe}}</article> |
| 282 | + </div> |
246 | 283 | </div> |
247 | 284 |
|
248 | 285 | <div class="challenge-main"> |
|
355 | 392 | myCodeMirror.setValue(code_under_test); |
356 | 393 | }; |
357 | 394 |
|
| 395 | + // Set up hints events and functions |
| 396 | + let hintBtn = document.getElementById('read-hints') |
| 397 | + hintBtn.onclick = function () { |
| 398 | + // Toggle the display of the hints message. |
| 399 | + let msgElem = document.getElementsByClassName('hints-message')[0]; |
| 400 | + if (msgElem.style.display === 'block') { |
| 401 | + msgElem.style.display = 'none'; |
| 402 | + } else { |
| 403 | + msgElem.style.display = 'block'; |
| 404 | + } |
| 405 | + }; |
| 406 | + // Make sure to open links in hints in new tab. |
| 407 | + document.querySelectorAll('.hints-message a').forEach(function(elem) { |
| 408 | + elem.setAttribute('target', '_blank'); |
| 409 | + }) |
| 410 | + |
358 | 411 | // Make sure the current challenge is visible to user. |
359 | 412 | activeChallengeInList = document.getElementById("{{level}}-{{name}}"); |
360 | 413 | activeChallengeInList.scrollIntoView({block: 'center'}); |
|
0 commit comments