Home

Awesome

Hold your horses!

Build status NPM version Known Vulnerabilities

<script>
  import { Fence, Search } from 'smoo';

  let users = [
    { id: 1, name: 'Juanito Hace', value: 'j@do.e' },
    { id: 2, name: 'Carlangas Marca', value: 'cmrx@so.co' },
  ];

  let members = [];
  let visible = false;

  function open() {
    visible = true;
  }
  function close() {
    visible = false;
  }
</script>

<Fence modal bind:visible on:cancel={close}>
  <h1>It works.</h1>
  <Search multiple data={users} bind:value={members} />
  <pre>Got: {JSON.stringify(members)}</pre>
</Fence>

<button on:click={open}>Open modal</button>

How it works?

smoo lets you place any kind of markup or components inside a <div role="dialog">...</div>, it also brings to you many other useful components, you'll see below.

Components

We have a Fence component, i.e. a thing you need to guard your cows...

<Fence {id} {class} {loading} {modal} {visible} {autofocus} on:submit on:cancel />

This is a <form /> wrapper that handle various effects:

Before submitting HTML5 validation will run, if it's valid a submit event will be triggered. The cancel event is fired when you click outside the modal, or press the <kbd>ESC</kbd> key to close the modal.

Available props:

Available slots:

Add the nofocus or data-nofocus attribute to any element to skip autofocus on it (useful for close-icons, etc.).

<Search {id} {pk} {keys} {data} {value} {class} {label} {disabled} {multiple} {autoclose} {placeholder} on:change />

This is an <input type="search" /> wrapper that handle various effects:

It uses checkboxes or radios to enable selection through the keyboard, once values are choosen a change event is fired with the current selection. You can use CSS to hide those inputs and render the items by using :focus and :checked selectors.

Available props:

Available slots:

If you like, place an icon like <svg slot="before">...</svg> and it will be positioned inside the <input /> on its left. Later you can use CSS to customize this through the [role=search] selector.