leaflet-theme-control 0.1.2 â 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -54
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -6,13 +6,14 @@ A Leaflet control for switching between visual themes using CSS filters. Perfect
|
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
-
|
|
9
|
+
- **Multiple themes**: Light, Dark, Grayscale, Custom
|
|
10
|
+
- **Theme Editor**: Customize filters with live preview sliders (optional)
|
|
10
11
|
- âŋ **Accessibility**: Adaptable themes for better visibility
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
12
|
+
- **CSS Filters**: No need for multiple tile sources
|
|
13
|
+
- **Persistent**: Saves user preference in localStorage
|
|
14
|
+
- **System Detection**: Automatically detects OS dark mode preference
|
|
15
|
+
- **i18n Ready**: Customizable labels with auto-update on language change
|
|
16
|
+
- **Lightweight**: Zero dependencies (except Leaflet)
|
|
16
17
|
- ⥠**Performance**: Instant theme switching without reloading tiles
|
|
17
18
|
|
|
18
19
|
## Installation
|
|
@@ -32,31 +33,13 @@ import "leaflet-theme-control/src/leaflet-theme-control.css";
|
|
|
32
33
|
|
|
33
34
|
**Without bundler (plain HTML):**
|
|
34
35
|
|
|
35
|
-
```html
|
|
36
|
-
<link rel="stylesheet" href="node_modules/leaflet-theme-control/src/leaflet-theme-control.css" />
|
|
37
|
-
|
|
38
|
-
<script type="importmap">
|
|
39
|
-
{
|
|
40
|
-
"imports": {
|
|
41
|
-
"leaflet-theme-control": "./node_modules/leaflet-theme-control/src/leaflet-theme-control.js"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
</script>
|
|
45
|
-
|
|
46
|
-
<script type="module">
|
|
47
|
-
import { ThemeControl } from "leaflet-theme-control";
|
|
48
|
-
// Your code here
|
|
49
|
-
</script>
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
**Or via CDN (coming soon):**
|
|
53
|
-
|
|
54
36
|
```html
|
|
55
37
|
<link rel="stylesheet" href="https://unpkg.com/leaflet-theme-control/src/leaflet-theme-control.css" />
|
|
56
38
|
|
|
57
39
|
<script type="importmap">
|
|
58
40
|
{
|
|
59
41
|
"imports": {
|
|
42
|
+
"leaflet": "https://unpkg.com/leaflet@2.0.0-alpha.1/dist/leaflet.js",
|
|
60
43
|
"leaflet-theme-control": "https://unpkg.com/leaflet-theme-control/src/leaflet-theme-control.js"
|
|
61
44
|
}
|
|
62
45
|
}
|
|
@@ -64,23 +47,10 @@ import "leaflet-theme-control/src/leaflet-theme-control.css";
|
|
|
64
47
|
|
|
65
48
|
<script type="module">
|
|
66
49
|
import { ThemeControl } from "leaflet-theme-control";
|
|
50
|
+
// Your code here
|
|
67
51
|
</script>
|
|
68
52
|
```
|
|
69
53
|
|
|
70
|
-
### As local module (development)
|
|
71
|
-
|
|
72
|
-
**HTML:**
|
|
73
|
-
|
|
74
|
-
```html
|
|
75
|
-
<link rel="stylesheet" href="./third-party/leaflet-theme-control/src/leaflet-theme-control.css" />
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
**JavaScript:**
|
|
79
|
-
|
|
80
|
-
```javascript
|
|
81
|
-
import { ThemeControl } from "./third-party/leaflet-theme-control/src/leaflet-theme-control.js";
|
|
82
|
-
```
|
|
83
|
-
|
|
84
54
|
## Usage
|
|
85
55
|
|
|
86
56
|
### Basic Example
|
|
@@ -209,7 +179,7 @@ console.log(themeControl.getCurrentTheme()); // "dark"
|
|
|
209
179
|
|
|
210
180
|
// Open editor from custom button
|
|
211
181
|
myCustomButton.onclick = () => {
|
|
212
|
-
themeControl.editor.
|
|
182
|
+
themeControl.editor.openThemeSelector();
|
|
213
183
|
};
|
|
214
184
|
```
|
|
215
185
|
|
|
@@ -237,17 +207,18 @@ See [examples/api.html](examples/api.html) for a complete example.
|
|
|
237
207
|
|
|
238
208
|
### Methods
|
|
239
209
|
|
|
240
|
-
| Method
|
|
241
|
-
|
|
|
242
|
-
| `setTheme(themeKey)`
|
|
243
|
-
| `getCurrentTheme()`
|
|
244
|
-
| `getThemes()`
|
|
210
|
+
| Method | Returns | Description |
|
|
211
|
+
| --------------------- | -------- | ------------------------------------------------- |
|
|
212
|
+
| `setTheme(themeKey)` | `void` | Switch to specific theme |
|
|
213
|
+
| `getCurrentTheme()` | `String` | Get current theme key |
|
|
214
|
+
| `getThemes()` | `Object` | Get all available themes |
|
|
215
|
+
| `updateButtonLabel()` | `void` | Update button label (auto-called on `html[lang]`) |
|
|
245
216
|
|
|
246
217
|
### Editor API (when `enableEditor: true`)
|
|
247
218
|
|
|
248
219
|
| Method | Returns | Description |
|
|
249
220
|
| ---------------------------------- | ------- | ------------------------------ |
|
|
250
|
-
| `editor.
|
|
221
|
+
| `editor.openThemeSelector()` | `void` | Open theme selector panel |
|
|
251
222
|
| `editor.openThemeEditor(themeKey)` | `void` | Open editor for specific theme |
|
|
252
223
|
| `editor.close()` | `void` | Close editor panel |
|
|
253
224
|
|
|
@@ -258,14 +229,6 @@ See [examples/api.html](examples/api.html) for a complete example.
|
|
|
258
229
|
- **Grayscale**: Black and white for printing or reduced distraction
|
|
259
230
|
- **Custom**: Fully customizable theme with combined filters (editable via theme editor)
|
|
260
231
|
|
|
261
|
-
## Browser Support
|
|
262
|
-
|
|
263
|
-
Works in all modern browsers that support CSS filters:
|
|
264
|
-
|
|
265
|
-
- Chrome/Edge 18+
|
|
266
|
-
- Firefox 35+
|
|
267
|
-
- Safari 9.1+
|
|
268
|
-
|
|
269
232
|
## License
|
|
270
233
|
|
|
271
234
|
MIT License. See [LICENSE](LICENSE.md) for details.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "leaflet-theme-control",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "A Leaflet control for switching between visual themes (light, dark, grayscale, custom, etc.) using CSS filters",
|
|
5
5
|
"main": "src/leaflet-theme-control.js",
|
|
6
6
|
"module": "src/leaflet-theme-control.js",
|
|
@@ -25,11 +25,14 @@
|
|
|
25
25
|
"leaflet",
|
|
26
26
|
"dark-mode",
|
|
27
27
|
"theme",
|
|
28
|
+
"theme-editor",
|
|
28
29
|
"accessibility",
|
|
29
30
|
"css-filter",
|
|
30
31
|
"map",
|
|
31
32
|
"grayscale",
|
|
32
|
-
"high-contrast"
|
|
33
|
+
"high-contrast",
|
|
34
|
+
"filter",
|
|
35
|
+
"leaflet-plugin"
|
|
33
36
|
],
|
|
34
37
|
"author": "Kristjan ESPERANTO",
|
|
35
38
|
"license": "MIT",
|