Git Product home page Git Product logo

tonic's Introduction

tests module semantic versioning dependencies license

tonic

https://tonicframework.dev



Tonic is a low profile component framework for the web. It's one file, less than 3kb gzipped and has no dependencies. It's designed to be used with modern Javascript and is compatible with all modern browsers and built on top of Web Components.

See the API docs

Install

npm install @bicycle-codes/tonic

Use

import Tonic from '@bicycle-codes/tonic'

You can use functions as components. They can be async or even an async generator function.

```js
async function MyGreeting () {
  const data = await (await fetch('https://example.com/data')).text()
  return this.html`<h1>Hello, ${data}</h1>`
}

Or you can use classes. Every class must have a render method.

class MyGreeting extends Tonic {
  async * render () {
    yield this.html`<div>Loading...</div>`

    const data = await (await fetch('https://example.com/data')).text()
    return this.html`<div>Hello, ${data}.</div>`
  }
}
Tonic.add(MyGreeting, 'my-greeting')

After adding your Javascript to your HTML, you can use your component anywhere.

<html>
  <head>
    <script src="my-greeting.js"></script>
  </head>
  <body>
    <my-greeting></my-greeting>
  </body>
</html>

fork

This is a fork of @socketsupply/tonic

See API docs

additions

Things added to the forked version:

types

See src/index.d.ts.

tag

Get the HTML tag name given a Tonic class.

static get tag():string;
class ExampleTwo extends Tonic {
    render () {
        return this.html`<div>example two</div>`
    }
}

ExampleTwo.tag
// => 'example-two'

Useful links

MIT License

tonic's People

Contributors

heapwolf avatar raynos avatar nichoth avatar chicoxyzzy avatar bcomnes avatar dependabot[bot] avatar aprile avatar jwerle avatar achou11 avatar dominictarr avatar joemccann avatar

Stargazers

 avatar

Watchers

 avatar

tonic's Issues

Types

Should have types for Tonic

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.