|
| 1 | +(ns language-learning.vocabulary-estimation.article-controls |
| 2 | + (:require [clojure.java.io :as io] |
| 3 | + [scicloj.kindly.v4.kind :as kind])) |
| 4 | + |
| 5 | +(defn- resource-text [filename] |
| 6 | + (slurp |
| 7 | + (io/resource |
| 8 | + (str "language_learning/vocabulary_estimation/" filename)))) |
| 9 | + |
| 10 | +(defn- toolbar [] |
| 11 | + [:div.article-explanations-toolbar |
| 12 | + {:role "region" :aria-labelledby "article-explanations-heading"} |
| 13 | + [:p |
| 14 | + [:strong#article-explanations-heading "Reading controls"] |
| 15 | + [:span#article-explanations-description.article-explanations-description |
| 16 | + "Open or close help, code, and equations. Choices for code and equations apply across this article namespace."] |
| 17 | + [:span#article-explanations-status.article-explanations-status |
| 18 | + {:aria-live "polite"} |
| 19 | + "Help is hidden."]] |
| 20 | + [:div#article-help-action.article-reading-action |
| 21 | + [:button#article-explanations-toggle.article-explanations-toggle |
| 22 | + {:type "button" |
| 23 | + :aria-pressed "false" |
| 24 | + :aria-describedby "article-explanations-description article-explanations-status"} |
| 25 | + "Show all help"]] |
| 26 | + [:div#article-code-action.article-reading-action |
| 27 | + [:button#article-code-toggle.article-code-toggle |
| 28 | + {:type "button" |
| 29 | + :aria-pressed "false" |
| 30 | + :aria-describedby "article-explanations-description article-code-status"} |
| 31 | + "Show all code"] |
| 32 | + [:span#article-code-status.article-code-status |
| 33 | + {:aria-live "polite"} |
| 34 | + "Code is hidden."]] |
| 35 | + [:div#article-equations-action.article-reading-action |
| 36 | + [:button#article-equations-toggle.article-equations-toggle |
| 37 | + {:type "button" |
| 38 | + :aria-pressed "true" |
| 39 | + :aria-describedby "article-explanations-description article-equations-status"} |
| 40 | + "Hide all equations"] |
| 41 | + [:span#article-equations-status.article-equations-status |
| 42 | + {:aria-live "polite"} |
| 43 | + "Equations are shown."]]]) |
| 44 | + |
| 45 | +(defn install |
| 46 | + "Install the controls stylesheet, explicit toolbar, and Scittle runtime." |
| 47 | + [] |
| 48 | + (kind/hiccup |
| 49 | + [:div.article-controls-installation |
| 50 | + [:style (resource-text "article_controls.css")] |
| 51 | + (toolbar) |
| 52 | + [:script {:type "application/x-scittle" |
| 53 | + :src "article_controls.cljs"}]])) |
0 commit comments