diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-09 21:14:59 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-09 21:15:06 +0800 |
| commit | 6a1c655e01839dc3f3b40d567e998ca931594e22 (patch) | |
| tree | 6cbfd5f1700ff1ae1ef9ed3d3683383f86bc0534 | |
| parent | e6f50c841924ed967070d628a6e4734b069128a6 (diff) | |
docs: update example of custom layouts
| -rw-r--r-- | README.md | 31 | ||||
| -rw-r--r-- | assets/layout-example1.png | bin | 0 -> 152853 bytes | |||
| -rw-r--r-- | assets/structure_1.jpg | bin | 65104 -> 62747 bytes | |||
| -rw-r--r-- | src/css/dumbymap.css | 5 |
4 files changed, 29 insertions, 7 deletions
| @@ -2,6 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | This library generate web maps from Semantic HTML, play around with [demo page](https://outdoorsafetylab.github.io/dumbymap/) | 3 | This library generate web maps from Semantic HTML, play around with [demo page](https://outdoorsafetylab.github.io/dumbymap/) |
| 4 | 4 | ||
| 5 | > [!CAUTION] | ||
| 6 | > API of DumbyMap is not stable now, use it carefully | ||
| 7 | |||
| 5 | ## Getting Started | 8 | ## Getting Started |
| 6 | 9 | ||
| 7 | Node.js: | 10 | Node.js: |
| @@ -20,12 +23,13 @@ document.body.append(container) | |||
| 20 | markdown2HTML(container, '# Heading\n\n```map\nid: foo\nuse: Maplibre\n```\n') | 23 | markdown2HTML(container, '# Heading\n\n```map\nid: foo\nuse: Maplibre\n```\n') |
| 21 | 24 | ||
| 22 | // Gernerate maps from code block | 25 | // Gernerate maps from code block |
| 23 | const dumbymap = generateMaps(container) | 26 | const dumbymap = generateMaps(container, options ?? {}) |
| 24 | ``` | 27 | ``` |
| 25 | 28 | ||
| 26 | Browser (CDN): | 29 | Browser (CDN): |
| 27 | - unpkg: https://unpkg.com/dumbymap@latest/dist/dumbymap.mjs | 30 | - unpkg: https://unpkg.com/dumbymap@latest/dist/dumbymap.mjs |
| 28 | 31 | ||
| 32 | |||
| 29 | ## Semantic HTML | 33 | ## Semantic HTML |
| 30 | 34 | ||
| 31 | Dumbymap adds several features by Semantic HTML: | 35 | Dumbymap adds several features by Semantic HTML: |
| @@ -34,7 +38,7 @@ Dumbymap adds several features by Semantic HTML: | |||
| 34 | 38 | ||
| 35 | Generated from Element fits CSS Selector `:has(.language-map)` | 39 | Generated from Element fits CSS Selector `:has(.language-map)` |
| 36 | 40 | ||
| 37 | It generates maps by `textContent` in YAML format, done by [`mapclay`](/outdoorsafetylab/mapclay). | 41 | It generates maps by `textContent` in YAML format, done by [mapclay] |
| 38 | 42 | ||
| 39 | For example: | 43 | For example: |
| 40 | ~~~markdown | 44 | ~~~markdown |
| @@ -122,6 +126,13 @@ After `generateMaps()`, the container has the following structure: | |||
| 122 | 126 | ||
| 123 |  | 127 |  |
| 124 | 128 | ||
| 129 | For each element: | ||
| 130 | * `class="Dumby"`: Container of DumbyMap Contents. It uses attribute `data-layout` to switch layout | ||
| 131 | * `class="SemanticHtml"`: Container of Semantic HTML | ||
| 132 | * `class="Showcase"`: Container of map with `class="focus"`. Some layouts use it to display focused map | ||
| 133 | * `class="dumby-block"`: Block contains part of contents of Semantic HTML. | ||
| 134 | * `class="mapclay"`: Map generated by [mapclay] | ||
| 135 | |||
| 125 | ## Layouts | 136 | ## Layouts |
| 126 | 137 | ||
| 127 | Dumbymap switch layouts by attribute `data-layout` of container. Most of the features are done by pure CSS. | 138 | Dumbymap switch layouts by attribute `data-layout` of container. Most of the features are done by pure CSS. |
| @@ -130,13 +141,15 @@ You can add custom layout by options `layouts`. For example, the following code | |||
| 130 | 141 | ||
| 131 | ```css | 142 | ```css |
| 132 | .Dumby[data-layout='sticky'] { | 143 | .Dumby[data-layout='sticky'] { |
| 144 | max-width: 80em; | ||
| 145 | |||
| 133 | .Showcase { | 146 | .Showcase { |
| 134 | display: block; | 147 | display: block; |
| 135 | width: 20vw; | 148 | width: 20vw; |
| 136 | height: 40vh; | 149 | height: 40vh; |
| 137 | position: absolute; | 150 | position: absolute; |
| 138 | right: 0; | 151 | right: 20px; |
| 139 | bottom: 0; | 152 | bottom: 20px; |
| 140 | background: red; | 153 | background: red; |
| 141 | } | 154 | } |
| 142 | } | 155 | } |
| @@ -146,13 +159,19 @@ You can add custom layout by options `layouts`. For example, the following code | |||
| 146 | generateMaps(container, { layouts: "sticky" }) | 159 | generateMaps(container, { layouts: "sticky" }) |
| 147 | ``` | 160 | ``` |
| 148 | 161 | ||
| 162 | <details><summary>Result:</summary> | ||
| 163 | |||
| 164 |  | ||
| 165 | |||
| 166 | </details> | ||
| 167 | |||
| 149 | 168 | ||
| 150 | ## Dependencies | 169 | ## Dependencies |
| 151 | 170 | ||
| 152 | - [leader-line](https://anseki.github.io/leader-line/) | 171 | - [leader-line](https://anseki.github.io/leader-line/) |
| 153 | - [plain-draggable](https://anseki.github.io/plain-draggable/) | 172 | - [plain-draggable](https://anseki.github.io/plain-draggable/) |
| 154 | - [markdown-it](https://github.com/markdown-it/markdown-it/) | 173 | - [markdown-it](https://github.com/markdown-it/markdown-it/) |
| 155 | - [mapclay](https://github.com/outdoorsafetylab/mapclay) | 174 | - [mapclay] |
| 156 | - [EasyMDE](https://github.com/Ionaru/easy-markdown-editor) | 175 | - [EasyMDE](https://github.com/Ionaru/easy-markdown-editor) |
| 157 | 176 | ||
| 158 | 177 | ||
| @@ -168,3 +187,5 @@ generateMaps(container, { layouts: "sticky" }) | |||
| 168 | * [obsidian-map-view](https://github.com/esm7/obsidian-map-view) | 187 | * [obsidian-map-view](https://github.com/esm7/obsidian-map-view) |
| 169 | * [odyssey.js](http://cartodb.github.io/odyssey.js/) | 188 | * [odyssey.js](http://cartodb.github.io/odyssey.js/) |
| 170 | * [StoryMapJS](https://storymap.knightlab.com/) | 189 | * [StoryMapJS](https://storymap.knightlab.com/) |
| 190 | |||
| 191 | [mapclay]: https://github.com/outdoorsafetylab/mapclay | ||
diff --git a/assets/layout-example1.png b/assets/layout-example1.png new file mode 100644 index 0000000..ae9eddc --- /dev/null +++ b/assets/layout-example1.png | |||
| Binary files differ | |||
diff --git a/assets/structure_1.jpg b/assets/structure_1.jpg index 03e709d..8c238ca 100644 --- a/assets/structure_1.jpg +++ b/assets/structure_1.jpg | |||
| Binary files differ | |||
diff --git a/src/css/dumbymap.css b/src/css/dumbymap.css index d31d7e6..10778e8 100644 --- a/src/css/dumbymap.css +++ b/src/css/dumbymap.css | |||
| @@ -783,14 +783,15 @@ a[href^='http']:not(:has(img))::after, | |||
| 783 | } | 783 | } |
| 784 | 784 | ||
| 785 | .Dumby[data-layout='sticky'] { | 785 | .Dumby[data-layout='sticky'] { |
| 786 | max-width: 80em; | ||
| 786 | .Showcase { | 787 | .Showcase { |
| 787 | display: block; | 788 | display: block; |
| 788 | width: 20vw; | 789 | width: 20vw; |
| 789 | height: 40vh; | 790 | height: 40vh; |
| 790 | 791 | ||
| 791 | position: absolute; | 792 | position: absolute; |
| 792 | right: 0; | 793 | right: 20px; |
| 793 | bottom: 0; | 794 | bottom: 20px; |
| 794 | 795 | ||
| 795 | background: red; | 796 | background: red; |
| 796 | } | 797 | } |