diff --git a/samples/react-hero-webpart/.gitignore b/samples/react-hero-webpart/.gitignore index d5ab57b0f..636a3337f 100644 --- a/samples/react-hero-webpart/.gitignore +++ b/samples/react-hero-webpart/.gitignore @@ -31,3 +31,7 @@ obj # Styles Generated Code *.scss.ts +# .CER Certificates +*.cer +# .PEM Certificates +*.pem diff --git a/samples/react-hero-webpart/README.md b/samples/react-hero-webpart/README.md index d45161bfb..637037c46 100644 --- a/samples/react-hero-webpart/README.md +++ b/samples/react-hero-webpart/README.md @@ -2,10 +2,10 @@ ## Summary -This solution creates a customisable Hero web part, it uses a stored collection from the PnP PropertyFieldCollectionData control +This solution creates a customisable Hero web part, it uses a stored collection from the PnP `PropertyFieldCollectionData` control ![Preview](./assets/Hero-Webpart.gif) - +![Preview](./assets/collage-hero-webpart.PNG) ## Compatibility @@ -34,17 +34,18 @@ hero-webpart | [Omar El-Anis](https://github.com/omarelanis) @ SP Bytes www.spby Version|Date|Comments -------|----|-------- +1.3|March 11, 2022|At the request of another user a option has been added to allow a collage of images to be shown in a flex grid layout
Added in placeholder configuration screen
Fixed webpart not loading the 5 temporary items on first adding webpart to new page in local workbench
General maintenance to remove unused imports
Updated CSS to add in collage feature 1.2|July 27, 2021|Updated to automatically detect how many items are being displayed and adjust the display layout based on this
Updated design to show the title on all images
Updated description area on hover
Updated hover effect of image to show a zoom effect when hovering over an item
General cleaning up of CSS and code 1.1|March 10, 2021|Update comment 1.0|January 29, 2021|Initial release ## Minimal Path to Awesome -- Clone this repository -- Ensure that you are at the solution folder -- in the command-line run: - - `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-hero-webpart) then unzip it) +* From your command line, change your current directory to the directory containing this sample (`react-hero-webpart`, 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. @@ -66,16 +67,22 @@ This extension illustrates the following concepts: - [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 - ## Help -We do not support samples, but we 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. + +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-hero-webpart%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-hero-webpart) and see what the community is saying. If you encounter any issues while 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-hero-webpart&template=bug-report.yml&sample=react-hero-webpart&authors=@omarelanis&title=react-hero-webpart%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-hero-webpart&template=question.yml&sample=react-hero-webpart&authors=@omarelanis&title=react-hero-webpart%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-hero-webpart&template=question.yml&sample=react-hero-webpart&authors=@omarelanis&title=react-hero-webpart%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-hero-webpart&template=suggestion.yml&sample=react-hero-webpart&authors=@omarelanis&title=react-hero-webpart%20-%20). ## Disclaimer diff --git a/samples/react-hero-webpart/assets/collage-hero-webpart.PNG b/samples/react-hero-webpart/assets/collage-hero-webpart.PNG new file mode 100644 index 000000000..d15b71e84 Binary files /dev/null and b/samples/react-hero-webpart/assets/collage-hero-webpart.PNG differ diff --git a/samples/react-hero-webpart/assets/sample.json b/samples/react-hero-webpart/assets/sample.json index c0ac18f2a..b0807c2a9 100644 --- a/samples/react-hero-webpart/assets/sample.json +++ b/samples/react-hero-webpart/assets/sample.json @@ -9,7 +9,7 @@ "This solution creates a customisable Hero web part, it uses a stored collection from the PnP PropertyFieldCollectionData control " ], "creationDateTime": "2021-04-02", - "updateDateTime": "2021-07-27", + "updateDateTime": "2022-03-11", "products": [ "SharePoint", "Office" diff --git a/samples/react-hero-webpart/config/package-solution.json b/samples/react-hero-webpart/config/package-solution.json index 3a5037c60..b4078c3bb 100644 --- a/samples/react-hero-webpart/config/package-solution.json +++ b/samples/react-hero-webpart/config/package-solution.json @@ -3,7 +3,7 @@ "solution": { "name": "Hero Layout Webpart", "id": "5efc0426-3e59-4fc7-b638-73eb77aaf788", - "version": "1.2.0.0", + "version": "1.3.0.0", "includeClientSideAssets": true, "skipFeatureDeployment": true, "isDomainIsolated": false, diff --git a/samples/react-hero-webpart/package-lock.json b/samples/react-hero-webpart/package-lock.json index 1989939a5..4867036df 100644 --- a/samples/react-hero-webpart/package-lock.json +++ b/samples/react-hero-webpart/package-lock.json @@ -1,6 +1,6 @@ { "name": "hero-webpart", - "version": "0.0.1", + "version": "1.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/samples/react-hero-webpart/package.json b/samples/react-hero-webpart/package.json index 6fd635d6b..2d5a10210 100644 --- a/samples/react-hero-webpart/package.json +++ b/samples/react-hero-webpart/package.json @@ -1,6 +1,6 @@ { "name": "hero-webpart", - "version": "1.2.0", + "version": "1.3.0", "private": true, "main": "lib/index.js", "scripts": { diff --git a/samples/react-hero-webpart/release/manifests/71d58a4f-1896-46aa-94a5-dbef33d14166.manifest.json b/samples/react-hero-webpart/release/manifests/71d58a4f-1896-46aa-94a5-dbef33d14166.manifest.json index a0959b101..40c381e61 100644 --- a/samples/react-hero-webpart/release/manifests/71d58a4f-1896-46aa-94a5-dbef33d14166.manifest.json +++ b/samples/react-hero-webpart/release/manifests/71d58a4f-1896-46aa-94a5-dbef33d14166.manifest.json @@ -2,7 +2,7 @@ "id": "71d58a4f-1896-46aa-94a5-dbef33d14166", "alias": "HeroWebpartWebPart", "componentType": "WebPart", - "version": "0.0.1", + "version": "1.3.0", "manifestVersion": 2, "requiresCustomScript": false, "supportedHosts": [ diff --git a/samples/react-hero-webpart/src/webparts/heroWebpart/HeroWebpartWebPart.ts b/samples/react-hero-webpart/src/webparts/heroWebpart/HeroWebpartWebPart.ts index 4ca51d8d3..a09884a10 100644 --- a/samples/react-hero-webpart/src/webparts/heroWebpart/HeroWebpartWebPart.ts +++ b/samples/react-hero-webpart/src/webparts/heroWebpart/HeroWebpartWebPart.ts @@ -12,13 +12,13 @@ import HeroWebpart from './components/HeroWebpart'; import { IHeroWebpartProps } from './components/IHeroWebpartProps'; import { PropertyFieldToggleWithCallout } from '@pnp/spfx-property-controls/lib/PropertyFieldToggleWithCallout'; -import { PropertyFieldSliderWithCallout } from '@pnp/spfx-property-controls/lib/PropertyFieldSliderWithCallout'; import { CalloutTriggers } from '@pnp/spfx-property-controls/lib/PropertyFieldHeader'; import { PropertyFieldCollectionData, CustomCollectionFieldType } from '@pnp/spfx-property-controls/lib/PropertyFieldCollectionData'; -import { PropertyFieldFilePicker, IPropertyFieldFilePickerProps, IFilePickerResult } from "@pnp/spfx-property-controls/lib/PropertyFieldFilePicker"; -import { FilePicker , IFilePickerProps } from '@pnp/spfx-controls-react/lib/FilePicker'; +import { IFilePickerResult } from "@pnp/spfx-property-controls/lib/PropertyFieldFilePicker"; +import { FilePicker } from '@pnp/spfx-controls-react/lib/FilePicker'; import { PropertyPaneWebPartInformation } from '@pnp/spfx-property-controls/lib/PropertyPaneWebPartInformation'; +import { DisplayMode } from '@microsoft/sp-core-library'; export interface IHeroWebpartWebPartProps { title: string; @@ -26,9 +26,11 @@ export interface IHeroWebpartWebPartProps { hideFirstPageJump: boolean; hideLastPageJump: boolean; showAllHero: boolean; + showCollage: boolean; collectionData: any[]; filePickerResult: IFilePickerResult; pageLimit:number; + displayMode: DisplayMode; } export default class HeroWebpartWebPart extends BaseClientSideWebPart { @@ -42,9 +44,11 @@ export default class HeroWebpartWebPart extends BaseClientSideWebPartAuthor: `, + description: `Author:
  • Omar El-Anis
`, key: 'authors' }), PropertyPaneTextField('title', { @@ -132,11 +136,20 @@ export default class HeroWebpartWebPart extends BaseClientSideWebPart { public render(): React.ReactElement { - //const classTotal = "itemShow"+this.props.totalShow; const items = this.props.items; - const viewType = items.length==1 ? "heroOne" : items.length==2 ? "heroTwo" : items.length==3 ? "heroThree" : + const viewType = this.props.isCollage ? "heroCollage" : items.length==1 ? "heroOne" : items.length==2 ? "heroTwo" : items.length==3 ? "heroThree" : items.length==4 ? "heroFour" : items.length==5 ? "heroFive" : "heroFive"; var arr = []; arr.push(items); @@ -25,7 +24,7 @@ export default class Hero extends React.Component { className={styles.heroItem} items={arr} getItemCountForPage={this._getItemCountForPage} - onRenderCell={this._onRenderHeroItem} + onRenderCell={this.props.isCollage?this._onRenderHeroCollage:this._onRenderHeroItem} {...this.props.listProps} /> @@ -70,4 +69,25 @@ export default class Hero extends React.Component { ); } + + private _onRenderHeroCollage = (items: any, index: number | undefined): JSX.Element => { + const thumbRend = "https://media.akamai.odsp.cdn.office.net/uksouth1-mediap.svc.ms/transform/thumbnail?provider=url&inputFormat=jpg&docid="; + var smalltemUrl; + return( + + ); + } } \ No newline at end of file diff --git a/samples/react-hero-webpart/src/webparts/heroWebpart/components/HeroWebpart.module.scss b/samples/react-hero-webpart/src/webparts/heroWebpart/components/HeroWebpart.module.scss index f7e3970da..4ce15cbaf 100644 --- a/samples/react-hero-webpart/src/webparts/heroWebpart/components/HeroWebpart.module.scss +++ b/samples/react-hero-webpart/src/webparts/heroWebpart/components/HeroWebpart.module.scss @@ -284,6 +284,65 @@ font-size: 14px; } } + + :global(.heroCollage) .collageContainer + { + display: flex; + flex-direction: row; + flex-wrap: wrap; + align-items: center; + + .collageitem { + overflow: hidden; + flex-shrink: 1; + padding: 6px; + width: calc(33% - 12px); + a{ + width: 100%; + } + img{ + width: inherit; + } + .heroTitle { + font-size: 14px; + width: calc(33% - 22px); + margin: -80px 0px 0px 0px; + position: absolute; + bottom: unset; + } + .heroTitleHover{ + font-size: 16px; + } + .info{ + font-size: 12px; + } + .description{ + @include ms-fontColor-white; + position: absolute; + margin: -90px 0px 0px 0px; + bottom: unset; + background: rgba(0, 0, 0, 0); + width: calc(33% - 22px); + transition: .5s ease; + font-size: 18px; + padding: 20px 0px;; + text-align: center; + } + } + + .collageItemInner:hover { + .description { + background: rgba(0, 0, 0, 0.9); + width: calc(33% - 22px); + position: absolute; + margin: -90px 0px 0px 0px; + bottom: unset; + .info,.heroTitleHover{ + opacity: 1; + } + } + } + } @media all and (max-width: 768px) { diff --git a/samples/react-hero-webpart/src/webparts/heroWebpart/components/HeroWebpart.tsx b/samples/react-hero-webpart/src/webparts/heroWebpart/components/HeroWebpart.tsx index 167ee24a7..801c9e6cb 100644 --- a/samples/react-hero-webpart/src/webparts/heroWebpart/components/HeroWebpart.tsx +++ b/samples/react-hero-webpart/src/webparts/heroWebpart/components/HeroWebpart.tsx @@ -8,6 +8,8 @@ import { sp } from '@pnp/sp'; import { Stack, IStackProps, IStackTokens } from 'office-ui-fabric-react/lib/Stack'; import { Label } from 'office-ui-fabric-react/lib/Label'; import { Spinner, SpinnerSize } from 'office-ui-fabric-react/lib/Spinner'; +import { Placeholder } from "@pnp/spfx-controls-react/lib/Placeholder"; +import { DisplayMode } from '@microsoft/sp-core-library'; const stackTokens: IStackTokens = { childrenGap: 20 }; @@ -87,11 +89,17 @@ export default class HeroWebpart extends React.Component - + && + ); }else{ - var itemList:any[]; - this.props.showAllHero ? itemList = this.state.itemsPaginated : itemList = this.state.items; + var itemList:any[] = this.state.items; + this.props.showAllHero && !this.props.showCollage ? itemList = this.state.itemsPaginated : itemList = this.state.items; } return ( @@ -99,9 +107,10 @@ export default class HeroWebpart extends React.Component {this.props.title} - - {this.props.showAllHero ? - + + this._getPage(page)} @@ -109,10 +118,20 @@ export default class HeroWebpart extends React.Component : "" } - + /> + + } + {!this.props.showAllHero && + + } + ); } + + private _onConfigure() { + // Context of the web part + this.props.spfxContext.propertyPane.open(); + } } diff --git a/samples/react-hero-webpart/src/webparts/heroWebpart/components/IHeroLayoutProps.ts b/samples/react-hero-webpart/src/webparts/heroWebpart/components/IHeroLayoutProps.ts index b40153204..b5b5159b2 100644 --- a/samples/react-hero-webpart/src/webparts/heroWebpart/components/IHeroLayoutProps.ts +++ b/samples/react-hero-webpart/src/webparts/heroWebpart/components/IHeroLayoutProps.ts @@ -4,4 +4,5 @@ import { IListProps } from 'office-ui-fabric-react/lib/List'; export interface IHeroLayoutProps { items:any[]; listProps?: Partial; + isCollage:boolean; } diff --git a/samples/react-hero-webpart/src/webparts/heroWebpart/components/IHeroWebpartProps.ts b/samples/react-hero-webpart/src/webparts/heroWebpart/components/IHeroWebpartProps.ts index 27655a41a..d996cbc70 100644 --- a/samples/react-hero-webpart/src/webparts/heroWebpart/components/IHeroWebpartProps.ts +++ b/samples/react-hero-webpart/src/webparts/heroWebpart/components/IHeroWebpartProps.ts @@ -1,4 +1,5 @@ import { WebPartContext } from '@microsoft/sp-webpart-base'; +import { DisplayMode } from '@microsoft/sp-core-library'; export interface IHeroWebpartProps { title: string; @@ -8,5 +9,7 @@ export interface IHeroWebpartProps { hideFirstPageJump: boolean; hideLastPageJump: boolean; showAllHero: boolean; + showCollage: boolean; items:any[]; + displayMode: DisplayMode; }