Skip to content

Commit

Permalink
Add webcomponentjs / lit element, allow custom schema in angular, and…
Browse files Browse the repository at this point in the history
… add my-element hello world example
  • Loading branch information
rjcorwin committed May 11, 2018
1 parent 5964bd4 commit d821d3d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
32 changes: 32 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"@angular/router": "^6.0.0",
"@polymer/lit-element": "^0.5.1",
"@webcomponents/webcomponentsjs": "^2.0.0",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26"
Expand Down
1 change: 1 addition & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!--The content below is only a placeholder and can be replaced.-->
<my-element></my-element>
<div style="text-align:center">
<h1>
Welcome to {{ title }}!
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './my-element';

import { AppComponent } from './app.component';

Expand All @@ -10,6 +11,7 @@ import { AppComponent } from './app.component';
imports: [
BrowserModule
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [],
bootstrap: [AppComponent]
})
Expand Down
15 changes: 15 additions & 0 deletions src/app/my-element.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import '@webcomponents/webcomponentsjs/webcomponents-loader.js';
import {LitElement, html} from '@polymer/lit-element';

class MyElement extends LitElement {

static get properties() { return { mood: String }}

_render({mood}) {
return html`<style> .mood { color: green; } </style>
Web Components are <span class="mood">${mood}</span>!`;
}

}

customElements.define('my-element', MyElement);

0 comments on commit d821d3d

Please sign in to comment.