Merge pull request #1557 from joelfmrodrigues/update-react-avatar

This commit is contained in:
Hugo Bernier 2020-10-20 22:08:03 -04:00 committed by GitHub
commit dd077fc34e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1766 additions and 1233 deletions

View 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
samples/react-avatar/.gitignore vendored Normal file
View 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

View File

@ -0,0 +1,12 @@
{
"@microsoft/generator-sharepoint": {
"isCreatingSolution": true,
"environment": "spo",
"version": "1.11.0",
"libraryName": "react-avatar",
"libraryId": "b96dfed7-ec48-4082-ba50-f6c7b09143c7",
"packageManager": "npm",
"isDomainIsolated": false,
"componentType": "webpart"
}
}

View File

@ -1,89 +1,89 @@
# SPFx Avatar # SPFx Avatar
## Summary ## Summary
This is a sample web part that helps user create their avatar and save as profile picture. User can even download their avatar as PNG file. This webpart can be useful in Intranet to help user create their avatar and save it as profile picture. This is a sample web part that helps user create their avatar and save as profile picture. User can even download their avatar as PNG file. This web part can be useful in Intranet to help user create their avatar and save it as profile picture.
##
## ![directory](/samples/react-avatar/assets/reactAvatarOutcome.gif)
![directory](/samples/react-avatar/assets/reactAvatarOutcome.gif)
## Features
## Features
* Avatar Generator from multiple options available
* Avatar Generator from multiple options available * Set Avatar as Profile Picture.
* Set Avatar as Profile Picture. * Download Avatar as PNG file.
* Download Avatar as PNG file.
## Used SharePoint Framework Version
## Used SharePoint Framework Version
![drop](https://img.shields.io/badge/version-1.10.0-green.svg) ![SPFx 1.11](https://img.shields.io/badge/version-1.11.0-green.svg)
## Applies to ## Applies to
* [SharePoint Online](https://docs.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview) * [SharePoint Online](https://docs.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
## Prerequisites ## Prerequisites
* SharePoint Online tenant * SharePoint Online tenant
* You have to provide permission in SharePoint admin for accessing Graph API on behalf of your solution. We can do it before deployment as proactive steps, or after deployment. You can refer to [steps about how to do this post-deployment](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aad-tutorial#deploy-the-solution-and-grant-permissions). You have to use API Access Page of SharePoint admin and add below permission for our use case. * You have to provide permission in SharePoint admin for accessing Graph API on behalf of your solution. We can do it before deployment as proactive steps, or after deployment. You can refer to [steps about how to do this post-deployment](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aad-tutorial#deploy-the-solution-and-grant-permissions). You have to use API Access Page of SharePoint admin and add below permission for our use case.
``` ```
"webApiPermissionRequests": [ "webApiPermissionRequests": [
{ {
"resource": "Microsoft Graph", "resource": "Microsoft Graph",
"scope": "User.ReadWrite" "scope": "User.ReadWrite"
} }
] ]
``` ```
## Concepts ## Concepts
This Web Part illustrates the following concepts on top of the SharePoint Framework: This Web Part illustrates the following concepts on top of the SharePoint Framework:
* Using react framework in SPFx webpart * Using react framework in SPFx webpart
* Calling Graph API my Photo to store the image in SPFx webpart * Calling Graph API my Photo to store the image in SPFx webpart
* Usage of Material UI Tab and Dialog * Usage of Material UI Tab and Dialog
* Usage of [avataaars](https://getavataaars.com/) * Usage of [avataaars](https://getavataaars.com/)
## WebPart Properties ## WebPart Properties
Property |Type|Required| comments Property |Type|Required| comments
--------------------|----|--------|---------- --------------------|----|--------|----------
Web Part Title | Text| no| Web Part Title | Text| no|
## Solution ## Solution
The web part Use avataaars library for creating avatars and MS Graph with User.ReadWrite and User.ReadWriteAll for saving avatar as current users Profile Picture.FileSaver for downloading avatar image as png file.
The web part Use avataaars library for creating avatars and MS Graph with User.ReadWrite and User.ReadWriteAll for saving avatar as current users Profile Picture.FileSaver for downloading avatar image as png file.
Solution|Author(s)
--------|--------- Solution|Author(s)
react Avatar|Kunj Sangani --------|---------
react Avatar|Kunj Sangani
## Version history
## Version history
Version|Date|Comments
-------|----|-------- Version|Date|Comments
1.0.0|August 1, 2020|Initial release -------|----|--------
1.0.0|August 1, 2020|Initial release
1.0.1|October 20, 2020|Update to SPFx 1.11.0
## 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.**
## 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.**
## Minimal Path to Awesome
---
- Clone this repository
- in the command line run: ## Minimal Path to Awesome
- `npm install`
- `gulp build` - Clone this repository
- `gulp bundle --ship` - in the command line run:
- `gulp package-solution --ship` - `npm install`
- `Add to AppCatalog and deploy` - `gulp build`
- `gulp bundle --ship`
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-avatar" /> - `gulp package-solution --ship`
- Add to AppCatalog and deploy
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-avatar" />

View File

@ -3,7 +3,7 @@
"solution": { "solution": {
"name": "react-avatars-client-side-solution", "name": "react-avatars-client-side-solution",
"id": "b96dfed7-ec48-4082-ba50-f6c7b09143c7", "id": "b96dfed7-ec48-4082-ba50-f6c7b09143c7",
"version": "1.0.0.0", "version": "1.0.1.0",
"includeClientSideAssets": true, "includeClientSideAssets": true,
"isDomainIsolated": false, "isDomainIsolated": false,
"webApiPermissionRequests": [ "webApiPermissionRequests": [
@ -11,9 +11,16 @@
"resource": "Microsoft Graph", "resource": "Microsoft Graph",
"scope": "User.ReadWrite" "scope": "User.ReadWrite"
} }
] ],
"developer": {
"name": "Contoso",
"privacyUrl": "https://contoso.com/privacy",
"termsOfUseUrl": "https://contoso.com/terms-of-use",
"websiteUrl": "https://contoso.com/my-app",
"mpnId": "000000"
}
}, },
"paths": { "paths": {
"zippedPackage": "solution/react-avatars.sppkg" "zippedPackage": "solution/react-avatars.sppkg"
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -13,18 +13,14 @@
}, },
"dependencies": { "dependencies": {
"@material-ui/core": "^4.11.0", "@material-ui/core": "^4.11.0",
"@microsoft/sp-core-library": "1.10.0", "@microsoft/sp-core-library": "1.11.0",
"@microsoft/sp-lodash-subset": "1.10.0", "@microsoft/sp-lodash-subset": "1.11.0",
"@microsoft/sp-office-ui-fabric-core": "1.10.0", "@microsoft/sp-office-ui-fabric-core": "1.11.0",
"@microsoft/sp-property-pane": "1.10.0", "@microsoft/sp-property-pane": "1.11.0",
"@microsoft/sp-webpart-base": "1.10.0", "@microsoft/sp-webpart-base": "1.11.0",
"@types/es6-promise": "0.0.33",
"@types/react": "16.8.8",
"@types/react-dom": "16.8.3",
"@types/webpack-env": "1.13.1",
"avataaars": "^1.2.1", "avataaars": "^1.2.1",
"file-saver": "^2.0.2", "file-saver": "^2.0.2",
"office-ui-fabric-react": "6.189.2", "office-ui-fabric-react": "6.214.0",
"react": "16.8.5", "react": "16.8.5",
"react-dom": "16.8.5" "react-dom": "16.8.5"
}, },
@ -32,14 +28,14 @@
"@types/react": "16.8.8" "@types/react": "16.8.8"
}, },
"devDependencies": { "devDependencies": {
"@microsoft/sp-build-web": "1.10.0",
"@microsoft/sp-tslint-rules": "1.10.0",
"@microsoft/sp-module-interfaces": "1.10.0",
"@microsoft/sp-webpart-workbench": "1.10.0",
"@microsoft/rush-stack-compiler-3.3": "0.3.5", "@microsoft/rush-stack-compiler-3.3": "0.3.5",
"gulp": "~3.9.1", "@microsoft/sp-build-web": "1.11.0",
"@microsoft/sp-module-interfaces": "1.11.0",
"@microsoft/sp-tslint-rules": "1.11.0",
"@microsoft/sp-webpart-workbench": "1.11.0",
"@types/chai": "3.4.34", "@types/chai": "3.4.34",
"@types/mocha": "2.2.38", "@types/mocha": "2.2.38",
"ajv": "~5.2.2" "ajv": "~5.2.2",
"gulp": "~3.9.1"
} }
} }

View File

@ -1,38 +1,39 @@
{ {
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json", "extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json",
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"jsx": "react", "jsx": "react",
"declaration": true, "declaration": true,
"sourceMap": true, "sourceMap": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"skipLibCheck": true, "skipLibCheck": true,
"outDir": "lib", "outDir": "lib",
"inlineSources": false, "inlineSources": false,
"strictNullChecks": false, "strictNullChecks": false,
"noUnusedLocals": false, "noUnusedLocals": false,
"typeRoots": [ "typeRoots": [
"./node_modules/@types", "./node_modules/@types",
"./node_modules/@microsoft" "./node_modules/@microsoft"
], ],
"types": [ "types": [
"es6-promise", "es6-promise",
"webpack-env" "webpack-env"
], ],
"lib": [ "lib": [
"es5", "es5",
"dom", "dom",
"es2015.collection" "es2015.collection"
] ]
}, },
"include": [ "include": [
"src/**/*.ts" "src/**/*.ts",
], "src/**/*.tsx"
"exclude": [ ],
"node_modules", "exclude": [
"lib" "node_modules",
] "lib"
} ]
}