mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 22:30:41 +08:00
Extract global .badge class into a component
By encapsulating the global `.badge` class into a component we make reasoning about how badges look a bit easier, because now there's a single place where it is defined. Otherwise it is not guaranteed that the class is going to be applied to the correct html tag. This also makes combining global CSS classes that don't make sense from a design perspective impossible. Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
+2
-4
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import Badge from "@app/Badge.svelte";
|
||||
|
||||
export let items: { key: string; title: string; value: string; badge: string | null }[];
|
||||
export let selected: string | null = null;
|
||||
@@ -19,9 +20,6 @@
|
||||
.dropdown-item:hover, .selected {
|
||||
background-color: var(--color-foreground-background-lighter);
|
||||
}
|
||||
.dropdown .badge {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.dropdown {
|
||||
@@ -36,7 +34,7 @@
|
||||
{#if key && value}
|
||||
<div class="dropdown-item" class:selected={value === selected} on:click={() => onSelect(value)} {title}>{@html key}
|
||||
{#if badge}
|
||||
<span class="badge primary">{badge}</span>
|
||||
<Badge variant="primary">{badge}</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user