Giter VIP home page Giter VIP logo

lit-element-webpack-hello-world's Introduction

LitElement Hello World Example with Webpack

To run:

npm install
npm run dev

This is the code:

import {LitElement, html, customElement, property} from 'lit-element'

@customElement('main-view')
class RandomView extends LitElement {
  @property({type: Number}) count = 0

  clickHandler() {
    this.count++
  }

  render() {
    return html`
      <p>The count is: ${this.count}</p>
      <button @click="${(this.clickHandler)}">Click</button>
    `
  }
}

LitElement is a cool library for creating web components. The problem is, the documentation sucks.

For example the home page example is literally just a "Hello World" that shows you nothing about how to change state or handle button clicks (Polymer team: please look at React's homepage for an example of how a library's homepage should look).

Nowhere in the documentation does it tell you how to set things up with webpack, instead telling you to simply use polymer serve. And getting things set up with Webpack with decorators is surprisingly time-consuming due to this bug with babel decorators.

I created this repo to 1. show a simple example of Lit-Element that's less worthless than "Hello World" 2. save you from the hassle of having to set up the webpack config.

The webpack config however is extremely simple and not meant for production. But at least with this basic working config, it should be easy to extend and get it to that point.

I'll probably update this repo to make things more complete as I learn more (still new to Lit-Element).

lit-element-webpack-hello-world's People

Contributors

jeremybernier 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.