Skip to content

Commit e60c2ac

Browse files
committed
updated mgtnew snippet
1 parent f70e64e commit e60c2ac

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

.vscode/snippets/typescript.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"MgtComponent": {
3-
"prefix": "newmgt",
3+
"prefix": "mgtnew",
44
"body": [
55
"import { html, css, customElement, property } from 'lit-element';",
66
"import * as MicrosoftGraph from '@microsoft/microsoft-graph-types';",
@@ -11,18 +11,21 @@
1111
"@customElement('${1:mgt-component}')",
1212
"export class ${2:MgtComponent} extends MgtTemplatedComponent {",
1313
" @property({",
14-
" attribute: 'my-name',",
14+
" attribute: 'my-title',",
1515
" type: String",
1616
" })",
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;",
1821
"",
1922
" attributeChangedCallback(name, oldval, newval) {",
2023
" super.attributeChangedCallback(name, oldval, newval);",
2124
"",
2225
" // TODO: handle when an attribute changes.",
2326
" //",
2427
" // Ex: load data when the name attribute changes",
25-
" // if (name === 'name' && oldval !== newval){",
28+
" // if (name === 'person-id' && oldval !== newval){",
2629
" // this.loadData();",
2730
" // }",
2831
" }",
@@ -40,25 +43,27 @@
4043
" }",
4144
"",
4245
" // TODO: load data from the graph",
46+
" this._me = await provider.graph.client.api('/me').get();",
4347
" }",
4448
"",
4549
" static get styles() {",
4650
" return css`",
47-
" .root {",
51+
" .title {",
4852
" color: red;",
4953
" }",
5054
" `;",
5155
" }",
5256
"",
5357
" render() {",
54-
" return html`",
58+
" $0return html`",
5559
" <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`}!",
5762
" </div>",
5863
" `;",
5964
" }",
6065
"}"
6166
],
62-
"description": "Create New Component"
67+
"description": "Create New Mgt Component"
6368
}
6469
}

0 commit comments

Comments
 (0)