6.2.0 • Published 10 months ago

panel v6.2.0

Weekly downloads
187
License
MIT
Repository
github
Last release
10 months ago

panel

Build Status NPM version

Build Status

Apps made of composable, manageable Web Components. UIs with supercharged web standards!

import { Component } from 'panel';
import counterTemplate from './counter.jade';

customElements.define('counter-app', class extends Component {
  get config() {
    return {
      defaultState: {count: 1},

      helpers: {
        decr: () => this.changeCounter(-1),
        incr: () => this.changeCounter(1),
      },

      template: counterTemplate,
    };
  }

  changeCounter(offset) {
    this.update({count: this.state.count + offset});
  }
});

document.body.appendChild(document.createElement('counter-app'));
.counter
  .val Counter: #{count}
  .controls
    button.decr(on={click: $helpers.decr}) -
    button.incr(on={click: $helpers.incr}) +

Motivation and technologies

Panel makes Web Components suitable for constructing full web UIs, not just low-level building blocks. It does so by providing an easy-to-use state management and rendering layer built on Virtual DOM (the basis of the core rendering technology of React). Through use of the Snabbdom Virtual DOM library and first-class support for multiple templating formats, Panel offers simple yet powerful APIs for rendering, animation, styling, and DOM lifecycle.

Each Panel application is a Web Component, composed of DOM elements and potentially arbitrarily nested child components, each of which can technically be an app in its own right. Parent and child components can share state, in the form of Plain Old JavaScript Objects which are passed to templates for rendering. When update() is called on a component with state changes, the DOM gets updated according to the diff. Templates can be in any format that produces Snabbdom-compatible hyperscript, including raw Hyperscript code or Jade or JSX.

The architecture of Panel draws upon aspects of and technologies from Mercury, Polymer, React, Redux, Cycle, and Backbone, with an emphasis on simple pragmatism over functional purity thanks to Henrik Joreteg's "Feather" app demo. Panel eschews opaque abstractions and data flow management layers to provide a straightforward state-based rendering cycle. There are no built-in data flow abstractions like Mercury's channels, Flux/React's stores, Cycle's observables, Backbone's event soup and DOM dependencies. More complex state management systems such as Redux and RxJS can plug in to Panel seamlessly if desired (hint: in most apps, you just don't need it). A built-in router (based on the Backbone Router) can sync URL updates and HTML5 History with a Panel app's state for automatic updating and view-swapping.

Since early 2016, Panel and Web Components have powered Mixpanel's most advanced new UIs in production, including Insights, Dashboards, Signal, and JQL Console.

Installation

npm install --save panel

If your target environment does not implement HTML custom elements natively, you must supply a polyfill, such as webcomponents.js.

Documentation and examples

API docs can be found at https://mixpanel.github.io/panel/.

For some sample apps with explanations see examples/. These include demonstrations of using Panel with JSX and Redux.

A brief tutorial is available in the examples/tutorial directory. The sample app accompanying the tutorial features routing, Jade templating, and infrastructure for practical usage such as Webpack/Babel configuration and inclusion of a Web Components polyfill.

A Panel implementation of the TodoMVC app spec is available at https://github.com/tdumitrescu/todomvc-panel.

Running tests

Browser tests run with Selenium through web-component-tester. Server-side rendering tests use mocha and chai directly.

Run with locally installed browsers

npm test

Tunnel to Sauce Labs

npm run build-test && npm run test-browser-sauce

Set credentials with environment variables SAUCE_USERNAME and SAUCE_ACCESS_KEY. The default browser/OS matrix is defined in wct.conf.json.

License

MIT

6.2.0

10 months ago

6.1.2

2 years ago

6.1.1

2 years ago

6.1.0

2 years ago

6.0.0

2 years ago

5.12.0

3 years ago

5.13.0

3 years ago

5.11.0

3 years ago

5.11.0-beta.1

3 years ago

5.11.0-beta.2

3 years ago

5.10.0

3 years ago

5.11.0-beta.0

3 years ago

5.10.0-perf.1

3 years ago

5.10.0-perf.2

3 years ago

5.10.0-perf.3

3 years ago

5.10.0-perf.4

3 years ago

5.10.0-perf.0

3 years ago

5.10.0-beta.0

3 years ago

5.9.0

4 years ago

5.8.0

4 years ago

5.7.0

4 years ago

5.6.0

4 years ago

5.6.0-rc1

4 years ago

5.5.0

4 years ago

5.4.0

4 years ago

5.3.0

4 years ago

5.2.0

4 years ago

5.1.0

4 years ago

5.0.0

4 years ago

4.0.2

4 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.1-rc

5 years ago

3.1.0

5 years ago

3.0.0-rc

5 years ago

3.0.0

5 years ago

2.7.3

5 years ago

2.7.2

5 years ago

2.7.1

5 years ago

2.7.0

5 years ago

2.6.0

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.0

5 years ago

2.3.0

5 years ago

2.2.0

5 years ago

2.1.3

5 years ago

2.2.0-beta2

5 years ago

2.2.0-beta1

5 years ago

2.2.0-beta

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.6

6 years ago

1.6.6-rc

6 years ago

1.6.5-rc

6 years ago

1.6.5

6 years ago

1.6.4

6 years ago

1.6.3

6 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.4

6 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.2.0-rc1

7 years ago

1.1.0

7 years ago

1.1.0-rc6

7 years ago

1.1.0-rc5

7 years ago

0.14.0

7 years ago

0.13.2

7 years ago

0.13.1

7 years ago

0.13.0

7 years ago

1.1.0-rc4

7 years ago

0.13.0-rc.1

7 years ago

1.1.0-rc3

7 years ago

1.1.0-rc2

7 years ago

0.12.0

7 years ago

0.12.0-rc1

7 years ago

1.1.0-rc1

7 years ago

0.11.0

7 years ago

1.0.0-rc1

8 years ago

0.10.0

8 years ago

0.10.0-rc9

8 years ago

0.10.0-rc8

8 years ago

0.10.0-rc7

8 years ago

0.10.0-rc6

8 years ago

0.10.0-rc5

8 years ago

0.10.0-rc4

8 years ago

0.10.0-rc3

8 years ago

0.10.0-rc2

8 years ago

0.10.0-rc1

8 years ago

0.9.1

8 years ago

0.9.0

8 years ago

0.8.5

8 years ago

0.8.4

8 years ago

0.8.3

9 years ago

0.8.2

9 years ago

0.8.1

9 years ago

0.8.0

9 years ago

0.7.2

9 years ago

0.7.1

9 years ago

0.7.0

9 years ago

0.6.2

9 years ago

0.6.1

9 years ago

0.6.0

9 years ago

0.5.5

9 years ago

0.5.4

9 years ago

0.5.3

9 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.4

9 years ago

0.4.3

9 years ago

0.4.2

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.0.0

11 years ago