|
| 1 | +{ |
| 2 | + "MgtComponent": { |
| 3 | + "prefix": "newmgt", |
| 4 | + "body": [ |
| 5 | + "import { html, css, customElement, property } from 'lit-element';", |
| 6 | + "import * as MicrosoftGraph from '@microsoft/microsoft-graph-types';", |
| 7 | + "import { MgtTemplatedComponent } from '../templatedComponent';", |
| 8 | + "import { Providers } from '../../Providers';", |
| 9 | + "import { ProviderState } from '../../providers/IProvider';", |
| 10 | + "", |
| 11 | + "@customElement('${1:mgt-component}')", |
| 12 | + "export class ${2:MgtComponent} extends MgtTemplatedComponent {", |
| 13 | + " @property({", |
| 14 | + " attribute: 'my-name',", |
| 15 | + " type: String", |
| 16 | + " })", |
| 17 | + " myName: string;", |
| 18 | + "", |
| 19 | + " attributeChangedCallback(name, oldval, newval) {", |
| 20 | + " super.attributeChangedCallback(name, oldval, newval);", |
| 21 | + "", |
| 22 | + " // TODO: handle when an attribute changes.", |
| 23 | + " //", |
| 24 | + " // Ex: load data when the name attribute changes", |
| 25 | + " // if (name === 'name' && oldval !== newval){", |
| 26 | + " // this.loadData();", |
| 27 | + " // }", |
| 28 | + " }", |
| 29 | + "", |
| 30 | + " firstUpdated() {", |
| 31 | + " Providers.onProviderUpdated(() => this.loadData());", |
| 32 | + " this.loadData();", |
| 33 | + " }", |
| 34 | + "", |
| 35 | + " private async loadData() {", |
| 36 | + " let provider = Providers.globalProvider;", |
| 37 | + "", |
| 38 | + " if (!provider || provider.state !== ProviderState.SignedIn) {", |
| 39 | + " return;", |
| 40 | + " }", |
| 41 | + "", |
| 42 | + " // TODO: load data from the graph", |
| 43 | + " }", |
| 44 | + "", |
| 45 | + " static get styles() {", |
| 46 | + " return css`", |
| 47 | + " .root {", |
| 48 | + " color: red;", |
| 49 | + " }", |
| 50 | + " `;", |
| 51 | + " }", |
| 52 | + "", |
| 53 | + " render() {", |
| 54 | + " return html`", |
| 55 | + " <div class='root'>", |
| 56 | + " Hello ${this.myName}!$0", |
| 57 | + " </div>", |
| 58 | + " `;", |
| 59 | + " }", |
| 60 | + "}" |
| 61 | + ], |
| 62 | + "description": "Create New Component" |
| 63 | + } |
| 64 | +} |
0 commit comments