Skip to content

Commit dc0f742

Browse files
lnhualinhuatechniq
authored
apply component setttings classes for Card (#590)
* apply component setttings classes for Card * fix(Card): Support passing classes from settings() to underlying header, content, and actions components --------- Co-authored-by: linhua <linhua@mbp.lan> Co-authored-by: Sean Lynch <techniq35@gmail.com>
1 parent d2b9540 commit dc0f742

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

.changeset/cruel-olives-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte-ux': patch
3+
---
4+
5+
fix(Card): Support passing classes from settings() to underlying header, content, and actions components

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import ProgressCircle from './ProgressCircle.svelte';
55
import Header from './Header.svelte';
66
import Overlay from './Overlay.svelte';
7-
import { cls } from '@layerstack/tailwind';
7+
import { cls, clsMerge } from '@layerstack/tailwind';
88
import { getComponentClasses } from './theme.js';
99
1010
export let title: string | string[] | null = null;
@@ -48,23 +48,23 @@
4848
{/if}
4949

5050
{#if title || subheading || $$slots.header}
51-
<div class={cls('p-4', classes.headerContainer)}>
51+
<div class={cls('p-4', settingsClasses.headerContainer, classes.headerContainer)}>
5252
<slot name="header">
53-
<Header {title} {subheading} classes={classes.header} />
53+
<Header {title} {subheading} classes={clsMerge(settingsClasses.header, classes.header)} />
5454
</slot>
5555
</div>
5656
{/if}
5757

5858
<slot />
5959

6060
{#if $$slots.contents}
61-
<div class={cls('px-4 flex-1', classes.content)}>
61+
<div class={cls('px-4 flex-1', settingsClasses.content, classes.content)}>
6262
<slot name="contents" />
6363
</div>
6464
{/if}
6565

6666
{#if $$slots.actions}
67-
<div class={cls('py-2 px-1', classes.actions)}>
67+
<div class={cls('py-2 px-1', settingsClasses.actions, classes.actions)}>
6868
<slot name="actions" />
6969
</div>
7070
{/if}

packages/svelte-ux/src/routes/docs/components/Card/+page.svelte

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { mdiDotsVertical } from '@mdi/js';
33
4-
import { Avatar, Button, Card, Header } from 'svelte-ux';
4+
import { Avatar, Button, Card, Header, Settings } from 'svelte-ux';
55
import Preview from '$lib/components/Preview.svelte';
66
</script>
77

@@ -125,3 +125,17 @@
125125
<Preview>
126126
<Card class="elevation-none">Contents</Card>
127127
</Preview>
128+
129+
<h2>Settings</h2>
130+
131+
<Settings
132+
components={{
133+
Card: {
134+
classes: { headerContainer: 'bg-surface-300 border-b', header: { title: 'text-3xl' } },
135+
},
136+
}}
137+
>
138+
<Card title="Title" subheading="Subheading">
139+
<div slot="contents">Contents</div>
140+
</Card>
141+
</Settings>

0 commit comments

Comments
 (0)