|
1 | 1 | { |
2 | 2 | "MgtComponent": { |
3 | | - "prefix": "newmgt", |
| 3 | + "prefix": "mgtnew", |
4 | 4 | "body": [ |
5 | 5 | "import { html, css, customElement, property } from 'lit-element';", |
6 | 6 | "import * as MicrosoftGraph from '@microsoft/microsoft-graph-types';", |
|
11 | 11 | "@customElement('${1:mgt-component}')", |
12 | 12 | "export class ${2:MgtComponent} extends MgtTemplatedComponent {", |
13 | 13 | " @property({", |
14 | | - " attribute: 'my-name',", |
| 14 | + " attribute: 'my-title',", |
15 | 15 | " type: String", |
16 | 16 | " })", |
17 | | - " myName: string;", |
| 17 | + " myTitle: string = 'My First Component';", |
| 18 | + "", |
| 19 | + " // assignment to this property will re-render the component", |
| 20 | + " @property({ attribute: false }) private _me: MicrosoftGraph.User;", |
18 | 21 | "", |
19 | 22 | " attributeChangedCallback(name, oldval, newval) {", |
20 | 23 | " super.attributeChangedCallback(name, oldval, newval);", |
21 | 24 | "", |
22 | 25 | " // TODO: handle when an attribute changes.", |
23 | 26 | " //", |
24 | 27 | " // Ex: load data when the name attribute changes", |
25 | | - " // if (name === 'name' && oldval !== newval){", |
| 28 | + " // if (name === 'person-id' && oldval !== newval){", |
26 | 29 | " // this.loadData();", |
27 | 30 | " // }", |
28 | 31 | " }", |
|
40 | 43 | " }", |
41 | 44 | "", |
42 | 45 | " // TODO: load data from the graph", |
| 46 | + " this._me = await provider.graph.client.api('/me').get();", |
43 | 47 | " }", |
44 | 48 | "", |
45 | 49 | " static get styles() {", |
46 | 50 | " return css`", |
47 | | - " .root {", |
| 51 | + " .title {", |
48 | 52 | " color: red;", |
49 | 53 | " }", |
50 | 54 | " `;", |
51 | 55 | " }", |
52 | 56 | "", |
53 | 57 | " render() {", |
54 | | - " return html`", |
| 58 | + " $0return html`", |
55 | 59 | " <div class='root'>", |
56 | | - " Hello ${this.myName}!$0", |
| 60 | + " <h1 class='title'>${this.myTitle}</h1>", |
| 61 | + " ${this._me ? `Hello ${this._me.displayName}` : `Not signed in`}!", |
57 | 62 | " </div>", |
58 | 63 | " `;", |
59 | 64 | " }", |
60 | 65 | "}" |
61 | 66 | ], |
62 | | - "description": "Create New Component" |
| 67 | + "description": "Create New Mgt Component" |
63 | 68 | } |
64 | 69 | } |
0 commit comments