Here's a list of my learnings while building this website.
- Add PostCSS with svelte-preprocess
- Use dynamic + static classes:
class="icon {svg}"
- How to log a reactive variable each time it changes:
$: foo, console.log('value:', foo);
- How to update a variable from the store: `customBackground.set('#000')``
- 🎉 How do I type reactive assignments? / I get an "implicitly has type 'any' error"? source
let show: boolean // <--- added above the reactive assignment
$: show = !!data.someKey // <-- `show` now has type `boolean`
- How to prevent CSS transition from happening on 1st render.
- add
aria-current
to a link to mark it as the current page link.
- 🎉 Source: Install the "Svelte for VS Code" extension and add this in your VSCode settings to enable formatting:
"[svelte]": {
"editor.defaultFormatter": "svelte.svelte-vscode"
},