Skip to content

Commit 5e0c0f1

Browse files
committed
sp-webpart sample cleanup
1 parent 9f6e67b commit 5e0c0f1

File tree

4 files changed

+22
-35
lines changed

4 files changed

+22
-35
lines changed

samples/sp-webpart/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ obj
3232

3333
# Styles Generated Code
3434
*.scss.ts
35+
36+
sharepoint

samples/sp-webpart/package.json

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"@microsoft/sp-office-ui-fabric-core": "1.12.1",
1717
"@microsoft/sp-property-pane": "1.12.1",
1818
"@microsoft/sp-webpart-base": "1.12.1",
19-
"@webcomponents/webcomponentsjs": "^2.4.3",
2019
"office-ui-fabric-react": "7.156.0",
2120
"react": "16.9.0",
2221
"react-dom": "16.9.0"
@@ -25,22 +24,15 @@
2524
"@types/react": "16.9.36"
2625
},
2726
"devDependencies": {
28-
"@babel/core": "^7.10.3",
29-
"@babel/preset-env": "^7.10.3",
30-
"@microsoft/rush-stack-compiler-3.7": "0.2.9",
27+
"@types/react": "16.9.36",
28+
"@types/react-dom": "16.9.8",
3129
"@microsoft/sp-build-web": "1.12.1",
32-
"@microsoft/sp-module-interfaces": "1.12.1",
3330
"@microsoft/sp-tslint-rules": "1.12.1",
31+
"@microsoft/sp-module-interfaces": "1.12.1",
3432
"@microsoft/sp-webpart-workbench": "1.12.1",
35-
"@types/es6-promise": "0.0.33",
36-
"@types/react": "16.9.36",
37-
"@types/react-dom": "16.9.8",
38-
"@types/webpack-env": "1.13.1",
39-
"ajv": "~5.2.2",
40-
"babel-loader": "^8.1.0",
33+
"@microsoft/rush-stack-compiler-3.7": "0.2.9",
4134
"gulp": "4.0.2",
42-
"regenerator-runtime": "^0.13.5",
43-
"typescript": "^3.4.3",
44-
"webpack": "^4.43.0"
35+
"ajv": "~5.2.2",
36+
"@types/webpack-env": "1.13.1"
4537
}
4638
}

samples/sp-webpart/src/webparts/mgtDemo/MgtDemoWebPart.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ import { Version } from '@microsoft/sp-core-library';
44
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
55
import { IPropertyPaneConfiguration, PropertyPaneTextField } from '@microsoft/sp-property-pane';
66

7-
// import web component polyfills for browsers that need them
8-
import 'regenerator-runtime/runtime';
9-
import 'core-js/es/number';
10-
import 'core-js/es/math';
11-
import 'core-js/es/string';
12-
import 'core-js/es/date';
13-
import 'core-js/es/array';
14-
import 'core-js/es/regexp';
15-
import '@webcomponents/webcomponentsjs/webcomponents-bundle.js';
16-
177
import * as strings from 'MgtDemoWebPartStrings';
188
import MgtDemo from './components/MgtDemo';
199
import { IMgtDemoProps } from './components/IMgtDemoProps';
@@ -26,19 +16,15 @@ export interface IMgtDemoWebPartProps {
2616
}
2717

2818
export default class MgtDemoWebPart extends BaseClientSideWebPart<IMgtDemoWebPartProps> {
29-
3019
// set the global provider
3120
protected async onInit() {
3221
Providers.globalProvider = new SharePointProvider(this.context);
3322
}
3423

3524
public render(): void {
36-
const element: React.ReactElement<IMgtDemoProps> = React.createElement(
37-
MgtDemo,
38-
{
39-
description: this.properties.description
40-
}
41-
);
25+
const element: React.ReactElement<IMgtDemoProps> = React.createElement(MgtDemo, {
26+
description: this.properties.description
27+
});
4228

4329
ReactDom.render(element, this.domElement);
4430
}

samples/sp-webpart/src/webparts/mgtDemo/components/MgtDemo.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
import * as React from 'react';
22
import styles from './MgtDemo.module.scss';
33
import { IMgtDemoProps } from './IMgtDemoProps';
4-
import { Person, People, Agenda, TeamsChannelPicker, Tasks, PeoplePicker } from '@microsoft/mgt-react';
5-
import { PersonViewType, PersonCardInteraction } from '@microsoft/mgt';
64

5+
// to ensure your webpart is leveraging the shared mgt library,
6+
// make sure you are only importing from
7+
// - @microsoft/mgt-react/dist/es6/spfx
8+
// - @microsoft/mgt-sfpx
9+
// and no other mgt packages
10+
import { Person, People, Agenda, TeamsChannelPicker, Tasks, PeoplePicker } from '@microsoft/mgt-react/dist/es6/spfx';
11+
import { PersonViewType, PersonCardInteraction } from '@microsoft/mgt-spfx';
712

813
export default class MgtDemo extends React.Component<IMgtDemoProps, {}> {
914
public render(): React.ReactElement<IMgtDemoProps> {
1015
return (
1116
<div className={styles.mgtDemo}>
1217
<div className={styles.container}>
13-
<Person personQuery="me"
18+
<Person
19+
personQuery="me"
1420
view={PersonViewType.twolines}
1521
personCardInteraction={PersonCardInteraction.hover}
16-
showPresence={true}></Person>
22+
showPresence={true}
23+
></Person>
1724

1825
<People></People>
1926

0 commit comments

Comments
 (0)