Merge pull request #3461 from joaojmendes/Birthdays
New react-modern-birthdays webParts
|
@ -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.16.1",
|
||||
"image": "docker.io/m365pnp/spfx:1.16.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**********"
|
|
@ -0,0 +1,352 @@
|
|||
require('@rushstack/eslint-config/patch/modern-module-resolution');
|
||||
module.exports = {
|
||||
extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'],
|
||||
parserOptions: { tsconfigRootDir: __dirname },
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.ts', '*.tsx'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
'parserOptions': {
|
||||
'project': './tsconfig.json',
|
||||
'ecmaVersion': 2018,
|
||||
'sourceType': 'module'
|
||||
},
|
||||
rules: {
|
||||
// Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin
|
||||
'@rushstack/no-new-null': 1,
|
||||
// Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin
|
||||
'@rushstack/hoist-jest-mock': 1,
|
||||
// Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security
|
||||
'@rushstack/security/no-unsafe-regexp': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/adjacent-overload-signatures': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
//
|
||||
// CONFIGURATION: By default, these are banned: String, Boolean, Number, Object, Symbol
|
||||
'@typescript-eslint/ban-types': [
|
||||
1,
|
||||
{
|
||||
'extendDefaults': false,
|
||||
'types': {
|
||||
'String': {
|
||||
'message': 'Use \'string\' instead',
|
||||
'fixWith': 'string'
|
||||
},
|
||||
'Boolean': {
|
||||
'message': 'Use \'boolean\' instead',
|
||||
'fixWith': 'boolean'
|
||||
},
|
||||
'Number': {
|
||||
'message': 'Use \'number\' instead',
|
||||
'fixWith': 'number'
|
||||
},
|
||||
'Object': {
|
||||
'message': 'Use \'object\' instead, or else define a proper TypeScript type:'
|
||||
},
|
||||
'Symbol': {
|
||||
'message': 'Use \'symbol\' instead',
|
||||
'fixWith': 'symbol'
|
||||
},
|
||||
'Function': {
|
||||
'message': 'The \'Function\' type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with \'new\'.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.'
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
// RATIONALE: Code is more readable when the type of every variable is immediately obvious.
|
||||
// Even if the compiler may be able to infer a type, this inference will be unavailable
|
||||
// to a person who is reviewing a GitHub diff. This rule makes writing code harder,
|
||||
// but writing code is a much less important activity than reading it.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/explicit-function-return-type': [
|
||||
1,
|
||||
{
|
||||
'allowExpressions': true,
|
||||
'allowTypedFunctionExpressions': true,
|
||||
'allowHigherOrderFunctions': false
|
||||
}
|
||||
],
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Rationale to disable: although this is a recommended rule, it is up to dev to select coding style.
|
||||
// Set to 1 (warning) or 2 (error) to enable.
|
||||
'@typescript-eslint/explicit-member-accessibility': 0,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-array-constructor': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
//
|
||||
// RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript.
|
||||
// This rule should be suppressed only in very special cases such as JSON.stringify()
|
||||
// where the type really can be anything. Even if the type is flexible, another type
|
||||
// may be more appropriate such as "unknown", "{}", or "Record<k,V>".
|
||||
'@typescript-eslint/no-explicit-any': 1,
|
||||
// RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch()
|
||||
// handler. Thus wherever a Promise arises, the code must either append a catch handler,
|
||||
// or else return the object to a caller (who assumes this responsibility). Unterminated
|
||||
// promise chains are a serious issue. Besides causing errors to be silently ignored,
|
||||
// they can also cause a NodeJS process to terminate unexpectedly.
|
||||
'@typescript-eslint/no-floating-promises': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'@typescript-eslint/no-for-in-array': 2,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-misused-new': 2,
|
||||
// RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks
|
||||
// a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler
|
||||
// optimizations. If you are declaring loose functions/variables, it's better to make them
|
||||
// static members of a class, since classes support property getters and their private
|
||||
// members are accessible by unit tests. Also, the exercise of choosing a meaningful
|
||||
// class name tends to produce more discoverable APIs: for example, search+replacing
|
||||
// the function "reverse()" is likely to return many false matches, whereas if we always
|
||||
// write "Text.reverse()" is more unique. For large scale organization, it's recommended
|
||||
// to decompose your code into separate NPM packages, which ensures that component
|
||||
// dependencies are tracked more conscientiously.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-namespace': [
|
||||
1,
|
||||
{
|
||||
'allowDeclarations': false,
|
||||
'allowDefinitionFiles': false
|
||||
}
|
||||
],
|
||||
// RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)"
|
||||
// that avoids the effort of declaring "title" as a field. This TypeScript feature makes
|
||||
// code easier to write, but arguably sacrifices readability: In the notes for
|
||||
// "@typescript-eslint/member-ordering" we pointed out that fields are central to
|
||||
// a class's design, so we wouldn't want to bury them in a constructor signature
|
||||
// just to save some typing.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Set to 1 (warning) or 2 (error) to enable the rule
|
||||
'@typescript-eslint/no-parameter-properties': 0,
|
||||
// RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code
|
||||
// may impact performance.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
1,
|
||||
{
|
||||
'vars': 'all',
|
||||
// Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code,
|
||||
// the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures
|
||||
// that are overriding a base class method or implementing an interface.
|
||||
'args': 'none'
|
||||
}
|
||||
],
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-use-before-define': [
|
||||
2,
|
||||
{
|
||||
'functions': false,
|
||||
'classes': true,
|
||||
'variables': true,
|
||||
'enums': true,
|
||||
'typedefs': true
|
||||
}
|
||||
],
|
||||
// Disallows require statements except in import statements.
|
||||
// In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports.
|
||||
'@typescript-eslint/no-var-requires': 'error',
|
||||
// RATIONALE: The "module" keyword is deprecated except when describing legacy libraries.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/prefer-namespace-keyword': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Rationale to disable: it's up to developer to decide if he wants to add type annotations
|
||||
// Set to 1 (warning) or 2 (error) to enable the rule
|
||||
'@typescript-eslint/no-inferrable-types': 0,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios
|
||||
'@typescript-eslint/no-empty-interface': 0,
|
||||
// RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake.
|
||||
'accessor-pairs': 1,
|
||||
// RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking.
|
||||
'dot-notation': [
|
||||
1,
|
||||
{
|
||||
'allowPattern': '^_'
|
||||
}
|
||||
],
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
'eqeqeq': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'for-direction': 1,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'guard-for-in': 2,
|
||||
// RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time
|
||||
// to split up your code.
|
||||
'max-lines': ['warn', { max: 2000 }],
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-async-promise-executor': 2,
|
||||
// RATIONALE: Deprecated language feature.
|
||||
'no-caller': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-compare-neg-zero': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-cond-assign': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-constant-condition': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-control-regex': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-debugger': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-delete-var': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-duplicate-case': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty-character-class': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty-pattern': 1,
|
||||
// RATIONALE: Eval is a security concern and a performance concern.
|
||||
'no-eval': 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-ex-assign': 2,
|
||||
// RATIONALE: System types are global and should not be tampered with in a scalable code base.
|
||||
// If two different libraries (or two versions of the same library) both try to modify
|
||||
// a type, only one of them can win. Polyfills are acceptable because they implement
|
||||
// a standardized interoperable contract, but polyfills are generally coded in plain
|
||||
// JavaScript.
|
||||
'no-extend-native': 1,
|
||||
// Disallow unnecessary labels
|
||||
'no-extra-label': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-fallthrough': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-func-assign': 1,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-implied-eval': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-invalid-regexp': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-label-var': 2,
|
||||
// RATIONALE: Eliminates redundant code.
|
||||
'no-lone-blocks': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-misleading-character-class': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-multi-str': 2,
|
||||
// RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to
|
||||
// a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()",
|
||||
// or else implies that the constructor is doing nontrivial computations, which is often
|
||||
// a poor class design.
|
||||
'no-new': 1,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
'no-new-func': 2,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
'no-new-object': 2,
|
||||
// RATIONALE: Obsolete notation.
|
||||
'no-new-wrappers': 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-octal': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
'no-octal-escape': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-regex-spaces': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-return-assign': 2,
|
||||
// RATIONALE: Security risk.
|
||||
'no-script-url': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-self-assign': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-self-compare': 2,
|
||||
// RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use
|
||||
// commas to create compound expressions. In general code is more readable if each
|
||||
// step is split onto a separate line. This also makes it easier to set breakpoints
|
||||
// in the debugger.
|
||||
'no-sequences': 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-shadow-restricted-names': 2,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-sparse-arrays': 2,
|
||||
// RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception,
|
||||
// such flexibility adds pointless complexity, by requiring every catch block to test
|
||||
// the type of the object that it receives. Whereas if catch blocks can always assume
|
||||
// that their object implements the "Error" contract, then the code is simpler, and
|
||||
// we generally get useful additional information like a call stack.
|
||||
'no-throw-literal': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-unmodified-loop-condition': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-unsafe-finally': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-unused-expressions': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-unused-labels': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-useless-catch': 1,
|
||||
// RATIONALE: Avoids a potential performance problem.
|
||||
'no-useless-concat': 1,
|
||||
// RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior.
|
||||
// Always use "let" or "const" instead.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'no-var': 2,
|
||||
// RATIONALE: Generally not needed in modern code.
|
||||
'no-void': 1,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-with': 2,
|
||||
// RATIONALE: Makes logic easier to understand, since constants always have a known value
|
||||
// @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js
|
||||
'prefer-const': 1,
|
||||
// RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused.
|
||||
'promise/param-names': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'require-atomic-updates': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'require-yield': 1,
|
||||
// "Use strict" is redundant when using the TypeScript compiler.
|
||||
'strict': [
|
||||
2,
|
||||
'never'
|
||||
],
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'use-isnan': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
// Set to 1 (warning) or 2 (error) to enable.
|
||||
// Rationale to disable: !!{}
|
||||
'no-extra-boolean-cast': 0,
|
||||
// ====================================================================
|
||||
// @microsoft/eslint-plugin-spfx
|
||||
// ====================================================================
|
||||
'@microsoft/spfx/import-requires-chunk-name': 1,
|
||||
'@microsoft/spfx/no-require-ensure': 2,
|
||||
'@microsoft/spfx/pair-react-dom-render-unmount': 1
|
||||
}
|
||||
},
|
||||
{
|
||||
// For unit tests, we can be a little bit less strict. The settings below revise the
|
||||
// defaults specified in the extended configurations, as well as above.
|
||||
files: [
|
||||
// Test files
|
||||
'*.test.ts',
|
||||
'*.test.tsx',
|
||||
'*.spec.ts',
|
||||
'*.spec.tsx',
|
||||
|
||||
// Facebook convention
|
||||
'**/__mocks__/*.ts',
|
||||
'**/__mocks__/*.tsx',
|
||||
'**/__tests__/*.ts',
|
||||
'**/__tests__/*.tsx',
|
||||
|
||||
// Microsoft convention
|
||||
'**/test/*.ts',
|
||||
'**/test/*.tsx'
|
||||
],
|
||||
rules: {}
|
||||
}
|
||||
]
|
||||
};
|
|
@ -0,0 +1,34 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
|
||||
# Build generated files
|
||||
dist
|
||||
lib
|
||||
release
|
||||
solution
|
||||
temp
|
||||
*.sppkg
|
||||
.heft
|
||||
|
||||
# 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
|
|
@ -0,0 +1,16 @@
|
|||
!dist
|
||||
config
|
||||
|
||||
gulpfile.js
|
||||
|
||||
release
|
||||
src
|
||||
temp
|
||||
|
||||
tsconfig.json
|
||||
tslint.json
|
||||
|
||||
*.log
|
||||
|
||||
.yo-rc.json
|
||||
.vscode
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"@microsoft/generator-sharepoint": {
|
||||
"plusBeta": false,
|
||||
"isCreatingSolution": false,
|
||||
"nodeVersion": "16.18.1",
|
||||
"sdksVersions": {
|
||||
"@microsoft/microsoft-graph-client": "3.0.2",
|
||||
"@microsoft/teams-js": "2.4.1"
|
||||
},
|
||||
"version": "1.16.1",
|
||||
"libraryName": "react-birthdays",
|
||||
"libraryId": "caf83914-77f3-470c-b71c-21d8820c48a9",
|
||||
"environment": "spo",
|
||||
"packageManager": "npm",
|
||||
"solutionName": "react-birthdays",
|
||||
"solutionShortDescription": "react-birthdays description",
|
||||
"skipFeatureDeployment": true,
|
||||
"isDomainIsolated": false,
|
||||
"componentType": "webpart"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
# Birthdays and Birthdays Timeline
|
||||
|
||||
## Summary
|
||||
|
||||
The Web Part(s) shows the upcoming birthdays in the company, the web parts reads birthdays from a list located on the tenant's root site with title "Birthdays."
|
||||
|
||||
![Birthdays Web Part](./src/assets/birthdays.png)
|
||||
![Birthdays Web Part](./src/assets/birthdays_teams.jpg)
|
||||
|
||||
## Compatibility
|
||||
|
||||
![SPFx 1.16.1](https://img.shields.io/badge/SPFx-1.16.1-green.svg)
|
||||
![Node.js v16 | v14](https://img.shields.io/badge/Node.js-v16%20|%20v14-green.svg)
|
||||
![SharePoint Online](https://img.shields.io/badge/SharePoint-Online-yellow.svg)
|
||||
![Workbench Hosted: Does not work with local workbench](https://img.shields.io/badge/Workbench-Hosted-yellow.svg "Does not work with local workbench")
|
||||
![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg)
|
||||
|
||||
## Applies to
|
||||
|
||||
* [SharePoint Framework](https://learn.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
|
||||
* [Microsoft 365 tenant](https://learn.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Existing list in tenant root site, with the Title "Birthdays" and columns:
|
||||
|
||||
Column Internal Name|Type|Required| comments
|
||||
--------------------|----|--------|----------
|
||||
JobTitle | Text| no
|
||||
Birthday | DateTime | true
|
||||
userAADGUID | Text | no | required if used Azure Function to get Birthdays from AAD
|
||||
Title | Text | true
|
||||
email | Text | true
|
||||
|
||||
> **IMPORTANT:** Create index on column "Birthday".
|
||||
|
||||
## Authors
|
||||
|
||||
[João Mendes](https://github.com/joaojmendes)
|
||||
|
||||
## Version history
|
||||
|
||||
Version|Date|Comments
|
||||
-------|----|--------
|
||||
1.0.0|January 31, 2023|Initial release
|
||||
|
||||
## Minimal Path to Awesome
|
||||
|
||||
* Clone this repository
|
||||
* in the command line run:
|
||||
* `npm install`
|
||||
* `gulp build`
|
||||
* `gulp bundle --ship`
|
||||
* `gulp package-solution --ship`
|
||||
* Add and Deploy Package to AppCatalog
|
||||
* Go to API Management - from SharePoint Admin Center new experience, and Approve the Permission Require to Use Graph API SCOPES
|
||||
|
||||
> 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
|
||||
|
||||
This project contains sample Birthday web parts built on the SharePoint Framework using React
|
||||
and an Azure Function to get user Birthdays from AAD.
|
||||
This sample illustrates the following concepts on top of the SharePoint Framework:
|
||||
|
||||
* using React for building SharePoint Framework client-side web parts
|
||||
* using React components for building Birthday web part
|
||||
* using MSGraph API to get data from SharePoint Lists
|
||||
* using MSGraph API to read users from AAD
|
||||
* Using React Hooks
|
||||
* using Global State Management (JOTAI)
|
||||
* using localStorage
|
||||
* using Fluent UI FrameWork
|
||||
*
|
||||
|
||||
## References
|
||||
|
||||
* [Getting started with SharePoint Framework](https://learn.microsoft.com/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||
* [Building for Microsoft teams](https://learn.microsoft.com/sharepoint/dev/spfx/build-for-teams-overview)
|
||||
* [Use Microsoft Graph in your solution](https://learn.microsoft.com/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
|
||||
* [Publish SharePoint Framework applications to the Marketplace](https://learn.microsoft.com/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
|
||||
* [Fluent UI version 9](https://github.com/microsoft/fluentui/tree/master/packages/react-components) - Converged Fluent UI components
|
||||
|
||||
## 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.
|
||||
|
||||
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.
|
||||
|
||||
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-birthdays&template=bug-report.yml&sample=react-birthdays&authors=@smaity%20@joaojmendes&title=react-birthdays%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-birthdays&template=question.yml&sample=react-birthdays&authors=@smaity%20@joaojmendes&title=react-birthdays%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-birthdays&template=question.yml&sample=react-birthdays&authors=@smaity%20@joaojmendes&title=react-birthdays%20-%20).
|
||||
|
||||
## 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-birthdays" />
|
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 519 KiB |
|
@ -0,0 +1,98 @@
|
|||
[
|
||||
{
|
||||
"name": "pnp-sp-dev-spfx-web-parts-react-modern-birthdays-timeline",
|
||||
"source": "pnp",
|
||||
"title": "Birthdays Timeline",
|
||||
"shortDescription": "Shows upcoming birthdays in the company in a timeline",
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-modern-birthdays",
|
||||
"downloadUrl": "https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-modern-birthdays",
|
||||
"longDescription": [
|
||||
"Shows upcoming birthdays in the company, laid out in a timeline"
|
||||
],
|
||||
"creationDateTime": "2023-01-31",
|
||||
"updateDateTime": "2023-01-31",
|
||||
"products": [
|
||||
"SharePoint"
|
||||
],
|
||||
"metadata": [
|
||||
{
|
||||
"key": "CLIENT-SIDE-DEV",
|
||||
"value": "React"
|
||||
},
|
||||
{
|
||||
"key": "SPFX-VERSION",
|
||||
"value": "1.16.1"
|
||||
}
|
||||
],
|
||||
"thumbnails": [
|
||||
{
|
||||
"type": "image",
|
||||
"order": 100,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-modern-birthdays/assets/birthdays.png",
|
||||
"alt": "Web Part Preview"
|
||||
}
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"gitHubAccount": "joaojmendes",
|
||||
"pictureUrl": "https://github.com/joaojmendes.png",
|
||||
"name": "João Mendes"
|
||||
}
|
||||
],
|
||||
"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"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "pnp-sp-dev-spfx-web-parts-react-modern-birthdays",
|
||||
"source": "pnp",
|
||||
"title": "Birthdays",
|
||||
"shortDescription": "Shows upcoming birthdays in the company",
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-modern-birthdays",
|
||||
"downloadUrl": "https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-modern-birthdays",
|
||||
"longDescription": [
|
||||
"The Web Part shows the upcoming birthdays in the company, the web parts reads birthdays from a list located on the tenant's root site with title \"Birthdays.\""
|
||||
],
|
||||
"creationDateTime": "2023-01-31",
|
||||
"updateDateTime": "2023-01-31",
|
||||
"products": [
|
||||
"SharePoint"
|
||||
],
|
||||
"metadata": [
|
||||
{
|
||||
"key": "CLIENT-SIDE-DEV",
|
||||
"value": "React"
|
||||
},
|
||||
{
|
||||
"key": "SPFX-VERSION",
|
||||
"value": "1.16.1"
|
||||
}
|
||||
],
|
||||
"thumbnails": [
|
||||
{
|
||||
"type": "image",
|
||||
"order": 100,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-modern-birthdays/assets/birthdays_teams.jpg",
|
||||
"alt": "Web Part Preview"
|
||||
}
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"gitHubAccount": "joaojmendes",
|
||||
"pictureUrl": "https://github.com/joaojmendes.png",
|
||||
"name": "João Mendes"
|
||||
}
|
||||
],
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||
"version": "2.0",
|
||||
"bundles": {
|
||||
"birthdays-web-part": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/webparts/birthdays/BirthdaysWebPart.js",
|
||||
"manifest": "./src/webparts/birthdays/BirthdaysWebPart.manifest.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"birthdays-timeline-web-part": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/webparts/birthdaysTimeline/BirthdaysTimelineWebPart.js",
|
||||
"manifest": "./src/webparts/birthdaysTimeline/BirthdaysTimelineWebPart.manifest.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"externals": {},
|
||||
"localizedResources": {
|
||||
"BirthdaysWebPartStrings": "lib/webparts/birthdays/loc/{locale}.js",
|
||||
"ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js",
|
||||
"PropertyControlStrings": "node_modules/@pnp/spfx-property-controls/lib/loc/{locale}.js",
|
||||
"BirthdaysTimelineWebPartStrings": "lib/webparts/birthdaysTimeline/loc/{locale}.js"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./release/assets/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "react-birthdays",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||
"solution": {
|
||||
"name": "react-birthdays-client-side-solution",
|
||||
"id": "caf83914-77f3-470c-b71c-21d8820c48a9",
|
||||
"version": "1.0.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"skipFeatureDeployment": true,
|
||||
"isDomainIsolated": false,
|
||||
"webApiPermissionRequests": [
|
||||
{
|
||||
"resource": "Microsoft Graph",
|
||||
"scope": "User.Read.All"
|
||||
},
|
||||
{
|
||||
"resource": "Microsoft Graph",
|
||||
"scope": "User.ReadBasic.All"
|
||||
},
|
||||
{
|
||||
"resource": "Microsoft Graph",
|
||||
"scope": "Sites.Read.All"
|
||||
},
|
||||
{
|
||||
"resource": "Microsoft Graph",
|
||||
"scope": "profile"
|
||||
}
|
||||
],
|
||||
"developer": {
|
||||
"name": "",
|
||||
"websiteUrl": "",
|
||||
"privacyUrl": "",
|
||||
"termsOfUseUrl": "",
|
||||
"mpnId": "Undefined-1.16.1"
|
||||
},
|
||||
"metadata": {
|
||||
"shortDescription": {
|
||||
"default": "react-birthdays "
|
||||
},
|
||||
"longDescription": {
|
||||
"default": "react-birthdays show today and upcoming birthdays "
|
||||
},
|
||||
"screenshotPaths": [],
|
||||
"videoUrl": "",
|
||||
"categories": []
|
||||
},
|
||||
"features": [
|
||||
{
|
||||
"title": "react-birthdays Feature",
|
||||
"description": "The feature that activates elements of the react-birthdays solution.",
|
||||
"id": "4e158b73-f806-44e0-b595-70ecf2fdc6e3",
|
||||
"version": "1.0.0.0"
|
||||
}
|
||||
]
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/react-birthdays.sppkg"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
|
||||
"port": 4321,
|
||||
"https": true,
|
||||
"initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
'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.`);
|
||||
|
||||
var getTasks = build.rig.getTasks;
|
||||
build.rig.getTasks = function () {
|
||||
var result = getTasks.call(build.rig);
|
||||
|
||||
result.set('serve', result.get('serve-deprecated'));
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
build.initialize(require('gulp'));
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"name": "react-birthdays",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=16.13.0 <17.0.0"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
"clean": "gulp clean",
|
||||
"test": "gulp test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.10.5",
|
||||
"@mantine/core": "^5.10.2",
|
||||
"@mantine/hooks": "^5.10.2",
|
||||
"@mantine/styles": "^5.10.2",
|
||||
"@microsoft/sp-core-library": "1.16.1",
|
||||
"@microsoft/sp-lodash-subset": "1.16.1",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.16.1",
|
||||
"@microsoft/sp-property-pane": "1.16.1",
|
||||
"@microsoft/sp-webpart-base": "1.16.1",
|
||||
"@pnp/spfx-controls-react": "3.12.0",
|
||||
"@pnp/spfx-property-controls": "^3.11.0",
|
||||
"date-fns": "^2.29.3",
|
||||
"html-to-image": "^1.11.4",
|
||||
"jotai": "^1.12.1",
|
||||
"office-ui-fabric-react": "^7.199.1",
|
||||
"react": "17.0.1",
|
||||
"react-dom": "17.0.1",
|
||||
"tslib": "2.3.1",
|
||||
"webfontloader": "^1.6.28"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/eslint-config-spfx": "1.16.1",
|
||||
"@microsoft/eslint-plugin-spfx": "1.16.1",
|
||||
"@microsoft/rush-stack-compiler-4.5": "0.2.2",
|
||||
"@microsoft/sp-build-web": "1.16.1",
|
||||
"@microsoft/sp-module-interfaces": "1.16.1",
|
||||
"@rushstack/eslint-config": "2.5.1",
|
||||
"@types/markdown-it": "^12.2.3",
|
||||
"@types/react": "17.0.45",
|
||||
"@types/react-dom": "17.0.17",
|
||||
"@types/webfontloader": "^1.6.35",
|
||||
"@types/webpack-env": "~1.15.2",
|
||||
"ajv": "^6.12.5",
|
||||
"eslint-plugin-react-hooks": "4.3.0",
|
||||
"gulp": "4.0.2",
|
||||
"typescript": "4.5.5"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 519 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,32 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { Stack } from 'office-ui-fabric-react/lib/components/Stack';
|
||||
import {
|
||||
MessageBar,
|
||||
MessageBarType,
|
||||
} from 'office-ui-fabric-react/lib/MessageBar';
|
||||
|
||||
export interface IShowMessageProps {
|
||||
message?: string;
|
||||
messageBarType: MessageBarType;
|
||||
isShow: boolean;
|
||||
}
|
||||
|
||||
export const ShowMessage: React.FunctionComponent<IShowMessageProps> = (
|
||||
props: React.PropsWithChildren<IShowMessageProps>
|
||||
) => {
|
||||
const { message, messageBarType, children, isShow } = props;
|
||||
|
||||
return (
|
||||
<>
|
||||
{isShow ? (
|
||||
<Stack horizontal horizontalAlign="center">
|
||||
<MessageBar messageBarType={messageBarType} isMultiline>
|
||||
{message}
|
||||
{children}
|
||||
</MessageBar>
|
||||
</Stack>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
export * from './ShowMessage';
|
|
@ -0,0 +1,31 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import {
|
||||
Spinner,
|
||||
SpinnerLabelPosition,
|
||||
SpinnerSize,
|
||||
} from 'office-ui-fabric-react/lib/Spinner';
|
||||
import { Stack } from 'office-ui-fabric-react/lib/Stack';
|
||||
|
||||
export interface IShowSpinnerProps {
|
||||
size?: SpinnerSize;
|
||||
label?: string;
|
||||
labelPosition?: SpinnerLabelPosition;
|
||||
isShow: boolean;
|
||||
}
|
||||
|
||||
export const ShowSpinner: React.FunctionComponent<IShowSpinnerProps> = (
|
||||
props: React.PropsWithChildren<IShowSpinnerProps>
|
||||
) => {
|
||||
const { size, label, labelPosition, isShow } = props;
|
||||
|
||||
return (
|
||||
<>
|
||||
{isShow ? (
|
||||
<Stack horizontal horizontalAlign="center" verticalAlign="center" verticalFill tokens={{padding: 30}} >
|
||||
<Spinner size={size ?? SpinnerSize.medium} label={label ?? ""} labelPosition={labelPosition ?? undefined} />
|
||||
</Stack>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
export * from './ShowSpinner';
|
|
@ -0,0 +1,43 @@
|
|||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import * as React from 'react';
|
||||
|
||||
import { DocumentCard } from '@fluentui/react';
|
||||
|
||||
import { useUtils } from '../../hooks';
|
||||
import { IUser } from '../../models/birthdays';
|
||||
import { BirthdayCardImage } from './BirthdayCardImage';
|
||||
import { BirthdayMessage } from './BirthdayMessage';
|
||||
import { BirthdayUserInfo } from './BirthdayUserInfo';
|
||||
/* import { BirthdayUserInfo } from "./BirthdayUserInfo"; */
|
||||
import { useBirthdaysStyles } from './useBirthdaysStyles';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface IBirthdayCardProps {
|
||||
user: IUser;
|
||||
}
|
||||
|
||||
export const BirthdayCard: React.FunctionComponent<IBirthdayCardProps> = (
|
||||
_props: React.PropsWithChildren<IBirthdayCardProps>
|
||||
) => {
|
||||
const { documentCardStyles } = useBirthdaysStyles();
|
||||
const { user } = _props;
|
||||
const { birthday } = user || ({} as IUser);
|
||||
const { isDateSameDayAndMonth } = useUtils();
|
||||
|
||||
const isSameDayAndMonth = React.useMemo(() => {
|
||||
const result = isDateSameDayAndMonth(birthday, new Date());
|
||||
return result;
|
||||
}, [birthday, isDateSameDayAndMonth]);
|
||||
|
||||
if (!user) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentCard styles={documentCardStyles} data-testid="birthday-card">
|
||||
<BirthdayCardImage isSameDayAndMonth={isSameDayAndMonth} data-testid="birthday-card-image" />
|
||||
<BirthdayMessage isSameDayAndMonth={isSameDayAndMonth} data-testid="birthday-card-message" />
|
||||
<BirthdayUserInfo user={user} data-testid="birthday-card-user_info" />
|
||||
</DocumentCard>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,21 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { useBirthdaysStyles } from './useBirthdaysStyles';
|
||||
|
||||
interface IBirthdayCardImageProps {
|
||||
isSameDayAndMonth: boolean;
|
||||
}
|
||||
|
||||
export const BirthdayCardImage: React.FunctionComponent<IBirthdayCardImageProps> = (props: IBirthdayCardImageProps) => {
|
||||
const { isSameDayAndMonth } = props;
|
||||
const { controlStyles } = useBirthdaysStyles();
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={
|
||||
isSameDayAndMonth ? controlStyles.todayBirthdaysImageStyles : controlStyles.upcomingBirthdaysImageStyles
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,48 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { useAtom } from 'jotai';
|
||||
|
||||
import {
|
||||
Stack,
|
||||
Text,
|
||||
} from '@fluentui/react';
|
||||
|
||||
import { globalState } from '../../jotai/atoms/birthdays';
|
||||
import { IGlobalState } from '../../models';
|
||||
import { useBirthdaysStyles } from './useBirthdaysStyles';
|
||||
|
||||
export interface IBirthdayMessage {
|
||||
isSameDayAndMonth?: boolean;
|
||||
}
|
||||
|
||||
export const BirthdayMessage: React.FunctionComponent<IBirthdayMessage> = (props: IBirthdayMessage) => {
|
||||
const { messageContainerStyles,todayMessageTextStyles, upComingMessageTextStyles } = useBirthdaysStyles();
|
||||
const [appGlobalState, ] = useAtom(globalState);
|
||||
const { todayBirthdaysMessage, upcomingBirthdaysMessage, } = appGlobalState || ({} as IGlobalState);
|
||||
const { isSameDayAndMonth } = props || ({} as IBirthdayMessage);
|
||||
|
||||
const messageTextStyles = React.useMemo(() => {
|
||||
if (isSameDayAndMonth) {
|
||||
return todayMessageTextStyles;
|
||||
} else {
|
||||
return upComingMessageTextStyles;
|
||||
}
|
||||
}, [isSameDayAndMonth, todayMessageTextStyles, upComingMessageTextStyles]);
|
||||
|
||||
const message = React.useMemo(() => {
|
||||
if (isSameDayAndMonth) {
|
||||
return todayBirthdaysMessage;
|
||||
} else {
|
||||
return upcomingBirthdaysMessage;
|
||||
}
|
||||
}, [isSameDayAndMonth, todayBirthdaysMessage, upcomingBirthdaysMessage]);
|
||||
return (
|
||||
<>
|
||||
<Stack horizontalAlign="center" horizontal styles={messageContainerStyles}>
|
||||
<Text variant="xLargePlus" styles={messageTextStyles}>
|
||||
{message ?? ""}
|
||||
</Text>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,83 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import * as React from 'react';
|
||||
|
||||
import { format } from 'date-fns';
|
||||
import { useAtom } from 'jotai';
|
||||
|
||||
import {
|
||||
Stack,
|
||||
Text,
|
||||
ThemeProvider,
|
||||
} from '@fluentui/react';
|
||||
import { LivePersona } from '@pnp/spfx-controls-react/lib/LivePersona';
|
||||
|
||||
import { useUtils } from '../../hooks';
|
||||
import { globalState } from '../../jotai/atoms/birthdays';
|
||||
import { IUser } from '../../models/birthdays';
|
||||
import { useBirthdaysStyles } from './useBirthdaysStyles';
|
||||
|
||||
export interface IBirthdayUserInfoProps {
|
||||
user: IUser;
|
||||
}
|
||||
|
||||
export const BirthdayUserInfo: React.FunctionComponent<IBirthdayUserInfoProps> = (
|
||||
props: React.PropsWithChildren<IBirthdayUserInfoProps>
|
||||
) => {
|
||||
const { isDateSameDayAndMonth } = useUtils();
|
||||
const {
|
||||
containerUserImageStyles,
|
||||
nameStyles,
|
||||
jobTitleStyles,
|
||||
birthdayStyles,
|
||||
controlStyles,
|
||||
} = useBirthdaysStyles();
|
||||
const { user } = props;
|
||||
|
||||
const { name, jobTitle, birthday, image, email } = user || ({} as IUser);
|
||||
const [appGlobalState] = useAtom(globalState);
|
||||
const { theme } = appGlobalState;
|
||||
const { context } = appGlobalState;
|
||||
const isSameDayAndMonth = React.useMemo(() => {
|
||||
const result = isDateSameDayAndMonth(birthday, new Date());
|
||||
|
||||
return result;
|
||||
}, [birthday, isDateSameDayAndMonth]);
|
||||
|
||||
const displayBirthday = React.useMemo(() => {
|
||||
if (isSameDayAndMonth) {
|
||||
return "TODAY";
|
||||
} else {
|
||||
return birthday ? format(birthday, "do MMMM ") : "";
|
||||
}
|
||||
}, [birthday, isSameDayAndMonth]);
|
||||
|
||||
if (!user) return null;
|
||||
return (
|
||||
<>
|
||||
<ThemeProvider theme={theme}>
|
||||
<Stack horizontalAlign="center" tokens={{ childrenGap: 10 }} styles={containerUserImageStyles}>
|
||||
<Stack horizontalAlign="center" tokens={{ childrenGap: 0 }}>
|
||||
<LivePersona
|
||||
upn={email}
|
||||
template={
|
||||
<>
|
||||
<img src={image} className={controlStyles.imageProfile} />
|
||||
</>
|
||||
}
|
||||
serviceScope={context.serviceScope as any}
|
||||
/>
|
||||
<Text variant="large" styles={nameStyles}>
|
||||
{name}
|
||||
</Text>
|
||||
<Text variant="smallPlus" styles={jobTitleStyles}>
|
||||
{jobTitle}
|
||||
</Text>
|
||||
</Stack>
|
||||
<Text variant="mediumPlus" styles={birthdayStyles(isSameDayAndMonth)}>
|
||||
{displayBirthday}
|
||||
</Text>
|
||||
</Stack>
|
||||
</ThemeProvider>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,40 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import strings from 'BirthdaysWebPartStrings';
|
||||
import { Provider } from 'jotai';
|
||||
import { ThemeProvider } from 'office-ui-fabric-react';
|
||||
|
||||
import { Placeholder } from '@pnp/spfx-controls-react/lib/Placeholder';
|
||||
|
||||
import { BirthdaysControl } from './BirthdaysControl';
|
||||
import { IBirthdaysProps } from './IBirthdaysProps';
|
||||
|
||||
export const Birthdays: React.FunctionComponent<IBirthdaysProps> = (
|
||||
props: React.PropsWithChildren<IBirthdaysProps>
|
||||
) => {
|
||||
|
||||
const { onConfigure , theme} = props || ({} as IBirthdaysProps);
|
||||
const { pageSize, gridHeight , numberDays } = props || ({} as IBirthdaysProps);
|
||||
|
||||
if (!pageSize || !gridHeight || !numberDays) {
|
||||
return (
|
||||
<Placeholder
|
||||
iconName="Edit"
|
||||
iconText={strings.PlaceHolderIconText}
|
||||
description={strings.PlaceHolderDescription}
|
||||
buttonLabel={strings.PlaceHolderButtonLabel}
|
||||
onConfigure={onConfigure}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<ThemeProvider theme={theme}>
|
||||
<Provider>
|
||||
<BirthdaysControl {...props} />
|
||||
</Provider>
|
||||
</ThemeProvider>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,77 @@
|
|||
/* eslint-disable @typescript-eslint/no-floating-promises */
|
||||
import * as React from 'react';
|
||||
|
||||
import { useAtom } from 'jotai';
|
||||
import { Stack } from 'office-ui-fabric-react';
|
||||
|
||||
import { WebPartTitle } from '@pnp/spfx-controls-react/lib/WebPartTitle';
|
||||
|
||||
import { useBirthdays } from '../../hooks/useBirthdays';
|
||||
import { globalState } from '../../jotai/atoms/birthdays';
|
||||
import { IUser } from '../../models';
|
||||
import { ILoadResults } from '../../models/ILoadResults';
|
||||
import { IBirthdaysProps } from './IBirthdaysProps';
|
||||
import { ListBirthdays } from './ListBirthdays';
|
||||
|
||||
export const BirthdaysControl: React.FunctionComponent<IBirthdaysProps> = (
|
||||
props: React.PropsWithChildren<IBirthdaysProps>
|
||||
) => {
|
||||
const [appGlobalState, setAppGlobalState] = useAtom(globalState);
|
||||
const { theme, context, numberDays, pageSize } = props || ({} as IBirthdaysProps);
|
||||
|
||||
const { getBirthDays } = useBirthdays(context, numberDays, pageSize);
|
||||
const { title, displayMode, updateProperty } = props || ({} as IBirthdaysProps);
|
||||
|
||||
const loadUsers = React.useCallback(async (): Promise<ILoadResults> => {
|
||||
const mapdata: IUser[] = [];
|
||||
try {
|
||||
const users = (await getBirthDays()) || [];
|
||||
for (const user of users) {
|
||||
mapdata.push({
|
||||
email: user.fields.email,
|
||||
name: user.fields.Title,
|
||||
birthday: new Date(user.fields.Birthday),
|
||||
image: `/_layouts/15/userphoto.aspx?size=L&username=${user.fields.email}`,
|
||||
jobTitle: user.fields.JobTitle,
|
||||
});
|
||||
}
|
||||
return { mapdata, isloading: false, error: undefined };
|
||||
} catch (error) {
|
||||
return { mapdata: [], isloading: false, error: error };
|
||||
}
|
||||
}, [getBirthDays]);
|
||||
|
||||
React.useEffect(() => {
|
||||
(async () => {
|
||||
setAppGlobalState({
|
||||
...appGlobalState,
|
||||
...props,
|
||||
theme: theme,
|
||||
users: [],
|
||||
isLoading: true,
|
||||
error: undefined,
|
||||
|
||||
|
||||
});
|
||||
const results: ILoadResults = await loadUsers();
|
||||
const { mapdata, isloading, error } = results;
|
||||
setAppGlobalState((prev) => ({
|
||||
...prev,
|
||||
users: mapdata,
|
||||
isLoading: isloading,
|
||||
error: error,
|
||||
hasError: error !== undefined,
|
||||
}));
|
||||
})();
|
||||
}, [props]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack tokens={{padding:15}} >
|
||||
<WebPartTitle displayMode={displayMode} title={title} updateProperty={updateProperty} />
|
||||
<ListBirthdays />
|
||||
</Stack>
|
||||
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,54 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import strings from 'BirthdaysWebPartStrings';
|
||||
import { useAtom } from 'jotai';
|
||||
import {
|
||||
format,
|
||||
IconButton,
|
||||
ITooltipHostStyles,
|
||||
Stack,
|
||||
Text,
|
||||
TooltipHost,
|
||||
} from 'office-ui-fabric-react';
|
||||
|
||||
import { useId } from '@fluentui/react-hooks';
|
||||
|
||||
import { globalState } from '../../jotai/atoms/birthdays';
|
||||
import { IGlobalState } from '../../models/birthdays';
|
||||
import { useBirthdaysStyles } from './useBirthdaysStyles';
|
||||
|
||||
export interface IBirthdaysNavigationProps {
|
||||
onNextPage: () => void;
|
||||
showNextPage: boolean;
|
||||
}
|
||||
|
||||
export const BirthdaysNavigation: React.FunctionComponent<IBirthdaysNavigationProps> = (
|
||||
props: React.PropsWithChildren<IBirthdaysNavigationProps>
|
||||
) => {
|
||||
const [appGlobalState] = useAtom(globalState);
|
||||
const { users, currentShowingItems } = appGlobalState || ({} as IGlobalState);
|
||||
const { onNextPage, showNextPage } = props || ({} as IBirthdaysNavigationProps);
|
||||
const { navigationTextStyles } = useBirthdaysStyles();
|
||||
const calloutProps = { gapSpace: 0 };
|
||||
const tooltipId = useId("tooltip");
|
||||
|
||||
const hostStyles: Partial<ITooltipHostStyles> = { root: { display: "inline-block" } };
|
||||
|
||||
if (!users?.length) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Stack verticalAlign="center" horizontal horizontalAlign="end" tokens={{ childrenGap: 20, padding:10 }}>
|
||||
<Text variant="medium" styles={navigationTextStyles}>
|
||||
{format(strings.showingNumberUserMessage,currentShowingItems,users?.length) }
|
||||
</Text>
|
||||
{showNextPage ? (
|
||||
<TooltipHost content={strings.ShowNextPageToolTipLabel} id={tooltipId} calloutProps={calloutProps} styles={hostStyles}>
|
||||
<IconButton iconProps={{ iconName: "ChevronRightSmall" }} onClick={onNextPage} />
|
||||
</TooltipHost>
|
||||
) : null}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,28 @@
|
|||
import { ITheme } from '@fluentui/react';
|
||||
import {
|
||||
BaseComponentContext,
|
||||
IReadonlyTheme,
|
||||
} from '@microsoft/sp-component-base';
|
||||
import { DisplayMode } from '@microsoft/sp-core-library';
|
||||
|
||||
export interface IBirthdaysProps {
|
||||
title: string;
|
||||
numberDays: number;
|
||||
upcomingBirthdaysMessage?: string;
|
||||
upcomingBirthdaysBackgroundImage?: string;
|
||||
todayBirthdaysMessage?: string;
|
||||
todayBirthdaysBackgroundImage?: string;
|
||||
theme?:ITheme | IReadonlyTheme;
|
||||
pageSize?: number;
|
||||
isDarkTheme?: boolean;
|
||||
hasTeamsContext?: boolean;
|
||||
containerWidth?: number;
|
||||
displayMode: DisplayMode;
|
||||
updateProperty: (value: string) => void;
|
||||
context: BaseComponentContext;
|
||||
onConfigure: () => void;
|
||||
todayBirthdaysMessageColor?: string;
|
||||
upcomingBirthdaysMessageColor?: string;
|
||||
noBirthdaysMessage?: string;
|
||||
gridHeight?: number;
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
/* eslint-disable no-return-assign */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/no-floating-promises */
|
||||
import react, * as React from 'react';
|
||||
|
||||
import { useAtom } from 'jotai';
|
||||
import {
|
||||
MessageBarType,
|
||||
SpinnerSize,
|
||||
} from 'office-ui-fabric-react';
|
||||
|
||||
import { Stack } from '@fluentui/react';
|
||||
|
||||
import { DEFAULT_PAGE_SIZE } from '../../constants';
|
||||
import { globalState } from '../../jotai/atoms/birthdays';
|
||||
import { IGlobalState } from '../../models/birthdays';
|
||||
import { ShowMessage } from '../ShowMessage';
|
||||
import { ShowSpinner } from '../ShowSpinner';
|
||||
import { BirthdayCard } from './BirthdayCard';
|
||||
import { BirthdaysNavigation } from './BirthdaysNavigation';
|
||||
import { NoBirthdayCard } from './NoBirthdaysCard';
|
||||
import { useBirthdaysStyles } from './useBirthdaysStyles';
|
||||
|
||||
export interface IListBirthdaysProps {}
|
||||
|
||||
const getPageIndex = (page: number, numberItemsPerPage: number): number => {
|
||||
return page * numberItemsPerPage;
|
||||
};
|
||||
export const ListBirthdays: React.FunctionComponent<IListBirthdaysProps> = (
|
||||
props: React.PropsWithChildren<IListBirthdaysProps>
|
||||
) => {
|
||||
const [appGlobalState, setAppGlobalState] = useAtom(globalState);
|
||||
const { users, pageSize, isLoading, hasError, error, noBirthdaysMessage } = appGlobalState || ({} as IGlobalState);
|
||||
const { controlStyles } = useBirthdaysStyles();
|
||||
const [hasMore, setHasMore] = React.useState<boolean>(true);
|
||||
const pageIndex = React.useRef<number>(0);
|
||||
const [userBirthdaysToRender, setUserBirthdaysToRender] = React.useState<JSX.Element[]>([]);
|
||||
|
||||
const loadUsers = React.useCallback(
|
||||
async (pageIndex: number): Promise<JSX.Element[]> => {
|
||||
if (!users?.length) {
|
||||
return [];
|
||||
}
|
||||
const pageToRender: JSX.Element[] = [];
|
||||
const numberItemsToLoad = pageSize ?? DEFAULT_PAGE_SIZE;
|
||||
const index = getPageIndex(pageIndex, numberItemsToLoad);
|
||||
const usersToLoad = users?.slice(index, index + numberItemsToLoad);
|
||||
for (let i = 0; i < usersToLoad.length; i++) {
|
||||
const user = usersToLoad[i];
|
||||
if (user) {
|
||||
pageToRender.push(<BirthdayCard key={`${user.email}_${i}`} user={user} />);
|
||||
}
|
||||
}
|
||||
return pageToRender;
|
||||
},
|
||||
[pageIndex, users, pageSize, setHasMore]
|
||||
);
|
||||
|
||||
react.useEffect(() => {
|
||||
(async () => {
|
||||
if (isLoading) return;
|
||||
pageIndex.current = 0;
|
||||
const usersToRender = await loadUsers(pageIndex.current);
|
||||
setUserBirthdaysToRender([]);
|
||||
setAppGlobalState((prev) => ({ ...prev, currentShowingItems: usersToRender?.length }));
|
||||
setUserBirthdaysToRender(usersToRender?.length ? usersToRender : [<NoBirthdayCard key="nobirthday" noBirthdaysMessage={noBirthdaysMessage}/>]);
|
||||
setHasMore((prevHasMore) => (usersToRender?.length < users?.length ? true : false));
|
||||
})();
|
||||
}, [isLoading, loadUsers, setUserBirthdaysToRender]);
|
||||
|
||||
const onNextPage = React.useCallback(() => {
|
||||
(async () => {
|
||||
pageIndex.current = pageIndex.current + 1;
|
||||
const usersToRender = await loadUsers(pageIndex.current);
|
||||
const newBirtdaysToRender = [...userBirthdaysToRender, ...usersToRender];
|
||||
setAppGlobalState((prev) => ({ ...prev, currentShowingItems: newBirtdaysToRender.length }));
|
||||
setUserBirthdaysToRender((prevUsers) => newBirtdaysToRender);
|
||||
setHasMore((prevHasMore) => (newBirtdaysToRender?.length < users?.length ? true : false));
|
||||
})();
|
||||
}, [setUserBirthdaysToRender, loadUsers, userBirthdaysToRender, setHasMore, setAppGlobalState]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack tokens={{ childrenGap: 10 }}>
|
||||
<ShowSpinner size={SpinnerSize.large} isShow={isLoading} />
|
||||
<ShowMessage messageBarType={MessageBarType.error} isShow={hasError}>
|
||||
{error?.message}
|
||||
</ShowMessage>
|
||||
{!isLoading && !hasError && (
|
||||
<>
|
||||
<BirthdaysNavigation onNextPage={onNextPage} showNextPage={hasMore} />
|
||||
<div className={controlStyles.scrollableContainerStyles}>
|
||||
<div className={controlStyles.ContainerGrid}>{userBirthdaysToRender}</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,51 @@
|
|||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import * as React from 'react';
|
||||
|
||||
import { Stack } from 'office-ui-fabric-react/lib/Stack';
|
||||
|
||||
import {
|
||||
DocumentCard,
|
||||
FontIcon,
|
||||
Text,
|
||||
} from '@fluentui/react';
|
||||
|
||||
import { nobirthdaysImage } from '../../constants/noBrithdaysImage';
|
||||
/* import { BirthdayUserInfo } from "./BirthdayUserInfo"; */
|
||||
import { useBirthdaysStyles } from './useBirthdaysStyles';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface INoBirthdaysCardProps {
|
||||
noBirthdaysMessage: string;
|
||||
}
|
||||
|
||||
export const NoBirthdayCard: React.FunctionComponent<INoBirthdaysCardProps> = (
|
||||
props: React.PropsWithChildren<INoBirthdaysCardProps>
|
||||
) => {
|
||||
const {
|
||||
noBirthdaysDocumentCardStyles,
|
||||
controlStyles,
|
||||
containerUserImageStyles,
|
||||
messageContainerStyles,
|
||||
noBirthdayMessageTextStyles,
|
||||
} = useBirthdaysStyles();
|
||||
|
||||
const { noBirthdaysMessage } = props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentCard styles={noBirthdaysDocumentCardStyles}>
|
||||
<Stack horizontalAlign="center" horizontal styles={messageContainerStyles}>
|
||||
<Text variant="xLargePlus" styles={noBirthdayMessageTextStyles}>
|
||||
{noBirthdaysMessage ?? ""}
|
||||
</Text>
|
||||
</Stack>
|
||||
<Stack horizontalAlign="center" tokens={{ childrenGap: 25 }} styles={containerUserImageStyles}>
|
||||
<Stack horizontalAlign="center" tokens={{ childrenGap: 0 }}>
|
||||
<img src={nobirthdaysImage} className={controlStyles.imageProfile} />
|
||||
</Stack>
|
||||
<FontIcon iconName="partyWhishtle" className={controlStyles.partyWhishtle} />
|
||||
</Stack>
|
||||
</DocumentCard>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
export * from './BirthdayCard';
|
||||
export * from './BirthdayCardImage';
|
||||
export * from './BirthdayMessage';
|
||||
|
||||
export * from './BirthdayUserInfo';
|
||||
export * from './Birthdays';
|
||||
export * from './BirthdaysControl';
|
||||
export * from './IBirthdaysProps';
|
||||
export * from './ListBirthdays';
|
||||
export * from './useBirthdaysStyles';
|
|
@ -0,0 +1,373 @@
|
|||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
import React from 'react';
|
||||
|
||||
import { useAtom } from 'jotai';
|
||||
|
||||
import {
|
||||
IButtonStyles,
|
||||
IDocumentCardDetailsStyles,
|
||||
IDocumentCardStyles,
|
||||
IIconStyles,
|
||||
IImageStyles,
|
||||
IStackStyles,
|
||||
ITextStyles,
|
||||
mergeStyles,
|
||||
mergeStyleSets,
|
||||
} from '@fluentui/react';
|
||||
|
||||
import { globalState } from '../../jotai/atoms/birthdays';
|
||||
import { IGlobalState } from '../../models/birthdays';
|
||||
|
||||
export const useBirthdaysStyles = () => {
|
||||
const [appGlobalState] = useAtom(globalState);
|
||||
const {
|
||||
upcomingBirthdaysBackgroundImage,
|
||||
todayBirthdaysBackgroundImage,
|
||||
theme,
|
||||
todayBirthdaysMessageColor,
|
||||
upcomingBirthdaysMessageColor,
|
||||
gridHeight,
|
||||
} = appGlobalState || ({} as IGlobalState);
|
||||
|
||||
const containerSocialInfoStyles: IStackStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: { position: "absolute", bottom: 15, width: "100%" },
|
||||
};
|
||||
}, []);
|
||||
|
||||
const bottomIconStyles: Partial<IIconStyles> = React.useMemo(() => {
|
||||
return {
|
||||
root: { fontSize: 12, color: theme?.semanticColors?.menuIcon },
|
||||
};
|
||||
}, [theme?.semanticColors?.menuIcon]);
|
||||
|
||||
const buttonStyles: Partial<IButtonStyles> = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
borderWidth: 1.5,
|
||||
borderStyle: "solid",
|
||||
borderColor: theme?.palette?.neutralQuaternaryAlt,
|
||||
borderRadius: "50%",
|
||||
padding: 5,
|
||||
width: 25,
|
||||
height: 25,
|
||||
},
|
||||
};
|
||||
}, [theme?.palette?.neutralQuaternaryAlt]);
|
||||
|
||||
const nameStyles: ITextStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
paddingTop: 7,
|
||||
color: theme?.semanticColors?.bodyText,
|
||||
fontWeight: 600,
|
||||
},
|
||||
};
|
||||
}, [theme?.semanticColors?.bodyText]);
|
||||
const navigationTextStyles: ITextStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
color: theme?.palette.themePrimary,
|
||||
fontWeight: 500,
|
||||
},
|
||||
};
|
||||
}, [theme?.semanticColors?.bodyText]);
|
||||
|
||||
const jobTitleStyles: ITextStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
color: theme?.semanticColors?.bodySubtext,
|
||||
},
|
||||
};
|
||||
}, [theme?.semanticColors?.bodySubtext]);
|
||||
|
||||
const birthdayStyles = React.useCallback(
|
||||
(isSameDayAndMonth: boolean): ITextStyles => {
|
||||
return {
|
||||
root: {
|
||||
color: isSameDayAndMonth ? theme?.palette?.themePrimary : theme?.semanticColors?.bodySubtext,
|
||||
fontWeight: 600,
|
||||
},
|
||||
};
|
||||
},
|
||||
[theme?.palette?.themePrimary, theme?.semanticColors?.bodySubtext]
|
||||
);
|
||||
|
||||
const containerUserImageStyles: IStackStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
position: "absolute",
|
||||
top: 95,
|
||||
width: "100%",
|
||||
},
|
||||
};
|
||||
}, []);
|
||||
|
||||
const userPhotoStyles: Partial<IImageStyles> = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
margingBottom: 5,
|
||||
},
|
||||
image: {
|
||||
padding: 5,
|
||||
backgroundColor: theme?.palette?.white,
|
||||
width: 100,
|
||||
height: 100,
|
||||
border: "5px solid",
|
||||
borderColor: theme?.palette?.neutralLighter,
|
||||
borderRadius: "50%",
|
||||
},
|
||||
};
|
||||
}, [theme?.palette?.neutralLighter, theme?.palette?.white]);
|
||||
|
||||
const messageContainerStyles: IStackStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
width: "100%",
|
||||
position: "absolute",
|
||||
top: 20,
|
||||
paddingLeft: 10,
|
||||
paddingRight: 10,
|
||||
},
|
||||
};
|
||||
}, []);
|
||||
|
||||
const todayMessageTextStyles: ITextStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
fontFamily: `"Dancing Script",cursive`,
|
||||
fontWeight: 600,
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "2",
|
||||
"-webkit-box-orient": "vertical",
|
||||
overflow: "hidden",
|
||||
textAlign: "center",
|
||||
lineHeight: 30,
|
||||
fontSize: 30,
|
||||
color: todayBirthdaysMessageColor,
|
||||
height: 65,
|
||||
},
|
||||
};
|
||||
}, [todayBirthdaysMessageColor]);
|
||||
|
||||
const noBirthdayMessageTextStyles: ITextStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
fontFamily: `"Dancing Script",cursive`,
|
||||
fontWeight: 600,
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "2",
|
||||
"-webkit-box-orient": "vertical",
|
||||
overflow: "hidden",
|
||||
textAlign: "center",
|
||||
lineHeight: 30,
|
||||
fontSize: 30,
|
||||
color: theme?.semanticColors?.bodySubtext,
|
||||
height: 65,
|
||||
},
|
||||
};
|
||||
}, [theme?.semanticColors?.bodySubtext]);
|
||||
|
||||
const upComingMessageTextStyles: ITextStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
fontFamily: `"Dancing Script",cursive`,
|
||||
fontWeight: 600,
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "2",
|
||||
"-webkit-box-orient": "vertical",
|
||||
overflow: "hidden",
|
||||
textAlign: "center",
|
||||
lineHeight: 30,
|
||||
fontSize: 30,
|
||||
color: upcomingBirthdaysMessageColor,
|
||||
height: 65,
|
||||
},
|
||||
};
|
||||
}, [upcomingBirthdaysMessageColor]);
|
||||
|
||||
const documentCardDetailsStyles: IDocumentCardDetailsStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
padding: "10px 16px",
|
||||
},
|
||||
};
|
||||
}, []);
|
||||
|
||||
const stackBottomStyles: Partial<IStackStyles> = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
padding: "0px 16px",
|
||||
color: theme?.semanticColors?.bodySubtext,
|
||||
position: "absolute",
|
||||
bottom: 10,
|
||||
width: "100%",
|
||||
},
|
||||
};
|
||||
}, [theme?.semanticColors?.bodySubtext]);
|
||||
|
||||
const documentCardStyles: IDocumentCardStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
// boxShadow: "0 1.6px 3.6px 0 rgb(0 0 0 / 13%), 0 0.3px 0.9px 0 rgb(0 0 0 / 11%)",
|
||||
boxShadow: "0 2px 5px rgba(0, 0, 0, 0.1)",
|
||||
borderColor: undefined,
|
||||
position: "relative",
|
||||
maxWidth: "100%",
|
||||
minWidth: 256,
|
||||
height: 330,
|
||||
borderRadius: 8,
|
||||
overflow: "hidden",
|
||||
|
||||
":hover:after": {
|
||||
borderRadius: 8,
|
||||
|
||||
border: "unset",
|
||||
},
|
||||
":hover": {
|
||||
borderColor: theme?.palette?.neutralTertiaryAlt,
|
||||
},
|
||||
},
|
||||
};
|
||||
}, [theme?.palette?.neutralTertiaryAlt]);
|
||||
|
||||
const noBirthdaysDocumentCardStyles: IDocumentCardStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
// boxShadow: "0 1.6px 3.6px 0 rgb(0 0 0 / 13%), 0 0.3px 0.9px 0 rgb(0 0 0 / 11%)",
|
||||
boxShadow: "0 2px 5px rgba(0, 0, 0, 0.1)",
|
||||
borderColor: undefined,
|
||||
position: "relative",
|
||||
maxWidth: "100%",
|
||||
minWidth: 256,
|
||||
height: 350,
|
||||
borderRadius: 8,
|
||||
overflow: "hidden",
|
||||
backgroundColor: theme?.palette?.neutralLighterAlt,
|
||||
opacity: 0.7,
|
||||
":hover:after": {
|
||||
borderRadius: 8,
|
||||
|
||||
border: "unset",
|
||||
},
|
||||
":hover": {
|
||||
borderColor: theme?.palette?.neutralTertiaryAlt,
|
||||
},
|
||||
},
|
||||
};
|
||||
}, [theme?.palette?.neutralTertiaryAlt]);
|
||||
|
||||
const iconCancelButtonStyles: Partial<IButtonStyles> = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
color: theme?.palette?.neutralPrimary,
|
||||
marginLeft: "auto",
|
||||
marginTop: "4px",
|
||||
marginRight: "2px",
|
||||
},
|
||||
rootHovered: {
|
||||
color: theme?.palette?.neutralDark,
|
||||
},
|
||||
};
|
||||
}, [theme?.palette?.neutralDark, theme?.palette?.neutralPrimary]);
|
||||
|
||||
const controlStyles = React.useMemo(() => {
|
||||
return mergeStyleSets({
|
||||
scrollableContainerStyles: {
|
||||
position: "relative",
|
||||
height: gridHeight,
|
||||
overflowY: "auto",
|
||||
overflowX: "hidden",
|
||||
"::-webkit-scrollbar-thumb": {
|
||||
backgroundColor: theme?.palette.themeLight,
|
||||
},
|
||||
"::-webkit-scrollbar": {
|
||||
height: 10,
|
||||
width: 7,
|
||||
},
|
||||
"scrollbar-color": theme?.semanticColors.bodyFrameBackground,
|
||||
"scrollbar-width": "thin",
|
||||
},
|
||||
imageProfile: {
|
||||
padding: 5,
|
||||
backgroundColor: theme?.palette?.white,
|
||||
width: 85,
|
||||
height: 85,
|
||||
border: "5px solid",
|
||||
borderColor: theme?.palette?.neutralLighter,
|
||||
borderRadius: "50%",
|
||||
objectFit: "cover",
|
||||
},
|
||||
partyWhishtle: {
|
||||
padding: 5,
|
||||
backgroundColor: "transparent",
|
||||
width: 45,
|
||||
height: 45,
|
||||
fill: theme?.palette?.neutralSecondaryAlt,
|
||||
},
|
||||
upcomingBirthdaysImageStyles: mergeStyles({
|
||||
height: 150,
|
||||
backgroundSize: "cover",
|
||||
backgroundImage: upcomingBirthdaysBackgroundImage ? ` url(${upcomingBirthdaysBackgroundImage})` : "",
|
||||
}),
|
||||
|
||||
todayBirthdaysImageStyles: mergeStyles({
|
||||
height: 150,
|
||||
backgroundSize: "cover",
|
||||
backgroundImage: todayBirthdaysBackgroundImage ? ` url(${todayBirthdaysBackgroundImage})` : "",
|
||||
}),
|
||||
|
||||
ContainerGrid: mergeStyles({
|
||||
display: "grid",
|
||||
gridTemplateColumns: "repeat(auto-fill, minmax(min(100%, 256px), 1fr))",
|
||||
columnGap: "10px",
|
||||
rowGap: "10px",
|
||||
overflow: "auto",
|
||||
paddingRight: 10,
|
||||
paddingleft: 10,
|
||||
"::-webkit-scrollbar-thumb": {
|
||||
display: "none",
|
||||
},
|
||||
"::-webkit-scrollbar": {
|
||||
height: 10,
|
||||
width: 7,
|
||||
},
|
||||
"scrollbar-width": "thin",
|
||||
}),
|
||||
separator: mergeStyles({
|
||||
height: "1px",
|
||||
backgroundColor: theme?.palette?.neutralLight,
|
||||
opacity: theme?.isInverted ? "0.2" : "1",
|
||||
width: "100%",
|
||||
}),
|
||||
});
|
||||
}, [
|
||||
todayBirthdaysBackgroundImage,
|
||||
upcomingBirthdaysBackgroundImage,
|
||||
theme?.isInverted,
|
||||
theme?.palette?.neutralLight,
|
||||
gridHeight,
|
||||
]);
|
||||
|
||||
return {
|
||||
messageContainerStyles,
|
||||
userPhotoStyles,
|
||||
todayMessageTextStyles,
|
||||
upComingMessageTextStyles,
|
||||
noBirthdayMessageTextStyles,
|
||||
controlStyles,
|
||||
documentCardStyles,
|
||||
documentCardDetailsStyles,
|
||||
containerUserImageStyles,
|
||||
stackBottomStyles,
|
||||
nameStyles,
|
||||
jobTitleStyles,
|
||||
birthdayStyles,
|
||||
bottomIconStyles,
|
||||
buttonStyles,
|
||||
containerSocialInfoStyles,
|
||||
iconCancelButtonStyles,
|
||||
noBirthdaysDocumentCardStyles,
|
||||
navigationTextStyles,
|
||||
};
|
||||
};
|
|
@ -0,0 +1,27 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { ThemeProvider } from 'office-ui-fabric-react';
|
||||
|
||||
import { MantineProvider } from '@mantine/core';
|
||||
|
||||
import {
|
||||
useMantineThemeFromFluentTheme,
|
||||
} from '../../hooks/useMantineThemeFromFluentTheme';
|
||||
import { BirthdaysTimelineControl } from './BirthdaysTimelineControl';
|
||||
import { IBirthdaysTimelineProps } from './IBirthdaysTimelineProps';
|
||||
|
||||
export const BirthdaysTimeline: React.FunctionComponent<IBirthdaysTimelineProps> = (props: React.PropsWithChildren<IBirthdaysTimelineProps>) => {
|
||||
const { theme } = props;
|
||||
const mantineTheme = useMantineThemeFromFluentTheme(theme);
|
||||
return (
|
||||
<>
|
||||
<MantineProvider theme={ mantineTheme} withCSSVariables={false}>
|
||||
<ThemeProvider theme={theme}>
|
||||
<BirthdaysTimelineControl {...props} />
|
||||
</ThemeProvider>
|
||||
</MantineProvider>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/* eslint-disable @typescript-eslint/no-floating-promises */
|
||||
import * as React from 'react';
|
||||
|
||||
import { useAtom } from 'jotai';
|
||||
import { Stack } from 'office-ui-fabric-react/lib/Stack';
|
||||
|
||||
import { WebPartTitle } from '@pnp/spfx-controls-react/lib/WebPartTitle';
|
||||
|
||||
import { useBirthdays } from '../../hooks/useBirthdays';
|
||||
import { globalState } from '../../jotai/atoms/birthdaysTimeline/globalState';
|
||||
import { IUser } from '../../models/birthdays';
|
||||
import { ILoadResults } from '../../models/ILoadResults';
|
||||
import { IBirthdaysTimelineProps } from './IBirthdaysTimelineProps';
|
||||
import { RenderTimeline } from './RenderTimeLine';
|
||||
|
||||
export const BirthdaysTimelineControl: React.FunctionComponent<IBirthdaysTimelineProps> = (props: React.PropsWithChildren<IBirthdaysTimelineProps>) => {
|
||||
const { displayMode, title, updateProperty, context, numberDays, pageSize, theme} = props;
|
||||
const { getBirthDays } = useBirthdays(context, numberDays, pageSize);
|
||||
const [appGlobalState, setAppGlobalState] =useAtom(globalState)
|
||||
|
||||
const loadUsers = React.useCallback(async (): Promise<ILoadResults> => {
|
||||
const mapdata: IUser[] = [];
|
||||
try {
|
||||
const users = (await getBirthDays()) || [];
|
||||
for (const user of users) {
|
||||
mapdata.push({
|
||||
email: user.fields.email,
|
||||
name: user.fields.Title,
|
||||
birthday: new Date(user.fields.Birthday),
|
||||
image: `/_layouts/15/userphoto.aspx?size=L&username=${user.fields.email}`,
|
||||
jobTitle: user.fields.JobTitle,
|
||||
});
|
||||
}
|
||||
return { mapdata, isloading: false, error: undefined };
|
||||
} catch (error) {
|
||||
return { mapdata: [], isloading: false, error: error };
|
||||
}
|
||||
}, [getBirthDays]);
|
||||
|
||||
|
||||
React.useEffect(() => {
|
||||
(async () => {
|
||||
setAppGlobalState({
|
||||
...appGlobalState,
|
||||
...props,
|
||||
theme: theme,
|
||||
users: [],
|
||||
isLoading: true,
|
||||
error: undefined,
|
||||
});
|
||||
const results: ILoadResults = await loadUsers();
|
||||
const { mapdata, isloading, error } = results;
|
||||
setAppGlobalState((prev) => ({
|
||||
...prev,
|
||||
users: mapdata,
|
||||
isLoading: isloading,
|
||||
error: error,
|
||||
hasError: error !== undefined,
|
||||
}));
|
||||
})();
|
||||
}, [props]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack horizontalAlign="start" >
|
||||
<WebPartTitle displayMode={displayMode} title={title} updateProperty={updateProperty} />
|
||||
<RenderTimeline data-testid="birthdayTimeline-card"/>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,21 @@
|
|||
import { ITheme } from 'office-ui-fabric-react/lib/Styling';
|
||||
|
||||
import {
|
||||
BaseComponentContext,
|
||||
IReadonlyTheme,
|
||||
} from '@microsoft/sp-component-base';
|
||||
import { DisplayMode } from '@microsoft/sp-core-library';
|
||||
|
||||
export interface IBirthdaysTimelineProps {
|
||||
title: string;
|
||||
numberDays: number;
|
||||
isDarkTheme: boolean;
|
||||
hasTeamsContext: boolean;
|
||||
theme?:ITheme | IReadonlyTheme;
|
||||
context: BaseComponentContext;
|
||||
displayMode: DisplayMode;
|
||||
pageSize:number;
|
||||
updateProperty: (value: string) => void;
|
||||
todayBirthdaysMessage?: string;
|
||||
noBirthdaysMessage?: string;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { Stack } from 'office-ui-fabric-react/lib/Stack';
|
||||
|
||||
import { IUser } from '../../models/IUser';
|
||||
import { RenderPersona } from './RenderPersona';
|
||||
import { useBirthdaysTimelineStyles } from './useBirthdaysTimelineStyles';
|
||||
|
||||
export interface IRenderItemProps {
|
||||
user: IUser;
|
||||
onSelect: (user: IUser) => void;
|
||||
isBirthdayToday?: boolean;
|
||||
}
|
||||
|
||||
export const RenderItem: React.FunctionComponent<IRenderItemProps> = (
|
||||
props: React.PropsWithChildren<IRenderItemProps>
|
||||
) => {
|
||||
const { user, onSelect } = props;
|
||||
|
||||
const { renderItemStyles } = useBirthdaysTimelineStyles();
|
||||
|
||||
const { name } = user;
|
||||
|
||||
const onMouseEnter = React.useCallback(() => {
|
||||
if (onSelect) onSelect(user);
|
||||
}, [user]);
|
||||
const onMouseLeave = React.useCallback(() => {
|
||||
if (onSelect) onSelect(undefined);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack
|
||||
styles={renderItemStyles}
|
||||
tokens={{ childrenGap: 10 }}
|
||||
horizontalAlign="start"
|
||||
verticalAlign="center"
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
title={name}
|
||||
>
|
||||
<RenderPersona user={user} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,38 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import {
|
||||
Stack,
|
||||
StackItem,
|
||||
Text,
|
||||
} from 'office-ui-fabric-react';
|
||||
|
||||
import { IUser } from '../../models';
|
||||
import { useBirthdaysTimelineStyles } from './useBirthdaysTimelineStyles';
|
||||
|
||||
/* import { useBirthdaysTimelineStyles } from './useBirthdaysTimelineStyles'; */
|
||||
|
||||
|
||||
export interface IRenderPersonaProps {
|
||||
user: IUser;
|
||||
|
||||
}
|
||||
|
||||
export const RenderPersona: React.FunctionComponent<IRenderPersonaProps> = (
|
||||
props: React.PropsWithChildren<IRenderPersonaProps>
|
||||
) => {
|
||||
const { user, } = props;
|
||||
const { name, jobTitle, image, } = user;
|
||||
const { personalPrimaryText, personalSecondaryText ,controlStyles} = useBirthdaysTimelineStyles();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack horizontal horizontalAlign="start" tokens={{childrenGap:7}}>
|
||||
<img src={image} className={controlStyles.imageProfile} />
|
||||
<StackItem >
|
||||
<Text variant="medium" styles={personalPrimaryText}> {name}</Text>
|
||||
<Text variant="small" styles={personalSecondaryText} > { jobTitle}</Text>
|
||||
</StackItem>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,132 @@
|
|||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
import * as React from 'react';
|
||||
|
||||
import format from 'date-fns/format';
|
||||
import { useAtom } from 'jotai';
|
||||
import {
|
||||
MessageBarType,
|
||||
SpinnerSize,
|
||||
Stack,
|
||||
} from 'office-ui-fabric-react';
|
||||
import {
|
||||
DocumentCard,
|
||||
DocumentCardDetails,
|
||||
} from 'office-ui-fabric-react/lib/DocumentCard';
|
||||
|
||||
import {
|
||||
Timeline,
|
||||
TimelineItem,
|
||||
} from '@mantine/core';
|
||||
import { groupBy } from '@microsoft/sp-lodash-subset';
|
||||
|
||||
import { ballonsImage } from '../../constants/ballons';
|
||||
import { congratulationsImage } from '../../constants/congratulationsImage';
|
||||
import { useUtils } from '../../hooks/useUtils';
|
||||
import { globalState } from '../../jotai/atoms/birthdaysTimeline/globalState';
|
||||
import { IUser } from '../../models/IUser';
|
||||
import { ShowMessage } from '../ShowMessage';
|
||||
import { ShowSpinner } from '../ShowSpinner';
|
||||
import { RenderItem } from './RenderItem';
|
||||
import { RenderTitle } from './RenderTitle';
|
||||
import { useBirthdaysTimelineStyles } from './useBirthdaysTimelineStyles';
|
||||
|
||||
export interface IRenderTimelineProps {}
|
||||
|
||||
export const RenderTimeline: React.FunctionComponent<IRenderTimelineProps> = (
|
||||
props: React.PropsWithChildren<IRenderTimelineProps>
|
||||
) => {
|
||||
const [appGlobalState, setAppGlobalState] = useAtom(globalState);
|
||||
const { users, noBirthdaysMessage, isLoading, hasError, error } = appGlobalState;
|
||||
const usersGroupedByDate = React.useMemo(() => groupBy(users, "birthday"), [users]);
|
||||
const { documentCardStyles, documentCardDetailsStyles, controlStyles } = useBirthdaysTimelineStyles();
|
||||
const { isDateSameDayAndMonth } = useUtils();
|
||||
|
||||
const isSameDayAndMonth = React.useCallback(
|
||||
(date: Date) => {
|
||||
const result = isDateSameDayAndMonth(date, new Date());
|
||||
return result;
|
||||
},
|
||||
[isDateSameDayAndMonth]
|
||||
);
|
||||
|
||||
const onSelect = React.useCallback((user) => setAppGlobalState({ ...appGlobalState, selectedUser: user }), [
|
||||
appGlobalState,
|
||||
]);
|
||||
|
||||
const onRenderUsers = React.useCallback(
|
||||
(users: IUser[], isBrithdayDay: boolean) => {
|
||||
return users.map((user, index) => {
|
||||
return <>
|
||||
|
||||
<RenderItem key={index} user={user} onSelect={onSelect} isBirthdayToday={isBrithdayDay} />
|
||||
|
||||
|
||||
</>;
|
||||
});
|
||||
},
|
||||
[users]
|
||||
);
|
||||
|
||||
const renderGroups = React.useCallback(() => {
|
||||
return Object.keys(usersGroupedByDate).map((key, index) => {
|
||||
const IsBrithdayDay = isSameDayAndMonth(new Date(key));
|
||||
const users = usersGroupedByDate[key];
|
||||
const date = new Date(key);
|
||||
const formattedDate = format(date, "dd MMMM");
|
||||
|
||||
return (
|
||||
<TimelineItem
|
||||
key={index}
|
||||
|
||||
title={<RenderTitle isDateToday={IsBrithdayDay} title={formattedDate} />}
|
||||
bullet={
|
||||
IsBrithdayDay ? (
|
||||
<img src={congratulationsImage} className={controlStyles.imageProfile} title={"congratulations"} />
|
||||
) : null
|
||||
}
|
||||
bulletSize={IsBrithdayDay ? 36 : 24}
|
||||
>
|
||||
<div className={controlStyles.usersContainer}>
|
||||
{onRenderUsers(users, IsBrithdayDay)}
|
||||
</div>
|
||||
|
||||
</TimelineItem>
|
||||
);
|
||||
});
|
||||
}, [usersGroupedByDate]);
|
||||
|
||||
const renderNoBirthdays = React.useCallback(() => {
|
||||
return (
|
||||
<Stack horizontalAlign="center" verticalAlign="center" tokens={{ childrenGap: 50 }}>
|
||||
<RenderTitle isDateToday={false} title={noBirthdaysMessage} />
|
||||
<img src={ballonsImage} className={controlStyles.ballons} title={noBirthdaysMessage} />
|
||||
</Stack>
|
||||
);
|
||||
}, [noBirthdaysMessage]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentCard styles={documentCardStyles}>
|
||||
<ShowSpinner size={SpinnerSize.large} isShow={isLoading} />
|
||||
<ShowMessage messageBarType={MessageBarType.error} isShow={hasError}>
|
||||
{error?.message}
|
||||
</ShowMessage>
|
||||
{!isLoading && !hasError && (
|
||||
<DocumentCardDetails styles={documentCardDetailsStyles}>
|
||||
<div className={controlStyles.scrollableContainerStyles}>
|
||||
<Stack horizontalAlign="center" tokens={{ padding: 15 }}>
|
||||
<Timeline active={1} bulletSize={24} lineWidth={2} radius={"xl"} >
|
||||
|
||||
|
||||
|
||||
{users?.length ? renderGroups() : renderNoBirthdays()}
|
||||
|
||||
</Timeline>
|
||||
</Stack>
|
||||
</div>
|
||||
</DocumentCardDetails>
|
||||
)}
|
||||
</DocumentCard>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { IUser } from '../../models';
|
||||
|
||||
export interface IRenderTimeLineItemsProps {
|
||||
usersGroupedByDate: { [key: string]: IUser[] };
|
||||
onSelect: (user: IUser) => void;
|
||||
}
|
||||
|
||||
export const RenderTimeLineItems: React.FunctionComponent<IRenderTimeLineItemsProps> = (
|
||||
props: React.PropsWithChildren<IRenderTimeLineItemsProps>
|
||||
) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
{}
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,52 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { useAtom } from 'jotai';
|
||||
import {
|
||||
Stack,
|
||||
Text,
|
||||
} from 'office-ui-fabric-react';
|
||||
|
||||
import { globalState } from '../../jotai/atoms/birthdaysTimeline';
|
||||
import { IGlobalState } from '../../models/birthdaysTimeline';
|
||||
import { useBirthdaysTimelineStyles } from './useBirthdaysTimelineStyles';
|
||||
|
||||
export interface IRenderTitleProps {
|
||||
title: string;
|
||||
isDateToday?: boolean;
|
||||
}
|
||||
const TODAY = "TODAY";
|
||||
export const RenderTitle: React.FunctionComponent<IRenderTitleProps> = (
|
||||
props: React.PropsWithChildren<IRenderTitleProps>
|
||||
) => {
|
||||
const { title, isDateToday } = props;
|
||||
const [appGlobalState] = useAtom(globalState);
|
||||
const { todayBirthdaysMessage } = appGlobalState || ({} as IGlobalState);
|
||||
const { messageCongratulationStyles, todayStyles } = useBirthdaysTimelineStyles();
|
||||
|
||||
if (!title) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isDateToday) {
|
||||
return (
|
||||
<>
|
||||
<Text variant="medium" styles={todayStyles} nowrap>
|
||||
{title}
|
||||
</Text>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack tokens={{ childrenGap: 10 }} horizontalAlign="start">
|
||||
<Text variant="xLargePlus" styles={messageCongratulationStyles}>
|
||||
{todayBirthdaysMessage ?? "Congratulations !"}
|
||||
</Text>
|
||||
<Text variant="medium" styles={todayStyles}>
|
||||
{TODAY}
|
||||
</Text>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,255 @@
|
|||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
import React from 'react';
|
||||
|
||||
import { useAtom } from 'jotai';
|
||||
import { IButtonStyles } from 'office-ui-fabric-react/lib/Button';
|
||||
import { IStackStyles } from 'office-ui-fabric-react/lib/components/Stack';
|
||||
import { IIconStyles } from 'office-ui-fabric-react/lib/Icon';
|
||||
import { mergeStyles } from 'office-ui-fabric-react/lib/Styling';
|
||||
import { ITextStyles } from 'office-ui-fabric-react/lib/Text';
|
||||
|
||||
import {
|
||||
IDocumentCardDetailsStyles,
|
||||
IDocumentCardStyles,
|
||||
IPersonaStyles,
|
||||
mergeStyleSets,
|
||||
} from '@fluentui/react';
|
||||
import { createStyles } from '@mantine/core';
|
||||
|
||||
import { globalState } from '../../jotai/atoms/birthdaysTimeline';
|
||||
import { IGlobalState } from '../../models/birthdays';
|
||||
|
||||
export const useBirthdaysTimelineStyles = () => {
|
||||
const [appGlobalState] = useAtom(globalState);
|
||||
const { theme } = appGlobalState || ({} as IGlobalState);
|
||||
|
||||
const bottomIconStyles: Partial<IIconStyles> = React.useMemo(() => {
|
||||
return {
|
||||
root: { fontSize: 14, color: theme?.semanticColors?.menuIcon },
|
||||
};
|
||||
}, [theme?.semanticColors?.menuIcon]);
|
||||
|
||||
const buttonStyles: Partial<IButtonStyles> = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
borderWidth: 0,
|
||||
borderStyle: "solid",
|
||||
borderColor: theme?.palette?.neutralQuaternaryAlt,
|
||||
},
|
||||
};
|
||||
}, [theme?.palette?.neutralQuaternaryAlt]);
|
||||
|
||||
const renderItemStyles: IStackStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
padding: 10,
|
||||
paddingBottom: 5,
|
||||
paddingTop: 5,
|
||||
":hover": {
|
||||
backgroundColor: theme?.palette.neutralLighterAlt,
|
||||
boxShadow: theme?.effects.elevation4,
|
||||
},
|
||||
},
|
||||
};
|
||||
}, [theme?.effects.elevation4, theme?.palette.neutralLighterAlt]);
|
||||
|
||||
const messageCongratulationStyles: ITextStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
fontFamily: `"Dancing Script",cursive`,
|
||||
fontWeight: 600,
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "1",
|
||||
"-webkit-box-orient": "vertical",
|
||||
overflow: "hidden",
|
||||
textAlign: "start",
|
||||
lineHeight: 35,
|
||||
fontSize: 30,
|
||||
wordBreak: "break-word",
|
||||
color: theme?.palette?.themePrimary,
|
||||
},
|
||||
};
|
||||
}, [theme?.palette?.themePrimary]);
|
||||
|
||||
const todayStyles: ITextStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
fontWeight: 600,
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "1",
|
||||
"-webkit-box-orient": "vertical",
|
||||
overflow: "hidden",
|
||||
color: theme?.palette?.themePrimary,
|
||||
|
||||
},
|
||||
|
||||
};
|
||||
}, [theme?.palette.themePrimary]);
|
||||
|
||||
const documentCardDetailsStyles: IDocumentCardDetailsStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
padding: 15
|
||||
},
|
||||
};
|
||||
}, []);
|
||||
|
||||
const documentCardStyles: IDocumentCardStyles = React.useMemo(() => {
|
||||
return {
|
||||
root: {
|
||||
// boxShadow: "0 1.6px 3.6px 0 rgb(0 0 0 / 13%), 0 0.3px 0.9px 0 rgb(0 0 0 / 11%)",
|
||||
boxShadow: "0 2px 5px rgba(0, 0, 0, 0.1)",
|
||||
borderColor: theme?.palette?.neutralLighter,
|
||||
position: "relative",
|
||||
width: "100%",
|
||||
maxWidth: 400,
|
||||
maxheight: 600,
|
||||
height: "100%",
|
||||
minHeight: 400,
|
||||
borderRadius: 8,
|
||||
overflow: "hidden",
|
||||
paddingBottom: 20,
|
||||
|
||||
":hover:after": {
|
||||
borderRadius: 8,
|
||||
|
||||
border: "unset",
|
||||
},
|
||||
":hover": {
|
||||
borderColor: theme?.palette?.neutralTertiaryAlt,
|
||||
},
|
||||
},
|
||||
};
|
||||
}, [theme?.palette?.neutralTertiaryAlt, theme?.palette?.neutralLighter]);
|
||||
|
||||
const personalPrimaryText :ITextStyles = React.useMemo(()=>{
|
||||
return {
|
||||
root:{
|
||||
fontWeight: 600,
|
||||
paddingRight: 10,
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "1",
|
||||
"-webkit-box-orient": "vertical",
|
||||
overflow: "hidden",
|
||||
textAlign: "start",
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
const personalSecondaryText :ITextStyles = React.useMemo(()=>{
|
||||
return {
|
||||
root:{
|
||||
paddingRight: 10,
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "1",
|
||||
"-webkit-box-orient": "vertical",
|
||||
overflow: "hidden",
|
||||
textAlign: "start",
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
const personaStyles: Partial<IPersonaStyles> = React.useMemo(() => {
|
||||
return {
|
||||
primaryText: {
|
||||
fontWeight: 600,
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "1",
|
||||
"-webkit-box-orient": "vertical",
|
||||
overflow: "hidden",
|
||||
textAlign: "start",
|
||||
},
|
||||
secondaryText: {
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "1",
|
||||
"-webkit-box-orient": "vertical",
|
||||
overflow: "hidden",
|
||||
textAlign: "start",
|
||||
}
|
||||
};
|
||||
}, [theme?.palette?.themePrimary]);
|
||||
|
||||
const controlStyles = React.useMemo(() => {
|
||||
return mergeStyleSets({
|
||||
usersContainer: mergeStyles({
|
||||
":nth-child(1n)": {
|
||||
paddingTop: 7,
|
||||
},
|
||||
}),
|
||||
imageProfile: mergeStyles({
|
||||
padding: 1,
|
||||
backgroundColor: theme?.palette?.white,
|
||||
width: 40,
|
||||
height:40,
|
||||
border: "2px solid",
|
||||
borderColor: theme?.palette?.neutralLighter,
|
||||
borderRadius: "50%",
|
||||
objectFit: "cover",
|
||||
}),
|
||||
partyWhishtle: mergeStyles({
|
||||
padding: 5,
|
||||
backgroundColor: "transparent",
|
||||
width: 45,
|
||||
height: 45,
|
||||
fill: theme?.palette?.neutralSecondaryAlt,
|
||||
}),
|
||||
ballons: mergeStyles({
|
||||
objectFit: "cover",
|
||||
height: 500,
|
||||
opacity: 0.3,
|
||||
}),
|
||||
scrollableContainerStyles: mergeStyles({
|
||||
position: "relative",
|
||||
minHeight: 300,
|
||||
height: "100%",
|
||||
maxHeight: 500,
|
||||
overflowY: "auto",
|
||||
overflowX: "hidden",
|
||||
"::-webkit-scrollbar-thumb": {
|
||||
backgroundColor: theme?.palette.themeLight,
|
||||
display: "none",
|
||||
},
|
||||
"::-webkit-scrollbar": {
|
||||
height: 10,
|
||||
width: 7,
|
||||
},
|
||||
"scrollbar-color": theme?.semanticColors.bodyFrameBackground,
|
||||
"scrollbar-width": "thin",
|
||||
}),
|
||||
separator: mergeStyles({
|
||||
height: "1px",
|
||||
paddingLeft: 10,
|
||||
paddingright: 10,
|
||||
|
||||
backgroundColor: theme?.palette?.neutralLighter,
|
||||
opacity: theme?.isInverted ? "0.2" : "1",
|
||||
width: "100%",
|
||||
}),
|
||||
});
|
||||
}, [theme?.isInverted, theme?.palette?.neutralLight]);
|
||||
|
||||
const timelineStyles = React.useCallback(
|
||||
() =>
|
||||
createStyles((theme, _params, getRef) => ({
|
||||
itemTitle: {
|
||||
color: theme?.primaryColor,
|
||||
},
|
||||
})),
|
||||
[]
|
||||
);
|
||||
|
||||
return {
|
||||
controlStyles,
|
||||
documentCardStyles,
|
||||
documentCardDetailsStyles,
|
||||
timelineStyles,
|
||||
messageCongratulationStyles,
|
||||
todayStyles,
|
||||
renderItemStyles,
|
||||
bottomIconStyles,
|
||||
buttonStyles,
|
||||
personaStyles,
|
||||
personalPrimaryText,
|
||||
personalSecondaryText
|
||||
};
|
||||
};
|
|
@ -0,0 +1,2 @@
|
|||
export * from './birthdays';
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
export const DEFAULT_PAGE_SIZE = 6;
|
||||
export const CARD_WIDTH = 256 ;
|
||||
export const birthdayListTitle = "Birthdays";
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
export * from './constants';
|
|
@ -0,0 +1,2 @@
|
|||
export const nobirthdaysImage =
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAACWCAYAAACb3McZAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAkbSURBVHhe7Z0LUxNJFIX3//8bRPDBW1FUFA0g+AAEBN+KBQHxgeOe1LBbu7nTmSQzSd/Od6q+Klezydx0n8x09+3bf42NjWUAYINBAAJgEIAAGAQgAAYBCIBBAAJgEIAAGAQgAAYBCIBBAAJgEIAAGAQgAAYBCIBBAAJgEIAAGAQgAAYBCIBBAAJgEIAAGAQgAAYBCIBBAAJgEIAAGAQgAAYBCIBBBsjU1FS2srKSbW9vZ+/fv8+Ojo5afP/+/Z8/v3v3rvXvep1eb70PDA4MUjPXr1/PXrx4kZ2enma9SP/fy5cvs9nZWfP9oV4wSE3Mz89n+/v72cXFRd7V+9eXL1+ypaUl8/OgHjBIxczNzWUfP37Mu3Q9klFkQOvzoVowSEWMj49nz58/r/SOEdLv37+zra2t7OrVq+b1QDVgkAq4ceNG61d9GNLnapxjXRf0Dwbpk4WFhez8/DzvrsPR2dlZ69HOuj7oDwzSB7dv385+/vyZd9PhStfBAL56MEiP3Lp1K/v161fePeOQxiWPHj0yrxd6A4P0wPT0dGtxL0ZpkuDu3bvmdUP3YJAumZiYyE5OTvLuGKd0Z2NhsRowSJfs7u7m3TBuHR8fMwVcARikC5aXl/Pu50N7e3tmHFAeDFISPVp9+/Yt73o+pEE7K+79gUFKooRDj/r8+bMZD5QDg5Tg2rVr0ax39KIHDx6YcUFnMEgJvN49LtVsNlu5YlZsEAaDdEBjD893j0utrq6a8UEYDNKBx48f513MtzTta8UHYTBIB4aVpVuHFhcXzRihGAwS4ObNm3nXSkPa4WjFCcVgkACNRiPvWmlI+WNXrlwxYwUbDBLg7du3eddKR0rRt2IFGwwSINaM3X707NkzM1awwSAFpDb+uJQKSljxgg0GKeD+/ft5l0pLP378MOMFGwxSwPr6et6l0pOKTFgxQzsYpACV/0xVd+7cMWOGdjBIAYeHh3l3Sk+q+2vFDO1gkAJURDpVra2tmTFDOxikAO2jSFWbm5tmzNAOBikgZYMofd+KGdrBIAXo/I5UpeMUrJihHQxSQMqDdBXZtmKGdjBIAcp8TVUbGxtmzNAOBilAv7Kp6smTJ2bM0A4GKUA1blMVpUnLg0EKUHHqVDUzM2PGDO1gkAJUtlOF11KT6vayaao8GCSAjmVOTdpjb8UKNhgkQIoJi4rJihVsMEiAe/fu5d0qHSkmK1awwSABNA5Jadutxh+Tk5NmrGCDQTqQ0oKhilBYMUIxGKQDKU33UsS6ezBICVKYzaImVm9gkBLol9e7KPfTGxikJJ73h6g6vc44seKCMBikJDrKzOvKOuntvYNBuuD169d5l/MjnauoM06seKAzGKQLVE/K22E6ykq2YoFyYJAuUckcLzo4ODBjgPJgkB7w8Kh1dnbGwLwCMEgPKAUl5pOnlFKiBU7r2qE7MEiP6Nf55OQk75LxSDNtKrxtXTN0DwbpAw3aYzKJzEFZ0WrBIH2iO0kMqSgXFxfZ8vKyeY3QOxikAjQmGebA/fz8nKPVagKDVIjK6eiAmkFKJ0Zx3kd9YJCK0SPXq1evak9LkRGpb1U/GKQmZmdna6nvq9QRnX7FzsDBgEFqRusRe3t7faeofP36tZU2wp6OwYJBCtBzvY4q02OMsmHVOZXRa722DBrILy0ttSqra5ExZBg9nuk1qkCiz52enjbfs1sWFhZa8ezs7GS7u7utuDQtrLud9XrAIP9BFT+0b1sr0UXSukdVCYAyoTrt/7Fe2w8aF3WaZdOOQ+2/13fAXepfRt4gU1NTrQNlNFXajT59+tQ6S916z5jQ3afZbOZXXU76Lp4+fUou19+MpEH0C6m7gDp5P9JMUsyFEBRjP2Mf3Uk1I6cfEev9R4GRM4g69PHxcd4FqpGe5zXGsD5vGGiGq+qFS71fVWMhT4yMQdS4/d4xQtLYZG5uzvzsQaKJAE0F1yGls+iOMkqPXiNhEM3UDGInoB5JVldXzWuoG22r1Z1sENKAflTOGEnaIBprDKMyombCBvkru7i4mJ2enuafPjg1Gg3zelIiWYOMj49nb968yZty8NKvbFXTwUXIhIO6axRJs13WtaVCkgbRnUO/4jFIC35Vz3RdTk0POjHSkhY1U64Yn6RBtFIcm7RHfGtrq6dndxleq/qqjhhjATsZNdUZruQMok1DsUuPX0pT1+OROr3SP7Sf43IlXf+tv9e/6w6k2aPYpanzFBMokzKInsm7XRFH1SnF4xWSMojm6NFwVffExKBJxiAauNa9SQl1lqabNYNotZFHkjGI9lygOLS2tma2kUeSMIgGh6EUdTRYKe3GaiePJGEQreiiuJRKlZUkDBJzGdBRlR55rbbyhnuDKIMWxadUzkR0bxDtq0ZxKoUC2u4NUuceD9SfNjY2zDbzhGuD6Bbu7cSnUZLqglnt5gnXBtHiIIpXGodY7eYJ1wbRORgobnnP8nVtEG3WQXHr4cOHZtt5wbVBhr2bDnWW9zPaXRuEBcL4pW3PVtt5wbVB2PsRv7SRymo7L7g1iAq1ofil3ZBW+3nBrUFUkRz5kOcTsNwaRJU0kA95TjlxaxBVMEQ+5Pn0XbcG0UE0yIc87zB0a5DDw8P860exy/NaiFuDsAbiR6o2Y7WhB9wahDUQPzo4ODDb0AMuDaKyMpT48aMPHz6Y7egBlwYhzd2Xjo6OzHb0gEuDqGIG8iMVk7Pa0QMuDaLylsiPtOvTakcPuDTI+vp6/tUjL4rpkNNucGmQ7e3t/GtHXuQ1H8ulQVgk9Kf5+XmzLWPHpUFiPGUJhaUTsqy2jB2XBmk2m/nXjrzIa8KiS4NQyd2fdKyc1Zax484gOmYN+dPm5qbZnrHjziAUq/YpnfBrtWfsuDOIjlFG/rS/v2+2Z+y4M8jKykr+lSNP8noCrjuDqGI48idV4bfaM3bcGWRnZyf/ypEnea2P5c4gqtSH/Ekb3Kz2jB13BmGrrU95LSDnziCsovvVxMSE2aYx484grKL7lceMXlcGmZyczL9q5FEzMzNmu8aMK4PoC0Z+5bEEqSuDsBfdtzymvLsyiFKmkV/pTEmrXWPGlUFU4xX5lYptWO0aM64MohqvyK8ajYbZrvEylv0BRxk2BoRZQcsAAAAASUVORK5CYII=";
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
export * from './useUtils';
|
|
@ -0,0 +1,73 @@
|
|||
/* eslint-disable @typescript-eslint/no-floating-promises */
|
||||
/* eslint-disable no-octal */
|
||||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
import {
|
||||
useCallback,
|
||||
useRef,
|
||||
} from 'react';
|
||||
|
||||
import {
|
||||
addDays,
|
||||
format,
|
||||
} from 'date-fns';
|
||||
|
||||
import { BaseComponentContext } from '@microsoft/sp-component-base';
|
||||
|
||||
import { birthdayListTitle } from '../constants';
|
||||
import { useLocalStorage } from './useLocalStorage';
|
||||
|
||||
export const useBirthdays = (context: BaseComponentContext, upcomingDays?: number, pageSize?:number) => {
|
||||
|
||||
const { instanceId, msGraphClientFactory, } = context;
|
||||
const upcomingDaysRef = useRef(upcomingDays);
|
||||
const [getStorageValue, setStorageValue] = useLocalStorage();
|
||||
const pageSizeRef = useRef(pageSize);
|
||||
const getDataChached = useCallback( async () => {
|
||||
const cachedData = getStorageValue(`__birthdays_users_${context.instanceId}`);
|
||||
if (cachedData && upcomingDaysRef.current === upcomingDays && pageSizeRef.current === pageSize ) {
|
||||
return JSON.parse(cachedData)
|
||||
}
|
||||
return false;
|
||||
}, [context.instanceId, upcomingDays, pageSize]);
|
||||
|
||||
const getBirthDays = useCallback(async () => {
|
||||
try {
|
||||
const dataChached = await getDataChached();
|
||||
if (dataChached) {
|
||||
return dataChached;
|
||||
}
|
||||
const today = format(new Date(), "2000-MM-dd");
|
||||
const todayMonth = format(new Date(), "MM");
|
||||
const upcomingDate = addDays(new Date(), upcomingDays);
|
||||
const upcomingMonth = format(upcomingDate, "MM");
|
||||
const newYear = "2000-01-01";
|
||||
let filter = "";
|
||||
if (Number(upcomingMonth) < Number(todayMonth)) {
|
||||
filter = `fields/Birthday ge '${today}' or (fields/Birthday ge '${newYear}' and fields/Birthday le '${format(
|
||||
upcomingDate,
|
||||
"2000-MM-dd"
|
||||
)}')`;
|
||||
} else {
|
||||
filter = `fields/Birthday ge '${today}' and fields/Birthday le '${format(upcomingDate, "2000-MM-dd")}'`;
|
||||
}
|
||||
|
||||
const graphClient = await msGraphClientFactory.getClient("3");
|
||||
const results = await graphClient
|
||||
.api(`sites/root/lists('${birthdayListTitle}')/items?orderby=Fields/Birthday`)
|
||||
.version("v1.0")
|
||||
.expand("fields")
|
||||
.filter(filter)
|
||||
.get();
|
||||
|
||||
setStorageValue(`__birthdays_users_${instanceId}`, JSON.stringify(results.value));
|
||||
|
||||
return results.value;
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
|
||||
}
|
||||
}, [upcomingDays, pageSize, instanceId, msGraphClientFactory, getDataChached, setStorageValue]);
|
||||
return {
|
||||
getBirthDays
|
||||
};
|
||||
};
|
|
@ -0,0 +1,30 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
import addSeconds from 'date-fns/addSeconds';
|
||||
import isAfter from 'date-fns/isAfter';
|
||||
|
||||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
interface IStorage {
|
||||
value: unknown;
|
||||
expires?: Date;
|
||||
}
|
||||
|
||||
const DEFAULT_EXPIRED_IN_SECONDS = 60 * 5; // 5 min
|
||||
|
||||
export const useLocalStorage = (): any => {
|
||||
const setStorageValue = (key: string, newValue: unknown, expiredInSeconds?: number) => {
|
||||
const expires = addSeconds(new Date(), expiredInSeconds ?? DEFAULT_EXPIRED_IN_SECONDS);
|
||||
sessionStorage.setItem(key, JSON.stringify({ value: newValue, expires }));
|
||||
};
|
||||
const getStorageValue = (key: string): any => {
|
||||
const storage: IStorage = JSON.parse(sessionStorage.getItem(key) || "{}");
|
||||
// getting stored value
|
||||
const { value, expires } = storage || ({} as IStorage);
|
||||
if (isAfter(new Date(expires), new Date())) {
|
||||
return value;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
return [getStorageValue, setStorageValue];
|
||||
};
|
|
@ -0,0 +1,87 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import {
|
||||
Depths,
|
||||
MotionTimings,
|
||||
} from 'office-ui-fabric-react';
|
||||
|
||||
import { MantineThemeOverride } from '@mantine/core';
|
||||
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||
|
||||
export function useMantineThemeFromFluentTheme(theme: IReadonlyTheme): MantineThemeOverride {
|
||||
|
||||
const mantineTheme: MantineThemeOverride = React.useMemo(() => {
|
||||
return {
|
||||
black: theme.palette.black,
|
||||
white: theme.palette.white,
|
||||
defaultRadius: "sm",
|
||||
colors: {
|
||||
"gray": [
|
||||
theme.palette.neutralLighterAlt,
|
||||
theme.palette.neutralLighter,
|
||||
theme.palette.neutralLight,
|
||||
theme.palette.neutralQuaternaryAlt,
|
||||
theme.palette.neutralTertiaryAlt,
|
||||
theme.palette.neutralTertiary,
|
||||
theme.palette.neutralSecondary,
|
||||
theme.palette.neutralPrimaryAlt,
|
||||
theme.palette.neutralPrimary,
|
||||
theme.palette.neutralDark,
|
||||
],
|
||||
"theme": [
|
||||
theme.palette.white,
|
||||
theme.palette.themeLighterAlt,
|
||||
theme.palette.themeLighter,
|
||||
theme.palette.themeLight,
|
||||
theme.palette.themeTertiary,
|
||||
theme.palette.themeSecondary,
|
||||
theme.palette.themePrimary,
|
||||
theme.palette.themeDarkAlt,
|
||||
theme.palette.themeDark,
|
||||
theme.palette.themeDarker,
|
||||
]
|
||||
},
|
||||
primaryColor: 'theme',
|
||||
fontFamily: theme.fonts.medium.fontFamily,
|
||||
headings: { fontFamily: theme.fonts.large.fontFamily },
|
||||
transitionTimingFunction: MotionTimings.decelerate,
|
||||
fontSizes: {
|
||||
xs: 12,
|
||||
sm: 14,
|
||||
md: 16,
|
||||
lg: 18,
|
||||
xl: 20
|
||||
},
|
||||
spacing: {
|
||||
xl: 32,
|
||||
lg: 20,
|
||||
md: 16,
|
||||
sm: 8,
|
||||
xs: 4
|
||||
},
|
||||
radius: {
|
||||
xl: 32,
|
||||
lg: 16,
|
||||
md: 8,
|
||||
sm: 4,
|
||||
xs: 2
|
||||
},
|
||||
shadows: {
|
||||
xl: theme.effects.elevation64,
|
||||
lg: theme.effects.elevation16,
|
||||
md: theme.effects.elevation8,
|
||||
sm: theme.effects.elevation4,
|
||||
xs: Depths.depth0
|
||||
},
|
||||
breakpoints: {
|
||||
xl: 1366,
|
||||
lg: 1024,
|
||||
md: 640,
|
||||
sm: 480,
|
||||
xs: 320
|
||||
}
|
||||
}
|
||||
}, [theme]);
|
||||
|
||||
return mantineTheme;
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
import * as React from 'react';
|
||||
|
||||
import {
|
||||
format,
|
||||
parseISO,
|
||||
} from 'date-fns';
|
||||
|
||||
const getDir = (radian: number, width: number, height: number): { x0: number; y0: number; x1: number; y1: number } => {
|
||||
const HALF_WIDTH = width * 0.5;
|
||||
const HALF_HEIGHT = height * 0.5;
|
||||
const lineLength = Math.abs(width * Math.sin(radian)) + Math.abs(height * Math.cos(radian));
|
||||
const HALF_LINE_LENGTH = lineLength / 2;
|
||||
|
||||
const x0 = HALF_WIDTH + Math.sin(radian) * HALF_LINE_LENGTH;
|
||||
const y0 = HALF_HEIGHT - Math.cos(radian) * HALF_LINE_LENGTH;
|
||||
const x1 = width - x0;
|
||||
const y1 = height - y0;
|
||||
|
||||
return { x0, x1, y0, y1 };
|
||||
};
|
||||
|
||||
export const useUtils = () => {
|
||||
const getTruncateText = React.useCallback((text: string, length: number) => {
|
||||
if (text.length > length) {
|
||||
return text.substring(0, length) + "...";
|
||||
}
|
||||
return text;
|
||||
}, []);
|
||||
|
||||
const getShortText = React.useCallback((text: string, length: number) => {
|
||||
if (text.length > length) {
|
||||
// const numberCharsToCut = 6;
|
||||
const first = text.substring(0, length / 2);
|
||||
const last = text.substring(text.length - length / 2, text.length);
|
||||
|
||||
const newText = first.trimEnd() + "..." + last.trimStart();
|
||||
return newText;
|
||||
}
|
||||
return text;
|
||||
}, []);
|
||||
|
||||
const getFileExtension = React.useCallback((fileName: string | undefined): string | undefined => {
|
||||
return fileName?.split(".").pop();
|
||||
}, []);
|
||||
|
||||
const getFileSize = React.useCallback((size: number): string => {
|
||||
if (size < 1024) {
|
||||
return size + " bytes";
|
||||
} else if (size < 1048576) {
|
||||
return (size / 1024).toFixed(2) + " KB";
|
||||
} else if (size < 1073741824) {
|
||||
return (size / 1048576).toFixed(2) + " MB";
|
||||
} else {
|
||||
return (size / 1073741824).toFixed(2) + " GB";
|
||||
}
|
||||
}, []);
|
||||
|
||||
const getTimeFromDate = React.useCallback((date: string): string => {
|
||||
try {
|
||||
if (date) {
|
||||
return format(parseISO(date), "dd MMM, p");
|
||||
}
|
||||
return "";
|
||||
} catch (error) {
|
||||
console.log(["getTimeFromDate"], error);
|
||||
|
||||
return "";
|
||||
}
|
||||
}, []);
|
||||
|
||||
const isDateSameDayAndMonth = (dateLeft: Date, dateRight: Date): boolean => {
|
||||
if (!dateLeft && !dateRight) {
|
||||
return false;
|
||||
}
|
||||
const dateLeftDay = format(dateLeft, "d");
|
||||
const dateLeftMonth = format(dateLeft, "M");
|
||||
const dateRightDay = format(dateRight, "d");
|
||||
const dateRightMonth = format(dateRight, "M");
|
||||
|
||||
if (dateLeftDay === dateRightDay && dateLeftMonth === dateRightMonth) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const convertBackgroundCssLinearGradientToImage = React.useCallback(
|
||||
(cssLinearGradient: string, width: number, height: number): string => {
|
||||
const split = cssLinearGradient.split("rgba");
|
||||
const rba1full = split[1].trim();
|
||||
const rba2full = split[2].trim();
|
||||
const rba1 = rba1full.substring(0, rba1full.indexOf(")") + 1);
|
||||
const rba2 = rba2full.substring(0, rba2full.indexOf(")") + 1);
|
||||
const div = document.createElement("div");
|
||||
div.style.width = width + "px";
|
||||
div.style.height = height + "px";
|
||||
div.style.background = cssLinearGradient;
|
||||
const canvaspng = document.createElement("canvas");
|
||||
canvaspng.width = width;
|
||||
canvaspng.height = height;
|
||||
|
||||
const ctx = canvaspng?.getContext("2d");
|
||||
|
||||
if (ctx) {
|
||||
const w = width;
|
||||
const h = height;
|
||||
const cssAng = 180;
|
||||
const dir = getDir(cssAng, w, h);
|
||||
const gr = ctx.createLinearGradient(dir.x0, dir.y0, dir.x1, dir.y1);
|
||||
gr.addColorStop(0, `rgba${rba1}`);
|
||||
gr.addColorStop(1, `rgba${rba2}`);
|
||||
ctx.fillStyle = gr;
|
||||
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
||||
const dataUrl = canvaspng.toDataURL("image/png");
|
||||
return dataUrl;
|
||||
}
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
return {
|
||||
convertBackgroundCssLinearGradientToImage,
|
||||
getFileSize,
|
||||
getTruncateText,
|
||||
getTimeFromDate,
|
||||
getShortText,
|
||||
getFileExtension,
|
||||
isDateSameDayAndMonth,
|
||||
};
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -0,0 +1,9 @@
|
|||
import { atom } from 'jotai';
|
||||
|
||||
import { IGlobalState } from '../../../models/birthdays';
|
||||
|
||||
export const globalState = atom<IGlobalState>({
|
||||
isLoading:true,
|
||||
error: undefined,
|
||||
hasError: false,
|
||||
} as IGlobalState);
|
|
@ -0,0 +1 @@
|
|||
export * from './globalState';
|
|
@ -0,0 +1,10 @@
|
|||
import { atom } from 'jotai';
|
||||
|
||||
import { IGlobalState } from '../../../models/birthdaysTimeline';
|
||||
|
||||
export const globalState = atom<IGlobalState>({
|
||||
isLoading:true,
|
||||
error: undefined,
|
||||
hasError: false,
|
||||
selectedUser: undefined,
|
||||
} as IGlobalState);
|
|
@ -0,0 +1 @@
|
|||
export * from './globalState';
|
|
@ -0,0 +1,9 @@
|
|||
export interface FileInfo {
|
||||
AbsoluteFileUrl: string;
|
||||
ServerRelativeUrl: string;
|
||||
FileExtension?: string;
|
||||
Id: string;
|
||||
ListId: string;
|
||||
WebId: string;
|
||||
SiteId: string;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import { IUser } from './birthdays';
|
||||
|
||||
export interface ILoadResults {
|
||||
mapdata: IUser[];
|
||||
isloading: boolean;
|
||||
error: Error;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
export interface IUser {
|
||||
name: string;
|
||||
image: string;
|
||||
birthday: Date;
|
||||
jobTitle?: string;
|
||||
email: string;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
import { ITheme } from '@fluentui/react';
|
||||
import {
|
||||
BaseComponentContext,
|
||||
IReadonlyTheme,
|
||||
} from '@microsoft/sp-component-base';
|
||||
|
||||
import { IUser } from '../IUser';
|
||||
|
||||
export interface IGlobalState {
|
||||
title: string;
|
||||
numberDays: number;
|
||||
upcomingBirthdaysMessage?: string;
|
||||
upcomingBirthdaysBackgroundImage?: string;
|
||||
todayBirthdaysMessage?: string;
|
||||
noBirthdaysMessage?: string;
|
||||
todayBirthdaysBackgroundImage?: string;
|
||||
users: IUser[];
|
||||
theme?: ITheme | IReadonlyTheme ;
|
||||
isLoading: boolean;
|
||||
hasError?: boolean;
|
||||
error? : Error;
|
||||
pageSize?: number;
|
||||
isDarkTheme?: boolean;
|
||||
hasTeamsContext?: boolean;
|
||||
containerWidth?: number;
|
||||
context: BaseComponentContext;
|
||||
todayBirthdaysMessageColor?: string;
|
||||
upcomingBirthdaysMessageColor?: string;
|
||||
adaptiveCard?: object;
|
||||
selectedUser?: IUser;
|
||||
showDialog?: boolean;
|
||||
currentPageIndex?: number;
|
||||
currentShowingItems?: number;
|
||||
gridHeight?: number;
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
export * from './IGlobalState';
|
||||
export * from '../IUser';
|
|
@ -0,0 +1,27 @@
|
|||
import { ITheme } from '@fluentui/react';
|
||||
import {
|
||||
BaseComponentContext,
|
||||
IReadonlyTheme,
|
||||
} from '@microsoft/sp-component-base';
|
||||
|
||||
import { IUser } from '../IUser';
|
||||
|
||||
export interface IGlobalState {
|
||||
title: string;
|
||||
numberDays: number;
|
||||
noBirthdaysMessage?: string;
|
||||
todayBirthdaysMessage?: string;
|
||||
users: IUser[];
|
||||
theme?: ITheme | IReadonlyTheme ;
|
||||
isLoading: boolean;
|
||||
hasError?: boolean;
|
||||
error? : Error;
|
||||
pageSize?: number;
|
||||
isDarkTheme?: boolean;
|
||||
hasTeamsContext?: boolean;
|
||||
context: BaseComponentContext;
|
||||
adaptiveCard?: object;
|
||||
selectedUser?: IUser;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export * from './IGlobalState';
|
|
@ -0,0 +1,5 @@
|
|||
export * from './FileInfo';
|
||||
export * from './ILoadResults';
|
||||
export * from './IUser';
|
||||
export * from './birthdays';
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# Load the PnP PowerShell module
|
||||
Import-Module SharePointPnPPowerShellOnline
|
||||
|
||||
param (
|
||||
[Parameter(Mandatory=$true)][string]$tenant
|
||||
)
|
||||
|
||||
# Validate the parameters
|
||||
if ($null -eq $tenant ) {
|
||||
Write-Host "Tenant is mandatory parameter. Please specify value."
|
||||
return
|
||||
}
|
||||
|
||||
# Connect to the SharePoint site
|
||||
$connection = Connect-PnPOnline -Url "https://$tenant" -Interactive
|
||||
if ($null -eq $connection) {
|
||||
Write-Host "Could not connect to the SharePoint tenant. Please check the tenant value and try again."
|
||||
return
|
||||
}
|
||||
|
||||
# Apply the PnP Provisioning Template
|
||||
Invoke-PnPSiteTemplate -Path template.xml
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
# Apply PnP Provisioning Template to SharePoint Site
|
||||
|
||||
This PowerShell script applies a PnP Provisioning Template to a SharePoint site to create the Birthdaylist on root Site.
|
||||
|
||||
## Requirements
|
||||
|
||||
- [SharePoint Online Management Shell](https://www.microsoft.com/en-us/download/details.aspx?id=35588)
|
||||
- [PnP PowerShell module](https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-pnp/sharepoint-pnp-cmdlets?view=sharepoint-ps)
|
||||
|
||||
## Usage
|
||||
|
||||
1. Download the script file `CreateBrithdaysList.zip` to your local machine.
|
||||
2. Unzip the file
|
||||
3. Open a SharePoint Online Management Shell.
|
||||
4. Run the following command to execute the script:
|
||||
|
||||
.\Create-List-Bridays.ps1 -tenant "[tenant].sharepoint.com"
|
||||
|
||||
Replace `[tenant]` with the actual value for your tenant.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `tenant`: The URL of the SharePoint Online tenant, in the format `[tenant].sharepoint.com`.
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2022/09/ProvisioningSchema">
|
||||
<pnp:Preferences Generator="PnP.Framework, Version=1.11.83.0, Culture=neutral, PublicKeyToken=0d501f89f11b748c" />
|
||||
<pnp:Templates ID="CONTAINER-TEMPLATE-270841F68E894A6EA82DBCA38EF92171">
|
||||
<pnp:ProvisioningTemplate ID="TEMPLATE-270841F68E894A6EA82DBCA38EF92171" Version="1" BaseSiteTemplate="SITEPAGEPUBLISHING#0" Scope="RootSite">
|
||||
<pnp:Lists>
|
||||
<pnp:ListInstance Title="Birthdays" Description="Birthdays" DocumentTemplate="" TemplateType="100" Url="Lists/Birthdays" EnableVersioning="true" MinorVersionLimit="0" MaxVersionLimit="50" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-de22-43b2-a848-c05709900100" EnableFolderCreation="false" DefaultDisplayFormUrl="{site}/Lists/Birthdays/DispForm.aspx" DefaultEditFormUrl="{site}/Lists/Birthdays/EditForm.aspx" DefaultNewFormUrl="{site}/Lists/Birthdays/NewForm.aspx" ImageUrl="{site}/_layouts/15/images/itgen.png?rev=47" IrmExpire="false" IrmReject="false" IsApplicationList="false" ValidationFormula="" ValidationMessage="">
|
||||
<pnp:ContentTypeBindings>
|
||||
<pnp:ContentTypeBinding ContentTypeID="0x01" Default="true" />
|
||||
<pnp:ContentTypeBinding ContentTypeID="0x0120" />
|
||||
</pnp:ContentTypeBindings>
|
||||
<pnp:Views>
|
||||
<View Name="{128CADE7-E54C-4EB5-8D56-987EA4AD11B6}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="All Items" Url="{site}/Lists/Birthdays/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="{site}/_layouts/15/images/generic.png?rev=47">
|
||||
<Query />
|
||||
<ViewFields>
|
||||
<FieldRef Name="LinkTitle" />
|
||||
<FieldRef Name="JobTitle" />
|
||||
<FieldRef Name="Birthday" />
|
||||
<FieldRef Name="userAADGUID" />
|
||||
<FieldRef Name="email" />
|
||||
</ViewFields>
|
||||
<RowLimit Paged="TRUE">30</RowLimit>
|
||||
<JSLink>clienttemplates.js</JSLink>
|
||||
<CustomFormatter />
|
||||
</View>
|
||||
</pnp:Views>
|
||||
<pnp:Fields>
|
||||
<Field Description="JobTitle" DisplayName="JobTitle" Format="Dropdown" IsModern="TRUE" MaxLength="255" Name="JobTitle" Title="JobTitle" Type="Text" ID="{578f3817-ca50-4cac-9a9a-b59ea6388e07}" SourceID="{{listid:Birthdays}}" StaticName="JobTitle" ColName="nvarchar4" RowOrdinal="0" />
|
||||
<Field Description="Birthday" DisplayName="Birthday" FriendlyDisplayFormat="Disabled" Format="DateOnly" IsModern="TRUE" Name="Birthday" Required="TRUE" Title="Birthday" Type="DateTime" ID="{3772f750-3d02-4096-8971-eb2d1d9a8f4a}" SourceID="{{listid:Birthdays}}" StaticName="Birthday" ColName="datetime1" RowOrdinal="0" Indexed="TRUE" Version="1" />
|
||||
<Field Description="userAADGUID" DisplayName="userAADGUID" Format="Dropdown" IsModern="TRUE" MaxLength="255" Name="userAADGUID" Title="userAADGUID" Type="Text" ID="{b7388871-f8a6-47ed-879d-8230dec5ee04}" SourceID="{{listid:Birthdays}}" StaticName="userAADGUID" ColName="nvarchar5" RowOrdinal="0" />
|
||||
<Field Description="email" DisplayName="email" Format="Dropdown" IsModern="TRUE" MaxLength="255" Name="email" Required="TRUE" Title="email" Type="Text" ID="{e1c39bbf-9076-44cb-9dbd-1b465eb850fd}" SourceID="{{listid:Birthdays}}" StaticName="email" ColName="nvarchar6" RowOrdinal="0" />
|
||||
</pnp:Fields>
|
||||
<pnp:FieldRefs>
|
||||
<pnp:FieldRef ID="fa564e0f-0c70-4ab9-b863-0177e6ddd247" Name="Title" Required="true" DisplayName="Title" />
|
||||
</pnp:FieldRefs>
|
||||
<pnp:Webhooks>
|
||||
<pnp:Webhook ServerNotificationUrl="https://northeurope1-0.pushnp.svc.ms/notifications?token=0f36650d-a415-4b55-a690-055ff17b1a39" ExpiresInDays="1" />
|
||||
</pnp:Webhooks>
|
||||
</pnp:ListInstance>
|
||||
</pnp:Lists>
|
||||
</pnp:ProvisioningTemplate>
|
||||
</pnp:Templates>
|
||||
</pnp:Provisioning>
|
|
@ -0,0 +1,155 @@
|
|||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { ServiceScope } from '@microsoft/sp-core-library';
|
||||
import { SPHttpClient } from '@microsoft/sp-http';
|
||||
|
||||
import { FileInfo } from '../models/FileInfo';
|
||||
import { UrlUtilities } from '../utils/UrlUtilities';
|
||||
|
||||
export class FilesService {
|
||||
private spHttpClient: SPHttpClient;
|
||||
public constructor(serviceScope: ServiceScope) {
|
||||
serviceScope.whenFinished(() => {
|
||||
this.spHttpClient = serviceScope.consume(SPHttpClient.serviceKey);
|
||||
});
|
||||
}
|
||||
public async getSPFileInfo(absoluteFileUrl: string): Promise<FileInfo> {
|
||||
try {
|
||||
// Parse URL to obtain proper web URL
|
||||
const remoteWebAbsoluteUrl = this.getSPSiteAbsoluteUrl(absoluteFileUrl);
|
||||
const fileServerRelativeUrl = this.getFileServerRelativeUrl(absoluteFileUrl);
|
||||
|
||||
const apiUrl = `${remoteWebAbsoluteUrl}/_api/web/getFileByServerRelativeUrl('${fileServerRelativeUrl}')?$select=UniqueId,ListId,WebId,SiteId`;
|
||||
const fileInfoResult = await this.spHttpClient.get(apiUrl, SPHttpClient.configurations.v1);
|
||||
if (!fileInfoResult || !fileInfoResult.ok) {
|
||||
throw new Error(`Something went wrong when retriving file info. Status='${fileInfoResult.status}'`);
|
||||
}
|
||||
|
||||
const fileInfoData = await fileInfoResult.json();
|
||||
const result: FileInfo = {
|
||||
Id: fileInfoData.UniqueId,
|
||||
ListId: fileInfoData.ListId,
|
||||
WebId: fileInfoData.WebId,
|
||||
ServerRelativeUrl: fileServerRelativeUrl,
|
||||
AbsoluteFileUrl: absoluteFileUrl,
|
||||
SiteId: fileInfoData.SiteId
|
||||
};
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error(`[FilesService.getFileInfo.getFileInfo]: error='${error.message}'`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public async checkIfListExists(siteUrl: string, listUrl: string): Promise<boolean> {
|
||||
let exists = false;
|
||||
|
||||
try {
|
||||
|
||||
const url: URL = new URL(siteUrl);
|
||||
const apiUrl = `${siteUrl}/_api/web/GetList(@listUrl)?$select=Title&@listUrl='${UrlUtilities().trimEndCharacter(
|
||||
url.pathname,
|
||||
"/"
|
||||
)}/${listUrl}'`;
|
||||
const data = await this.spHttpClient.get(apiUrl, SPHttpClient.configurations.v1);
|
||||
|
||||
if (data.ok) {
|
||||
exists = true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`ListService:checkIfListExists: Something failed checking if the list exists. error='${error.message}'`
|
||||
);
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
public async ensureSiteAssetsFile(webUrl: string, file: File, folderAbsoluteUrl: string, fileName?: string): Promise<FileInfo> {
|
||||
try {
|
||||
const dstWebUrl = new URL(webUrl);
|
||||
// Parse URL to obtain proper web URL
|
||||
const foldersNames = folderAbsoluteUrl.replace(`${webUrl}/`, "").split("/");
|
||||
const libraryName = foldersNames.shift();
|
||||
const spFileName = fileName ? fileName : file.name;
|
||||
const ensureFolderApiUrl = `${webUrl}/_api/web/folders`;
|
||||
|
||||
// Ensure SiteAssets library exists
|
||||
|
||||
const siteAssetsExists = await this.checkIfListExists(webUrl, libraryName);
|
||||
if (!siteAssetsExists) {
|
||||
throw new Error('No Site Assets library could be found on the target site. Please create it first');
|
||||
}
|
||||
|
||||
let currentFolderPath = `${dstWebUrl.pathname}/${libraryName}`;
|
||||
for (let i = 0; i < foldersNames.length; i++) {
|
||||
const folderName = foldersNames[i];
|
||||
const escapedFolderName = folderName.replace(/[/\\?%*:|"'<>@#./]/g, "_");
|
||||
const normalizedFolderName = escapedFolderName.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
||||
currentFolderPath += `/${normalizedFolderName}`;
|
||||
currentFolderPath = UrlUtilities().trimBeginDoubleSlash(currentFolderPath);
|
||||
// Ensure folder
|
||||
await this.spHttpClient.post(ensureFolderApiUrl, SPHttpClient.configurations.v1, {
|
||||
headers: {
|
||||
"accept": "application/json;odata=nometadata",
|
||||
"content-type": "application/json;odata=nometadata",
|
||||
"odata-version": ""
|
||||
},
|
||||
body: JSON.stringify({
|
||||
'ServerRelativeUrl': currentFolderPath
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// Folders are created -> upload file
|
||||
const uploadFileUrl = `${webUrl}/_api/web/GetFolderByServerRelativePath(decodedUrl='${currentFolderPath}')/Files/add(url='${spFileName}',overwrite=true)`;
|
||||
const fileContent = await this.readFileContent(file);
|
||||
const uploadFileResult = await this.spHttpClient.post(uploadFileUrl, SPHttpClient.configurations.v1, {
|
||||
headers: {
|
||||
"accept": "application/json;odata=nometadata",
|
||||
"content-type": "application/json;odata=nometadata",
|
||||
"odata-version": ""
|
||||
},
|
||||
body: fileContent
|
||||
});
|
||||
|
||||
|
||||
if (!uploadFileResult || !uploadFileResult.ok) {
|
||||
throw new Error('Something went wrong when uploading file.');
|
||||
}
|
||||
return this.getSPFileInfo(`https://${window.location.hostname}${currentFolderPath}/${spFileName}`);
|
||||
} catch (error) {
|
||||
console.error(`[FilesService.ensureSiteAssetsFile]: error='${error.message}'`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private readFileContent(file: File): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fr = new FileReader();
|
||||
fr.onloadend = (e) => {
|
||||
resolve(fr.result);
|
||||
};
|
||||
fr.readAsArrayBuffer(file);
|
||||
});
|
||||
}
|
||||
|
||||
private getSPSiteAbsoluteUrl(absolutefileUrl: string): string {
|
||||
const hostname = window.location.hostname;
|
||||
const rootSiteUrl = `https://${hostname}`;
|
||||
if (absolutefileUrl.indexOf(`${rootSiteUrl}/sites/`) > -1 || absolutefileUrl.indexOf(`${rootSiteUrl}/teams/`) > -1) {
|
||||
const fileServerRelativeUrl = absolutefileUrl.split(hostname)[1];
|
||||
// Split server relative URL by '/' to obtain web name
|
||||
const webName = fileServerRelativeUrl.split("/")[2];
|
||||
let webAbsoluteUrl = `https://${hostname}/sites/${webName}`;
|
||||
if (absolutefileUrl.indexOf(`${rootSiteUrl}/teams/`) > -1) {
|
||||
webAbsoluteUrl = `https://${hostname}/teams/${webName}`;
|
||||
}
|
||||
return webAbsoluteUrl;
|
||||
}
|
||||
return rootSiteUrl;
|
||||
}
|
||||
|
||||
private getFileServerRelativeUrl(absoluteFileUrl: string): string {
|
||||
let fileServerRelativeUrl = absoluteFileUrl.split(window.location.hostname)[1];
|
||||
fileServerRelativeUrl = UrlUtilities().trimBeginDoubleSlash(fileServerRelativeUrl);
|
||||
return fileServerRelativeUrl;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"themePrimary": "#6264a7",
|
||||
"themeLighterAlt": "#f7f7fb",
|
||||
"themeLighter": "#e1e1f1",
|
||||
"themeLight": "#c8c9e4",
|
||||
"themeTertiary": "#989ac9",
|
||||
"themeSecondary": "#7173b0",
|
||||
"themeDarkAlt": "#585a95",
|
||||
"themeDark": "#4a4c7e",
|
||||
"themeDarker": "#37385d",
|
||||
"neutralLighterAlt": "#0b0b0b",
|
||||
"neutralLighter": "#151515",
|
||||
"neutralLight": "#252525",
|
||||
"neutralQuaternaryAlt": "#2f2f2f",
|
||||
"neutralQuaternary": "#373737",
|
||||
"neutralTertiaryAlt": "#595959",
|
||||
"neutralTertiary": "#c8c8c8",
|
||||
"neutralSecondary": "#d0d0d0",
|
||||
"neutralPrimaryAlt": "#dadada",
|
||||
"neutralPrimary": "#ffffff",
|
||||
"neutralDark": "#f4f4f4",
|
||||
"black": "#f8f8f8",
|
||||
"white": "#000000"
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"themePrimary": "#7f85f5",
|
||||
"themeLighterAlt": "#05050a",
|
||||
"themeLighter": "#141527",
|
||||
"themeLight": "#262849",
|
||||
"themeTertiary": "#4c5093",
|
||||
"themeSecondary": "#7075d7",
|
||||
"themeDarkAlt": "#8c91f6",
|
||||
"themeDark": "#9da2f7",
|
||||
"themeDarker": "#b6baf9",
|
||||
"neutralLighterAlt": "#282828",
|
||||
"neutralLighter": "#313131",
|
||||
"neutralLight": "#3f3f3f",
|
||||
"neutralQuaternaryAlt": "#484848",
|
||||
"neutralQuaternary": "#4f4f4f",
|
||||
"neutralTertiaryAlt": "#6d6d6d",
|
||||
"neutralTertiary": "#c8c8c8",
|
||||
"neutralSecondary": "#d0d0d0",
|
||||
"neutralPrimaryAlt": "#dadada",
|
||||
"neutralPrimary": "#ffff",
|
||||
"neutralDark": "#f4f4f4",
|
||||
"black": "#ffffff",
|
||||
"white": "#1f1f1f"
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"themePrimary": "#6264a7",
|
||||
"themeLighterAlt": "#f7f7fb",
|
||||
"themeLighter": "#e1e1f1",
|
||||
"themeLight": "#c8c9e4",
|
||||
"themeTertiary": "#989ac9",
|
||||
"themeSecondary": "#7173b0",
|
||||
"themeDarkAlt": "#585a95",
|
||||
"themeDark": "#4a4c7e",
|
||||
"themeDarker": "#37385d",
|
||||
"neutralLighterAlt": "#ecebe9",
|
||||
"neutralLighter": "#e8e7e6",
|
||||
"neutralLight": "#dedddc",
|
||||
"neutralQuaternaryAlt": "#cfcecd",
|
||||
"neutralQuaternary": "#c6c5c4",
|
||||
"neutralTertiaryAlt": "#bebdbc",
|
||||
"neutralTertiary": "#b5b4b2",
|
||||
"neutralSecondary": "#9d9c9a",
|
||||
"neutralPrimaryAlt": "#868482",
|
||||
"neutralPrimary": "#252423",
|
||||
"neutralDark": "#565453",
|
||||
"black": "#3e3d3b",
|
||||
"white": "#f3f2f1"
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
/* eslint-disable @typescript-eslint/no-use-before-define */
|
||||
import { isEmpty } from '@microsoft/sp-lodash-subset';
|
||||
|
||||
export const UrlUtilities = () => {
|
||||
const removeEndSlash = (url: string): string => {
|
||||
return trimEndCharacter(url, "/");
|
||||
};
|
||||
|
||||
const removeBeginSlash = (url: string): string => {
|
||||
return trimBeginCharacter(url, "/");
|
||||
};
|
||||
|
||||
const trimEndCharacter = (url: string, trailiingCharacter: string): string => {
|
||||
if (isEmpty(url) || isEmpty(trailiingCharacter)) {
|
||||
return url;
|
||||
}
|
||||
|
||||
if (endsWith(url, trailiingCharacter)) {
|
||||
url = url.substring(0, url.length - trailiingCharacter.length);
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
const trimBeginCharacter = (url: string, character: string): string => {
|
||||
if (isEmpty(url) || isEmpty(character)) {
|
||||
return url;
|
||||
}
|
||||
|
||||
if (beginsWith(url, character)) {
|
||||
url = url.substring(1, url.length - character.length);
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
const beginsWith = (value: string, search: string): boolean => {
|
||||
if (!value || !search) {
|
||||
return false;
|
||||
}
|
||||
return value.indexOf(search) === 0;
|
||||
};
|
||||
|
||||
const endsWith = (value: string, search: string): boolean => {
|
||||
if (!value || !search) {
|
||||
return false;
|
||||
}
|
||||
return value.substring(value.length - search.length, value.length) === search;
|
||||
};
|
||||
|
||||
const trimBeginDoubleSlash = (value: string) => {
|
||||
if (value.charAt(0) === "/" && value.charAt(1) === "/") {
|
||||
return value.substring(1, value.length);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
const combine = (baseUrl: string, ...parts: string[]): string => {
|
||||
let url = baseUrl;
|
||||
|
||||
if (!parts || parts.length === 0) {
|
||||
return url;
|
||||
}
|
||||
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
const part = parts[i];
|
||||
const subParts = part.split("/");
|
||||
if (subParts.length > 0) {
|
||||
for (let j = 0; j < subParts.length; j++) {
|
||||
const subPart = subParts[j];
|
||||
url = `${removeEndSlash(url)}/${removeBeginSlash(subPart)}`;
|
||||
}
|
||||
} else {
|
||||
url = `${removeEndSlash(url)}/${removeBeginSlash(part)}`;
|
||||
}
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
const sanitizeImageUrl = (url: string): string => {
|
||||
if (isEmpty(url)) {
|
||||
return url;
|
||||
}
|
||||
const imgElement = document.createElement("img");
|
||||
imgElement.src = url;
|
||||
return imgElement.src;
|
||||
};
|
||||
|
||||
return {
|
||||
removeEndSlash,
|
||||
removeBeginSlash,
|
||||
trimEndCharacter,
|
||||
trimBeginCharacter,
|
||||
beginsWith,
|
||||
endsWith,
|
||||
trimBeginDoubleSlash,
|
||||
combine,
|
||||
sanitizeImageUrl,
|
||||
};
|
||||
};
|
|
@ -0,0 +1,53 @@
|
|||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
|
||||
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||
|
||||
export const getMessageColors = (theme: IReadonlyTheme) => {
|
||||
|
||||
const themeColors = [
|
||||
{ color: theme?.palette?.themePrimary, label: 'Theme Primary' },
|
||||
{ color: theme?.palette?.themeSecondary, label: 'Theme Secondary' },
|
||||
{ color: theme?.palette?.themeTertiary, label: 'Theme Tertiary' },
|
||||
{ color: theme?.palette?.themeLighterAlt, label: 'Theme Lighter Alt' },
|
||||
{ color: theme?.palette?.themeLighter, label: 'Theme Lighter' },
|
||||
{ color: theme?.palette?.themeLight, label: 'Theme Light' },
|
||||
{ color: theme?.palette?.neutralDark, label: 'Neutral Dark' },
|
||||
{ color: theme?.palette?.themeDark, label: 'Theme Dark' },
|
||||
{ color: theme?.palette?.themeDarker, label: 'Theme Darker' },
|
||||
{ color: theme?.palette?.neutralPrimary, label: 'Neutral Primary' },
|
||||
{ color: theme?.palette?.neutralPrimaryAlt, label: 'Neutral Primary Alt' },
|
||||
{ color: theme?.palette?.neutralLight, label: 'Neutral Light' },
|
||||
{ color: theme?.palette?.neutralLighter, label: 'Neutral Lighter' },
|
||||
{ color: theme?.palette?.neutralLighterAlt, label: 'Neutral Lighter Alt' },
|
||||
{ color: theme?.palette?.neutralSecondary, label: 'Neutral Secondary' },
|
||||
{ color: theme?.palette?.neutralTertiary, label: 'Neutral Tertiary' },
|
||||
{ color: theme?.palette?.neutralTertiaryAlt, label: 'Neutral Tertiary Alt' },
|
||||
{ color: theme?.palette?.neutralQuaternary, label: 'Neutral Quaternary' },
|
||||
{ color: theme?.palette?.neutralQuaternaryAlt, label: 'Neutral Quaternary Alt' },
|
||||
|
||||
];
|
||||
|
||||
const standartColors = [
|
||||
{ color: '#ffb900', label: 'Yellow' },
|
||||
{ color: '#fff100', label: 'Light Yellow' },
|
||||
{ color: '#d83b01', label: 'Orange'},
|
||||
{ color: '#e81123', label: 'Red' },
|
||||
{ color: '#a80000', label: 'Dark Red'},
|
||||
{ color: '#5c005c', label: 'Dark Magenta' },
|
||||
{ color: '#e3008c', label: 'Light Magenta'},
|
||||
{ color: '#5c2d91', label: 'Purple'},
|
||||
{ color: '#0078d4', label: 'Blue'},
|
||||
{ color: '#00bcf2', label: 'Light Blue' },
|
||||
{ color: '#008272', label: 'Teal'},
|
||||
{ color: '#107c10', label: 'Green'},
|
||||
{ color: '#bad80a', label: 'Light Green' },
|
||||
{ color: '#eaeaea'},
|
||||
{ color: 'black', label: 'Black'},
|
||||
{ color: '#333333', label: 'Neutral'},
|
||||
{ color: 'rgba(102, 102, 102, 0.5)', label: 'Half Gray' }
|
||||
]
|
||||
|
||||
if (!theme) return [standartColors];
|
||||
const messageColors = [...themeColors, ...standartColors];
|
||||
return messageColors;
|
||||
};
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||
"id": "701c8eaf-0e27-4fd0-b006-1614433a2cac",
|
||||
"alias": "BirthdaysWebPart",
|
||||
"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,
|
||||
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"],
|
||||
"supportsThemeVariants": true,
|
||||
|
||||
"preconfiguredEntries": [
|
||||
{
|
||||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced
|
||||
"group": { "default": "Advanced" },
|
||||
"title": { "default": "Birthdays" },
|
||||
"description": { "default": "Birthdays" },
|
||||
"officeFabricIconFontName": "Balloons",
|
||||
"properties": {
|
||||
"title": "Birthdays",
|
||||
"numberDays": 30,
|
||||
"backgroundImage": "",
|
||||
"upcomingBirthdaysMessage": "Upcoming Birthdays",
|
||||
"todayBirthdaysMessage": "Happy Birthday !",
|
||||
"noBirthdaysMessage": "No Upcoming Birthdays",
|
||||
"pageSize": 6,
|
||||
"gridHeight": 750
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,370 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
|
||||
import * as strings from 'BirthdaysWebPartStrings';
|
||||
import { loadTheme } from 'office-ui-fabric-react';
|
||||
|
||||
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||
import { Version } from '@microsoft/sp-core-library';
|
||||
import { SPComponentLoader } from '@microsoft/sp-loader';
|
||||
import { isEqual } from '@microsoft/sp-lodash-subset';
|
||||
import {
|
||||
IPropertyPaneConfiguration,
|
||||
IPropertyPaneGroup,
|
||||
PropertyPaneLabel,
|
||||
PropertyPaneSlider,
|
||||
PropertyPaneTextField,
|
||||
} from '@microsoft/sp-property-pane';
|
||||
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
||||
import {
|
||||
IFilePickerResult,
|
||||
PropertyFieldFilePicker,
|
||||
} from '@pnp/spfx-property-controls/lib/PropertyFieldFilePicker';
|
||||
import {
|
||||
PropertyFieldSwatchColorPicker,
|
||||
} from '@pnp/spfx-property-controls/lib/PropertyFieldSwatchColorPicker';
|
||||
|
||||
import {
|
||||
Birthdays,
|
||||
IBirthdaysProps,
|
||||
} from '../../components';
|
||||
import { FileInfo } from '../../models/FileInfo';
|
||||
import { FilesService } from '../../services/FilesService';
|
||||
import { getMessageColors } from '../../utils/getMessageColors';
|
||||
import { registerSVGIcons } from '../../utils/registrySVGIcons';
|
||||
import { UrlUtilities } from '../../utils/UrlUtilities';
|
||||
|
||||
export interface IBirthdaysWebPartProps {
|
||||
title: string;
|
||||
numberDays: number;
|
||||
upcomingBirthdaysBackgroundImage?: string;
|
||||
filePickerResultUpCommingImage: IFilePickerResult;
|
||||
todayBirthdaysBackgroundImage?: string;
|
||||
filePickerResultTodayImage: IFilePickerResult;
|
||||
|
||||
upcomingBirthdaysMessage?: string;
|
||||
upcomingBirthdaysMessageColor?: string;
|
||||
todayBirthdaysMessage?: string;
|
||||
todayBirthdaysMessageColor?: string;
|
||||
noBirthdaysMessage?: string;
|
||||
pageSize?: number;
|
||||
gridHeight?: number;
|
||||
}
|
||||
|
||||
const teamsDefaultTheme = require("../../teamsThemes/TeamsDefaultTheme.json");
|
||||
const teamsDarkTheme = require("../../teamsThemes/TeamsDarkTheme.json");
|
||||
const teamsContrastTheme = require("../../teamsThemes/TeamsContrastTheme.json");
|
||||
export default class BirthdaysWebPart extends BaseClientSideWebPart<IBirthdaysWebPartProps> {
|
||||
private _isDarkTheme: boolean = false;
|
||||
private containerWidth: number = 0;
|
||||
private _currentTheme: IReadonlyTheme | undefined;
|
||||
private filesService: FilesService;
|
||||
private messageColor: any = undefined;
|
||||
// Apply Teams Context
|
||||
private _applyTheme = (theme: string): void => {
|
||||
this.context.domElement.setAttribute("data-theme", theme);
|
||||
document.body.setAttribute("data-theme", theme);
|
||||
|
||||
if (theme === "dark") {
|
||||
loadTheme({
|
||||
palette: teamsDarkTheme,
|
||||
});
|
||||
}
|
||||
|
||||
if (theme === "default") {
|
||||
loadTheme({
|
||||
palette: teamsDefaultTheme,
|
||||
});
|
||||
}
|
||||
|
||||
if (theme === "contrast") {
|
||||
loadTheme({
|
||||
palette: teamsContrastTheme,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
public render(): void {
|
||||
const element: React.ReactElement<IBirthdaysProps> = React.createElement(Birthdays, {
|
||||
title: this.properties.title,
|
||||
numberDays: this.properties.numberDays,
|
||||
upcomingBirthdaysBackgroundImage: this.properties.upcomingBirthdaysBackgroundImage,
|
||||
todayBirthdaysBackgroundImage: this.properties.todayBirthdaysBackgroundImage,
|
||||
upcomingBirthdaysMessage: this.properties.upcomingBirthdaysMessage,
|
||||
todayBirthdaysMessage: this.properties.todayBirthdaysMessage,
|
||||
pageSize: this.properties.pageSize,
|
||||
isDarkTheme: this._isDarkTheme,
|
||||
theme: this._currentTheme,
|
||||
hasTeamsContext: this.context.sdks.microsoftTeams ? true : false,
|
||||
containerWidth: this.containerWidth,
|
||||
displayMode: this.displayMode,
|
||||
updateProperty: (value: string) => {
|
||||
this.properties.title = value;
|
||||
},
|
||||
context: this.context,
|
||||
onConfigure: () => this.context.propertyPane.open(),
|
||||
todayBirthdaysMessageColor: this.properties.todayBirthdaysMessageColor,
|
||||
upcomingBirthdaysMessageColor: this.properties.upcomingBirthdaysMessageColor,
|
||||
noBirthdaysMessage: this.properties.noBirthdaysMessage,
|
||||
gridHeight: this.properties.gridHeight,
|
||||
});
|
||||
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
|
||||
protected async onInit(): Promise<void> {
|
||||
registerSVGIcons(this._currentTheme);
|
||||
SPComponentLoader.loadCss("https://fonts.googleapis.com/css2?family=Dancing+Script&display=swap");
|
||||
this.filesService = new FilesService(this.context.serviceScope);
|
||||
this.messageColor = getMessageColors(this._currentTheme);
|
||||
if (this.context.sdks.microsoftTeams) {
|
||||
// in teams ?
|
||||
const teamsContext = await this.context.sdks.microsoftTeams?.teamsJs.app.getContext();
|
||||
this._applyTheme(teamsContext.app.theme || "default");
|
||||
this.context.sdks.microsoftTeams.teamsJs.app.registerOnThemeChangeHandler(this._applyTheme);
|
||||
}
|
||||
this.containerWidth = this.domElement.clientWidth;
|
||||
return super.onInit();
|
||||
}
|
||||
|
||||
protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void {
|
||||
if (!currentTheme) {
|
||||
return;
|
||||
}
|
||||
this._isDarkTheme = !!currentTheme.isInverted;
|
||||
this._currentTheme = currentTheme;
|
||||
}
|
||||
|
||||
protected onDispose(): void {
|
||||
ReactDom.unmountComponentAtNode(this.domElement);
|
||||
}
|
||||
|
||||
protected get dataVersion(): Version {
|
||||
return Version.parse("1.0");
|
||||
}
|
||||
|
||||
private async processSPImage(siteUrl: string, folderName: string, fileResult: IFilePickerResult):Promise<FileInfo> {
|
||||
const { removeEndSlash } = UrlUtilities();
|
||||
const image = await fileResult.downloadFileContent();
|
||||
const filexExtension = fileResult.fileName.replace(fileResult.fileNameWithoutExtension, "");
|
||||
const dstImgName = `${new Date().getTime()}${filexExtension}`;
|
||||
const folderAbsoluteUrl = folderName
|
||||
? `${siteUrl}/SiteAssets/SitePages/${folderName}`
|
||||
: `${siteUrl}/SiteAssets/SitePages`;
|
||||
siteUrl = removeEndSlash(siteUrl);
|
||||
const fileInfo: FileInfo = await this.filesService.ensureSiteAssetsFile(
|
||||
siteUrl,
|
||||
image,
|
||||
folderAbsoluteUrl,
|
||||
dstImgName
|
||||
);
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
protected get disableReactivePropertyChanges(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected onFilePickerPaneFieldChanged = async (
|
||||
oldFileResult: IFilePickerResult,
|
||||
newfileResult: IFilePickerResult,
|
||||
propertyPath: string
|
||||
):Promise<void> => {
|
||||
const filepickerResult =
|
||||
propertyPath === "filePicker1"
|
||||
? this.properties.filePickerResultUpCommingImage
|
||||
: this.properties.filePickerResultTodayImage;
|
||||
|
||||
if (!newfileResult.fileAbsoluteUrl) {
|
||||
filepickerResult.fileAbsoluteUrl = oldFileResult?.fileAbsoluteUrl ?? null;
|
||||
const siteUrl = this.context.pageContext.web.absoluteUrl;
|
||||
const folderName = this.context.manifest.alias;
|
||||
const fileInfo = await this.processSPImage(siteUrl, folderName, newfileResult);
|
||||
filepickerResult.fileAbsoluteUrl = fileInfo?.AbsoluteFileUrl;
|
||||
}
|
||||
if (propertyPath === "filePicker1") {
|
||||
this.properties.upcomingBirthdaysBackgroundImage = filepickerResult?.fileAbsoluteUrl;
|
||||
} else {
|
||||
this.properties.todayBirthdaysBackgroundImage = filepickerResult?.fileAbsoluteUrl;
|
||||
}
|
||||
|
||||
this.context.propertyPane.refresh();
|
||||
};
|
||||
|
||||
protected onPropertyPaneFieldChanged = async (propertyPath: string, oldValue: any, newValue: any):Promise<void> => {
|
||||
if ((propertyPath === "filePicker1" || propertyPath === "filePicker2") && !isEqual(oldValue, newValue)) {
|
||||
await this.onFilePickerPaneFieldChanged(oldValue, newValue, propertyPath);
|
||||
}
|
||||
|
||||
super.onPropertyPaneFieldChanged(propertyPath, oldValue, newValue);
|
||||
};
|
||||
|
||||
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||
const groupGridProperties: IPropertyPaneGroup = {
|
||||
groupName: strings.GroupGridProperties,
|
||||
isCollapsed: true,
|
||||
groupFields: [
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
PropertyPaneTextField("title", {
|
||||
label: strings.DescriptionFieldLabel,
|
||||
value: this.properties.title ?? strings.DescriptionFieldLabel,
|
||||
}),
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
PropertyPaneSlider("numberDays", {
|
||||
label: strings.UpComingDaysPropertyLabel,
|
||||
min: 1,
|
||||
max: 60,
|
||||
value: this.properties.numberDays ?? 30,
|
||||
}),
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
PropertyPaneSlider("pageSize", {
|
||||
label: strings.PageSizePropertyLabel,
|
||||
min: 6,
|
||||
max: 12,
|
||||
value: this.properties.pageSize ?? 6,
|
||||
}),
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
PropertyPaneSlider("gridHeight", {
|
||||
label: strings.GridHeightPropertyLabel,
|
||||
min: 400,
|
||||
max: 800,
|
||||
value: this.properties.gridHeight ?? 600,
|
||||
}),
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
const upCommingBrithdaysProperties: IPropertyPaneGroup = {
|
||||
groupName: strings.upComingBirthdays,
|
||||
isCollapsed: true,
|
||||
groupFields: [
|
||||
PropertyPaneTextField("upcomingBirthdaysMessage", {
|
||||
label: strings.UpComingBirthdaysMessageLabel,
|
||||
value: this.properties.upcomingBirthdaysMessage,
|
||||
}),
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
PropertyPaneLabel("filePicker1", {
|
||||
text: strings.UpComingBirthdayBackGroundImagePropertyLabel,
|
||||
}),
|
||||
PropertyFieldFilePicker("filePicker1", {
|
||||
context: this.context as any,
|
||||
filePickerResult: this.properties.filePickerResultUpCommingImage,
|
||||
onPropertyChange: this.onPropertyPaneFieldChanged,
|
||||
properties: this.properties,
|
||||
onSave: (e: IFilePickerResult) => {
|
||||
this.properties.filePickerResultUpCommingImage = e;
|
||||
},
|
||||
onChanged: (e: IFilePickerResult) => {
|
||||
this.properties.filePickerResultUpCommingImage = e;
|
||||
},
|
||||
key: "filePickerId1",
|
||||
buttonLabel: strings.SelectImagePropertyLabel,
|
||||
accepts: [".gif", ".jpg", ".jpeg", ".png", ".svg"],
|
||||
buttonIcon: "",
|
||||
}),
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
PropertyFieldSwatchColorPicker("upcomingBirthdaysMessageColor", {
|
||||
label: strings.MessageColorPropertyLabel,
|
||||
selectedColor: this.properties.upcomingBirthdaysMessageColor,
|
||||
colors: this.messageColor,
|
||||
onPropertyChange: this.onPropertyPaneFieldChanged,
|
||||
properties: this.properties,
|
||||
key: "colorFieldId",
|
||||
showAsCircles: true,
|
||||
columnCount: 8,
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
const todayBrithdaysProperties: IPropertyPaneGroup = {
|
||||
groupName: strings.todayBirthdays,
|
||||
isCollapsed: true,
|
||||
groupFields: [
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
PropertyPaneTextField("todayBirthdaysMessage", {
|
||||
label: strings.TodayBirthdayMessagePropertyLabel,
|
||||
value: this.properties.todayBirthdaysMessage,
|
||||
}),
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
PropertyPaneLabel("filePicker1", {
|
||||
text: strings.TodayBackgroundPropertyImageLabel,
|
||||
}),
|
||||
PropertyFieldFilePicker("filePicker2", {
|
||||
context: this.context as any,
|
||||
filePickerResult: this.properties.filePickerResultTodayImage,
|
||||
onPropertyChange: this.onPropertyPaneFieldChanged,
|
||||
properties: this.properties,
|
||||
onSave: (e: IFilePickerResult) => {
|
||||
this.properties.filePickerResultTodayImage = e;
|
||||
},
|
||||
onChanged: (e: IFilePickerResult) => {
|
||||
this.properties.filePickerResultTodayImage = e;
|
||||
},
|
||||
key: "filePickerId2",
|
||||
buttonLabel: strings.SelectImagePropertyLabel ,
|
||||
accepts: [".gif", ".jpg", ".jpeg", ".png", ".svg"],
|
||||
}),
|
||||
PropertyFieldSwatchColorPicker("todayBirthdaysMessageColor", {
|
||||
label: strings.MessageColorPropertyLabel,
|
||||
selectedColor: this.properties.todayBirthdaysMessageColor,
|
||||
colors: this.messageColor,
|
||||
onPropertyChange: this.onPropertyPaneFieldChanged,
|
||||
properties: this.properties,
|
||||
key: "colorFieldId",
|
||||
showAsCircles: true,
|
||||
columnCount: 8,
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
const noBrithdaysProperties: IPropertyPaneGroup = {
|
||||
groupName: strings.noBirthdays,
|
||||
isCollapsed: true,
|
||||
groupFields: [
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
PropertyPaneTextField("noBirthdaysMessage", {
|
||||
label: strings.NoUpcomingBirthdayMessageLabel,
|
||||
value: this.properties.noBirthdaysMessage,
|
||||
}),
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
return {
|
||||
pages: [
|
||||
{
|
||||
header: {
|
||||
description: strings.PropertyPaneDescription,
|
||||
},
|
||||
displayGroupsAsAccordion: true,
|
||||
groups: [groupGridProperties, upCommingBrithdaysProperties, todayBrithdaysProperties, noBrithdaysProperties],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
define([], function() {
|
||||
return {
|
||||
BottomEditLabel: "Edit",
|
||||
ErrorMessageText: "\"Something went wrong when sending message\"",
|
||||
GridHeightPropertyLabel: "Grid Height",
|
||||
MessageColorPropertyLabel: "Message Color",
|
||||
ModalCancelButtonLabel: "Cancel",
|
||||
ModalHeaderLabel: "Send Congratulations Message",
|
||||
NoUpcomingBirthdayMessageLabel: "No UpComing Birthdays Message",
|
||||
PageSizePropertyLabel: "Number cards per page",
|
||||
PlaceHolderButtonLabel: "Configure",
|
||||
PlaceHolderDescription: "Please configure the web part.",
|
||||
PlaceHolderIconText: "Configure Brithdays web part",
|
||||
PreviewLabel: "Preview",
|
||||
SelectImagePropertyLabel: "Select Image",
|
||||
SendLabel: "Send",
|
||||
ShowNextPageToolTipLabel: "load next page of users",
|
||||
TodayBackgroundPropertyImageLabel: "Today Background Image",
|
||||
TodayBirthdayMessagePropertyLabel: "Today Birthdays Message",
|
||||
UpComingBirthdayBackGroundImagePropertyLabel: "Upcoming Birthday Background Image",
|
||||
UpComingBirthdaysMessageLabel: "Upcoming Birthdays Message",
|
||||
UpComingDaysPropertyLabel: "Upcoming Days",
|
||||
"PropertyPaneDescription": "Show birthdays of your colleagues",
|
||||
"DescriptionFieldLabel": "Title",
|
||||
"GroupGridProperties": "Grid properties",
|
||||
"upComingBirthdays": "Upcoming Birthdays properties",
|
||||
"todayBirthdays": "Today Birthdays properties",
|
||||
"noBirthdays": "No Birthdays properties",
|
||||
"showingNumberUserMessage": "Showing {0} users of {1} users",
|
||||
}
|
||||
});
|
|
@ -0,0 +1,34 @@
|
|||
declare interface IBirthdaysWebPartStrings {
|
||||
BottomEditLabel: string;
|
||||
PropertyPaneDescription: string;
|
||||
DescriptionFieldLabel: string;
|
||||
ErrorMessageText: string;
|
||||
GridHeightPropertyLabel: string;
|
||||
GroupGridProperties: string;
|
||||
MessageColorPropertyLabel: string;
|
||||
ModalCancelButtonLabel: string;
|
||||
ModalHeaderLabel: string;
|
||||
upComingBirthdays: string;
|
||||
todayBirthdays: string;
|
||||
noBirthdays: string;
|
||||
NoUpcomingBirthdayMessageLabel: string;
|
||||
PageSizePropertyLabel: string;
|
||||
PlaceHolderButtonLabel: string;
|
||||
PlaceHolderDescription: string;
|
||||
PlaceHolderIconText: string;
|
||||
PreviewLabel: string;
|
||||
SelectImagePropertyLabel: string;
|
||||
SendLabel: string;
|
||||
ShowNextPageToolTipLabel: string;
|
||||
TodayBackgroundPropertyImageLabel: string;
|
||||
TodayBirthdayMessagePropertyLabel: string;
|
||||
UpComingBirthdayBackGroundImagePropertyLabel: string;
|
||||
UpComingBirthdaysMessageLabel: string;
|
||||
UpComingDaysPropertyLabel: string;
|
||||
showingNumberUserMessage: string;
|
||||
}
|
||||
|
||||
declare module 'BirthdaysWebPartStrings' {
|
||||
const strings: IBirthdaysWebPartStrings;
|
||||
export = strings;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||
"id": "369bf019-e832-45d1-a4d4-0ee95fdf7573",
|
||||
"alias": "BirthdaysTimelineWebPart",
|
||||
"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,
|
||||
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage" ],
|
||||
"supportsThemeVariants": true,
|
||||
|
||||
"preconfiguredEntries": [{
|
||||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced
|
||||
"group": { "default": "Advanced" },
|
||||
"title": { "default": "Birthdays Timeline" },
|
||||
"description": { "default": "Birthdays Timeline" },
|
||||
"officeFabricIconFontName": "Balloons",
|
||||
"properties": {
|
||||
"title": ""
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
|
||||
import * as strings from 'BirthdaysTimelineWebPartStrings';
|
||||
import { loadTheme } from 'office-ui-fabric-react/lib/Styling';
|
||||
|
||||
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||
import { Version } from '@microsoft/sp-core-library';
|
||||
import { SPComponentLoader } from '@microsoft/sp-loader';
|
||||
import {
|
||||
IPropertyPaneConfiguration,
|
||||
PropertyPaneLabel,
|
||||
PropertyPaneSlider,
|
||||
PropertyPaneTextField,
|
||||
} from '@microsoft/sp-property-pane';
|
||||
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
||||
|
||||
import {
|
||||
BirthdaysTimeline,
|
||||
} from '../../components/birthdaysTimeline/BirthdaysTimeline';
|
||||
import {
|
||||
IBirthdaysTimelineProps,
|
||||
} from '../../components/birthdaysTimeline/IBirthdaysTimelineProps';
|
||||
import { registerSVGIcons } from '../../utils/registrySVGIcons';
|
||||
|
||||
const teamsDefaultTheme = require("../../teamsThemes/TeamsDefaultTheme.json");
|
||||
const teamsDarkTheme = require("../../teamsThemes/TeamsDarkTheme.json");
|
||||
const teamsContrastTheme = require("../../teamsThemes/TeamsContrastTheme.json");
|
||||
|
||||
export interface IBirthdaysTimelineWebPartProps {
|
||||
title: string;
|
||||
numberDays: number;
|
||||
todayBirthdaysMessage?: string;
|
||||
noBirthdaysMessage?: string;
|
||||
}
|
||||
|
||||
export default class BirthdaysTimelineWebPart extends BaseClientSideWebPart<IBirthdaysTimelineWebPartProps> {
|
||||
private _isDarkTheme: boolean = false;
|
||||
|
||||
private _currentTheme: IReadonlyTheme | undefined;
|
||||
|
||||
private _applyTheme = (theme: string): void => {
|
||||
this.context.domElement.setAttribute("data-theme", theme);
|
||||
document.body.setAttribute("data-theme", theme);
|
||||
|
||||
if (theme === "dark") {
|
||||
loadTheme({
|
||||
palette: teamsDarkTheme,
|
||||
});
|
||||
}
|
||||
|
||||
if (theme === "default") {
|
||||
loadTheme({
|
||||
palette: teamsDefaultTheme,
|
||||
});
|
||||
}
|
||||
|
||||
if (theme === "contrast") {
|
||||
loadTheme({
|
||||
palette: teamsContrastTheme,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
public render(): void {
|
||||
const element: React.ReactElement<IBirthdaysTimelineProps> = React.createElement(BirthdaysTimeline, {
|
||||
title: this.properties.title ?? strings.titleDefaultValue,
|
||||
numberDays: this.properties.numberDays ?? 30,
|
||||
isDarkTheme: this._isDarkTheme,
|
||||
hasTeamsContext: this.context.sdks.microsoftTeams ? true : false,
|
||||
theme: this._currentTheme,
|
||||
context: this.context,
|
||||
displayMode: this.displayMode,
|
||||
pageSize: 10,
|
||||
updateProperty: (value: string) => {
|
||||
this.properties.title = value;
|
||||
},
|
||||
todayBirthdaysMessage: this.properties.todayBirthdaysMessage ?? strings.TodayBirthdayMessagePropertyDefaultVaue,
|
||||
noBirthdaysMessage: this.properties.noBirthdaysMessage ?? strings.NoUpcomingBirthdayMessageDefaultVaue,
|
||||
});
|
||||
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
|
||||
protected async onInit(): Promise<void> {
|
||||
SPComponentLoader.loadCss("https://fonts.googleapis.com/css2?family=Dancing+Script&display=swap");
|
||||
registerSVGIcons(this._currentTheme);
|
||||
if (this.context.sdks.microsoftTeams) {
|
||||
// in teams ?
|
||||
const teamsContext = await this.context.sdks.microsoftTeams?.teamsJs.app.getContext();
|
||||
this._applyTheme(teamsContext.app.theme || "default");
|
||||
this.context.sdks.microsoftTeams.teamsJs.app.registerOnThemeChangeHandler(this._applyTheme);
|
||||
}
|
||||
return super.onInit();
|
||||
}
|
||||
|
||||
protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void {
|
||||
if (!currentTheme) {
|
||||
return;
|
||||
}
|
||||
this._isDarkTheme = !!currentTheme.isInverted;
|
||||
this._currentTheme = currentTheme;
|
||||
}
|
||||
|
||||
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: [
|
||||
PropertyPaneTextField("title", {
|
||||
label: strings.DescriptionFieldLabel,
|
||||
value: this.properties.title ?? strings.DescriptionFieldLabel,
|
||||
}),
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
PropertyPaneSlider("numberDays", {
|
||||
label: strings.UpComingDaysPropertyLabel,
|
||||
min: 1,
|
||||
max: 60,
|
||||
value: this.properties.numberDays ?? 30,
|
||||
}),
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
PropertyPaneTextField("todayBirthdaysMessage", {
|
||||
label: strings.TodayBirthdayMessagePropertyLabel,
|
||||
value: this.properties.todayBirthdaysMessage ?? strings.TodayBirthdayMessagePropertyDefaultVaue,
|
||||
}),
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
PropertyPaneTextField("noBirthdaysMessage", {
|
||||
label: strings.NoUpcomingBirthdayMessageLabel,
|
||||
value: this.properties.noBirthdaysMessage ?? strings.NoUpcomingBirthdayMessageDefaultVaue,
|
||||
}),
|
||||
PropertyPaneLabel("separator", {
|
||||
text: "",
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
define([], function() {
|
||||
return {
|
||||
"PropertyPaneDescription": "Birthdays Timeline",
|
||||
"BasicGroupName": "Properties",
|
||||
"DescriptionFieldLabel": "Title",
|
||||
TodayBirthdayMessagePropertyLabel: "Today Birthdays Message",
|
||||
NoUpcomingBirthdayMessageLabel: "No UpComing Birthdays Message",
|
||||
UpComingDaysPropertyLabel: "Upcoming Days",
|
||||
TodayBirthdayMessagePropertyDefaultVaue: "Congratulations !",
|
||||
NoUpcomingBirthdayMessageDefaultVaue: "No Upcoming Birthdays",
|
||||
titleDefaultValue: "Birthdays",
|
||||
}
|
||||
});
|
16
samples/react-modern-birthdays/src/webparts/birthdaysTimeline/loc/mystrings.d.ts
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
declare interface IBirthdaysTimelineWebPartStrings {
|
||||
PropertyPaneDescription: string;
|
||||
BasicGroupName: string;
|
||||
DescriptionFieldLabel: string;
|
||||
TodayBirthdayMessagePropertyLabel: string;
|
||||
NoUpcomingBirthdayMessageLabel: string;
|
||||
UpComingDaysPropertyLabel: string;
|
||||
TodayBirthdayMessagePropertyDefaultVaue: string;
|
||||
NoUpcomingBirthdayMessageDefaultVaue: string;
|
||||
titleDefaultValue: string;
|
||||
}
|
||||
|
||||
declare module 'BirthdaysTimelineWebPartStrings' {
|
||||
const strings: IBirthdaysTimelineWebPartStrings;
|
||||
export = strings;
|
||||
}
|
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 542 B |
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"extends": "./node_modules/@microsoft/rush-stack-compiler-4.5/includes/tsconfig-web.json",
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"jsx": "react",
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"experimentalDecorators": true,
|
||||
"skipLibCheck": true,
|
||||
"outDir": "lib",
|
||||
"inlineSources": false,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitAny": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./node_modules/@microsoft"
|
||||
],
|
||||
"types": [
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection",
|
||||
"es2015.promise",
|
||||
"ES2019"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
]
|
||||
}
|