mirror of
https://github.com/shadoll/sLogos.git
synced 2025-12-20 03:26:59 +00:00
Refactor country name highlighting logic in CountryMap component for improved readability and maintainability
This commit is contained in:
@@ -22,19 +22,22 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Highlight by country name (name attribute)
|
// Highlight by country name (name attribute)
|
||||||
const names = Array.isArray(countryNames) ? countryNames : countryNames ? [countryNames] : [];
|
const names = Array.isArray(countryNames)
|
||||||
names.forEach((name) => {
|
? countryNames
|
||||||
// Find all elements with matching name attribute or class name
|
: countryNames
|
||||||
console.log(`Highlighting country: ${name}`);
|
? [countryNames]
|
||||||
const pathsByName = svgEl.querySelectorAll(`[name='${name}']`);
|
: [];
|
||||||
const pathsByClass = svgEl.querySelectorAll(`.${name.replace(/ /g, '.')}`);
|
names.forEach((name) => {
|
||||||
const allPaths = [...pathsByName, ...pathsByClass];
|
const pathsByName = svgEl.querySelectorAll(`[name='${name}']`);
|
||||||
console.log(`Found paths for ${name}:`, allPaths, `(${allPaths.length})`);
|
const pathsByClass = svgEl.querySelectorAll(
|
||||||
allPaths.forEach((countryPath) => {
|
`.${name.replace(/ /g, ".")}`,
|
||||||
countryPath.setAttribute("fill", "#4f8cff");
|
);
|
||||||
countryPath.setAttribute("stroke", "#222");
|
const allPaths = [...pathsByName, ...pathsByClass];
|
||||||
countryPath.style.filter = "drop-shadow(0 0 4px #4f8cff44)";
|
allPaths.forEach((countryPath) => {
|
||||||
});
|
countryPath.setAttribute("fill", "#4f8cff");
|
||||||
|
countryPath.setAttribute("stroke", "#222");
|
||||||
|
countryPath.style.filter = "drop-shadow(0 0 4px #4f8cff44)";
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user