Socket
Book a DemoInstallSign in
Socket

kickflip

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kickflip

Functional SkateJS inspired by you-know-who.

latest
Source
npmnpm
Version
0.0.7
Version published
Weekly downloads
2
-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Kickflip

Kickflip gives you a simple, opinionated wrapper around Skate to write functional web components against W3C specs.

Install

Package managers:

bower install kickflip
jspm install npm:kickflip
npm install kickflip
  • Global / UMD bundles are located in dist/.
  • UMD sources are located in lib/.
  • ES2015 modules are located in src/.

Usage

Here's some working examples of how to build web components with Kickflip.

Hello

http://jsbin.com/tataweq/2

<x-hello name="John"></x-hello>
import kickflip from 'kickflip/src/register';
import { div } from 'kickflip/src/vdom';

kickflip('x-hello', {
  properties: {
    name: {}
  },
  render (elem) {
    return div('Hello, ', elem.name, '!');
  }
});

Counter

http://jsbin.com/cetidi/1

<x-counter></x-counter>
import kickflip, { state } from 'kickflip/src/register';
import { div } from 'kickflip/src/vdom';

const intervals = new WeakMap();

kickflip('x-counter', {
  properties: {
    count: { default: 0 }
  },
  attached (elem) {
    intervals.set(elem, setInterval(function () {
      state(elem, { count: elem.count + 1 });
    }, 1000));
  },
  detached (elem) {
    clearInterval(intervals.get(elem));
  },
  render (elem) {
    return div('Count: ', elem.count.toString());
  }
});

Todos

http://jsbin.com/basego/3

<x-todos>
  <x-item>Item 1</x-item>
  <x-item>Item 2</x-item>
  <x-item>Item 3</x-item>
</x-todos>
import kickflip, { state } from 'kickflip';
import vdom, { button, div, li } from 'kickflip/src/vdom';

kickflip('x-todos', {
  slots: ['content'],
  render (elem) {
    function add (e) {
      if (e.keyCode === 13) {
        state(elem, {
          content: elem.content.concat(vdom('x-item', e.target.value)),
          value: ''
        });
      }
    }

    function remove (index) {
      return function () {
        state(elem, {
          content: elem.content.slice(0, index).concat(elem.content.slice(index + 1))
        });
      };
    }

    const items = elem.content.map(function (item, index) {
      return li(item, ' ', button({ onclick: remove(index) }, 'x'));
    });

    return div(
      input({ onkeyup: add, value: elem.value }),
      items.length ? ul(items) : p('There are no items.')
    );
  }
});

Keywords

functional

FAQs

Package last updated on 27 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts