129 lines
6.3 KiB
Plaintext
129 lines
6.3 KiB
Plaintext
component List {
|
|
outputs {
|
|
select(payload: { sourceEvent?: Event; [key: string]: string | number | boolean | null | object })
|
|
}
|
|
|
|
props {
|
|
size: string = "default"
|
|
color: string = "primary"
|
|
title: string = "List"
|
|
description: string = ""
|
|
items: unknown[] = []
|
|
variant: string = "default"
|
|
class: string = ""
|
|
}
|
|
|
|
view {
|
|
<section
|
|
data-ui-component="List"
|
|
aria-label='{title}'
|
|
class='wrn-list {class}'
|
|
>
|
|
{#if title || description}
|
|
<header class="wrn-list__header">
|
|
{#if title}
|
|
<h3 class="wrn-list__title">{title}</h3>
|
|
{/if}
|
|
{#if description}
|
|
<p class="wrn-list__description">{description}</p>
|
|
{/if}
|
|
</header>
|
|
{/if}
|
|
|
|
<ul
|
|
class="wrn-list__items"
|
|
data-variant='{variant}'
|
|
>
|
|
{#each items as item, index}
|
|
<li
|
|
class="wrn-list__item"
|
|
data-variant='{variant}'
|
|
@click='if (!item.href) { output.select({ item: item, index: index }) }'
|
|
>
|
|
{#if item.href}
|
|
<a
|
|
href='{item.href}'
|
|
class="wrn-list__row"
|
|
data-size='{size}'
|
|
@click='output.select({ item: item, index: index })'
|
|
>
|
|
{#if item.icon}
|
|
<span class="wrn-list__leading-icon"><span class='{item.icon}' aria-hidden="true"></span>
|
|
</span>
|
|
{/if}
|
|
{#if item.imageSrc}
|
|
<img src='{item.imageSrc}' alt='{item.imageAlt || ""}' class="wrn-list__image" loading="lazy" />
|
|
{/if}
|
|
<div class="wrn-list__body">
|
|
<div class="wrn-list__heading">
|
|
<p class="wrn-list__item-title">{item.title || item.label}</p>
|
|
{#if item.meta}
|
|
<span class="wrn-list__meta">{item.meta}</span>
|
|
{/if}
|
|
</div>
|
|
{#if item.description}
|
|
<p class="wrn-list__item-description">{item.description}</p>
|
|
{/if}
|
|
{#if item.badge}
|
|
<span class="wrn-list__badge">{item.badge}</span>
|
|
{/if}
|
|
</div>
|
|
<span class="icon-[lucide--chevron-right] wrn-list__chevron" aria-hidden="true"></span>
|
|
</a>
|
|
{:else}
|
|
<div class="wrn-list__row" data-size='{size}'>
|
|
{#if item.icon}
|
|
<span class="wrn-list__leading-icon"><span class='{item.icon}' aria-hidden="true"></span>
|
|
</span>
|
|
{/if}
|
|
<div class="wrn-list__body">
|
|
<p class="wrn-list__item-title">{item.title || item.label}</p>
|
|
{#if item.description}
|
|
<p class="wrn-list__item-description">{item.description}</p>
|
|
{/if}
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
</li>
|
|
{:empty}
|
|
<li class="wrn-list__empty">
|
|
No items available.
|
|
</li>
|
|
{/each}
|
|
</ul>
|
|
|
|
<slot></slot>
|
|
</section>
|
|
}
|
|
|
|
style {
|
|
.wrn-list { width: 100%; }
|
|
.wrn-list__header { margin-bottom: 1rem; }
|
|
.wrn-list__title { color: var(--wrn-color-text); font-size: 1.125rem; font-weight: 700; }
|
|
.wrn-list__description { margin-top: 0.25rem; color: var(--wrn-color-text-muted); font-size: 0.875rem; line-height: 1.5rem; }
|
|
.wrn-list__items { overflow: hidden; }
|
|
.wrn-list__items:is([data-variant="default"], [data-variant="divided"]) > .wrn-list__item + .wrn-list__item { border-top: 1px solid var(--wrn-color-border); }
|
|
.wrn-list__items[data-variant="card"] { border: 1px solid var(--wrn-color-border); border-radius: calc(var(--wrn-radius) * 1.5); background: var(--wrn-color-surface-raised); }
|
|
.wrn-list__items[data-variant="separated"] { display: grid; gap: 0.75rem; }
|
|
.wrn-list__item { min-width: 0; }
|
|
.wrn-list__item[data-variant="separated"] { border: 1px solid var(--wrn-color-border); border-radius: var(--wrn-radius); background: var(--wrn-color-surface-raised); }
|
|
.wrn-list__row { display: flex; min-width: 0; align-items: flex-start; gap: 0.75rem; padding: 0.75rem 1rem; outline: none; transition: background var(--wrn-motion-base); }
|
|
a.wrn-list__row:hover { background: var(--wrn-color-surface-soft); }
|
|
.wrn-list__row:focus-visible { box-shadow: inset 0 0 0 2px var(--wrn-color-focus); }
|
|
.wrn-list__row[data-size="sm"] { padding: 0.625rem 0.75rem; }
|
|
.wrn-list__row[data-size="lg"] { padding: 1rem 1.25rem; }
|
|
.wrn-list__leading-icon { display: flex; width: 2.5rem; height: 2.5rem; flex: none; align-items: center; justify-content: center; border-radius: var(--wrn-radius); color: var(--wrn-color-primary); background: var(--wrn-color-primary-soft); }
|
|
.wrn-list__leading-icon > span { width: 1.25rem; height: 1.25rem; }
|
|
.wrn-list__image { width: 3rem; height: 3rem; flex: none; border-radius: var(--wrn-radius); object-fit: cover; }
|
|
.wrn-list__body { min-width: 0; flex: 1; }
|
|
.wrn-list__heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
|
|
.wrn-list__item-title { overflow: hidden; color: var(--wrn-color-text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
|
|
.wrn-list__meta { flex: none; color: var(--wrn-color-text-muted); font-size: 0.75rem; }
|
|
.wrn-list__item-description { display: -webkit-box; margin-top: 0.25rem; overflow: hidden; color: var(--wrn-color-text-muted); font-size: 0.875rem; line-height: 1.25rem; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
|
|
.wrn-list__badge { display: inline-flex; margin-top: 0.5rem; padding: 0.25rem 0.625rem; border-radius: 999px; color: var(--wrn-color-primary); background: var(--wrn-color-primary-soft); font-size: 0.75rem; font-weight: 600; }
|
|
.wrn-list__chevron { width: 1rem; height: 1rem; flex: none; margin-top: 0.25rem; color: var(--wrn-color-text-muted); transition: color var(--wrn-motion-base), transform var(--wrn-motion-base); }
|
|
.wrn-list__row:hover .wrn-list__chevron { color: var(--wrn-color-primary); transform: translateX(0.125rem); }
|
|
.wrn-list__empty { padding: 1.5rem; border: 1px dashed var(--wrn-color-border); border-radius: var(--wrn-radius); color: var(--wrn-color-text-muted); font-size: 0.875rem; text-align: center; }
|
|
}
|
|
}
|