diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/css/dumbymap.css | 30 | ||||
| -rw-r--r-- | src/dumbymap.mjs | 7 |
2 files changed, 33 insertions, 4 deletions
diff --git a/src/css/dumbymap.css b/src/css/dumbymap.css index a7729f0..e6e736a 100644 --- a/src/css/dumbymap.css +++ b/src/css/dumbymap.css | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | .Dumby { | 1 | .Dumby { |
| 2 | --block-focus-color: lightyellow; | 2 | --block-focus-color: lightyellow; |
| 3 | counter-reset: block; | ||
| 3 | } | 4 | } |
| 4 | 5 | ||
| 5 | [class^="leader-line"] { | 6 | [class^="leader-line"] { |
| @@ -13,7 +14,7 @@ | |||
| 13 | 14 | ||
| 14 | @keyframes fade-out { | 15 | @keyframes fade-out { |
| 15 | from { opacity: 1; } | 16 | from { opacity: 1; } |
| 16 | to { opacity: 0; } | 17 | to { opacity: 0; visibility: hidden; } |
| 17 | } | 18 | } |
| 18 | 19 | ||
| 19 | @keyframes map-fade-in { | 20 | @keyframes map-fade-in { |
| @@ -90,11 +91,13 @@ | |||
| 90 | 91 | ||
| 91 | position: relative; | 92 | position: relative; |
| 92 | 93 | ||
| 94 | counter-increment: block; | ||
| 95 | |||
| 93 | &::before { | 96 | &::before { |
| 94 | content: ""; | 97 | content: ""; |
| 95 | height: calc(100% - 2rem); | 98 | height: calc(100% - 2rem); |
| 96 | |||
| 97 | position: absolute; | 99 | position: absolute; |
| 100 | |||
| 98 | left: 0.8rem; | 101 | left: 0.8rem; |
| 99 | 102 | ||
| 100 | border-left: 0.5em solid #e0e0e0; | 103 | border-left: 0.5em solid #e0e0e0; |
| @@ -102,6 +105,29 @@ | |||
| 102 | 105 | ||
| 103 | &.focus { | 106 | &.focus { |
| 104 | background: var(--block-focus-color); | 107 | background: var(--block-focus-color); |
| 108 | |||
| 109 | &::after { | ||
| 110 | content: counter(block) "/" attr(data-total); | ||
| 111 | padding: .3rem .5rem; | ||
| 112 | |||
| 113 | position: absolute; | ||
| 114 | left: 0; | ||
| 115 | top: 10px; | ||
| 116 | left: 50%; | ||
| 117 | transform: translateX(-50%); | ||
| 118 | |||
| 119 | border: solid transparent; | ||
| 120 | border-radius: 5px; | ||
| 121 | |||
| 122 | background: gray; | ||
| 123 | |||
| 124 | color: white; | ||
| 125 | font-size: 1.5em; | ||
| 126 | font-weight: bold; | ||
| 127 | |||
| 128 | opacity: 0; | ||
| 129 | animation: 1s forwards fade-out cubic-bezier(.44,.18,.86,-0.21); | ||
| 130 | } | ||
| 105 | } | 131 | } |
| 106 | } | 132 | } |
| 107 | 133 | ||
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index 595de5c..1e8c38d 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs | |||
| @@ -131,8 +131,11 @@ export const markdown2HTML = (container, mdContent) => { | |||
| 131 | htmlHolder.innerHTML = md.render(contentWithToc); | 131 | htmlHolder.innerHTML = md.render(contentWithToc); |
| 132 | 132 | ||
| 133 | // TODO Do this in markdown-it | 133 | // TODO Do this in markdown-it |
| 134 | htmlHolder.querySelectorAll(':scope > div:not(:has(nav))') | 134 | const blocks = htmlHolder.querySelectorAll(':scope > div:not(:has(nav))') |
| 135 | .forEach(b => b.classList.add('dumby-block')) | 135 | blocks.forEach(b => { |
| 136 | b.classList.add('dumby-block') | ||
| 137 | b.setAttribute('data-total', blocks.length) | ||
| 138 | }) | ||
| 136 | 139 | ||
| 137 | return container | 140 | return container |
| 138 | //}}} | 141 | //}}} |