aboutsummaryrefslogtreecommitdiffhomepage
path: root/README.md
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-10-09 21:14:59 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-10-09 21:15:06 +0800
commit6a1c655e01839dc3f3b40d567e998ca931594e22 (patch)
tree6cbfd5f1700ff1ae1ef9ed3d3683383f86bc0534 /README.md
parente6f50c841924ed967070d628a6e4734b069128a6 (diff)
docs: update example of custom layouts
Diffstat (limited to 'README.md')
-rw-r--r--README.md31
1 files changed, 26 insertions, 5 deletions
diff --git a/README.md b/README.md
index 8fec281..1a46a05 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,9 @@
2 2
3This library generate web maps from Semantic HTML, play around with [demo page](https://outdoorsafetylab.github.io/dumbymap/) 3This 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
7Node.js: 10Node.js:
@@ -20,12 +23,13 @@ document.body.append(container)
20markdown2HTML(container, '# Heading\n\n```map\nid: foo\nuse: Maplibre\n```\n') 23markdown2HTML(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
23const dumbymap = generateMaps(container) 26const dumbymap = generateMaps(container, options ?? {})
24``` 27```
25 28
26Browser (CDN): 29Browser (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
31Dumbymap adds several features by Semantic HTML: 35Dumbymap adds several features by Semantic HTML:
@@ -34,7 +38,7 @@ Dumbymap adds several features by Semantic HTML:
34 38
35Generated from Element fits CSS Selector `:has(.language-map)` 39Generated from Element fits CSS Selector `:has(.language-map)`
36 40
37It generates maps by `textContent` in YAML format, done by [`mapclay`](/outdoorsafetylab/mapclay). 41It generates maps by `textContent` in YAML format, done by [mapclay]
38 42
39For example: 43For example:
40~~~markdown 44~~~markdown
@@ -122,6 +126,13 @@ After `generateMaps()`, the container has the following structure:
122 126
123![structure](./assets/structure_1.jpg) 127![structure](./assets/structure_1.jpg)
124 128
129For 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
127Dumbymap switch layouts by attribute `data-layout` of container. Most of the features are done by pure CSS. 138Dumbymap 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
146generateMaps(container, { layouts: "sticky" }) 159generateMaps(container, { layouts: "sticky" })
147``` 160```
148 161
162<details><summary>Result:</summary>
163
164![](./assets/layout-example1.png)
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