-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
982 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
spfx-pnp-controls/src/webparts/playWithChart/PlayWithChartWebPart.manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json", | ||
"id": "f0f0c856-3e9d-4ed6-a59b-524e90343256", | ||
"alias": "PlayWithChartWebPart", | ||
"componentType": "WebPart", | ||
|
||
// The "*" signifies that the version should be taken from the package.json | ||
"version": "*", | ||
"manifestVersion": 2, | ||
|
||
// If true, the component can only be installed on sites where Custom Script is allowed. | ||
// Components that allow authors to embed arbitrary script code should set this to true. | ||
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f | ||
"requiresCustomScript": false, | ||
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"], | ||
"supportsThemeVariants": true, | ||
|
||
"preconfiguredEntries": [{ | ||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other | ||
"group": { "default": "Other" }, | ||
"title": { "default": "PlayWithChart" }, | ||
"description": { "default": "PlayWithChart description" }, | ||
"officeFabricIconFontName": "Page", | ||
"properties": { | ||
"description": "PlayWithChart" | ||
} | ||
}] | ||
} |
97 changes: 97 additions & 0 deletions
97
spfx-pnp-controls/src/webparts/playWithChart/PlayWithChartWebPart.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import * as React from 'react'; | ||
import * as ReactDom from 'react-dom'; | ||
import { Version } from '@microsoft/sp-core-library'; | ||
import { | ||
IPropertyPaneConfiguration, | ||
PropertyPaneTextField | ||
} from '@microsoft/sp-property-pane'; | ||
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base'; | ||
import { IReadonlyTheme } from '@microsoft/sp-component-base'; | ||
|
||
import * as strings from 'PlayWithChartWebPartStrings'; | ||
import PlayWithChart from './components/PlayWithChart'; | ||
import { IPlayWithChartProps } from './components/IPlayWithChartProps'; | ||
|
||
export interface IPlayWithChartWebPartProps { | ||
description: string; | ||
} | ||
|
||
export default class PlayWithChartWebPart extends BaseClientSideWebPart<IPlayWithChartWebPartProps> { | ||
|
||
private _isDarkTheme: boolean = false; | ||
private _environmentMessage: string = ''; | ||
|
||
protected onInit(): Promise<void> { | ||
this._environmentMessage = this._getEnvironmentMessage(); | ||
|
||
return super.onInit(); | ||
} | ||
|
||
public render(): void { | ||
const element: React.ReactElement<IPlayWithChartProps> = React.createElement( | ||
PlayWithChart, | ||
{ | ||
description: this.properties.description, | ||
isDarkTheme: this._isDarkTheme, | ||
environmentMessage: this._environmentMessage, | ||
hasTeamsContext: !!this.context.sdks.microsoftTeams, | ||
userDisplayName: this.context.pageContext.user.displayName | ||
} | ||
); | ||
|
||
ReactDom.render(element, this.domElement); | ||
} | ||
|
||
private _getEnvironmentMessage(): string { | ||
if (!!this.context.sdks.microsoftTeams) { // running in Teams | ||
return this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment; | ||
} | ||
|
||
return this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment; | ||
} | ||
|
||
protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void { | ||
if (!currentTheme) { | ||
return; | ||
} | ||
|
||
this._isDarkTheme = !!currentTheme.isInverted; | ||
const { | ||
semanticColors | ||
} = currentTheme; | ||
this.domElement.style.setProperty('--bodyText', semanticColors.bodyText); | ||
this.domElement.style.setProperty('--link', semanticColors.link); | ||
this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered); | ||
|
||
} | ||
|
||
protected onDispose(): void { | ||
ReactDom.unmountComponentAtNode(this.domElement); | ||
} | ||
|
||
protected get dataVersion(): Version { | ||
return Version.parse('1.0'); | ||
} | ||
|
||
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration { | ||
return { | ||
pages: [ | ||
{ | ||
header: { | ||
description: strings.PropertyPaneDescription | ||
}, | ||
groups: [ | ||
{ | ||
groupName: strings.BasicGroupName, | ||
groupFields: [ | ||
PropertyPaneTextField('description', { | ||
label: strings.DescriptionFieldLabel | ||
}) | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.5 KB
spfx-pnp-controls/src/webparts/playWithChart/assets/welcome-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions
7
spfx-pnp-controls/src/webparts/playWithChart/components/IPlayWithChartProps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface IPlayWithChartProps { | ||
description: string; | ||
isDarkTheme: boolean; | ||
environmentMessage: string; | ||
hasTeamsContext: boolean; | ||
userDisplayName: string; | ||
} |
34 changes: 34 additions & 0 deletions
34
spfx-pnp-controls/src/webparts/playWithChart/components/PlayWithChart.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@import '~office-ui-fabric-react/dist/sass/References.scss'; | ||
|
||
.playWithChart { | ||
overflow: hidden; | ||
padding: 1em; | ||
color: "[theme:bodyText, default: #323130]"; | ||
color: var(--bodyText); | ||
&.teams { | ||
font-family: $ms-font-family-fallbacks; | ||
} | ||
} | ||
|
||
.welcome { | ||
text-align: center; | ||
} | ||
|
||
.welcomeImage { | ||
width: 100%; | ||
max-width: 420px; | ||
} | ||
|
||
.links { | ||
a { | ||
text-decoration: none; | ||
color: "[theme:link, default:#03787c]"; | ||
color: var(--link); // note: CSS Custom Properties support is limited to modern browsers only | ||
|
||
&:hover { | ||
text-decoration: underline; | ||
color: "[theme:linkHovered, default: #014446]"; | ||
color: var(--linkHovered); // note: CSS Custom Properties support is limited to modern browsers only | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
spfx-pnp-controls/src/webparts/playWithChart/components/PlayWithChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import * as React from 'react'; | ||
import styles from './PlayWithChart.module.scss'; | ||
import { IPlayWithChartProps } from './IPlayWithChartProps'; | ||
import { escape } from '@microsoft/sp-lodash-subset'; | ||
|
||
import { ChartControl, ChartPalette, ChartType } from '@pnp/spfx-controls-react/lib/ChartControl'; | ||
import { ChartData } from 'chart.js'; | ||
|
||
const data: ChartData = { | ||
labels: ['Italy', 'USA', 'France', 'Germany', 'UK', 'Spain'], | ||
datasets: [ | ||
{ | ||
label: 'Sells', | ||
data: [1250, 1450, 1200, 1400, 200, 680] | ||
}, | ||
{ | ||
label: 'Customers', | ||
data: [120, 150, 90, 50, 4, 15] | ||
} | ||
] | ||
}; | ||
|
||
export default class PlayWithChart extends React.Component<IPlayWithChartProps, {}> { | ||
public render(): React.ReactElement<IPlayWithChartProps> { | ||
const { | ||
description, | ||
isDarkTheme, | ||
environmentMessage, | ||
hasTeamsContext, | ||
userDisplayName | ||
} = this.props; | ||
|
||
return ( | ||
<section className={`${styles.playWithChart} ${hasTeamsContext ? styles.teams : ''}`}> | ||
<div className={styles.welcome}> | ||
<h2>Here is a demo of the ChartControl PnP Reusable Control</h2> | ||
<ChartControl | ||
type={ChartType.Pie} | ||
palette={ChartPalette.OfficeColorful1} | ||
datapromise={this._loadData()} | ||
/> | ||
</div> | ||
</section> | ||
); | ||
} | ||
|
||
private _loadData = async (): Promise<ChartData> => { | ||
return new Promise<ChartData>((resolve, reject) => { | ||
resolve(data); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
define([], function() { | ||
return { | ||
"PropertyPaneDescription": "Description", | ||
"BasicGroupName": "Group Name", | ||
"DescriptionFieldLabel": "Description Field", | ||
"AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part", | ||
"AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app", | ||
"AppSharePointEnvironment": "The app is running on SharePoint page", | ||
"AppTeamsTabEnvironment": "The app is running in Microsoft Teams" | ||
} | ||
}); |
14 changes: 14 additions & 0 deletions
14
spfx-pnp-controls/src/webparts/playWithChart/loc/mystrings.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
declare interface IPlayWithChartWebPartStrings { | ||
PropertyPaneDescription: string; | ||
BasicGroupName: string; | ||
DescriptionFieldLabel: string; | ||
AppLocalEnvironmentSharePoint: string; | ||
AppLocalEnvironmentTeams: string; | ||
AppSharePointEnvironment: string; | ||
AppTeamsTabEnvironment: string; | ||
} | ||
|
||
declare module 'PlayWithChartWebPartStrings' { | ||
const strings: IPlayWithChartWebPartStrings; | ||
export = strings; | ||
} |
28 changes: 28 additions & 0 deletions
28
...-pnp-controls/src/webparts/playWithMonacoEditor/PlayWithMonacoEditorWebPart.manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json", | ||
"id": "ad390a2d-6f5a-4e65-be51-467eda28b18c", | ||
"alias": "PlayWithMonacoEditorWebPart", | ||
"componentType": "WebPart", | ||
|
||
// The "*" signifies that the version should be taken from the package.json | ||
"version": "*", | ||
"manifestVersion": 2, | ||
|
||
// If true, the component can only be installed on sites where Custom Script is allowed. | ||
// Components that allow authors to embed arbitrary script code should set this to true. | ||
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f | ||
"requiresCustomScript": false, | ||
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"], | ||
"supportsThemeVariants": true, | ||
|
||
"preconfiguredEntries": [{ | ||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other | ||
"group": { "default": "Other" }, | ||
"title": { "default": "PlayWithMonacoEditor" }, | ||
"description": { "default": "PlayWithMonacoEditor description" }, | ||
"officeFabricIconFontName": "Page", | ||
"properties": { | ||
"description": "PlayWithMonacoEditor" | ||
} | ||
}] | ||
} |
Oops, something went wrong.