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>
const vases = [
{ value: 'What\'s this? The Herb?', odds: 0.25 },
{ value: 'What\'s this? The Cloth?', odds: 0.1 },
{ value: 'What\'s this? The STRseed?', odds: 0.05 },
{ value: 'What\'s this? The DEFseed?', odds: 0.05 },
{ value: 'But nothing was found.', odds: 0.55 },
].reduce((acc, { value, odds }) => [...acc, { value, odds: acc[acc.length - 1] ? acc[acc.length - 1].odds + odds : odds }], [])
function getOptions(n = 4) {
return Array(n).fill().map(_ => {
const id = Math.random();
const { value } = vases.find(({odds}) => id < odds);
return {
id,
value
}
});
}
let option;
let options = getOptions();
function handleFocus() {
option = null;
// // regenerate the options
options = getOptions();
}
function typewriter(node, { speed = 50 }) {
const { textContent: text } = node;
const { length } = text;
const duration = speed * length;
return {
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */