How to use spect - 5 common examples

To help you get started, we’ve selected a few spect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spectjs / spect / example / counter.js View on Github external
import $, { state, html } from 'spect'

$('#counter', el => {
  let { value = 0 } = state()

  // html side-effect
  html`<${el}>
    <input value="${value}">
    <button> state({value: value+1})}&gt;+</button>
    <button> state({value: value-1})}&gt;-</button>
  `
})

$(document.body, el =&gt; html`
github spectjs / spect / example / counter.js View on Github external
import $, { state, html } from 'spect'

$('#counter', el =&gt; {
  let { value = 0 } = state()

  // html side-effect
  html`&lt;${el}&gt;
    <input value="${value}">
    <button> state({value: value+1})}&gt;+</button>
    <button> state({value: value-1})}&gt;-</button>
  `
})

$(document.body, el =&gt; html`
github spectjs / spect / example / router.js View on Github external
import $, { html, route } from 'spect'

$('#app', el =&gt; html`
  <header title="App title">
  <aside>
  <main>${page}</main>
`)

function page(main) {
  html`Loading...`

  // unredirect
  path = ({
    '/dashboard': '/',
    '/signIn': '/sign-in',
    '/user/:userId': '/user'
  })[path]

  import(path).then(html, html)</aside></header>
github spectjs / spect / example / email-validator.js View on Github external
import $, {html, state} from 'spect'

const isValidEmail = (s) =&gt; /.+@.+\..+/i.test(s);

$('#mount', main)

function main(el) {
  let {value} = state()

  html`&lt;${el}&gt;
    Please enter an email address:
    <input name="email"> state({value: e.target.value})}/&gt;

    The address is ${isValidEmail(value)}
  `
}
github spectjs / spect / example / email-validator.js View on Github external
function main(el) {
  let {value} = state()

  html`&lt;${el}&gt;
    Please enter an email address:
    <input name="email"> state({value: e.target.value})}/&gt;

    The address is ${isValidEmail(value)}
  `
}

spect

Observe selectors in DOM

MIT
Latest version published 2 years ago

Package Health Score

45 / 100
Full package analysis

Popular spect functions