leaflet-theme-control 0.0.3 → 0.0.5
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "leaflet-theme-control",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
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",
|
|
@@ -158,11 +158,29 @@ export class ThemeControl extends Control {
|
|
|
158
158
|
const theme = this.options.themes[themeKey]
|
|
159
159
|
const label = this._getThemeLabel(themeKey)
|
|
160
160
|
|
|
161
|
-
button
|
|
162
|
-
|
|
161
|
+
// Get translated button prefix or use default
|
|
162
|
+
let buttonPrefix = 'Theme'
|
|
163
|
+
if (this.options.getEditorLabels) {
|
|
164
|
+
const translated = this.options.getEditorLabels('themeButton')
|
|
165
|
+
if (translated && translated !== 'themeButton') {
|
|
166
|
+
buttonPrefix = translated
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const fullLabel = `${buttonPrefix}: ${label}`
|
|
171
|
+
button.setAttribute('aria-label', fullLabel)
|
|
172
|
+
button.title = fullLabel
|
|
163
173
|
button.textContent = theme.icon || '🎨'
|
|
164
174
|
}
|
|
165
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Update button label (useful for language changes)
|
|
178
|
+
* Call this method after changing language to update the button's aria-label and title
|
|
179
|
+
*/
|
|
180
|
+
updateButtonLabel() {
|
|
181
|
+
this._updateButton(this.button, this.currentTheme)
|
|
182
|
+
}
|
|
183
|
+
|
|
166
184
|
_getThemeLabel(themeKey) {
|
|
167
185
|
// Use custom label function if provided
|
|
168
186
|
if (this.options.getLabel) {
|
|
@@ -152,6 +152,7 @@ export class ThemeEditor {
|
|
|
152
152
|
contrast: 'Contrast',
|
|
153
153
|
sepia: 'Sepia',
|
|
154
154
|
grayscaleFilter: 'Grayscale',
|
|
155
|
+
themeButton: 'Theme',
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
return labels[key] || key
|
|
@@ -332,20 +333,23 @@ export class ThemeEditor {
|
|
|
332
333
|
selectBtn.appendChild(this._el('span', { 'className': 'theme-active-badge', 'aria-hidden': 'true' }, '✓'))
|
|
333
334
|
}
|
|
334
335
|
|
|
335
|
-
// Create edit button
|
|
336
|
-
const editBtn = this._el('button', {
|
|
337
|
-
'className': 'theme-edit-btn',
|
|
338
|
-
'data-theme': themeKey,
|
|
339
|
-
'aria-label': `${this._getLabel('customizeTheme')}: ${themeLabel}`,
|
|
340
|
-
}, '⚙️')
|
|
341
|
-
|
|
342
336
|
// Create row container
|
|
343
337
|
const row = this._el('div', {
|
|
344
338
|
'className': `theme-row ${isActive ? 'active' : ''}`,
|
|
345
339
|
'data-theme': themeKey,
|
|
346
340
|
})
|
|
347
341
|
row.appendChild(selectBtn)
|
|
348
|
-
|
|
342
|
+
|
|
343
|
+
// Only show edit button for the active theme
|
|
344
|
+
// User needs to see the theme to edit it meaningfully
|
|
345
|
+
if (isActive) {
|
|
346
|
+
const editBtn = this._el('button', {
|
|
347
|
+
'className': 'theme-edit-btn',
|
|
348
|
+
'data-theme': themeKey,
|
|
349
|
+
'aria-label': `${this._getLabel('customizeTheme')}: ${themeLabel}`,
|
|
350
|
+
}, '⚙️')
|
|
351
|
+
row.appendChild(editBtn)
|
|
352
|
+
}
|
|
349
353
|
|
|
350
354
|
return row
|
|
351
355
|
}
|