Initial commit
This commit is contained in:
25
.editorconfig
Normal file
25
.editorconfig
Normal file
@@ -0,0 +1,25 @@
|
||||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
|
||||
[*]
|
||||
|
||||
# change these settings to your own preference
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# we recommend you to keep these unchanged
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[{package,bower}.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
32
.gitignore
vendored
Normal file
32
.gitignore
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
|
||||
# Build generated files
|
||||
dist
|
||||
lib
|
||||
solution
|
||||
temp
|
||||
*.sppkg
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# OSX
|
||||
.DS_Store
|
||||
|
||||
# Visual Studio files
|
||||
.ntvs_analysis.dat
|
||||
.vs
|
||||
bin
|
||||
obj
|
||||
|
||||
# Resx Generated Code
|
||||
*.resx.ts
|
||||
|
||||
# Styles Generated Code
|
||||
*.scss.ts
|
||||
11
.yo-rc.json
Normal file
11
.yo-rc.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"@microsoft/generator-sharepoint": {
|
||||
"isCreatingSolution": true,
|
||||
"environment": "onprem19",
|
||||
"version": "1.10.0",
|
||||
"libraryName": "full-width-section-web-part",
|
||||
"libraryId": "c11ccbaa-162d-4b65-9421-6a5f63acd34c",
|
||||
"packageManager": "npm",
|
||||
"componentType": "webpart"
|
||||
}
|
||||
}
|
||||
26
README.md
Normal file
26
README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
## full-width-section-web-part
|
||||
|
||||
This is where you include your WebPart documentation.
|
||||
|
||||
### Building the code
|
||||
|
||||
```bash
|
||||
git clone the repo
|
||||
npm i
|
||||
npm i -g gulp
|
||||
gulp
|
||||
```
|
||||
|
||||
This package produces the following:
|
||||
|
||||
* lib/* - intermediate-stage commonjs build artifacts
|
||||
* dist/* - the bundled script, along with other resources
|
||||
* deploy/* - all resources which should be uploaded to a CDN.
|
||||
|
||||
### Build options
|
||||
|
||||
gulp clean - TODO
|
||||
gulp test - TODO
|
||||
gulp serve - TODO
|
||||
gulp bundle - TODO
|
||||
gulp package-solution - TODO
|
||||
18
config/config.json
Normal file
18
config/config.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||
"version": "2.0",
|
||||
"bundles": {
|
||||
"full-width-section-web-part-web-part": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/webparts/fullWidthSectionWebPart/FullWidthSectionWebPartWebPart.js",
|
||||
"manifest": "./src/webparts/fullWidthSectionWebPart/FullWidthSectionWebPartWebPart.manifest.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"externals": {},
|
||||
"localizedResources": {
|
||||
"FullWidthSectionWebPartWebPartStrings": "lib/webparts/fullWidthSectionWebPart/loc/{locale}.js"
|
||||
}
|
||||
}
|
||||
4
config/copy-assets.json
Normal file
4
config/copy-assets.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
|
||||
"deployCdnPath": "temp/deploy"
|
||||
}
|
||||
7
config/deploy-azure-storage.json
Normal file
7
config/deploy-azure-storage.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./temp/deploy/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "full-width-section-web-part",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
||||
13
config/package-solution.json
Normal file
13
config/package-solution.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||
"solution": {
|
||||
"name": "full-width-section-web-part-client-side-solution",
|
||||
"id": "c11ccbaa-162d-4b65-9421-6a5f63acd34c",
|
||||
"version": "1.0.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"skipFeatureDeployment": true
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/full-width-section-web-part.sppkg"
|
||||
}
|
||||
}
|
||||
10
config/serve.json
Normal file
10
config/serve.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
|
||||
"port": 4321,
|
||||
"https": true,
|
||||
"initialPage": "https://localhost:5432/workbench",
|
||||
"api": {
|
||||
"port": 5432,
|
||||
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
||||
}
|
||||
}
|
||||
4
config/write-manifests.json
Normal file
4
config/write-manifests.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||
}
|
||||
7
gulpfile.js
Normal file
7
gulpfile.js
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
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.initialize(require('gulp'));
|
||||
17487
package-lock.json
generated
Normal file
17487
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
38
package.json
Normal file
38
package.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "full-width-section-web-part",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"main": "lib/index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
"clean": "gulp clean",
|
||||
"test": "gulp test"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "15.6.2",
|
||||
"react-dom": "15.6.2",
|
||||
"@types/react": "15.6.6",
|
||||
"@types/react-dom": "15.5.6",
|
||||
"@microsoft/sp-core-library": "~1.4.0",
|
||||
"@microsoft/sp-webpart-base": "~1.4.0",
|
||||
"@microsoft/sp-lodash-subset": "~1.4.0",
|
||||
"@microsoft/sp-office-ui-fabric-core": "~1.4.0",
|
||||
"@types/webpack-env": "1.13.1",
|
||||
"@types/es6-promise": "0.0.33"
|
||||
},
|
||||
"resolutions": {
|
||||
"@types/react": "15.6.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/sp-build-web": "~1.4.1",
|
||||
"@microsoft/sp-module-interfaces": "~1.4.1",
|
||||
"@microsoft/sp-webpart-workbench": "~1.4.1",
|
||||
"gulp": "~3.9.1",
|
||||
"@types/chai": "3.4.34",
|
||||
"@types/mocha": "2.2.38",
|
||||
"ajv": "~5.2.2"
|
||||
}
|
||||
}
|
||||
1
src/index.ts
Normal file
1
src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||
"id": "70bdea85-6ba4-4d45-82dd-2a2b4b95684b",
|
||||
"alias": "FullWidthSectionWebPartWebPart",
|
||||
"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,
|
||||
|
||||
"preconfiguredEntries": [{
|
||||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||
"group": { "default": "Other" },
|
||||
"title": { "default": "FullWidthSectionWebPart" },
|
||||
"description": { "default": "FullWidthSectionWebPart" },
|
||||
"officeFabricIconFontName": "Page",
|
||||
"properties": {
|
||||
"horizontalPadding": 20
|
||||
}
|
||||
}]
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
import { DisplayMode, Version } from '@microsoft/sp-core-library';
|
||||
import {
|
||||
BaseClientSideWebPart,
|
||||
IPropertyPaneConfiguration,
|
||||
PropertyPaneSlider
|
||||
} from '@microsoft/sp-webpart-base';
|
||||
|
||||
import * as strings from 'FullWidthSectionWebPartWebPartStrings';
|
||||
import FullWidthSectionWebPart from './components/FullWidthSectionWebPart';
|
||||
import { IFullWidthSectionWebPartProps } from './components/IFullWidthSectionWebPartProps';
|
||||
|
||||
export interface IFullWidthSectionWebPartWebPartProps {
|
||||
horizontalPadding: number;
|
||||
padding?: number;
|
||||
}
|
||||
|
||||
export default class FullWidthSectionWebPartWebPart extends BaseClientSideWebPart<IFullWidthSectionWebPartWebPartProps> {
|
||||
|
||||
protected onInit(): Promise<void> {
|
||||
return super.onInit().then(() => {
|
||||
if (typeof this.properties.horizontalPadding !== 'number' && typeof this.properties.padding === 'number') {
|
||||
this.properties.horizontalPadding = this.properties.padding;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public render(): void {
|
||||
let horizontalPadding = 20;
|
||||
|
||||
if (typeof this.properties.horizontalPadding === 'number') {
|
||||
horizontalPadding = this.properties.horizontalPadding;
|
||||
} else if (typeof this.properties.padding === 'number') {
|
||||
horizontalPadding = this.properties.padding;
|
||||
}
|
||||
|
||||
const element: React.ReactElement<IFullWidthSectionWebPartProps> = React.createElement(
|
||||
FullWidthSectionWebPart,
|
||||
{
|
||||
horizontalPadding: horizontalPadding,
|
||||
domElement: this.domElement,
|
||||
displayMode: this.displayMode
|
||||
}
|
||||
);
|
||||
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
|
||||
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: [
|
||||
PropertyPaneSlider('horizontalPadding', {
|
||||
label: strings.HorizontalPaddingFieldLabel,
|
||||
min: 0,
|
||||
max: 100,
|
||||
step: 1,
|
||||
showValue: true
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
||||
|
||||
:global(.SPCanvas-canvas) {
|
||||
max-width: unset !important
|
||||
}
|
||||
|
||||
.fullWidthSectionWebPart {
|
||||
.container {
|
||||
max-width: 99%;
|
||||
margin: 0px auto;
|
||||
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.row {
|
||||
@include ms-Grid-row;
|
||||
@include ms-fontColor-white;
|
||||
background-color: $ms-color-themeDark;
|
||||
padding-top: 20px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.column {
|
||||
@include ms-Grid-col;
|
||||
@include ms-lg10;
|
||||
@include ms-xl8;
|
||||
@include ms-xlPush2;
|
||||
@include ms-lgPush1;
|
||||
}
|
||||
|
||||
.title {
|
||||
@include ms-font-xl;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.subTitle {
|
||||
@include ms-font-l;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.description {
|
||||
@include ms-font-l;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.button {
|
||||
text-decoration: none;
|
||||
height: 32px;
|
||||
min-width: 80px;
|
||||
background-color: $ms-color-themePrimary;
|
||||
border-color: $ms-color-themePrimary;
|
||||
color: $ms-color-white;
|
||||
outline: transparent;
|
||||
position: relative;
|
||||
font-family: "Segoe UI WestEuropean","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-size: $ms-font-size-m;
|
||||
font-weight: $ms-font-weight-regular;
|
||||
border-width: 0;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
padding: 0 16px;
|
||||
|
||||
.label {
|
||||
font-weight: $ms-font-weight-semibold;
|
||||
font-size: $ms-font-size-m;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
margin: 0 4px;
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import * as React from 'react';
|
||||
import { DisplayMode } from '@microsoft/sp-core-library';
|
||||
import styles from './FullWidthSectionWebPart.module.scss';
|
||||
import { IFullWidthSectionWebPartProps } from './IFullWidthSectionWebPartProps';
|
||||
|
||||
const DESCRIPTION_TEXT = 'FullWidthSectionWebPart';
|
||||
|
||||
export default class FullWidthSectionWebPart extends React.Component<IFullWidthSectionWebPartProps, {}> {
|
||||
|
||||
public componentDidMount(): void {
|
||||
this.applySectionStyling();
|
||||
}
|
||||
|
||||
public componentDidUpdate(): void {
|
||||
this.applySectionStyling();
|
||||
}
|
||||
|
||||
public componentWillUnmount(): void {
|
||||
const section = this.getSectionElement();
|
||||
|
||||
if (section) {
|
||||
section.style.paddingLeft = '';
|
||||
section.style.paddingRight = '';
|
||||
section.classList.remove('CanvasZone--fullWidth');
|
||||
section.classList.remove('CanvasZone--fullWidth--read');
|
||||
}
|
||||
}
|
||||
|
||||
private getSectionElement(): HTMLElement | null {
|
||||
return this.props.domElement.closest('[data-automation-id="CanvasZone"]') as HTMLElement;
|
||||
}
|
||||
|
||||
private applySectionStyling(): void {
|
||||
const section = this.getSectionElement();
|
||||
|
||||
if (section) {
|
||||
section.classList.add('CanvasZone--fullWidth');
|
||||
section.classList.add('CanvasZone--fullWidth--read');
|
||||
section.style.paddingLeft = this.props.horizontalPadding + 'px';
|
||||
section.style.paddingRight = this.props.horizontalPadding + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
public render(): React.ReactElement<IFullWidthSectionWebPartProps> {
|
||||
if (this.props.displayMode !== DisplayMode.Edit) {
|
||||
return <div dangerouslySetInnerHTML={{ __html: '<!--- Full Width Section --->' }} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.fullWidthSectionWebPart}>
|
||||
<div className={styles.container}>
|
||||
<div className={styles.row}>
|
||||
<div className={styles.column}>
|
||||
<span className={styles.title}>Full Width Web Part</span>
|
||||
<p className={styles.subTitle}></p>
|
||||
<p className={styles.description}>{DESCRIPTION_TEXT}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { DisplayMode } from '@microsoft/sp-core-library';
|
||||
|
||||
export interface IFullWidthSectionWebPartProps {
|
||||
horizontalPadding: number;
|
||||
domElement: HTMLElement;
|
||||
displayMode: DisplayMode;
|
||||
}
|
||||
7
src/webparts/fullWidthSectionWebPart/loc/en-us.js
Normal file
7
src/webparts/fullWidthSectionWebPart/loc/en-us.js
Normal file
@@ -0,0 +1,7 @@
|
||||
define([], function() {
|
||||
return {
|
||||
"PropertyPaneDescription": "Layout settings",
|
||||
"BasicGroupName": "Spacing",
|
||||
"HorizontalPaddingFieldLabel": "Horizontal padding (left/right, px)"
|
||||
}
|
||||
});
|
||||
10
src/webparts/fullWidthSectionWebPart/loc/mystrings.d.ts
vendored
Normal file
10
src/webparts/fullWidthSectionWebPart/loc/mystrings.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
declare interface IFullWidthSectionWebPartWebPartStrings {
|
||||
PropertyPaneDescription: string;
|
||||
BasicGroupName: string;
|
||||
HorizontalPaddingFieldLabel: string;
|
||||
}
|
||||
|
||||
declare module 'FullWidthSectionWebPartWebPartStrings' {
|
||||
const strings: IFullWidthSectionWebPartWebPartStrings;
|
||||
export = strings;
|
||||
}
|
||||
26
tsconfig.json
Normal file
26
tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"jsx": "react",
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"experimentalDecorators": true,
|
||||
"skipLibCheck": true,
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./node_modules/@microsoft"
|
||||
],
|
||||
"types": [
|
||||
"es6-promise",
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection"
|
||||
]
|
||||
}
|
||||
}
|
||||
30
tslint.json
Normal file
30
tslint.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"extends": "@microsoft/sp-tslint-rules/base-tslint.json",
|
||||
"rules": {
|
||||
"class-name": false,
|
||||
"export-name": false,
|
||||
"forin": false,
|
||||
"label-position": false,
|
||||
"member-access": true,
|
||||
"no-arg": false,
|
||||
"no-console": false,
|
||||
"no-construct": false,
|
||||
"no-duplicate-variable": true,
|
||||
"no-eval": false,
|
||||
"no-function-expression": true,
|
||||
"no-internal-module": true,
|
||||
"no-shadowed-variable": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-unnecessary-semicolons": true,
|
||||
"no-unused-expression": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-with-statement": true,
|
||||
"semicolon": true,
|
||||
"trailing-comma": false,
|
||||
"typedef": false,
|
||||
"typedef-whitespace": false,
|
||||
"use-named-parameter": true,
|
||||
"variable-name": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user