refactor: migrate to Svelte 5
use runes ($props, $state, $derived, $effect, etc)
This commit is contained in:
@@ -6,19 +6,30 @@
|
||||
import { cx } from 'classix'
|
||||
import Image from '$components/atoms/Image.svelte'
|
||||
|
||||
export let street: string
|
||||
export let location: string
|
||||
export let region: string = undefined
|
||||
export let country: string
|
||||
export let flagId: string
|
||||
export let size: string = undefined
|
||||
let {
|
||||
street,
|
||||
location,
|
||||
region,
|
||||
country,
|
||||
flagId,
|
||||
size,
|
||||
...props
|
||||
}: {
|
||||
street: string
|
||||
location: string
|
||||
region?: string
|
||||
country: string
|
||||
flagId: string
|
||||
size?: string
|
||||
class?: string
|
||||
} = $props()
|
||||
|
||||
const className = 'postcard'
|
||||
$: classes = cx(
|
||||
className,
|
||||
...[size].map(variant => variant && `${className}--${variant}`),
|
||||
$$props.class
|
||||
)
|
||||
const cardClass = 'postcard'
|
||||
const classes = $derived(cx(
|
||||
cardClass,
|
||||
...[size].map(variant => variant && `${cardClass}--${variant}`),
|
||||
props.class,
|
||||
))
|
||||
</script>
|
||||
|
||||
<div class={classes}>
|
||||
|
||||
Reference in New Issue
Block a user