Skip to content

Commit

Permalink
warnings method
Browse files Browse the repository at this point in the history
  • Loading branch information
dbauszus-glx committed Mar 4, 2024
1 parent 508d0ba commit a2c1c7d
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions lib/layer/styleParser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export default layer => {
}
}

warnings(layer)

if (layer.style?.theme) {
parseTheme(layer.style.theme)
}
Expand All @@ -22,18 +24,6 @@ export default layer => {
})
}

// Handle deprecated layer.style.hover and layer.style.hovers.
if (layer.style?.hovers && layer.style?.hover) {
console.warn(`Layer: ${layer.key}, cannot use both layer.style.hover and layer.style.hovers. Layer.style.hover has been deleted.`);
delete layer.style.hover;
}

// Handle deprecated layer.style.label and layer.style.labels.
if (layer.style?.labels && layer.style?.label) {
console.warn(`Layer: ${layer.key}, cannot use both layer.style.label and layer.style.labels. Layer.style.label has been deleted.`);
delete layer.style.label;
}

// Handle multiple themes in layer style.
if (layer.style?.themes) {
Object.keys(layer.style.themes).forEach(key => {
Expand All @@ -50,13 +40,6 @@ export default layer => {
layer.style.label = layer.style.labels[layer.style.theme.setLabel];
}

// Handle deprecated layer.hover configuration.
if (layer.hover) {
console.warn(`Layer: ${layer.key}, layer.hover{} should be defined within layer.style{}.`);
layer.style.hover = layer.hover;
delete layer.hover;
}

// Handle setHover and hovers in layer style.
if (layer.style?.theme?.setHover && layer.style?.hovers) {
layer.style.hover = layer.style.hovers[layer.style.theme.setHover];
Expand All @@ -77,6 +60,29 @@ export default layer => {
layer.style.label = typeof layer.style.label === 'object' ? layer.style.label : layer.style.labels[layer.style.label || Object.keys(layer.style.labels)[0]];
}

function warnings(layer) {

// Handle deprecated layer.hover configuration.
if (layer.hover) {
console.warn(`Layer: ${layer.key}, layer.hover{} should be defined within layer.style{}.`);
layer.style.hover = layer.hover;
delete layer.hover;
}

// Handle deprecated layer.style.hover and layer.style.hovers.
if (layer.style?.hovers && layer.style?.hover) {
console.warn(`Layer: ${layer.key}, cannot use both layer.style.hover and layer.style.hovers. Layer.style.hover has been deleted.`);
delete layer.style.hover;
}

// Handle deprecated layer.style.label and layer.style.labels.
if (layer.style?.labels && layer.style?.label) {
console.warn(`Layer: ${layer.key}, cannot use both layer.style.label and layer.style.labels. Layer.style.label has been deleted.`);
delete layer.style.label;
}

}

function parseTheme(theme) {

if (theme?.cat) {
Expand Down

0 comments on commit a2c1c7d

Please sign in to comment.