diff options
Diffstat (limited to 'snippets')
-rw-r--r-- | snippets/css_html_showcase | 32 | ||||
-rw-r--r-- | snippets/css_html_structure | 85 | ||||
-rw-r--r-- | snippets/css_transition_common | 21 | ||||
-rw-r--r-- | snippets/html_mapclay | 8 | ||||
-rw-r--r-- | snippets/javascript_mutationoberserver | 12 | ||||
-rw-r--r-- | snippets/js_maplibre_terrain | 27 | ||||
-rw-r--r-- | snippets/sh_shebang | 1 |
7 files changed, 186 insertions, 0 deletions
diff --git a/snippets/css_html_showcase b/snippets/css_html_showcase new file mode 100644 index 0000000..2941cc1 --- /dev/null +++ b/snippets/css_html_showcase | |||
@@ -0,0 +1,32 @@ | |||
1 | <div style="display: flex; align-items: center; flex-direction: row !important;"> | ||
2 | <pre> | ||
3 | { | ||
4 | use: mapX | ||
5 | width: 300px | ||
6 | height: 400px | ||
7 | center: Taiwan | ||
8 | } | ||
9 | </pre> | ||
10 | <pre> | ||
11 | => | ||
12 | </pre> | ||
13 | |||
14 | ```map | ||
15 | use: Maplibre | ||
16 | width: 300px | ||
17 | height: 400px | ||
18 | center: [121,24] | ||
19 | zoom: 6 | ||
20 | ``` | ||
21 | |||
22 | |||
23 | |||
24 | </div> | ||
25 | |||
26 | <style> | ||
27 | pre { | ||
28 | font-size: 2rem; | ||
29 | font-weight: 700; | ||
30 | line-height: 1.9; | ||
31 | } | ||
32 | </style> | ||
diff --git a/snippets/css_html_structure b/snippets/css_html_structure new file mode 100644 index 0000000..e96d9f8 --- /dev/null +++ b/snippets/css_html_structure | |||
@@ -0,0 +1,85 @@ | |||
1 | <style> | ||
2 | ._dumby { | ||
3 | &::before { | ||
4 | content: 'class="Dumby"'; | ||
5 | } | ||
6 | &, & * { | ||
7 | display: flex; | ||
8 | position: relative; | ||
9 | padding-top:2rem; | ||
10 | margin: 0.5rem; | ||
11 | &::before { | ||
12 | position: absolute; | ||
13 | top: 0.3rem; | ||
14 | left: 1rem; | ||
15 | } | ||
16 | } | ||
17 | |||
18 | border: 5px solid red; | ||
19 | width: 100%; | ||
20 | background: rgba(255, 0, 0, 20%); | ||
21 | } | ||
22 | ._SemanticHtml { | ||
23 | flex: 80%; | ||
24 | display: block; | ||
25 | border: 3px solid blue; | ||
26 | background: skyblue; | ||
27 | &::before { | ||
28 | content: 'class="SemanticHtml"'; | ||
29 | } | ||
30 | } | ||
31 | ._dumby-block { | ||
32 | border: 3px solid gray; | ||
33 | background: lightgray; | ||
34 | &::before { | ||
35 | content: 'class="dumby-block"'; | ||
36 | } | ||
37 | } | ||
38 | ._target { | ||
39 | border: 3px solid chocolate; | ||
40 | background: wheat; | ||
41 | width: 100%; | ||
42 | height: 300px; | ||
43 | display: flex; | ||
44 | padding-top: 3rem; | ||
45 | &::before { | ||
46 | content: 'CUSTOM SELECTOR, by default:\Apre:has(.language-map)'; | ||
47 | white-space: pre; | ||
48 | } | ||
49 | } | ||
50 | ._map-container { | ||
51 | flex: 50%; | ||
52 | border: 3px solid steelblue; | ||
53 | background: lightCyan; | ||
54 | padding: 0.5rem; | ||
55 | &::before { | ||
56 | transform: rotate(0.13turn) translate(0.7rem, 2.5rem); | ||
57 | content: 'class=\A"map-container"'; | ||
58 | white-space: pre; | ||
59 | } | ||
60 | } | ||
61 | ._Showcase { | ||
62 | flex: 30%; | ||
63 | border: 3px solid green; | ||
64 | background: lightgreen; | ||
65 | &::before { | ||
66 | content: 'class="Showcase"'; | ||
67 | } | ||
68 | } | ||
69 | </style> | ||
70 | |||
71 | <div class="_dumby"> | ||
72 | <div class="_SemanticHtml"> | ||
73 | <div class="_dumby-block"> | ||
74 | <div class="_target"> | ||
75 | <div class="_map-container"></div> | ||
76 | <div class="_map-container"></div> | ||
77 | <div class="_map-container"></div> | ||
78 | </div> | ||
79 | </div> | ||
80 | <div class="_dumby-block"></div> | ||
81 | <div class="_dumby-block"></div> | ||
82 | </div> | ||
83 | <div class="_Showcase"> | ||
84 | </div> | ||
85 | </div> | ||
diff --git a/snippets/css_transition_common b/snippets/css_transition_common new file mode 100644 index 0000000..4884c90 --- /dev/null +++ b/snippets/css_transition_common | |||
@@ -0,0 +1,21 @@ | |||
1 | @media (prefers-reduced-motion: no-preference) { | ||
2 | transition: | ||
3 | opacity .5s ease-in, | ||
4 | scale .5s ease-in, | ||
5 | display .5s ease-in; | ||
6 | height .5s ease-in; | ||
7 | transition-behavior: allow-discrete; | ||
8 | } | ||
9 | |||
10 | @starting-style { | ||
11 | opacity: 0; | ||
12 | scale: 1.1; | ||
13 | } | ||
14 | |||
15 | &[hidden] { | ||
16 | opacity: 0; | ||
17 | scale: .9; | ||
18 | display: none !important; | ||
19 | transition-duration: .4s; | ||
20 | transition-timing-function: ease-out; | ||
21 | } | ||
diff --git a/snippets/html_mapclay b/snippets/html_mapclay new file mode 100644 index 0000000..a89867b --- /dev/null +++ b/snippets/html_mapclay | |||
@@ -0,0 +1,8 @@ | |||
1 | <pre> | ||
2 | use: Leaflet | ||
3 | XYZ: https://tile.openstreetmap.jp/styles/osm-bright/512/{z}/{x}/{y}.png | ||
4 | draw: true | ||
5 | control: | ||
6 | scale: true | ||
7 | </pre> | ||
8 | <script data-target="pre" src='http://localhost:8080/mapclay/dist/mapclay.js'></script> | ||
diff --git a/snippets/javascript_mutationoberserver b/snippets/javascript_mutationoberserver new file mode 100644 index 0000000..48f17af --- /dev/null +++ b/snippets/javascript_mutationoberserver | |||
@@ -0,0 +1,12 @@ | |||
1 | new window.MutationObserver((ms) => { | ||
2 | for (const m of ms) { | ||
3 | console.log(m) | ||
4 | console.log('m', m.target.innerHTML) | ||
5 | console.log('m', m.target.classList) | ||
6 | } | ||
7 | }).observe(item, { | ||
8 | attributes: true, | ||
9 | attributeFilter: ['class'], | ||
10 | attributeOldValue: true, | ||
11 | characterDataOldValue: true | ||
12 | }) | ||
diff --git a/snippets/js_maplibre_terrain b/snippets/js_maplibre_terrain new file mode 100644 index 0000000..a6466db --- /dev/null +++ b/snippets/js_maplibre_terrain | |||
@@ -0,0 +1,27 @@ | |||
1 | map.addSource('hillshading', { | ||
2 | "type": "raster-dem", | ||
3 | "tiles": [ | ||
4 | "https://osmhacktw.github.io/terrain-rgb/tiles/{z}/{x}/{y}.png" | ||
5 | ], | ||
6 | "tileSize": 256, | ||
7 | "maxzoom": 12 | ||
8 | }); | ||
9 | map.setTerrain({ 'source': 'hillshading', 'exaggeration': 1.5 }); | ||
10 | |||
11 | map.addLayer({ | ||
12 | "id": "hillshading", | ||
13 | "type": "hillshade", | ||
14 | "source": "hillshading", | ||
15 | "minzoom": 6 | ||
16 | }); | ||
17 | |||
18 | map.on('load', function () { | ||
19 | document.getElementById('slider').addEventListener('input', function (e) { | ||
20 | console.log(e.target.value); | ||
21 | map.setPaintProperty( | ||
22 | 'hillshading', | ||
23 | 'hillshade-illumination-direction', | ||
24 | parseInt(e.target.value) | ||
25 | ); | ||
26 | }); | ||
27 | }); | ||
diff --git a/snippets/sh_shebang b/snippets/sh_shebang new file mode 100644 index 0000000..36ac368 --- /dev/null +++ b/snippets/sh_shebang | |||
@@ -0,0 +1 @@ | |||
#! /bin/bash | |||