Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
<script>
import { onDestroy } from 'svelte';
const dots = ['#f0c49a', '#ff798b', '#945a8b'].map((color, i, { length }) => {
const cx = (i - Math.floor(length / 2)) * 10;
const cy = i % 2 === 0 ? 0 : -5;
return {
color,
cx,
cy
}
})
const rays = {
sun: 7,
moon: 3
};
const intervalDuration = 1.5;
let isDark;
let count = 0;
let direction = 1;
let interval = setInterval(() => {
count += direction;
if(count > dots.length - 1 || count < 0) {
direction *= -1;
isDark = !isDark;
}
}, intervalDuration * 1000)
onDestroy(() => {
clearInterval(interval)
})
</script>

<style>
:global(body) {
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */