question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Example of using custom element

See original GitHub issue

Hey @nathancahill, I like where Sveltik is headed, and I’d like to help out with the porting of Formik over to Svelte, but I was wanting to see if I could get you to provide an example of how you can use a custom element with Sveltik.

Here is a real-world element as an example

step-counter.svelte

<script>
	export let value = 0
	export let min = 0
	export let max = 10
	export let label = ''
	export let name = ''

	const decrement = () => { if (value > min) value -= 1 }
	const increment = () => { if (value < max) value += 1 }
</script>

<template>
	<div>
		<button on:click={decrement}>Decrement</button>
		<input type='number' {name} step='1' bind:value={value} readonly>
		<button on:click={increment}>Increment</button>
		{#if label}<p>{label}</p>{/if}
	</div>
</template>

Thanks!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
nathancahillcommented, Jun 9, 2020

Here’s an example with the step counter: https://svelte.dev/repl/38b0d1009d5b4041877b138809d421df?version=3

0reactions
nathancahillcommented, Jun 9, 2020

Responding on #9 to keep things organized.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using custom elements - Web Components | MDN
Let's have a look at an example of an autonomous custom element — <popup-info-box> (see a live example). This takes an image icon...
Read more >
Custom elements - The Modern JavaScript Tutorial
Example : “time-formatted” · Observing attributes · Rendering order · Customized built-in elements · References · Summary · Tasks · Comments.
Read more >
Custom Elements v1 - Reusable Web Components
Custom elements allow web developers to define new HTML tags, extend existing ones, and create reusable web components.
Read more >
Creating a Custom Element from Scratch | CSS-Tricks
Essentially, a custom element consists of two pieces: a tag name and a class that extends the built-in HTMLElement class. The most basic...
Read more >
Your First Custom Element | DigitalOcean
In this post we'll explore the basic syntax and concepts to allow you to start dabbling with Custom Elements and Shadow DOM.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found