Added sample.json and fixed readme
This commit is contained in:
parent
23760ec883
commit
c25552bd2a
|
@ -0,0 +1,39 @@
|
||||||
|
// For more information on how to run this SPFx project in a VS Code Remote Container, please visit https://aka.ms/spfx-devcontainer
|
||||||
|
{
|
||||||
|
"name": "SPFx 1.13.1",
|
||||||
|
"image": "docker.io/m365pnp/spfx:1.13.1",
|
||||||
|
// Set *default* container specific settings.json values on container create.
|
||||||
|
"settings": {},
|
||||||
|
// Add the IDs of extensions you want installed when the container is created.
|
||||||
|
"extensions": [
|
||||||
|
"editorconfig.editorconfig",
|
||||||
|
"dbaeumer.vscode-eslint"
|
||||||
|
],
|
||||||
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
|
"forwardPorts": [
|
||||||
|
4321,
|
||||||
|
35729
|
||||||
|
],
|
||||||
|
"portsAttributes": {
|
||||||
|
"4321": {
|
||||||
|
"protocol": "https",
|
||||||
|
"label": "Manifest",
|
||||||
|
"onAutoForward": "silent",
|
||||||
|
"requireLocalPort": true
|
||||||
|
},
|
||||||
|
// Not needed for SPFx>= 1.12.1
|
||||||
|
// "5432": {
|
||||||
|
// "protocol": "https",
|
||||||
|
// "label": "Workbench",
|
||||||
|
// "onAutoForward": "silent"
|
||||||
|
// },
|
||||||
|
"35729": {
|
||||||
|
"protocol": "https",
|
||||||
|
"label": "LiveReload",
|
||||||
|
"onAutoForward": "silent",
|
||||||
|
"requireLocalPort": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"postCreateCommand": "bash .devcontainer/spfx-startup.sh",
|
||||||
|
"remoteUser": "node"
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
echo
|
||||||
|
echo -e "\e[1;94mInstalling Node dependencies\e[0m"
|
||||||
|
npm install
|
||||||
|
|
||||||
|
## commands to create dev certificate and copy it to the root folder of the project
|
||||||
|
echo
|
||||||
|
echo -e "\e[1;94mGenerating dev certificate\e[0m"
|
||||||
|
gulp trust-dev-cert
|
||||||
|
|
||||||
|
# Convert the generated PEM certificate to a CER certificate
|
||||||
|
openssl x509 -inform PEM -in ~/.rushstack/rushstack-serve.pem -outform DER -out ./spfx-dev-cert.cer
|
||||||
|
|
||||||
|
# Copy the PEM ecrtificate for non-Windows hosts
|
||||||
|
cp ~/.rushstack/rushstack-serve.pem ./spfx-dev-cert.pem
|
||||||
|
|
||||||
|
## add *.cer to .gitignore to prevent certificates from being saved in repo
|
||||||
|
if ! grep -Fxq '*.cer' ./.gitignore
|
||||||
|
then
|
||||||
|
echo "# .CER Certificates" >> .gitignore
|
||||||
|
echo "*.cer" >> .gitignore
|
||||||
|
fi
|
||||||
|
|
||||||
|
## add *.pem to .gitignore to prevent certificates from being saved in repo
|
||||||
|
if ! grep -Fxq '*.pem' ./.gitignore
|
||||||
|
then
|
||||||
|
echo "# .PEM Certificates" >> .gitignore
|
||||||
|
echo "*.pem" >> .gitignore
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo -e "\e[1;92mReady!\e[0m"
|
||||||
|
|
||||||
|
echo -e "\n\e[1;94m**********\nOptional: if you plan on using gulp serve, don't forget to add the container certificate to your local machine. Please visit https://aka.ms/spfx-devcontainer for more information\n**********"
|
|
@ -1,4 +1,4 @@
|
||||||
# palette-picker
|
# Palette Picker
|
||||||
|
|
||||||
## Summary
|
## Summary
|
||||||
|
|
||||||
|
@ -8,65 +8,98 @@ Built it to get an understanding of [Property Pane Portal](https://www.npmjs.com
|
||||||
![property pane view](images/palettePickerWebPart.gif)
|
![property pane view](images/palettePickerWebPart.gif)
|
||||||
![after save and refresh](images/palettePickerWebPartAfterSaveAndRefresh.gif)
|
![after save and refresh](images/palettePickerWebPartAfterSaveAndRefresh.gif)
|
||||||
|
|
||||||
## Used SharePoint Framework Version
|
## Compatibility
|
||||||
|
|
||||||
![version](https://img.shields.io/badge/version-1.13-green.svg)
|
![SPFx 1.13.1](https://img.shields.io/badge/SPFx-1.12.1-green.svg)
|
||||||
|
![Node.js v14 | v12](https://img.shields.io/badge/Node.js-v14%20%7C%20v12-green.svg)
|
||||||
|
![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg)
|
||||||
|
![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower")
|
||||||
|
![Does not work with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1")
|
||||||
|
![Local Workbench Unsupported](https://img.shields.io/badge/Local%20Workbench-Unsupported-red.svg "Local workbench is no longer available as of SPFx 1.13 and above")
|
||||||
|
![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg)
|
||||||
|
![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg)
|
||||||
|
|
||||||
## Applies to
|
## Applies to
|
||||||
|
|
||||||
- [SharePoint Framework](https://aka.ms/spfx)
|
* [SharePoint Framework](https://docs.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
|
||||||
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
* [Microsoft 365 tenant](https://docs.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
|
||||||
|
|
||||||
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
|
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
|
||||||
|
|
||||||
|
|
||||||
## Solution
|
## Solution
|
||||||
|
|
||||||
Solution|Author(s)
|
Solution|Author(s)
|
||||||
--------|---------
|
--------|---------
|
||||||
react Palette Picker Web Part | [Linda K](https://github.com/flowerbot)
|
react Palette Picker Web Part | [Linda K](https://github.com/flowerbot)
|
||||||
|
|
||||||
|
|
||||||
## Version history
|
## Version history
|
||||||
|
|
||||||
Version|Date|Comments
|
Version|Date|Comments
|
||||||
-------|----|--------
|
-------|----|--------
|
||||||
1.0|August, 2022|Initial release
|
1.0|August, 2022|Initial release
|
||||||
|
|
||||||
## Disclaimer
|
|
||||||
|
|
||||||
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
## Prerequisites
|
||||||
|
|
||||||
---
|
<!--
|
||||||
|
Any special pre-requisites? Include any lists, permissions, offerings to the demo gods, or whatever else needs to be done for this web part to work.
|
||||||
|
|
||||||
## Minimal Path to Awesome
|
Please describe the steps to configure the pre-requisites. Feel free to add screen shots, but make sure that there is a text description of the steps to perform.
|
||||||
|
|
||||||
- Clone this repository
|
-->
|
||||||
- Ensure that you are at the solution folder
|
|
||||||
- in the command-line run:
|
## Minimal path to awesome
|
||||||
- **npm install**
|
|
||||||
- **gulp serve**
|
|
||||||
|
* Clone this repository (or [download this solution as a .ZIP file](https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/REACT-PALETTE-PICKER) then unzip it)
|
||||||
|
* From your command line, change your current directory to the directory containing this sample (`REACT-PALETTE-PICKER`, located under `samples`)
|
||||||
|
* in the command line run:
|
||||||
|
* `npm install`
|
||||||
|
* `gulp serve`
|
||||||
|
|
||||||
|
> This sample can also be opened with [VS Code Remote Development](https://code.visualstudio.com/docs/remote/remote-overview). Visit <https://aka.ms/spfx-devcontainer> for further instructions.
|
||||||
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
Multi-parameter sliders* in property pane from [react-range](https://www.npmjs.com/package/react-range), dynamic colour updating, css snippet generation, apply colours to MS dropdown component options.
|
Multi-parameter sliders* in property pane from [react-range](https://www.npmjs.com/package/react-range), dynamic color updating, CSS snippet generation, apply colors to MS dropdown component options.
|
||||||
|
|
||||||
*\* PnP - please consider :)*
|
*\* PnP - please consider :)*
|
||||||
|
|
||||||
This web part illustrates the following concepts:
|
This web part illustrates the following concepts:
|
||||||
|
|
||||||
- custom property pane
|
* custom property pane
|
||||||
- dynamic css in spFx property pane
|
* dynamic CSS in SPFx property pane
|
||||||
- custom css colour on dropdown options
|
* custom CSS color on dropdown options
|
||||||
|
|
||||||
|
## Help
|
||||||
|
|
||||||
> Share your web part with others through Microsoft 365 Patterns and Practices program to get visibility and exposure. More details on the community, open-source projects and other activities from http://aka.ms/m365pnp.
|
We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.
|
||||||
|
|
||||||
|
If you're having issues building the solution, please run [spfx doctor](https://pnp.github.io/cli-microsoft365/cmd/spfx/spfx-doctor/) from within the solution folder to diagnose incompatibility issues with your environment.
|
||||||
|
|
||||||
|
You can try looking at [issues related to this sample](https://github.com/pnp/sp-dev-fx-webparts/issues?q=label%3A%22sample%3A%20REACT-PALETTE-PICKER%22) to see if anybody else is having the same issues.
|
||||||
|
|
||||||
|
You can also try looking at [discussions related to this sample](https://github.com/pnp/sp-dev-fx-webparts/discussions?discussions_q=REACT-PALETTE-PICKER) and see what the community is saying.
|
||||||
|
|
||||||
|
If you encounter any issues using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected%2Csample%3A%20REACT-PALETTE-PICKER&template=bug-report.yml&sample=REACT-PALETTE-PICKER&authors=@flowerbot&title=REACT-PALETTE-PICKER%20-%20).
|
||||||
|
|
||||||
|
For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aquestion%2Csample%3A%20REACT-PALETTE-PICKER&template=question.yml&sample=REACT-PALETTE-PICKER&authors=@flowerbot&title=REACT-PALETTE-PICKER%20-%20).
|
||||||
|
|
||||||
|
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aenhancement%2Csample%3A%20REACT-PALETTE-PICKER&template=suggestion.yml&sample=REACT-PALETTE-PICKER&authors=@flowerbot&title=REACT-PALETTE-PICKER%20-%20).
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
- [Property Pane Portal](https://blog.pathtosharepoint.com/2021/07/29/introducing-the-property-pane-portal/) (thank you Christophe!)
|
* [Property Pane Portal](https://blog.pathtosharepoint.com/2021/07/29/introducing-the-property-pane-portal/) (thank you Christophe!)
|
||||||
- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
* [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||||
- [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
|
* [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
|
||||||
- [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
|
* [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
|
||||||
- [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
|
* [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
|
||||||
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development
|
* [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
||||||
|
|
||||||
|
<img src="https://pnptelemetry.azurewebsites.net/sp-dev-fx-webparts/samples/REACT-PALETTE-PICKER" />
|
||||||
|
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
|
@ -0,0 +1,50 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "pnp-sp-dev-spfx-web-parts-react-palette-picker",
|
||||||
|
"source": "pnp",
|
||||||
|
"title": "Palette Picker",
|
||||||
|
"shortDescription": "Custom Property Pane pain resolved (whew), color palette generator inspired by [Jhey](https://codepen.io/jh3y/pen/rNjbmBQ?editors=0011).",
|
||||||
|
"url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-palette-picker",
|
||||||
|
"downloadUrl": "https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-palette-picker",
|
||||||
|
"longDescription": [
|
||||||
|
"Built it to get an understanding of [Property Pane Portal](https://www.npmjs.com/package/property-pane-portal) and cuz I want to eventually build in a dynamic palette generator/css reader for my web parts."
|
||||||
|
],
|
||||||
|
"creationDateTime": "2022-08-01",
|
||||||
|
"updateDateTime": "2022-08-01",
|
||||||
|
"products": [
|
||||||
|
"SharePoint"
|
||||||
|
],
|
||||||
|
"metadata": [
|
||||||
|
{
|
||||||
|
"key": "CLIENT-SIDE-DEV",
|
||||||
|
"value": "React"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "SPFX-VERSION",
|
||||||
|
"value": "1.13.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"thumbnails": [
|
||||||
|
{
|
||||||
|
"type": "image",
|
||||||
|
"order": 100,
|
||||||
|
"url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-palette-picker/assets/YOUR-IMAGE-NAME-HERE",
|
||||||
|
"alt": "Web Part Preview"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"gitHubAccount": "flowerbot",
|
||||||
|
"pictureUrl": "https://github.com/flowerbot.png",
|
||||||
|
"name": "author"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"name": "Build your first SharePoint client-side web part",
|
||||||
|
"description": "Client-side web parts are client-side components that run in the context of a SharePoint page. Client-side web parts can be deployed to SharePoint environments that support the SharePoint Framework. You can also use modern JavaScript web frameworks, tools, and libraries to build them.",
|
||||||
|
"url": "https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
|
@ -3,6 +3,21 @@
|
||||||
const build = require('@microsoft/sp-build-web');
|
const build = require('@microsoft/sp-build-web');
|
||||||
|
|
||||||
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'slider-track' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'toolbar-item' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'code-toolbar' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'inline-color' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'inline-color-wrapper' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'line-numbers-rows' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'line-numbers' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'attr-value' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'class-name' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'function-name' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'attr-name' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'block-comment' is not camelCase and will not be type-safe.`);
|
||||||
|
build.addSuppression(`Warning - [sass] The local CSS class 'slider-thumb' is not camelCase and will not be type-safe.`);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var getTasks = build.rig.getTasks;
|
var getTasks = build.rig.getTasks;
|
||||||
build.rig.getTasks = function () {
|
build.rig.getTasks = function () {
|
||||||
|
|
|
@ -40,7 +40,7 @@ export default class PalettePickerWebPart extends BaseClientSideWebPart<IPalette
|
||||||
context: this.context,
|
context: this.context,
|
||||||
cssObject: this.properties["cssObjectText"] != undefined ? JSON.parse(this.properties["cssObjectText"]) : {},
|
cssObject: this.properties["cssObjectText"] != undefined ? JSON.parse(this.properties["cssObjectText"]) : {},
|
||||||
fontColor: this.properties.fontColor
|
fontColor: this.properties.fontColor
|
||||||
}
|
};
|
||||||
|
|
||||||
const customPropertyPaneProperties = {
|
const customPropertyPaneProperties = {
|
||||||
context: this.context,
|
context: this.context,
|
||||||
|
|
|
@ -18,7 +18,7 @@ export const Colors: React.FC<IColorsProps> = (props) => {
|
||||||
Object.keys(props.colorObject).map((key) => {
|
Object.keys(props.colorObject).map((key) => {
|
||||||
return (
|
return (
|
||||||
<div style={{backgroundColor: props.colorObject[key]}} ><code style={{color:props.fontColor}}>{`${key}: ${props.colorObject[key]}`};</code></div>
|
<div style={{backgroundColor: props.colorObject[key]}} ><code style={{color:props.fontColor}}>{`${key}: ${props.colorObject[key]}`};</code></div>
|
||||||
)
|
);
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,19 +17,19 @@ export const CustomPropertyPane: React.FunctionComponent<ICustomPropertyPaneProp
|
||||||
const cssObject = (hue, saturation, lightness, shades) => {
|
const cssObject = (hue, saturation, lightness, shades) => {
|
||||||
let obj = {};
|
let obj = {};
|
||||||
try {
|
try {
|
||||||
const HUE_STEP = (hue[1] - hue[0]) / shades
|
const HUE_STEP = (hue[1] - hue[0]) / shades;
|
||||||
const LIGHT_STEP = (lightness[1] - lightness[0]) / shades
|
const LIGHT_STEP = (lightness[1] - lightness[0]) / shades;
|
||||||
const SAT_STEP = (saturation[1] - saturation[0]) / shades
|
const SAT_STEP = (saturation[1] - saturation[0]) / shades;
|
||||||
for (let s = 0; s < shades + 1; s++) {
|
for (let s = 0; s < shades + 1; s++) {
|
||||||
const HUE = Math.floor(hue[1] - s * HUE_STEP)
|
const HUE = Math.floor(hue[1] - s * HUE_STEP);
|
||||||
const LIGHTNESS = Math.floor(lightness[1] - s * LIGHT_STEP)
|
const LIGHTNESS = Math.floor(lightness[1] - s * LIGHT_STEP);
|
||||||
const SATURATION = Math.floor(saturation[1] - s * SAT_STEP)
|
const SATURATION = Math.floor(saturation[1] - s * SAT_STEP);
|
||||||
obj[`--color-${s + 1}`] = `hsl(${HUE}, ${SATURATION}%, ${LIGHTNESS}%)`;
|
obj[`--color-${s + 1}`] = `hsl(${HUE}, ${SATURATION}%, ${LIGHTNESS}%)`;
|
||||||
}
|
}
|
||||||
} catch(ex) {console.log("obj problems"); }
|
} catch(ex) {console.log("obj problems"); }
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
};
|
||||||
|
|
||||||
const[colorObj, setColorObj] = React.useState({});
|
const[colorObj, setColorObj] = React.useState({});
|
||||||
|
|
||||||
|
@ -61,11 +61,11 @@ export const CustomPropertyPane: React.FunctionComponent<ICustomPropertyPaneProp
|
||||||
setColorObj(cssObject(props.properties["fieldSetHue"], props.properties["fieldSetSat"],props.properties["fieldSetLight"],props.properties["fieldSetShades"][0]));
|
setColorObj(cssObject(props.properties["fieldSetHue"], props.properties["fieldSetSat"],props.properties["fieldSetLight"],props.properties["fieldSetShades"][0]));
|
||||||
props.updateWebPartProperty("cssObject", colorObj);
|
props.updateWebPartProperty("cssObject", colorObj);
|
||||||
}}
|
}}
|
||||||
renderTrack={({ props, children }) => (
|
renderTrack={({ props: innerProps, children }) => (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...innerProps}
|
||||||
style={{
|
style={{
|
||||||
...props.style,
|
...innerProps.style,
|
||||||
height: '6px',
|
height: '6px',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
backgroundColor: '#ccc'
|
backgroundColor: '#ccc'
|
||||||
|
@ -74,11 +74,11 @@ export const CustomPropertyPane: React.FunctionComponent<ICustomPropertyPaneProp
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
renderThumb={({ props }) => (
|
renderThumb={({ props: innerProps }) => (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...innerProps}
|
||||||
style={{
|
style={{
|
||||||
...props.style,
|
...innerProps.style,
|
||||||
height: '30px',
|
height: '30px',
|
||||||
width: '30px',
|
width: '30px',
|
||||||
backgroundColor: '#999'
|
backgroundColor: '#999'
|
||||||
|
@ -102,11 +102,11 @@ export const CustomPropertyPane: React.FunctionComponent<ICustomPropertyPaneProp
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
renderTrack={({ props, children }) => (
|
renderTrack={({ props: innerProps, children }) => (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...innerProps}
|
||||||
style={{
|
style={{
|
||||||
...props.style,
|
...innerProps.style,
|
||||||
height: '6px',
|
height: '6px',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
backgroundColor: '#ccc'
|
backgroundColor: '#ccc'
|
||||||
|
@ -115,11 +115,11 @@ export const CustomPropertyPane: React.FunctionComponent<ICustomPropertyPaneProp
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
renderThumb={({ props }) => (
|
renderThumb={({ props: innerProps }) => (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...innerProps}
|
||||||
style={{
|
style={{
|
||||||
...props.style,
|
...innerProps.style,
|
||||||
height: '30px',
|
height: '30px',
|
||||||
width: '30px',
|
width: '30px',
|
||||||
backgroundColor: '#999'
|
backgroundColor: '#999'
|
||||||
|
@ -147,11 +147,11 @@ export const CustomPropertyPane: React.FunctionComponent<ICustomPropertyPaneProp
|
||||||
|
|
||||||
|
|
||||||
}}
|
}}
|
||||||
renderTrack={({ props, children }) => (
|
renderTrack={({ props: innerProps, children }) => (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...innerProps}
|
||||||
style={{
|
style={{
|
||||||
...props.style,
|
...innerProps.style,
|
||||||
height: '6px',
|
height: '6px',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
backgroundColor: '#ccc'
|
backgroundColor: '#ccc'
|
||||||
|
@ -160,11 +160,11 @@ export const CustomPropertyPane: React.FunctionComponent<ICustomPropertyPaneProp
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
renderThumb={({ props }) => (
|
renderThumb={({ props: innerProps }) => (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...innerProps}
|
||||||
style={{
|
style={{
|
||||||
...props.style,
|
...innerProps.style,
|
||||||
height: '30px',
|
height: '30px',
|
||||||
width: '30px',
|
width: '30px',
|
||||||
backgroundColor: '#999'
|
backgroundColor: '#999'
|
||||||
|
@ -189,11 +189,11 @@ export const CustomPropertyPane: React.FunctionComponent<ICustomPropertyPaneProp
|
||||||
props.updateWebPartProperty("cssObject", colorObj);
|
props.updateWebPartProperty("cssObject", colorObj);
|
||||||
|
|
||||||
}}
|
}}
|
||||||
renderTrack={({ props, children }) => (
|
renderTrack={({ props: innerProps, children }) => (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...innerProps}
|
||||||
style={{
|
style={{
|
||||||
...props.style,
|
...innerProps.style,
|
||||||
height: '6px',
|
height: '6px',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
backgroundColor: '#ccc'
|
backgroundColor: '#ccc'
|
||||||
|
@ -202,11 +202,11 @@ export const CustomPropertyPane: React.FunctionComponent<ICustomPropertyPaneProp
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
renderThumb={({ props }) => (
|
renderThumb={({ props: innerProps }) => (
|
||||||
<div
|
<div
|
||||||
{...props}
|
{...innerProps}
|
||||||
style={{
|
style={{
|
||||||
...props.style,
|
...innerProps.style,
|
||||||
height: '30px',
|
height: '30px',
|
||||||
width: '30px',
|
width: '30px',
|
||||||
backgroundColor: '#999'
|
backgroundColor: '#999'
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { Dropdown, DropdownMenuItemType, IDropdownStyles, IDropdownOption } from
|
||||||
const options: IDropdownOption[] = [
|
const options: IDropdownOption[] = [
|
||||||
{ key: 'apple', text: 'Apple' },
|
{ key: 'apple', text: 'Apple' },
|
||||||
{ key: 'banana', text: 'Banana' },
|
{ key: 'banana', text: 'Banana' },
|
||||||
{ key: 'orange', text: 'Orange'},
|
{ key: 'orange', text: 'Orange' },
|
||||||
{ key: 'grape', text: 'Grape' },
|
{ key: 'grape', text: 'Grape' },
|
||||||
{ key: 'broccoli', text: 'Broccoli' },
|
{ key: 'broccoli', text: 'Broccoli' },
|
||||||
{ key: 'carrot', text: 'Carrot' },
|
{ key: 'carrot', text: 'Carrot' },
|
||||||
|
@ -18,43 +18,44 @@ const returnCss = (obj) => {
|
||||||
|
|
||||||
let newObj = {};
|
let newObj = {};
|
||||||
Object.keys(obj).map((key, i) => {
|
Object.keys(obj).map((key, i) => {
|
||||||
newObj[`.ms-Dropdown-item:nth-of-type(${i+1})`] = { "backgroundColor": obj[key] };
|
newObj[`.ms-Dropdown-item:nth-of-type(${i + 1})`] = { "backgroundColor": obj[key] };
|
||||||
});
|
});
|
||||||
|
|
||||||
return newObj;
|
return newObj;
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
export default class PalettePicker extends React.Component<IPalettePickerProps, {}> {
|
export default class PalettePicker extends React.Component<IPalettePickerProps, {}> {
|
||||||
|
|
||||||
constructor(props: IPalettePickerProps) {
|
constructor(props: IPalettePickerProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private dropdownStyles: Partial<IDropdownStyles> = {
|
private dropdownStyles: Partial<IDropdownStyles> = {
|
||||||
root: this.props.cssObject,
|
root: this.props.cssObject,
|
||||||
label: {color: this.props.fontColor},
|
label: { color: this.props.fontColor },
|
||||||
/* dropdownItem: {
|
/* dropdownItem: {
|
||||||
backgroundColor: 'pink'
|
backgroundColor: 'pink'
|
||||||
}, */
|
}, */
|
||||||
/* dropdownItemsWrapper: {
|
/* dropdownItemsWrapper: {
|
||||||
style: this.props.cssObject ? this.props.cssObject : {},
|
style: this.props.cssObject ? this.props.cssObject : {},
|
||||||
}, */
|
}, */
|
||||||
|
|
||||||
dropdownItems: {
|
dropdownItems: {
|
||||||
selectors: returnCss(this.props.cssObject),
|
selectors: returnCss(this.props.cssObject),
|
||||||
dropdown: { width: 300
|
dropdown: {
|
||||||
|
width: 300
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,32 +63,32 @@ constructor(props: IPalettePickerProps) {
|
||||||
|
|
||||||
public render(): React.ReactElement<IPalettePickerProps> {
|
public render(): React.ReactElement<IPalettePickerProps> {
|
||||||
|
|
||||||
console.log("styles:", this.dropdownStyles);
|
console.log("styles:", this.dropdownStyles);
|
||||||
console.log("obj", returnCss(this.props.cssObject));
|
console.log("obj", returnCss(this.props.cssObject));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={this.props.cssObject} className={ styles.palettePicker }>
|
<div style={this.props.cssObject} className={styles.palettePicker}>
|
||||||
<div>
|
<div>
|
||||||
<div className={ styles.row } style={{backgroundColor: this.props.cssObject["--color-1"], color: this.props.fontColor}}>
|
<div className={styles.row} style={{ backgroundColor: this.props.cssObject["--color-1"], color: this.props.fontColor }}>
|
||||||
<div className={ styles.column }>
|
<div className={styles.column}>
|
||||||
<span className={ styles.title } style={{color: this.props.fontColor}}>Here's a Palette Picker for you!</span>
|
<span className={styles.title} style={{ color: this.props.fontColor }}>Here's a Palette Picker for you!</span>
|
||||||
<p className={ styles.subTitle } style={{color: this.props.fontColor}}>Allow users to select a color palette for your web part.</p>
|
<p className={styles.subTitle} style={{ color: this.props.fontColor }}>Allow users to select a color palette for your web part.</p>
|
||||||
<div style={{height: 'auto', minHeight: '20px', backgroundColor: this.props.fontColor}}>
|
<div style={{ height: 'auto', minHeight: '20px', backgroundColor: this.props.fontColor }}>
|
||||||
{Object.keys(this.props.cssObject).map((key,i) =>{
|
{Object.keys(this.props.cssObject).map((key, i) => {
|
||||||
return <div style={{backgroundColor: this.props.cssObject[key], height:'10px', width: '10px', display: 'inline-block', borderRadius: '50%', left: 0, top: 0 }}></div>
|
return <div style={{ backgroundColor: this.props.cssObject[key], height: '10px', width: '10px', display: 'inline-block', borderRadius: '50%', left: 0, top: 0 }}></div>;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Dropdown placeholder="Select an option" label="Color your dropdown options .." options={options} styles={this.dropdownStyles} />
|
<Dropdown placeholder="Select an option" label="Color your dropdown options .." options={options} styles={this.dropdownStyles} />
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<a href="https://aka.ms/spfx" className={ styles.button } style={{backgroundColor: this.props.cssObject["--color-3"], color: this.props.fontColor}}>
|
<a href="https://aka.ms/spfx" className={styles.button} style={{ backgroundColor: this.props.cssObject["--color-3"], color: this.props.fontColor }}>
|
||||||
<span className={ styles.label } style={{color: this.props.fontColor}}>Learn more</span>
|
<span className={styles.label} style={{ color: this.props.fontColor }}>Learn more</span>
|
||||||
</a>
|
</a>
|
||||||
<pre style={{font: 'courier', backgroundColor: this.props.cssObject["--color-5"], color: this.props.fontColor}}> {JSON.stringify(this.props.cssObject, null, 4)}</pre>
|
<pre style={{ font: 'courier', backgroundColor: this.props.cssObject["--color-5"], color: this.props.fontColor }}> {JSON.stringify(this.props.cssObject, null, 4)}</pre>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue