Code Monkey home page Code Monkey logo

tonic's Introduction

tonic

SYNOPSIS

A minimalist component class inspired by React and Web Components.

GOALS

  • Tonic is tiny. About 150 lines of code.
  • React-like component composition.
  • One-way binding; pipe data though connected components.
  • Prefer event delegation over individual event listeners.
  • Prefer Javascript Template Literals to weird Template Langauges.
  • Unopinionated about Routers, Reducers, Validators, etc.

NON-GOALS

  • When re-rendering performance is truly important, a virtual dom is not the right tool. In these cases you should either A. update some specific dom nodes directly or B. use a graphics/animation engine. The one-way-everywhere approach might make some code easy to reason about, but it ends up being a performance compromise with added complexity.
  • "Isomorphic" components add a huge amount of complexity to a component library. I don't send html from a server very often. My html pages are pretty static and served by a cdn. Otherwise, I'm creating electron apps for the decentralized web. This may be a deal breaker for some people doing more traditional client-server development.
  • JSX
  • Magic

USAGE

You can find an api doc here, a trouble shooting guide here, and a bunch of examples here.

npm install @conductorlab/tonic

EXAMPLE

class Greeting extends Tonic {
  stylesheet () {
    return `
      greeting div {
        display: inline-block;
        border: 1px dotted #666;
        height: 100px;
        width: 100px;
        line-height: 90px;
      }
    `
  }

  click (event) {
    alert(this.innerHTML)
  }

  render () {
    return this.html`
      <h1 class="example">
        ${this.props.value}
      </h1>
    `
  }
}

Tonic.add(Greeting)
<greeting value="Hello, World">
</greeting>

tonic's People

Contributors

heapwolf avatar aprile avatar

Watchers

 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.