feat: improved backdrop group name resolution (#1645)

This commit is contained in:
Jakob Guddas
2023-10-31 21:02:35 +01:00
committed by GitHub
parent 66cfe527b3
commit da5ad547b5
+8 -5
View File
@@ -17,11 +17,14 @@ export default eventHandler((event) => {
const children = [];
// If the icon already exists, it uses the existing icon as the backdrop.
// If the icon does not exist but an icon exists that starts with the same group name, that icon
// is used as the backdrop
const backdropName =
name in iconNodes ? name : name.split('-')[0] in iconNodes ? name.split('-')[0] : null;
// Finds the longest matching icon to be use as the backdrop.
// For `square-dashed-bottom-code` it suggests `square-dashed-bottom-code`.
// For `square-dashed-bottom-i-dont-exist` it suggests `square-dashed-bottom`.
const backdropName = name
.split('-')
.map((_, idx, arr) => arr.slice(0, idx + 1).join('-'))
.reverse()
.find((groupName) => groupName in iconNodes);
if (backdropName) {
const iconNode = iconNodes[backdropName];