Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of using custom element #103

Open
aarongeorge opened this issue Jun 9, 2020 · 6 comments
Open

Example of using custom element #103

aarongeorge opened this issue Jun 9, 2020 · 6 comments

Comments

@aarongeorge
Copy link
Contributor

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!

@nathancahill
Copy link
Owner

Awesome. I'll take a look at this. Definitely a missing hole in the docs.

@nathancahill
Copy link
Owner

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

@aarongeorge
Copy link
Contributor Author

Awesome! Thanks @nathancahill that helps a lot

Feel free to close this off now, or leave it open until it's in the docs

So how can I help man, where's the priority list so I can start knocking out things?

@nathancahill
Copy link
Owner

Going to leave this open until it's in the docs.

Yup validation #9 is really high on the list but haven't had time to dive in to it.

I also want to collect a bunch of examples, with REPL links like the StepCounter above, and stick them in a USAGE.md or something. Stuff that's easy to copy and paste. Especially for custom components like this one: agustinl/svelte-tags-input

At some point I want to make a docs website, but that's down the road. Right now everything is in README.md

@aarongeorge
Copy link
Contributor Author

Cool, good to know

Do you want to Sveltik to take the validationSchema prop just like Formik?

I'll keep some custom components aside as I build them and add them as I go.

@nathancahill
Copy link
Owner

Responding on #9 to keep things organized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants