Skip to content

Commit d429148

Browse files
committed
updated snippet to include tsdocs, added recomended extension for generating docs
1 parent 948920d commit d429148

File tree

2 files changed

+66
-25
lines changed

2 files changed

+66
-25
lines changed

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"bierner.lit-html",
77
"esbenp.prettier-vscode",
88
"rebornix.project-snippets",
9-
"ms-vscode.vscode-typescript-tslint-plugin"
9+
"ms-vscode.vscode-typescript-tslint-plugin",
10+
"joelday.docthis"
1011
]
1112
}

.vscode/snippets/typescript.json

Lines changed: 64 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,57 @@
22
"MgtComponent": {
33
"prefix": "mgtnew",
44
"body": [
5-
"import { html, css, customElement, property } from 'lit-element';",
65
"import * as MicrosoftGraph from '@microsoft/microsoft-graph-types';",
7-
"import { MgtTemplatedComponent } from '../templatedComponent';",
6+
"import { css, customElement, html, property } from 'lit-element';",
87
"import { Providers } from '../../Providers';",
98
"import { ProviderState } from '../../providers/IProvider';",
9+
"import { MgtTemplatedComponent } from '../templatedComponent';",
1010
"",
11+
"/**",
12+
" *",
13+
" *",
14+
" * @export",
15+
" * @class ${1}",
16+
" * @extends {MgtTemplatedComponent}",
17+
" */",
1118
"@customElement('${1:mgt-component}')",
1219
"export class ${2:MgtComponent} extends MgtTemplatedComponent {",
20+
" /**",
21+
" * Array of styles to apply to the element. The styles should be defined",
22+
" * using the `css` tag function.",
23+
" */",
24+
" static get styles() {",
25+
" return css`",
26+
" .title {",
27+
" color: red;",
28+
" }",
29+
" `;",
30+
" }",
31+
"",
32+
" /**",
33+
" *",
34+
" *",
35+
" * @type {string}",
36+
" * @memberof MgtComponent",
37+
" */",
1338
" @property({",
1439
" attribute: 'my-title',",
1540
" type: String",
1641
" })",
17-
" myTitle: string = 'My First Component';",
42+
" public myTitle: string = 'My First Component';",
1843
"",
1944
" // assignment to this property will re-render the component",
2045
" @property({ attribute: false }) private _me: MicrosoftGraph.User;",
2146
"",
22-
" attributeChangedCallback(name, oldval, newval) {",
47+
" /**",
48+
" * Synchronizes property values when attributes change.",
49+
" *",
50+
" * @param {*} name",
51+
" * @param {*} oldValue",
52+
" * @param {*} newValue",
53+
" * @memberof MgtPersonCard",
54+
" */",
55+
" public attributeChangedCallback(name, oldval, newval) {",
2356
" super.attributeChangedCallback(name, oldval, newval);",
2457
"",
2558
" // TODO: handle when an attribute changes.",
@@ -30,13 +63,36 @@
3063
" // }",
3164
" }",
3265
"",
33-
" firstUpdated() {",
66+
" /**",
67+
" * Invoked when the element is first updated. Implement to perform one time",
68+
" * work on the element after update.",
69+
" *",
70+
" * Setting properties inside this method will trigger the element to update",
71+
" * again after this update cycle completes.",
72+
" *",
73+
" * * @param _changedProperties Map of changed properties with old values",
74+
" */",
75+
" public firstUpdated() {",
3476
" Providers.onProviderUpdated(() => this.loadData());",
3577
" this.loadData();",
3678
" }",
3779
"",
80+
" /**",
81+
" * Invoked on each update to perform rendering tasks. This method must return",
82+
" * a lit-html TemplateResult. Setting properties inside this method will *not*",
83+
" * trigger the element to update.",
84+
" */",
85+
" protected render() {",
86+
" $0return html`",
87+
" <div class='root'>",
88+
" <h1 class='title'>${this.myTitle}</h1>",
89+
" ${this._me ? `Hello ${this._me.displayName}` : 'Not signed in'}!",
90+
" </div>",
91+
" `;",
92+
" }",
93+
"",
3894
" private async loadData() {",
39-
" let provider = Providers.globalProvider;",
95+
" const provider = Providers.globalProvider;",
4096
"",
4197
" if (!provider || provider.state !== ProviderState.SignedIn) {",
4298
" return;",
@@ -45,24 +101,8 @@
45101
" // TODO: load data from the graph",
46102
" this._me = await provider.graph.client.api('/me').get();",
47103
" }",
48-
"",
49-
" static get styles() {",
50-
" return css`",
51-
" .title {",
52-
" color: red;",
53-
" }",
54-
" `;",
55-
" }",
56-
"",
57-
" render() {",
58-
" $0return html`",
59-
" <div class='root'>",
60-
" <h1 class='title'>${this.myTitle}</h1>",
61-
" ${this._me ? `Hello ${this._me.displayName}` : `Not signed in`}!",
62-
" </div>",
63-
" `;",
64-
" }",
65-
"}"
104+
"}",
105+
""
66106
],
67107
"description": "Create New Mgt Component"
68108
}

0 commit comments

Comments
 (0)