Skip to content

Commit a049fe2

Browse files
authored
Add classes to Card to Header (#268)
1 parent 9ef5fd9 commit a049fe2

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

.changeset/nine-tigers-smash.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-ux": patch
3+
---
4+
5+
Add `classes` to Card to Header

packages/svelte-ux/src/lib/components/Card.svelte

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import type { ComponentProps } from 'svelte';
3+
24
import ProgressCircle from './ProgressCircle.svelte';
35
import Header from './Header.svelte';
46
import Overlay from './Overlay.svelte';
@@ -11,6 +13,14 @@
1113
let className: string | undefined = undefined;
1214
export { className as class };
1315
16+
export let classes: {
17+
root?: string;
18+
header?: ComponentProps<Header>['classes'];
19+
headerContainer?: string;
20+
content?: string;
21+
actions?: string;
22+
} = {};
23+
1424
const settingsClasses = getComponentClasses('Card');
1525
</script>
1626

@@ -27,6 +37,7 @@
2737
'Card',
2838
'relative z-0 bg-surface-100 border rounded elevation-1 flex flex-col justify-between',
2939
settingsClasses.root,
40+
classes.root,
3041
className
3142
)}
3243
>
@@ -37,23 +48,23 @@
3748
{/if}
3849

3950
{#if title || subheading || $$slots.header}
40-
<div class="p-4">
51+
<div class={cls('p-4', classes.headerContainer)}>
4152
<slot name="header">
42-
<Header {title} {subheading} />
53+
<Header {title} {subheading} classes={classes.header} />
4354
</slot>
4455
</div>
4556
{/if}
4657

4758
<slot />
4859

4960
{#if $$slots.contents}
50-
<div class="px-4 flex-1">
61+
<div class={cls('px-4 flex-1', classes.content)}>
5162
<slot name="contents" />
5263
</div>
5364
{/if}
5465

5566
{#if $$slots.actions}
56-
<div class="py-2 px-1">
67+
<div class={cls('py-2 px-1', classes.actions)}>
5768
<slot name="actions" />
5869
</div>
5970
{/if}

packages/svelte-ux/src/lib/components/Header.svelte

+17-5
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,41 @@
88
let className: string | undefined = undefined;
99
export { className as class };
1010
11+
export let classes: {
12+
root?: string;
13+
container?: string;
14+
title?: string;
15+
subheading?: string;
16+
} = {};
17+
1118
const settingsClasses = getComponentClasses('Header');
1219
</script>
1320

14-
<div class={cls('Header', 'flex items-center gap-4', settingsClasses.root, className)}>
21+
<div
22+
class={cls('Header', 'flex items-center gap-4', settingsClasses.root, classes.root, className)}
23+
>
1524
<slot name="avatar" />
1625

17-
<div class="flex-1">
26+
<div class={cls('flex-1', classes.container)}>
1827
<slot name="title">
1928
{#if title}
2029
{#if Array.isArray(title)}
2130
<Breadcrumb items={title} class="text-lg" />
2231
{:else}
23-
<div class="text-lg">{title}</div>
32+
<div class={cls('text-lg', classes.title)}>{title}</div>
2433
{/if}
2534
{/if}
2635
</slot>
2736

2837
<slot name="subheading">
2938
{#if subheading}
3039
{#if Array.isArray(subheading)}
31-
<Breadcrumb items={subheading} class="text-sm text-surface-content/50" />
40+
<Breadcrumb
41+
items={subheading}
42+
class={cls('text-sm text-surface-content/50', classes.subheading)}
43+
/>
3244
{:else}
33-
<div class="text-sm text-surface-content/50">{subheading}</div>
45+
<div class={cls('text-sm text-surface-content/50', classes.subheading)}>{subheading}</div>
3446
{/if}
3547
{/if}
3648
</slot>

0 commit comments

Comments
 (0)