Skip to content

Commit 8644fac

Browse files
dimfeldtechniq
authored andcommitted
Change "theme" to "classes" in Settings (#172)
* Rename settings `theme` to `classes` in preparation for adding theme support * Rename getComponentTheme to getComponentClasses
1 parent 7dd7dfe commit 8644fac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+314
-305
lines changed

.changeset/for-you-sean.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'svelte-ux': minor
3+
---
4+
5+
- Rename settings `theme` argument to `classes`
6+
- Rename getTheme to getClasses and getComponentTheme to getComponentClasses
7+

packages/create-svelte-ux/templates/layerchart/src/routes/+layout.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import '../app.postcss';
66
77
settings({
8-
theme: {
8+
classes: {
99
AppBar: 'bg-primary text-white shadow-md',
1010
AppLayout: {
1111
nav: 'bg-neutral-800'

packages/create-svelte-ux/templates/starter/src/routes/+layout.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import '../app.postcss';
66
77
settings({
8-
theme: {
8+
classes: {
99
AppBar: 'bg-primary text-white shadow-md',
1010
AppLayout: {
1111
nav: 'bg-neutral-800'

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import Button from './Button.svelte';
77
import { browser } from '../utils/env';
88
import { cls } from '../utils/styles';
9-
import { getComponentTheme } from './theme';
9+
import { getComponentClasses } from './theme';
1010
1111
export let title: string | number | Array<string | number> = '';
1212
@@ -15,7 +15,7 @@
1515
*/
1616
export let head = true;
1717
18-
const theme = getComponentTheme('AppBar');
18+
const settingsClasses = getComponentClasses('AppBar');
1919
2020
$: titleString = Array.isArray(title) ? title.filter((x) => x).join('') : title.toString();
2121
@@ -26,7 +26,7 @@
2626
</script>
2727

2828
<header
29-
class={cls('AppBar', 'px-4 flex items-center relative z-50', theme.root, $$restProps.class)}
29+
class={cls('AppBar', 'px-4 flex items-center relative z-50', settingsClasses.root, $$restProps.class)}
3030
>
3131
<Button icon={mdiMenu} on:click={() => ($showDrawer = !$showDrawer)} class="p-3" />
3232
{#if $$slots.title}

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
import { breakpoints, mdScreen } from '../stores/matchMedia';
1111
import { cls } from '../utils/styles';
12-
import { getComponentTheme } from './theme';
12+
import { getComponentClasses } from './theme';
1313
1414
export let navWidth = 240;
1515
export let headerHeight = 64;
@@ -28,7 +28,7 @@
2828
aside?: string;
2929
nav?: string;
3030
} = {};
31-
const theme = getComponentTheme('AppLayout');
31+
const settingsClasses = getComponentClasses('AppLayout');
3232
3333
$: temporaryDrawer = browser ? !$mdScreen : false;
3434
</script>
@@ -41,7 +41,7 @@
4141
class={cls(
4242
'AppLayout',
4343
'grid grid-cols-[auto,1fr] grid-rows-[var(--headerHeight),1fr] h-screen',
44-
theme.root,
44+
settingsClasses.root,
4545
classes.root,
4646
$$props.class
4747
)}
@@ -58,11 +58,13 @@
5858
class={cls(
5959
'w-[var(--drawerWidth)] transition-all duration-500 overflow-hidden',
6060
temporaryDrawer && 'fixed h-full z-50 elevation-10',
61-
theme.aside,
61+
settingsClasses.aside,
6262
classes.aside
6363
)}
6464
>
65-
<nav class={cls('nav h-full overflow-auto w-[var(--navWidth)]', theme.nav, classes.nav)}>
65+
<nav
66+
class={cls('nav h-full overflow-auto w-[var(--navWidth)]', settingsClasses.nav, classes.nav)}
67+
>
6668
<slot name="nav" />
6769
</nav>
6870
</aside>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<script lang="ts">
22
import { cls } from '../utils/styles';
33
import Icon from './Icon.svelte';
4-
import { getComponentTheme } from './theme';
4+
import { getComponentClasses } from './theme';
55
66
export let size: 'sm' | 'md' | 'lg' | 'unset' = 'md';
77
export let icon: string | undefined = undefined;
88
9-
const theme = getComponentTheme('Avatar');
9+
const settingsClasses = getComponentClasses('Avatar');
1010
</script>
1111

1212
<div
@@ -18,7 +18,7 @@
1818
md: 'w-10 h-10',
1919
lg: 'w-14 h-14',
2020
}[size],
21-
theme.root,
21+
settingsClasses.root,
2222
$$props.class
2323
)}
2424
>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
44
import { portal as portalAction, type PortalOptions } from '../actions/portal';
55
import { cls } from '../utils/styles';
6-
import { getComponentTheme } from './theme';
6+
import { getComponentClasses } from './theme';
77
88
export let blur: boolean = false;
99
export let portal: PortalOptions = false;
1010
1111
export let fadeParams: FadeParams = { duration: 300 };
1212
13-
const theme = getComponentTheme('Backdrop');
13+
const settingsClasses = getComponentClasses('Backdrop');
1414
</script>
1515

1616
<div
1717
class={cls(
1818
'Backdrop',
1919
'fixed top-0 bottom-0 left-0 right-0 flex items-center justify-center bg-surface-content/50 dark:bg-surface-300/70',
2020
blur && 'backdrop-blur-sm',
21-
theme.root,
21+
settingsClasses.root,
2222
$$props.class
2323
)}
2424
on:keydown

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { cls } from '../utils/styles';
3-
import { getComponentTheme } from './theme';
3+
import { getComponentClasses } from './theme';
44
55
export let value: number = $$slots.value ? 1 : 0;
66
export let small = false;
@@ -9,7 +9,7 @@
99
1010
export let placement: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' = 'top-right';
1111
12-
const theme = getComponentTheme('Badge');
12+
const settingsClasses = getComponentClasses('Badge');
1313
</script>
1414

1515
<div class="inline-grid grid-stack">
@@ -71,7 +71,7 @@
7171
'scale-0': (value ?? 0) === 0,
7272
'scale-100': (value ?? 0) !== 0,
7373
},
74-
theme.root,
74+
settingsClasses.root,
7575
$$props.class
7676
)}
7777
>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
44
import Icon from './Icon.svelte';
55
import { cls } from '../utils/styles';
6-
import { getComponentTheme } from './theme';
6+
import { getComponentClasses } from './theme';
77
88
export let items = [];
99
export let divider: string | undefined = undefined;
1010
export let inline = false;
1111
12-
const theme = getComponentTheme('Breadcrumb');
12+
const settingsClasses = getComponentClasses('Breadcrumb');
1313
1414
$: displayItems = items?.filter((x) => x != null) ?? [];
1515
</script>
@@ -20,7 +20,7 @@
2020
'Breadcrumb',
2121
inline ? 'inline-flex' : 'flex',
2222
'items-center justify-start flex-wrap',
23-
theme.root,
23+
settingsClasses.root,
2424
$$props.class
2525
)}
2626
>

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { multi } from '../actions/multi';
88
import type { Actions } from '../actions/multi';
99
import type { ThemeColors } from '$lib/types';
10-
import { getComponentTheme } from './theme';
10+
import { getComponentClasses } from './theme';
1111
import { getButtonGroup } from './ButtonGroup.svelte';
1212
import { asIconData, type IconInput } from '$lib/utils/icons';
1313
@@ -40,7 +40,7 @@
4040
icon?: string;
4141
loading?: string;
4242
} = {};
43-
const theme = getComponentTheme('Button');
43+
const settingsClasses = getComponentClasses('Button');
4444
4545
// Override default from `ButtonGroup` if set
4646
const groupContext = getButtonGroup();
@@ -443,7 +443,7 @@
443443
variant ?? 'none'
444444
) && 'ring-[--ring-color]',
445445
446-
theme.root,
446+
settingsClasses.root,
447447
classes?.root,
448448
$$props.class
449449
);
@@ -468,18 +468,18 @@
468468
>
469469
{#if loading}
470470
<span transition:slide={{ axis: 'x', duration: 200 }}>
471-
<ProgressCircle size={16} width={2} class={cls(theme.loading, classes.loading)} />
471+
<ProgressCircle size={16} width={2} class={cls(settingsClasses.loading, classes.loading)} />
472472
</span>
473473
{:else if icon}
474474
<span in:slide={{ axis: 'x', duration: 200 }}>
475475
{#if typeof icon === 'string' || 'icon' in icon}
476476
<!-- font path/url/etc or font-awesome IconDefinition -->
477477
<Icon
478478
data={asIconData(icon)}
479-
class={cls('pointer-events-none', theme.icon, classes.icon)}
479+
class={cls('pointer-events-none', settingsClasses.icon, classes.icon)}
480480
/>
481481
{:else}
482-
<Icon class={cls('pointer-events-none', theme.icon, classes.icon)} {...icon} />
482+
<Icon class={cls('pointer-events-none', settingsClasses.icon, classes.icon)} {...icon} />
483483
{/if}
484484
</span>
485485
{/if}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333

3434
<script lang="ts">
3535
import { cls } from '../utils/styles';
36-
import { getComponentTheme } from './theme';
36+
import { getComponentClasses } from './theme';
3737
3838
export let variant: ComponentProps<Button>['variant'] = undefined;
3939
export let size: ComponentProps<Button>['size'] | undefined = undefined;
4040
export let color: ComponentProps<Button>['color'] | undefined = undefined;
4141
export let rounded: ComponentProps<Button>['rounded'] | undefined = undefined;
4242
export let disabled: boolean = false;
4343
44-
const theme = getComponentTheme('ButtonGroup');
44+
const settingsClasses = getComponentClasses('ButtonGroup');
4545
4646
$: _class = cls(
4747
'ButtonGroup',
@@ -69,7 +69,7 @@
6969
'[&.variant-fill-light_.Button:not(:first-child)]:ml-px',
7070
'[&.variant-fill-light_:not(:first-child)_.Button]:ml-px',
7171
72-
theme.root,
72+
settingsClasses.root,
7373
$$props.class
7474
);
7575

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import Header from './Header.svelte';
44
import Overlay from './Overlay.svelte';
55
import { cls } from '../utils/styles';
6-
import { getComponentTheme } from './theme';
6+
import { getComponentClasses } from './theme';
77
88
export let title: string | string[] | null = null;
99
export let subheading: string | string[] | null = null;
1010
export let loading: boolean | null = null;
1111
12-
const theme = getComponentTheme('Card');
12+
const settingsClasses = getComponentClasses('Card');
1313
</script>
1414

1515
<!--
@@ -24,7 +24,7 @@
2424
class={cls(
2525
'Card',
2626
'relative z-0 bg-surface-100 border rounded elevation-1 flex flex-col justify-between',
27-
theme.root,
27+
settingsClasses.root,
2828
$$props.class
2929
)}
3030
>

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import Icon from './Icon.svelte';
55
import { uniqueId } from '../utils/string';
66
import { cls } from '../utils/styles';
7-
import { getComponentTheme } from './theme';
7+
import { getComponentClasses } from './theme';
88
99
export let id = uniqueId('checkbox-');
1010
export let name = '';
@@ -22,7 +22,7 @@
2222
label?: string;
2323
icon?: string;
2424
} = {};
25-
const theme = getComponentTheme('Checkbox');
25+
const settingsClasses = getComponentClasses('Checkbox');
2626
2727
// Update when group changes. Separate function to break reactivity loop
2828
$: if (group !== null) {
@@ -47,7 +47,7 @@
4747
}
4848
</script>
4949

50-
<div class={cls('Checkbox', 'inline-flex items-center', theme.root, classes.root, $$props.class)}>
50+
<div class={cls('Checkbox', 'inline-flex items-center', settingsClasses.root, classes.root, $$props.class)}>
5151
<input
5252
{id}
5353
{name}
@@ -73,7 +73,7 @@
7373
? 'bg-gray-500 border-gray-500'
7474
: 'bg-primary border-primary'
7575
: 'border-gray-500',
76-
theme.checkbox,
76+
settingsClasses.checkbox,
7777
classes.checkbox
7878
)}
7979
>
@@ -82,7 +82,7 @@
8282
class={cls(
8383
'pointer-events-none text-primary-content transition-transform',
8484
checked ? 'scale-100' : 'scale-0',
85-
theme.icon,
85+
settingsClasses.icon,
8686
classes.icon
8787
)}
8888
size={{
@@ -105,7 +105,7 @@
105105
md: 'text-md', // 16px
106106
lg: 'text-lg', // 18px
107107
}[size],
108-
theme.label,
108+
settingsClasses.label,
109109
classes.label
110110
)}
111111
>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import 'prism-svelte';
44
55
import { cls } from '$lib/utils/styles';
6-
import { getComponentTheme } from './theme';
6+
import { getComponentClasses } from './theme';
77
import CopyButton from './CopyButton.svelte';
88
99
export let source: string | null = null;
@@ -18,10 +18,10 @@
1818
code?: string;
1919
} = {};
2020
21-
const theme = getComponentTheme('Code');
21+
const settingsClasses = getComponentClasses('Code');
2222
</script>
2323

24-
<div class={cls('Code', 'rounded', theme.root, classes.root, $$props.class)}>
24+
<div class={cls('Code', 'rounded', settingsClasses.root, classes.root, $$props.class)}>
2525
{#if source}
2626
<div class="relative">
2727
<pre

0 commit comments

Comments
 (0)