GithubHelp home page GithubHelp logo

ember-lit-element's Introduction

ember-lit-element

This addons allows for easy integration of LitElement inside an ember project. [Short description of the addon.]

Compatibility

  • Ember.js v3.2 or above
  • Ember CLI v2.13 or above

Installation

ember install ember-lit-element

Usage

  1. Place your LitElements inside /app/lit-elements/my-element.js.
  2. Make sure to export default your LitElement class.
  3. Make sure your call to customElements.define('my-element', MyElement); matches your filename. You can omit this call and ember-lit-element will automatically insert it.
  4. Call your LitElement from your ember application with <MyElement @myarg={{data}} />.

ember-lit-element will automatically serialize your arguments as JSON. Passing null, undefined or false will remove the attribute from the custom element. This aligns with the defaults of LitElement to handle attributes and allows to pass complex object or array structures to the LitElement.

Usage example

Define your LitElement inside app/lit-elements/my-element.js like this:

import { LitElement, html } from 'lit-element';

// It is import to *export default* the class.
export default class MyElement extends LitElement {
  static get properties() { return {
    data: { type: Object }
  };}

  constructor() {
    super();
    this.data = {};
  }

  render() {
    return html`
      <p>${this.data.title}</p>
    `;
  }
}

// I could omit this, but it *must* match the filename.
customElements.define('my-element', MyElement);

And then use it from any ember component or route template like this:

<MyElement
  @data={{hash title="Welcome to ember"}}
/>

License

This project is licensed under the MIT License.

ember-lit-element's People

Contributors

ember-tomster avatar luxzeitlos 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.