fix(ui): render only supplied mega menu metadata
This commit is contained in:
@@ -58,23 +58,6 @@ component MegaMenu {
|
||||
return column && Array.isArray(column.items) ? column.items : []
|
||||
}
|
||||
|
||||
shared function itemIcon(item) {
|
||||
if (item && item.icon) {
|
||||
return item.icon
|
||||
}
|
||||
return variant === "catalog" ? "icon-[lucide--component]" : ""
|
||||
}
|
||||
|
||||
shared function itemDescription(item, column) {
|
||||
if (item && item.description) {
|
||||
return item.description
|
||||
}
|
||||
if (variant === "catalog" && item && item.label) {
|
||||
return "Open " + item.label + (column && column.heading ? " in " + column.heading : "")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
shared function railList() {
|
||||
return Array.isArray(rail) ? rail : []
|
||||
}
|
||||
@@ -259,11 +242,11 @@ component MegaMenu {
|
||||
<li>
|
||||
<a class="wrn-mega__link" href='{item.href || "#"}' data-wrn-roving-item="true" aria-disabled='{item.disabled ? "true" : "false"}' @click='choose(item)'>
|
||||
{#if item.image}<img class="wrn-mega__link-image" src='{item.image}' alt="" loading="lazy" />{/if}
|
||||
<span class='wrn-mega__link-icon {itemIcon(item)}' data-show="itemIcon(item)" aria-hidden="true"></span>
|
||||
{#if item.icon}<span class='wrn-mega__link-icon {item.icon}' aria-hidden="true"></span>{/if}
|
||||
<span class="wrn-mega__link-body">
|
||||
{#if item.eyebrow}<span class="wrn-mega__link-eyebrow">{item.eyebrow}</span>{/if}
|
||||
<span class="wrn-mega__link-label">{item.label}{#if item.badge}<span class="wrn-mega__badge">{item.badge}</span>{/if}</span>
|
||||
<span class="wrn-mega__link-description" data-show="itemDescription(item, column)">{itemDescription(item, column)}</span>
|
||||
{#if item.description}<span class="wrn-mega__link-description">{item.description}</span>{/if}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/ui",
|
||||
"version": "0.8.36",
|
||||
"version": "0.8.37",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
|
||||
@@ -2972,6 +2972,8 @@ test("catalog mega menu renders only the active rail category", async () => {
|
||||
expect(source).toContain("overflow-y: auto");
|
||||
expect(source).not.toContain("@mouseenter='chooseCategory(item, index)'");
|
||||
expect(dom.querySelector(".wrn-mega__column-header")?.textContent).toContain("Sales");
|
||||
expect(dom.querySelectorAll(".wrn-mega__link-icon")).toHaveLength(0);
|
||||
expect(dom.querySelectorAll(".wrn-mega__link-description")).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("mega menu supports rails, icons, badges, media, featured content and footer actions", async () => {
|
||||
|
||||
Reference in New Issue
Block a user