A Pen by Stephen S. Mitchell on CodePen.
Created
November 22, 2019 22:29
-
-
Save stephensmitchell/ea86c365b45cc3ab9125e73ba3e80e03 to your computer and use it in GitHub Desktop.
Examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Learn about this code on MDN: https://developer.mozilla.org/en-US/docs/Web/API/HTMLDetailsElement/toggle_event --> | |
| <aside id="log"> | |
| <b>Open chapters:</b> | |
| <div data-id="ch1" hidden>I</div> | |
| <div data-id="ch2" hidden>II</div> | |
| <div data-id="ch3" hidden>III</div> | |
| </aside> | |
| <section id="summaries"> | |
| <b>Chapter summaries:</b> | |
| <details id="ch1"> | |
| <summary>Chapter I</summary> | |
| Philosophy reproves Boethius for the foolishness of his complaints against Fortune. Her very nature is caprice. | |
| </details> | |
| <details id="ch2"> | |
| <summary>Chapter II</summary> | |
| Philosophy in Fortune's name replies to Boethius' reproaches, and proves that the gifts of Fortune are hers to give and to take away. | |
| </details> | |
| <details id="ch3"> | |
| <summary>Chapter III</summary> | |
| Boethius falls back upon his present sense of misery. Philosophy reminds him of the brilliancy of his former fortunes. | |
| </details> | |
| </section> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function logItem(e) { | |
| const item = document.querySelector(`[data-id=${e.target.id}]`); | |
| item.toggleAttribute('hidden'); | |
| } | |
| const chapters = document.querySelectorAll('details'); | |
| chapters.forEach((chapter) => { | |
| chapter.addEventListener('toggle', logItem); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body { | |
| display: flex; | |
| flex-direction: row-reverse; | |
| } | |
| #log { | |
| flex-shrink: 0; | |
| padding-left: 3em; | |
| } | |
| #summaries { | |
| flex-grow: 1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment