Snippets Collections
const sleep = (ms: number) =>
	new Promise((resolve) =>
	setTimeout(resolve, ms),
);

{#await data.streamed.members}
	{#await sleep (200) then _}
	    Loading data
    {/await}
{:then value}
  {#each value as { id, full_name }}
  	{id}: {full_name}
  {/each}
{/await}
<script>
  import ExperimentOne from './ExperimentOne.svelte';
  import ExperimentTwo from './ExperimentTwo.svelte';
 
  let component = (Math.random() * 100) > 50 ? 
    ExperimentTwo :
    ExperimentOne;
</script>
 
<svelte:component this={component} />
<script>
  import { Button } from "@dztek/ui-components";
</script>

<Button class={className} {iconLeft} {iconRight} {value} {iconSize} />
<script>
    const sections = {
        "Title 1": "paragraph",
        "Title 2": "paragraph",
        "Title 3": "paragraph",
        "Title 4": "paragraph",
        "Title 5": "paragraph"
    }
    // Object.entries() converts an Object into an array of arrays, 
    // each sub array first index is the a key and the second index is a value
    // Object.entries({key: value, key:value}) => [[key, value], [key,value]]
</script>

{#each Object.entries(sections) as [title, paragraph]}
    <h1>{title}</h1>
    <p>{paragraph}</p>
{/each}
<script>
	// Import markdown conversion library
  import marked from 'marked'
  
	// Declare a variable to store the markdown data. Set a default value
  let markdown = "# Example Title\n\n- this\n- is\n- a list"
</script>

<!-- Declare a textarea where the user can enter markdown, and bind it to the variable `markdown` -->
<textarea bind:value={markdown} placeholder="Enter markdown here"/>

<!-- Convert the markdown to HTML and display it -->
<div class="preview">{@html marked(markdown)}</div>

<!-- Make it look (slightly) nicer ;) -->
<style>
	textarea, .preview {
		box-sizing: border-box;
		display: block;
		width: 100%;
		background-color:azure;
	}
	
	.preview {
		background-color:white;
	}
	
	textarea {
		font-family: monospace, Roboto;
		height: 25%;
		border: none;
		margin: 0;
	}
	
	.preview {
		height: 75%;
		padding: 2rem;
		border-top: solid 2px #888;
	}
	
	:global(body) {
		padding: 0;
	}
</style>
<script>
  import Toggle from "svelte-toggle@1.0.0";

  let toggled = false;
</script>

<svelte:head>
	<!-- override REPL button margin rule -->
	<style>button{margin:0}</style>
</svelte:head>
        
<Toggle
  label="My toggle label"
  switchColor="#eee"
  toggledColor="#24a148"
  untoggledColor="#fa4d56"
  on="On"
  off="Off"
  bind:toggled />
star

Tue Oct 17 2023 07:59:00 GMT+0000 (Coordinated Universal Time)

#svelte #delay-loading-spinner
star

Fri Sep 08 2023 13:14:00 GMT+0000 (Coordinated Universal Time)

#javascript #svelte
star

Thu May 05 2022 06:09:45 GMT+0000 (Coordinated Universal Time)

#svelte
star

Sun Jul 25 2021 12:17:04 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/64909382/how-to-print-both-object-key-and-value-with-each-block-in-svelte

#svelte
star

Mon Oct 26 2020 11:41:17 GMT+0000 (Coordinated Universal Time) https://svelte.dev/repl/hello-world?version

#svelte
star

Mon Oct 26 2020 11:39:34 GMT+0000 (Coordinated Universal Time) https://svelte.dev/repl/hello-world?version

#svelte #javascript

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension