0.0.2 • Published 4 years ago
pelte-simple v0.0.2
pelte-simple
pelte-simple is a vanilla javascript component which will work in any frontend framework. You can install from npm like this:
npm install --save pelte-simple
Usage: Javascript (assumes es module)
import Simple from 'pelte-simple'
let simple = new Simple({target:document.body, props: { name1: 'Init Value' });
simple.name1 = 'Updated Value';
// Other props: name2, name3, name4, name5, name6, name7
The "target" is where the component is created. Here it is added to the html body with "document.body", but it could also be document.getElementById('id-of-html-element').
You initialize properties with "props" and you can change the prop values by just assigning the props to new values - this will be updated in the UI.
Usage: Legacy Javascript
Below you can see how to use the component with vanilla js.
...
<head>
...
<script src="https://unpkg.com/pelte-simple@0.0.2/index.js"></script>
</head>
<body>
<script>
let simple = new Simple({target:document.body})
</script>
</body>
Usage: Web Component (aka. Custom Element)
You can use it as a web component.
<head>
<script src="https://unpkg.com/pelte-simple@0.0.2/index.js"></script>
</head>
<body>
<svelte-simple name1="Init Value" />
</body>
Svelte Component
<script>
import Simple from 'pelte-simple';
</script>
<Simple/>
Pelte
This component was created by pelte (aka publish-svelte)