Giter Club home page Giter Club logo

skatejs's Introduction

Skate

NPM version Build Status Downloads per month OpenCollective OpenCollective Join the chat at https://gitter.im/skatejs/skatejs Follow @skate_js on Twitter

Skate is a functional abstraction over the web component standards that:

  • Produces cross-framework compatible components.
  • Abstracts away common attribute / property semantics via props, such as attribute reflection and coercion.
  • Adds several lifecycle callbacks for responding to prop updates, rendering and updating, as well as a way to manage internal component state.
  • Provides a base set of mixins that hook into renderers such as @skatejs/renderer-preact.

Installing

Skate is on NPM:

npm install skatejs

The core principle of Skate is to provide abstractions for writing custom elements based on best-practices; things that aren't controversial. However, templating can be highly contentious. For this reason, Skate provides a hook to inject renderers for any view library. For example, if you wanted to write your custom elements with Preact, you'd install it like so:

npm install skatejs @skatejs/renderer-preact preact

There are renderers for many popular view libraries:

Usage

This is how you might write a web component using Skate and Preact:

// @jsx h

import { props, withComponent } from 'skatejs';
import withPreact from '@skatejs/renderer-preact';
import { h } from 'preact';

class WithPreact extends withComponent(withPreact()) {
  static get props() {
    return {
      name: props.string
    };
  }
  render({ name }) {
    return <span>Hello, {name}!</span>;
  }
}

customElements.define('with-preact', WithPreact);

Getting started

To get up and running with Skate, head over to the getting started guide.

Polyfills

Skate builds upon the Custom Elements and the Shadow DOM standards. Skate is capable of operating without the Shadow DOM โ€” it just means you don't get any encapsulation of your component's HTML or styles. It also means that it's up to you to provide a way to project content (i.e. <slot>). It's highly recommended you use Shadow DOM whenever possible.

Though most modern browsers support these standards, some still need polyfills to implement missing or inconsistent behaviours for them.

For more information on the polyfills, see the web components polyfill documentation.

Browser Support

Skate supports all evergreens and IE11, and is subject to the browser support matrix of the polyfills.

Backers

Support us with a monthly donation and help us continue our activities. Become a backer!

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. Become a sponsor!

skatejs's People

Contributors

treshugart avatar greenkeeperio-bot avatar joscha avatar renovate-bot avatar nvenegas avatar bengummer avatar bqx avatar hotell avatar bradleyayers avatar jpnelson avatar matiasatlassian avatar matthewp avatar andreawyss avatar lukebatchelor avatar adevnadia avatar vvakame avatar wangersnmash avatar cary-smith avatar blikblum avatar bedeoverend avatar trusktr avatar trescenzi avatar nminhnguyen avatar klipstein avatar juicelink avatar chrisdarroch avatar zzarcon avatar deini avatar freeman avatar alexlafroscia avatar

Watchers

James Cloos avatar Alex Suttmiller avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.