clove/pkviewer
web/src/lib/components/manage/ThemePreview.svelte
back to web/src/lib/components/manage
<!-- web/src/lib/components/manage/ThemePreview.svelte -->
<script lang="ts">
import Icon from "../Icon.svelte";
import TokenStyle from "../TokenStyle.svelte";
// Not an iframe: the same --pkv-* properties the public renderer uses, with local sample content
let {
vars,
darkVars,
scheme,
name,
}: {
vars: Record<string, string>;
darkVars: Record<string, string>;
scheme: "auto" | "light" | "dark";
name: string;
} = $props();
</script>
<div id="pkv-preview" class="pkv-preview">
<TokenStyle {vars} {darkVars} colorScheme={scheme} scope={{ elementId: "pkv-preview" }} />
<div class="pv-head">
<div class="pv-avatar" aria-hidden="true">
<Icon name="person-circle" size={26} />
</div>
<div>
<p class="pv-name">{name}</p>
<p class="pv-id">they/them · 12 members</p>
</div>
</div>
<p class="pv-body">
This is how a description reads, with a <span class="pv-link">link</span> in it.
</p>
<div class="pv-cards">
{#each ["Ash", "Juniper", "Wren"] as member (member)}
<div class="pv-card">
<div>{member}</div>
<div class="pv-sub">she/her</div>
</div>
{/each}
</div>
</div>
<style>
.pkv-preview {
background: var(--pkv-color-page);
color: var(--pkv-color-text);
font-family: var(--pkv-font-body);
font-size: var(--pkv-font-size);
border: 1px solid var(--mg-line);
border-radius: var(--mg-radius);
padding: calc(1.25rem * var(--pkv-density));
overflow: hidden;
}
.pv-name {
font-family: var(--pkv-font-heading);
font-size: 1.55em;
font-weight: 600;
line-height: 1.15;
margin: 0;
}
.pv-id {
color: var(--pkv-color-muted);
font-size: 0.85em;
margin: 2px 0 0;
}
.pv-body {
margin: calc(0.75rem * var(--pkv-density)) 0 0;
line-height: 1.55;
}
.pv-link {
color: var(--pkv-color-accent);
text-decoration: underline;
}
.pv-head {
display: flex;
gap: calc(0.9rem * var(--pkv-density));
align-items: center;
}
.pv-avatar {
width: 56px;
height: 56px;
flex: none;
border-radius: var(--pkv-avatar-radius);
background: var(--pkv-color-border);
display: grid;
place-items: center;
color: var(--pkv-color-muted);
}
.pv-cards {
margin-top: calc(1rem * var(--pkv-density));
display: grid;
gap: calc(0.6rem * var(--pkv-density));
grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr));
}
.pv-card {
background: var(--pkv-surface-bg);
border: 1px solid var(--pkv-surface-border);
border-radius: var(--pkv-radius);
padding: calc(0.7rem * var(--pkv-density) * var(--pkv-surface-pad) + 0.2rem);
font-size: 0.9em;
}
.pv-sub {
color: var(--pkv-color-muted);
font-size: 0.85em;
}
</style>