Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fit-html

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fit-html

5KB functional Web Components without bloat

  • 0.4.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
2
Weekly downloads
 
Created
Source

💪 fit-html

Travis Greenkeeper badge

5KB web components + lit-html + redux library without bloat.

Overview

fit-html is a combination of lit-html, web components and redux bringing efficient rendering and a functional application architecture together. Yet, it still manages to keep the total size of the framework below 5KB1, including dependencies.

Small Example

You need the following:

import { connect, createProvider, withExtended } from 'fit-html';
import { html } from 'lit-html';
import { createStore } from 'redux';

Set up redux store:

const todos = (state = [], action) => {
  switch (action.type) {
    case 'ADD_TODO':
      return state.concat([action.text]);
    default:
      return state;
  }
};

const store = createStore(todos, ['Use Redux']);

Set up redux provider element (this must be at the root of your element tree):

const provider = createProvider(store);
customElements.define('redux-provider', provider);

Define actions and view:

function addTodo() {
  return {
    type: 'ADD_TODO',
    text: `Hello ${Math.random()}`
  };
}

const render = ({ addTodo, todos }) => html`
  <ul>
    ${todos.map(text => html`<li>${text}</li>`)}
  </ul>

  <button on-click="${addTodo}">
    Add
  </button>
`;

const TodosApp = withExtended(connect(
  state => ({ todos: state }),
  { addTodo },
  render
));

customElements.define('todo-app', TodosApp);

index.html:

<html>
  <head>
    <title>My cool 💪-html app</title>
  </head>
  <body>
    <redux-provider>
      <todo-app></todo-app>
    </redux-provider>
  </body>
</html>

Please see https://github.com/Festify/fit-html-demo for more and larger examples.

License

MIT

1: Actually 4k right now

FAQs

Package last updated on 15 Jan 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc