Skip to content

Commit d2098fd

Browse files
authored
Merge branch 'master' into mhawker/vue-sample-demo
2 parents b04a8ab + ad33829 commit d2098fd

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-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
}

CONTRIBUTING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,26 @@ npm install
3535
npm start
3636
```
3737

38+
## Creating a new component (quick start)
39+
40+
The best way to get started with a new component is to use our snippets for scaffolding:
41+
42+
> Note: The steps below assume you are using Visual Studio Code and you've installed all the recommended extensions.
43+
44+
1. Chose a name for your component. The component must be prefixed with `mgt`. For example `mgt-component`
45+
46+
1. Create a new folder for your new component under `src` \ `components` and name it with the name of your component.
47+
48+
1. Create a new typescript file in your new folder with the same name. Ex: `mgt-component.ts`
49+
50+
1. Open the file and use the `mgtnew` snippet to scaffold the new component.
51+
52+
> To use a snippet, start typing the name of the snippet (`mgtnew`) and press `tab`
53+
54+
1. Tab through the generated code to set the name of your component.
55+
56+
1. Add your code!
57+
3858
<!-- ## Testing the preview NPM package
3959
4060
If you want to install the preview package just once, run this command:

0 commit comments

Comments
 (0)