Skip to content

Commit a62cc53

Browse files
committed
✨ Make Svelte component props reactive
1 parent bf13af0 commit a62cc53

71 files changed

Lines changed: 271 additions & 281 deletions

File tree

Some content is hidden

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ html body {
259259
Depending on your installed blocks, you can also use the following variables to override default block styles:
260260

261261
```scss
262-
:root {
262+
html body {
263263
// Error page
264264
--w-error-page-type-color: var(--w-color-info);
265265
}

src/blocks/Author/Author.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
...rest
1818
}: AuthorProps = $props()
1919
20-
const classes = classNames([
20+
const classes = $derived(classNames([
2121
'flex sm column sm-row',
2222
bodyClassName
23-
])
23+
]))
2424
</script>
2525

2626
<Card bodyClassName={classes} {...rest}>

src/blocks/AvatarWithRating/AvatarWithRating.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
className
1414
}: AvatarWithRatingProps = $props()
1515
16-
const classes = classNames([
16+
const classes = $derived(classNames([
1717
'flex sm items-center',
1818
styles.avatar,
1919
className
20-
])
20+
]))
2121
</script>
2222

2323
<div class={classes}>

src/blocks/DeviceMockup/DeviceMockup.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
children
1616
}: SvelteDeviceMockupProps = $props()
1717
18-
const classes = classNames([
18+
const classes = $derived(classNames([
1919
styles.mockup,
2020
className
21-
])
21+
]))
2222
2323
const getColor = (color: string | undefined) => color
2424
? `background:${color};`

src/blocks/Empty/Empty.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
className
1616
}: EmptyProps = $props()
1717
18-
const classes = classNames([
18+
const classes = $derived(classNames([
1919
'flex column center xs',
2020
iconWithBackground && styles['icon-bg'],
2121
styles.empty,
2222
className
23-
])
23+
]))
2424
</script>
2525

2626
<section class={classes}>

src/blocks/ErrorPage/ErrorPage.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
...rest
1414
}: ErrorPageProps = $props()
1515
16-
const typeStyle = typeColor
16+
const typeStyle = $derived(typeColor
1717
? `--w-error-page-type-color: ${typeColor};`
1818
: null
19+
)
1920
</script>
2021

2122
<section class={styles.error} {...rest}>

src/blocks/ExpandableTable/ExpandableTable.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
2424
let expanded = $state(false)
2525
26-
const classes = classNames([
26+
const classes = $derived(classNames([
2727
styles.table,
2828
hover && styles.hover,
2929
striped && styles[`striped-${striped}s`],
3030
offsetStripe && styles.offset,
3131
compact && styles.compact,
3232
maxHeight && styles.scroll,
3333
className
34-
])
34+
]))
3535
3636
const toggle = () => expanded = !expanded
3737
</script>

src/blocks/FAQ/FAQ.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
...rest
1616
}: SvelteFAQProps = $props()
1717
18-
const classes = classNames([
18+
const classes = $derived(classNames([
1919
styles.faq,
2020
className
21-
])
21+
]))
2222
</script>
2323

2424
<svelte:element this={element} class={classes}>

src/blocks/Form/Form.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
...rest
2121
}: FormProps = $props()
2222
23-
const classes = classNames([
23+
const classes = $derived(classNames([
2424
'flex column',
2525
gap || 'md',
2626
className
27-
])
27+
]))
2828
</script>
2929

3030
{#snippet input(field: FormField)}

src/blocks/GridWithIcons/GridWithIcons.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414
className
1515
}: GridWithIconsProps = $props()
1616
17-
const classes = classNames([
17+
const classes = $derived(classNames([
1818
`grid sm-${columns || 3}`,
1919
styles.list,
2020
alignment && styles[alignment],
2121
iconWithBackground && styles['icon-bg'],
2222
secondary && styles.secondary,
2323
className
24-
])
24+
]))
2525
26-
const wrapperClasses = classNames([
26+
const wrapperClasses = $derived(classNames([
2727
'flex sm items-center',
2828
alignment === 'center' && 'justify-center',
2929
alignment === 'right' && 'justify-end'
30-
])
30+
]))
3131
</script>
3232

3333
<ul class={classes}>

0 commit comments

Comments
 (0)