import { Version } from '@microsoft/sp-core-library'; import { BaseClientSideWebPart, IPropertyPaneConfiguration, PropertyPaneTextField, PropertyPaneButton, PropertyPaneButtonType } from '@microsoft/sp-webpart-base'; import { escape } from '@microsoft/sp-lodash-subset'; import styles from './SvgHeroWebPart.module.scss'; import * as strings from 'SvgHeroWebPartStrings'; //Import the special property pane controls from the PnP SPFx-Property-Controls package import { PropertyFieldColorPicker, PropertyFieldColorPickerStyle } from '@pnp/spfx-property-controls/lib/PropertyFieldColorPicker'; import { PropertyFieldSpinButton } from '@pnp/spfx-property-controls/lib/PropertyFieldSpinButton'; export interface ISvgHeroWebPartProps { colorPants: string; colorHair: string; colorBelt: string; colorBuckle: string; colorSkin: string; colorCape: string; colorDiaper: string; colorShoes: string; colorShirt: string; colorLogo: string; height: number; } export default class SvgHeroWebPartWebPart extends BaseClientSideWebPart { public render(): void { //This will draw the SVG version of the SharePoint PnP Super Hero with custom colors // You can find the SVG file at https://github.com/thechriskent/PnPMan this.domElement.innerHTML = `
SharePoint Patterns and Practices Hero image/svg+xml SharePoint Patterns and Practices Hero Chris Kent Do Whatever
`; } private resetToDefault(): void { this.properties.colorSkin = '#ffb900'; this.properties.colorHair = '#262626'; this.properties.colorPants = '#d83b01'; this.properties.colorBelt = '#ffc929'; this.properties.colorBuckle = '#ffb900'; this.properties.colorCape = '#003c6c'; this.properties.colorDiaper = '#262626'; this.properties.colorShoes = '#0078d7'; this.properties.colorShirt = '#0078d7'; this.properties.colorLogo = '#ffffff'; } protected get dataVersion(): Version { return Version.parse('1.0'); } protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration { return { pages: [ { header: { description: strings.PropertyPaneDescription }, groups: [ { groupName: strings.SizeGroupName, groupFields: [ PropertyFieldSpinButton('height', { label: strings.HeightFieldLabel, initialValue: this.properties.height, onPropertyChange: this.onPropertyPaneFieldChanged, properties: this.properties, suffix: " mm", min: 25, max: 150, step: 5, decimalPlaces: 2, key: 'height' }) ] }, { groupName: strings.ColorGroupName, groupFields: [ PropertyFieldColorPicker('colorHair', { label: strings.HairFieldLabel, selectedColor: this.properties.colorHair, onPropertyChange: this.onPropertyPaneFieldChanged, properties: this.properties, key: 'colorHair' }), PropertyFieldColorPicker('colorSkin', { label: strings.SkinFieldLabel, selectedColor: this.properties.colorSkin, onPropertyChange: this.onPropertyPaneFieldChanged, properties: this.properties, key: 'colorSkin' }), PropertyFieldColorPicker('colorCape', { label: strings.CapeFieldLabel, selectedColor: this.properties.colorCape, onPropertyChange: this.onPropertyPaneFieldChanged, properties: this.properties, key: 'colorCape' }), PropertyFieldColorPicker('colorShirt', { label: strings.ShirtFieldLabel, selectedColor: this.properties.colorShirt, onPropertyChange: this.onPropertyPaneFieldChanged, properties: this.properties, key: 'colorShirt' }), PropertyFieldColorPicker('colorLogo', { label: strings.LogoFieldLabel, selectedColor: this.properties.colorLogo, onPropertyChange: this.onPropertyPaneFieldChanged, properties: this.properties, key: 'colorLogo' }), PropertyFieldColorPicker('colorBuckle', { label: strings.BuckleFieldLabel, selectedColor: this.properties.colorBuckle, onPropertyChange: this.onPropertyPaneFieldChanged, properties: this.properties, key: 'colorBuckle' }), PropertyFieldColorPicker('colorBelt', { label: strings.BeltFieldLabel, selectedColor: this.properties.colorBelt, onPropertyChange: this.onPropertyPaneFieldChanged, properties: this.properties, key: 'colorBelt' }), PropertyFieldColorPicker('colorDiaper', { label: strings.DiaperFieldLabel, selectedColor: this.properties.colorDiaper, onPropertyChange: this.onPropertyPaneFieldChanged, properties: this.properties, key: 'colorDiaper' }), PropertyFieldColorPicker('colorPants', { label: strings.PantsFieldLabel, selectedColor: this.properties.colorPants, onPropertyChange: this.onPropertyPaneFieldChanged, properties: this.properties, key: 'colorPants' }), PropertyFieldColorPicker('colorShoes', { label: strings.ShoesFieldLabel, selectedColor: this.properties.colorShoes, onPropertyChange: this.onPropertyPaneFieldChanged, properties: this.properties, key: 'colorShoes' }), PropertyPaneButton('reset',{ text: strings.ResetButtonLabel, buttonType: PropertyPaneButtonType.Command, icon: 'Warning', onClick: this.resetToDefault.bind(this) }) ] } ] } ] }; } }