clean up Tree Item component

This commit is contained in:
Keviin Åberg Kultalahti 2021-04-20 16:44:08 +02:00
parent 1f50a970c1
commit 69823b1d52
1 changed files with 13 additions and 19 deletions

View File

@ -5,12 +5,14 @@
export let icon; export let icon;
</script> </script>
<li class:is-selected={selected} class:is-open={open} class="spectrum-TreeView-item"> <li
{#if $$slots.default} class:is-selected={selected} class:is-open={open} class="spectrum-TreeView-item">
<a class="spectrum-TreeView-itemLink" href="#"> <a on:click class="spectrum-TreeView-itemLink" href="#">
<svg class="spectrum-Icon spectrum-UIIcon-ChevronRight100 spectrum-TreeView-itemIndicator" focusable="false" aria-hidden="true"> {#if $$slots.default}
<use xlink:href="#spectrum-css-icon-Chevron100" /> <svg class="spectrum-Icon spectrum-UIIcon-ChevronRight100 spectrum-TreeView-itemIndicator" focusable="false" aria-hidden="true">
</svg> <use xlink:href="#spectrum-css-icon-Chevron100" />
</svg>
{/if}
{#if icon} {#if icon}
<svg class="spectrum-TreeView-itemIcon spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true" aria-label="Layers"> <svg class="spectrum-TreeView-itemIcon spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true" aria-label="Layers">
<use xlink:href="#spectrum-icon-18-{icon}" /> <use xlink:href="#spectrum-icon-18-{icon}" />
@ -18,17 +20,9 @@
{/if} {/if}
<span class="spectrum-TreeView-itemLabel">{title}</span> <span class="spectrum-TreeView-itemLabel">{title}</span>
</a> </a>
<ul class="spectrum-TreeView"> {#if $$slots.default}
<slot /> <ul class="spectrum-TreeView">
</ul> <slot />
{:else} </ul>
<a class="spectrum-TreeView-itemLink" href="#"> {/if}
{#if icon}
<svg class="spectrum-TreeView-itemIcon spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true" aria-label="Layers">
<use xlink:href="#spectrum-icon-18-{icon}" />
</svg>
{/if}
<span class="spectrum-TreeView-itemLabel">{title}</span>
</a>
{/if}
</li> </li>