@vixoniccom/aniversarios 1.2.1-dev.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -7
- package/build.zip +0 -0
- package/configuration.json +0 -4
- package/package.json +4 -3
- package/src/App.tsx +73 -59
- package/src/components/{FontLoader/index.tsx → FontLoader.tsx} +12 -11
- package/src/components/FormattedText.tsx +81 -0
- package/src/components/{Render/index.tsx → Render.tsx} +11 -9
- package/src/components/anniversary-item/AnniversaryItem.tsx +22 -0
- package/src/components/anniversary-item/clasic/ClasicItem.tsx +220 -0
- package/src/components/{AnniversaryItem/components/AnniversaryImage/index.tsx → anniversary-item/shared/AnniversaryImage.tsx} +19 -11
- package/src/components/{AnniversaryItem/components/AnniversaryDate/index.tsx → anniversary-item/shared/anniversary-date/AnniversaryDate.tsx} +11 -7
- package/src/components/anniversary-item/shared/anniversary-date/DateUtils.ts +33 -0
- package/src/components/anniversary-item/shared/anniversary-date/circle/CircleDate.tsx +39 -0
- package/src/components/anniversary-item/shared/anniversary-date/flat/FlatDate.tsx +79 -0
- package/src/components/{AnniversaryItem/components/AnniversaryDate/OutlineDate/index.tsx → anniversary-item/shared/anniversary-date/outline/OutlineDate.tsx} +25 -7
- package/src/components/{AnniversaryItem/components/AnniversaryDate/TextDate/index.tsx → anniversary-item/shared/anniversary-date/text/TextDate.tsx} +12 -2
- package/src/components/{AnniversaryItem/components/AnniversaryDate/TextCalendarDate/index.tsx → anniversary-item/shared/anniversary-date/text-calendar/TextCalendarDate.tsx} +16 -7
- package/src/components/{AnniversaryItem/components/Separator → anniversary-item/shared/separator}/Separator.tsx +6 -3
- package/src/components/anniversary-item/shared/utils.ts +10 -0
- package/src/components/{ItemsContainer/components → items-container}/Item.tsx +10 -2
- package/src/components/{ItemsContainer/index.tsx → items-container/ItemsContainer.tsx} +61 -52
- package/src/components/items-container/animation.ts +125 -0
- package/src/contex/configureContext/ConfigureContext.tsx +8 -0
- package/src/contex/configureContext/ConfigureProvider.tsx +77 -0
- package/src/contex/configureContext/configureReducer.ts +67 -0
- package/src/contex/dataContext/DataContex.tsx +8 -0
- package/src/contex/dataContext/DataProvider.tsx +31 -0
- package/src/contex/dataContext/dataReducer.ts +19 -0
- package/src/helpers/filterEmployees.ts +37 -31
- package/src/helpers/getEmployees.ts +22 -18
- package/src/helpers/parseMonthAndDay.ts +38 -0
- package/src/helpers/setToken.ts +69 -0
- package/src/helpers/utils.ts +50 -44
- package/src/hooks/useFetch.ts +47 -0
- package/src/main.tsx +2 -2
- package/src/model/income.ts +129 -0
- package/src/test/parameters.json +97 -97
- package/src/components/AnniversaryItem/components/AnniversaryDate/CircleDate/index.tsx +0 -31
- package/src/components/AnniversaryItem/components/AnniversaryDate/FlatDate/index.tsx +0 -47
- package/src/components/AnniversaryItem/components/AnniversaryDate/utils.ts +0 -18
- package/src/components/AnniversaryItem/components/ClassicItem/index.tsx +0 -109
- package/src/components/AnniversaryItem/components/index.ts +0 -11
- package/src/components/AnniversaryItem/components/utils.ts +0 -75
- package/src/components/AnniversaryItem/index.tsx +0 -17
- package/src/components/FormattedText/index.tsx +0 -81
- package/src/components/ItemsContainer/components/animation.ts +0 -130
- package/src/components/index.ts +0 -13
- package/src/context/configureContext/ConfigureContext.tsx +0 -8
- package/src/context/configureContext/ConfigureProvider.tsx +0 -72
- package/src/context/configureContext/configureReducer.ts +0 -62
- package/src/context/dataContext/DataContex.tsx +0 -8
- package/src/context/dataContext/DataProvider.tsx +0 -25
- package/src/context/dataContext/dataReducer.ts +0 -12
- /package/src/components/{AnniversaryItem/components → anniversary-item/shared}/default-profile.png +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,13 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
### [1.2.1
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
* code refactored ([41cf858](https://github.com/Vixonic/store-aniversarios/commit/41cf85868e516175ee55640434247c5f70d5d579))
|
|
11
|
-
* createItems now works properly ([db2623a](https://github.com/Vixonic/store-aniversarios/commit/db2623ab1156ca93bd5386598dd1c1dc486a46ff))
|
|
5
|
+
### [1.2.1](https://github.com/Vixonic/store-aniversarios/compare/v1.2.0...v1.2.1) (2025-02-28)
|
|
12
6
|
|
|
13
7
|
## [1.2.0](https://github.com/Vixonic/store-aniversarios/compare/v1.2.0-dev.1...v1.2.0) (2025-02-27)
|
|
14
8
|
|
package/build.zip
CHANGED
|
Binary file
|
package/configuration.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixoniccom/aniversarios",
|
|
3
3
|
"alias": "Aniversarios",
|
|
4
|
-
"version": "1.2.1
|
|
4
|
+
"version": "1.2.1",
|
|
5
5
|
"description": "Muestra el día que el trabajador está de aniversario en la empresa.",
|
|
6
6
|
"main": "main.js",
|
|
7
7
|
"author": "",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"animejs": "^3.2.2",
|
|
21
21
|
"axios": "^1.6.0",
|
|
22
|
+
"jquery": "^3.6.0",
|
|
22
23
|
"localforage": "^1.10.0",
|
|
23
24
|
"moment": "^2.29.4",
|
|
24
25
|
"prop-types": "^15.8.1",
|
|
@@ -32,8 +33,8 @@
|
|
|
32
33
|
"@types/node": "^12.20.37",
|
|
33
34
|
"@types/react": "^17.0.35",
|
|
34
35
|
"@types/react-dom": "^17.0.11",
|
|
35
|
-
"@vixoniccom/module-packager": "^2.10.1",
|
|
36
|
-
"@vixoniccom/modules": "^2.20.0",
|
|
36
|
+
"@vixoniccom/module-packager": "^2.10.1-dev.1",
|
|
37
|
+
"@vixoniccom/modules": "^2.20.0-dev.1",
|
|
37
38
|
"standard-version": "^9.5.0"
|
|
38
39
|
}
|
|
39
40
|
}
|
package/src/App.tsx
CHANGED
|
@@ -1,89 +1,97 @@
|
|
|
1
|
-
import React, { useContext, useEffect, useState } from "react"
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
1
|
+
import React, { useContext, useEffect, useState } from "react";
|
|
2
|
+
import { ConfigureContext } from "./contex/configureContext/ConfigureContext";
|
|
3
|
+
import { DataContext } from "./contex/dataContext/DataContex";
|
|
4
|
+
import { Render } from "./components/Render";
|
|
5
|
+
import { FormattedText } from "./components/FormattedText";
|
|
6
|
+
import { getEmployees, getEmployeesYearly } from "./helpers/getEmployees";
|
|
7
|
+
import { filterEmployees } from "./helpers/filterEmployees";
|
|
8
|
+
import moment from "moment";
|
|
9
|
+
import { getMonth } from "./helpers/utils";
|
|
10
|
+
import localforage from "localforage";
|
|
10
11
|
|
|
11
12
|
type Props = {
|
|
12
|
-
data: VixonicData
|
|
13
|
-
start: boolean
|
|
14
|
-
}
|
|
13
|
+
data: VixonicData;
|
|
14
|
+
start: boolean;
|
|
15
|
+
};
|
|
15
16
|
|
|
16
|
-
type Msj =
|
|
17
|
+
type Msj =
|
|
18
|
+
| 'Ningún ingreso que mostrar'
|
|
17
19
|
| 'Cargando Empleados...'
|
|
18
20
|
| 'Missing google sheets'
|
|
19
21
|
| ""
|
|
20
|
-
| 'Invalid URL'
|
|
22
|
+
| 'Invalid URL';
|
|
21
23
|
|
|
22
|
-
export const App
|
|
23
|
-
const { addConfiguration, configureState } = useContext(ConfigureContext)
|
|
24
|
-
const { addEmployee } = useContext(DataContext)
|
|
24
|
+
export const App = ({ data, start }: Props) => {
|
|
25
|
+
const { addConfiguration, configureState } = useContext(ConfigureContext);
|
|
26
|
+
const { addEmployee } = useContext(DataContext);
|
|
25
27
|
const [dataState, setDataState] = useState(data)
|
|
26
|
-
const [msj, setMsj] = useState<Msj>("")
|
|
27
|
-
const { apiDomain, dataMode, excludePast } = configureState.parameters
|
|
28
|
-
let updateTimer: any
|
|
28
|
+
const [msj, setMsj] = useState<Msj>("");
|
|
29
|
+
const { apiDomain, dataMode, excludePast } = configureState.parameters;
|
|
30
|
+
let updateTimer : any
|
|
29
31
|
|
|
30
|
-
const setUpdateTime = (updatedTime: number) => {
|
|
31
|
-
clearTimeout(updateTimer)
|
|
32
|
-
updateTimer = setTimeout(getData, updatedTime)
|
|
33
|
-
}
|
|
34
32
|
|
|
35
|
-
useEffect(()
|
|
36
|
-
if
|
|
37
|
-
|
|
33
|
+
useEffect(()=> {
|
|
34
|
+
if(apiDomain){
|
|
35
|
+
localforage.config({
|
|
36
|
+
name: `url_request_${apiDomain}`
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
},[apiDomain])
|
|
38
40
|
|
|
39
41
|
useEffect(() => {
|
|
40
|
-
addConfiguration(data)
|
|
41
|
-
setDataState(configureState)
|
|
42
|
-
}, [data])
|
|
42
|
+
addConfiguration(data);
|
|
43
|
+
setDataState(configureState);
|
|
44
|
+
}, [data]);
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const setUpdateTime =(updatedTime: number) => {
|
|
48
|
+
clearTimeout(updateTimer)
|
|
49
|
+
updateTimer = setTimeout(getData, updatedTime)
|
|
50
|
+
}
|
|
43
51
|
|
|
44
52
|
useEffect(() => {
|
|
45
53
|
const { updateTime } = configureState.parameters
|
|
46
54
|
|
|
47
55
|
if (apiDomain && dataMode) {
|
|
48
|
-
localforage.getItem<{ items: any[], date: number, mode: string }>('anniversary-docs').then((data) => {
|
|
49
|
-
if
|
|
56
|
+
localforage.getItem<{ items: any[], date: number, mode: string }>('anniversary-docs').then((data) => {
|
|
57
|
+
if(!data || dataMode !== data.mode ) {
|
|
50
58
|
getData()
|
|
51
59
|
setUpdateTime(updateTime!)
|
|
52
|
-
return
|
|
60
|
+
return
|
|
53
61
|
}
|
|
54
|
-
|
|
62
|
+
|
|
55
63
|
const now = Date.now()
|
|
56
64
|
const targetDate = data?.date! + updateTime!
|
|
57
65
|
|
|
58
|
-
if
|
|
66
|
+
if(now >= targetDate){
|
|
59
67
|
getData()
|
|
60
68
|
setUpdateTime(updateTime!)
|
|
61
|
-
}
|
|
69
|
+
}else {
|
|
62
70
|
data && addEmployee(data.items)
|
|
63
|
-
setMsj("")
|
|
64
|
-
setUpdateTime(targetDate
|
|
71
|
+
setMsj("");
|
|
72
|
+
setUpdateTime(targetDate-now)
|
|
65
73
|
}
|
|
66
74
|
})
|
|
67
75
|
}
|
|
68
|
-
if (!apiDomain) setMsj("Missing google sheets")
|
|
69
|
-
}, [dataState])
|
|
76
|
+
if (!apiDomain) setMsj("Missing google sheets");
|
|
77
|
+
}, [dataState]);
|
|
70
78
|
|
|
71
79
|
const getData = async () => {
|
|
72
|
-
const urlValid = "https://docs.google.com/spreadsheets/d/"
|
|
80
|
+
const urlValid = "https://docs.google.com/spreadsheets/d/";
|
|
73
81
|
let contractEmployees: any
|
|
74
82
|
let employee: any = []
|
|
75
83
|
try {
|
|
76
|
-
if (apiDomain
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
if (apiDomain !== undefined && apiDomain.includes(urlValid)) {
|
|
85
|
+
let month = Number(moment().format("M")) - 1;
|
|
86
|
+
let nextMonth = (month === 11) ? 0 : (month + 1);
|
|
87
|
+
let monthTab = getMonth(month);
|
|
88
|
+
let nextMonthTab = getMonth(nextMonth);
|
|
81
89
|
if (dataMode !== 'yearly') {
|
|
82
|
-
contractEmployees = await getEmployees(apiDomain, monthTab)
|
|
90
|
+
contractEmployees = await getEmployees(apiDomain, dataMode, monthTab);
|
|
83
91
|
const { values } = contractEmployees.data
|
|
84
92
|
employee.push(...filterEmployees(values, dataMode, excludePast, month))
|
|
85
|
-
if
|
|
86
|
-
contractEmployees = await getEmployees(apiDomain, nextMonthTab)
|
|
93
|
+
if( dataMode === 'weekly') {
|
|
94
|
+
contractEmployees = await getEmployees(apiDomain, dataMode, nextMonthTab);
|
|
87
95
|
const { values: valuesnextMonth } = contractEmployees.data
|
|
88
96
|
employee.push(...filterEmployees(valuesnextMonth, dataMode, excludePast, nextMonth))
|
|
89
97
|
}
|
|
@@ -92,34 +100,40 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
92
100
|
if (dataMode === 'yearly') {
|
|
93
101
|
setMsj('Cargando Empleados...')
|
|
94
102
|
for (let numberMonth: number = 0; numberMonth <= 11; numberMonth++) {
|
|
95
|
-
contractEmployees = await getEmployeesYearly(apiDomain, numberMonth)
|
|
103
|
+
contractEmployees = await getEmployeesYearly(apiDomain, numberMonth);
|
|
96
104
|
const { values } = contractEmployees.data
|
|
97
105
|
employee.push(...filterEmployees(values, dataMode, excludePast, numberMonth))
|
|
98
106
|
}
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
if (contractEmployees) {
|
|
102
|
-
addEmployee(employee)
|
|
103
|
-
setMsj("")
|
|
110
|
+
addEmployee(employee);
|
|
111
|
+
setMsj("");
|
|
104
112
|
localforage.setItem('anniversary-docs', {
|
|
105
113
|
items: employee,
|
|
106
114
|
date: Date.now() + updateTimer,
|
|
107
115
|
mode: dataMode
|
|
108
116
|
})
|
|
109
117
|
} else {
|
|
110
|
-
setMsj("Ningún ingreso que mostrar")
|
|
118
|
+
setMsj("Ningún ingreso que mostrar");
|
|
111
119
|
}
|
|
112
120
|
} else {
|
|
113
|
-
setMsj("Invalid URL")
|
|
121
|
+
setMsj("Invalid URL");
|
|
114
122
|
}
|
|
115
123
|
} catch (error) {
|
|
116
|
-
console.log(error)
|
|
124
|
+
console.log(error);
|
|
117
125
|
}
|
|
118
|
-
}
|
|
126
|
+
};
|
|
119
127
|
|
|
120
128
|
return msj !== "" ? (
|
|
121
|
-
<FormattedText
|
|
129
|
+
<FormattedText
|
|
130
|
+
text={msj}
|
|
131
|
+
format={
|
|
132
|
+
configureState.parameters.nameFormat ||
|
|
133
|
+
configureState.parameters.descriptionFormat
|
|
134
|
+
}
|
|
135
|
+
/>
|
|
122
136
|
) : (
|
|
123
137
|
<Render start={start} />
|
|
124
|
-
)
|
|
125
|
-
}
|
|
138
|
+
);
|
|
139
|
+
};
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import { ConfigureContext } from '
|
|
3
|
+
import { ConfigureContext } from '../contex/configureContext/ConfigureContext'
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
paths: Array<string>
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const FontLoader = ({ paths
|
|
9
|
+
export const FontLoader = ({ paths}: Props) => {
|
|
10
|
+
|
|
10
11
|
const { configureState } = useContext(ConfigureContext)
|
|
11
12
|
const { parameters, downloadsPath } = configureState
|
|
12
13
|
|
|
13
|
-
const _getValueByPath = (path:
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const _getValueByPath = (path: any, obj: any): any => {
|
|
15
|
+
let pathsArray = path.split('.')
|
|
16
|
+
let propertyName = pathsArray[0]
|
|
16
17
|
if (pathsArray.length === 1) return obj[propertyName]
|
|
17
18
|
else {
|
|
18
19
|
pathsArray.splice(0, 1)
|
|
19
20
|
return _getValueByPath(pathsArray.join('.'), obj[propertyName])
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
const fonts = paths.map((path: any) => {
|
|
23
|
+
let fonts = paths.map((path: any) => {
|
|
24
24
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
let fontParam = _getValueByPath(path, parameters)
|
|
26
|
+
let font = {
|
|
27
27
|
family: fontParam.filename.replace('.', '-'),
|
|
28
28
|
src: `${downloadsPath}/${fontParam.filename}`
|
|
29
29
|
}
|
|
30
30
|
return `
|
|
31
31
|
@font-face {
|
|
32
|
-
font-family:
|
|
33
|
-
src: url(
|
|
32
|
+
font-family: "${font.family}";
|
|
33
|
+
src: url("${font.src}");
|
|
34
34
|
}
|
|
35
35
|
`
|
|
36
36
|
} catch (err) {
|
|
@@ -43,6 +43,7 @@ export const FontLoader = ({ paths }: Props) => {
|
|
|
43
43
|
)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
|
|
46
47
|
FontLoader.defaultProps = {
|
|
47
48
|
paths: [],
|
|
48
49
|
parameters: {},
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { isNumber } from 'lodash'
|
|
3
|
+
|
|
4
|
+
const alignments = {
|
|
5
|
+
center: 'center',
|
|
6
|
+
left: 'flex-start',
|
|
7
|
+
right: 'flex-end'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type aligment = {
|
|
11
|
+
horizontal: keyof typeof alignments,
|
|
12
|
+
vertical: keyof typeof alignments
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
format?: any
|
|
18
|
+
lineHeight: number
|
|
19
|
+
maxChar?: number
|
|
20
|
+
style?: number
|
|
21
|
+
text: string
|
|
22
|
+
unit: string
|
|
23
|
+
}
|
|
24
|
+
export const FormattedText = ({ text, format, maxChar, lineHeight, style, unit }: Props) => {
|
|
25
|
+
|
|
26
|
+
const trimText = (text: any, maxChar: any) => {
|
|
27
|
+
const isValid = maxChar && isNumber(maxChar) && maxChar >= 3
|
|
28
|
+
if (isValid && (text && text.length > maxChar) || false) {
|
|
29
|
+
let returnText = text.substring(0, maxChar - 3)
|
|
30
|
+
returnText.substr(-1, 3)
|
|
31
|
+
return `${returnText.trim()}...`
|
|
32
|
+
}
|
|
33
|
+
return text
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const checkNested = (obj: any, path: any): any => {
|
|
37
|
+
let arr = path.split('.')
|
|
38
|
+
if (arr.length > 0) {
|
|
39
|
+
if (obj.hasOwnProperty(arr[0])) {
|
|
40
|
+
if (arr.length > 1) return checkNested(obj[arr[0]], arr.splice(1).join('.'))
|
|
41
|
+
else return true
|
|
42
|
+
} else return false
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const getHorizontalAlignment = (alignment: aligment) => {
|
|
47
|
+
if (alignment) {
|
|
48
|
+
let hA = alignment.horizontal
|
|
49
|
+
return alignments.hasOwnProperty(hA) ? alignments[alignment.horizontal] : 'flex-start'
|
|
50
|
+
}
|
|
51
|
+
return 'flex-start'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const renderText = maxChar ? trimText(text, maxChar) : text
|
|
55
|
+
|
|
56
|
+
let containerStyle = Object.assign({
|
|
57
|
+
display: 'inline-flex',
|
|
58
|
+
justifyContent: getHorizontalAlignment(format.alignment)
|
|
59
|
+
}, style)
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div style={containerStyle}>
|
|
63
|
+
<span style={{
|
|
64
|
+
color: format.fontColor,
|
|
65
|
+
fontFamily: checkNested(format, 'font.filename') ? `"${format.font.filename.replace('.', '-')}"` : '',
|
|
66
|
+
fontSize: `${format.fontSize}${unit}`,
|
|
67
|
+
textAlign: checkNested(format, 'alignment.horizontal') ? format.alignment.horizontal : 'left',
|
|
68
|
+
lineHeight: lineHeight
|
|
69
|
+
}}>{renderText}</span>
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
FormattedText.defaultProps = {
|
|
77
|
+
format: {},
|
|
78
|
+
lineHeight: 1,
|
|
79
|
+
unit: 'vh',
|
|
80
|
+
maxChar: undefined
|
|
81
|
+
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
|
-
import { ConfigureContext } from '
|
|
3
|
-
import { DataContext } from '
|
|
4
|
-
import { FontLoader } from '
|
|
5
|
-
import { FormattedText } from '
|
|
6
|
-
import { AnniversaryItem } from '
|
|
7
|
-
import { ItemsContainer } from '
|
|
2
|
+
import { ConfigureContext } from '../contex/configureContext/ConfigureContext';
|
|
3
|
+
import { DataContext } from '../contex/dataContext/DataContex';
|
|
4
|
+
import { FontLoader } from './FontLoader';
|
|
5
|
+
import { FormattedText } from './FormattedText';
|
|
6
|
+
import { AnniversaryItem } from './anniversary-item/AnniversaryItem';
|
|
7
|
+
import { ItemsContainer } from './items-container/ItemsContainer';
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
10
|
start: boolean
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const Render = ({ start }: Props) => {
|
|
14
|
+
|
|
14
15
|
const { configureState } = useContext(ConfigureContext)
|
|
15
16
|
const { dataEmployee } = useContext(DataContext)
|
|
16
17
|
const { parameters, downloadsPath } = configureState
|
|
@@ -23,10 +24,11 @@ export const Render = ({ start }: Props) => {
|
|
|
23
24
|
animationTime,
|
|
24
25
|
} = parameters
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
? `url("${downloadsPath}/${backgroundImage.filename}")`
|
|
27
|
+
let backgroundImageState = backgroundImage && backgroundImage.filename
|
|
28
|
+
? `url("${downloadsPath}/${backgroundImage.filename}")`
|
|
29
|
+
: ''
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
let anniversaryItems = dataEmployee.dataEmployee.map((anniversary: DataEmployee) => {
|
|
30
32
|
return <AnniversaryItem style={'standard'} anniversary={anniversary} />
|
|
31
33
|
})
|
|
32
34
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { ClasicItem } from './clasic/ClasicItem'
|
|
3
|
+
|
|
4
|
+
const itemStyles = {
|
|
5
|
+
standard: ClasicItem
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
style: string,
|
|
10
|
+
anniversary: DataEmployee
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const AnniversaryItem = ({ style, anniversary }: Props) => {
|
|
14
|
+
|
|
15
|
+
// let StyledItem = itemStyles.hasOwnProperty(this.props.style) ? itemStyles['circle'] : itemStyles.standard
|
|
16
|
+
let StyledItem = itemStyles.hasOwnProperty(style) ? itemStyles['standard'] : itemStyles.standard
|
|
17
|
+
|
|
18
|
+
return <StyledItem anniversary={anniversary} />
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { AnniversaryImage } from "../shared/AnniversaryImage";
|
|
3
|
+
import { Separator } from "../shared/separator/Separator";
|
|
4
|
+
import { AnniversaryDate } from "../shared/anniversary-date/AnniversaryDate";
|
|
5
|
+
import { FormattedText } from "../../FormattedText";
|
|
6
|
+
import { ConfigureContext } from "../../../contex/configureContext/ConfigureContext";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
anniversary: DataEmployee;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const ClasicItem = ({ anniversary }: Props) => {
|
|
13
|
+
const { configureState } = useContext(ConfigureContext);
|
|
14
|
+
const { parameters, downloadsPath } = configureState;
|
|
15
|
+
|
|
16
|
+
const { orientation, separatorColor, separatorWidth, imageSize } = parameters;
|
|
17
|
+
const cont = useRef(null);
|
|
18
|
+
|
|
19
|
+
const parseBorderMargin = (marginString: any) => {
|
|
20
|
+
let pattern = /(( )?[+-]?[0-9]+.?([0-9]+)?(px|em|ex|%|in|cm|mm|pt|pc))?/g;
|
|
21
|
+
let match = marginString ? marginString.match(pattern) : [""];
|
|
22
|
+
switch (match.length) {
|
|
23
|
+
case 1:
|
|
24
|
+
return { r: "4%", l: "4%" };
|
|
25
|
+
case 2:
|
|
26
|
+
return { r: match[0], l: match[0] };
|
|
27
|
+
default:
|
|
28
|
+
return { r: match[0], l: match[1] };
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const parseElementStyles = (
|
|
33
|
+
margin: string,
|
|
34
|
+
position: number,
|
|
35
|
+
defaultPosition: number,
|
|
36
|
+
parameters: VixonicParameters
|
|
37
|
+
) => {
|
|
38
|
+
const { orientation, separator } = parameters;
|
|
39
|
+
const marginAttr = orientation === "v" ? "marginBottom" : "marginRight";
|
|
40
|
+
const sizeAttr = orientation === "v" ? "width" : "height";
|
|
41
|
+
let pos = position !== undefined ? position : defaultPosition;
|
|
42
|
+
return {
|
|
43
|
+
order: pos,
|
|
44
|
+
[sizeAttr]: "100%",
|
|
45
|
+
[marginAttr]:
|
|
46
|
+
margin !== undefined && margin !== ""
|
|
47
|
+
? `${margin}%`
|
|
48
|
+
: pos === 3 || separator === true
|
|
49
|
+
? 0
|
|
50
|
+
: "4%",
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const parseParameters = (parameters: any) => {
|
|
55
|
+
const imageAlignment = parameters.imageAlignment || "center";
|
|
56
|
+
const textAlignment = parameters.textAlignment || "center";
|
|
57
|
+
const dateAlignment = parameters.dateAlignment || "center";
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
imageEnabled: parameters.imageEnabled,
|
|
61
|
+
imageStyle: Object.assign(
|
|
62
|
+
{
|
|
63
|
+
flexShrink: 0,
|
|
64
|
+
display: "flex",
|
|
65
|
+
justifyContent: imageAlignment,
|
|
66
|
+
alignItems: imageAlignment,
|
|
67
|
+
},
|
|
68
|
+
parseElementStyles(
|
|
69
|
+
parameters.imageMargin,
|
|
70
|
+
parameters.imagePosition,
|
|
71
|
+
1,
|
|
72
|
+
parameters
|
|
73
|
+
)
|
|
74
|
+
),
|
|
75
|
+
descriptionEnabled: parameters.descriptionEnabled,
|
|
76
|
+
optionalEnabled: parameters.optionalEnabled,
|
|
77
|
+
textStyle: Object.assign(
|
|
78
|
+
{ display: "flex", justifyContent: textAlignment, flex: 1 },
|
|
79
|
+
parseElementStyles(
|
|
80
|
+
parameters.textMargin,
|
|
81
|
+
parameters.textPosition,
|
|
82
|
+
2,
|
|
83
|
+
parameters
|
|
84
|
+
)
|
|
85
|
+
),
|
|
86
|
+
dateEnabled: parameters.dateEnabled,
|
|
87
|
+
dateStyle: Object.assign(
|
|
88
|
+
{
|
|
89
|
+
display: "flex",
|
|
90
|
+
justifyContent: dateAlignment,
|
|
91
|
+
alignItems: dateAlignment,
|
|
92
|
+
flexShrink: 0,
|
|
93
|
+
},
|
|
94
|
+
parseElementStyles(
|
|
95
|
+
parameters.dateMargin,
|
|
96
|
+
parameters.datePosition,
|
|
97
|
+
3,
|
|
98
|
+
parameters
|
|
99
|
+
)
|
|
100
|
+
),
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const [margins, setMargins] = useState(
|
|
105
|
+
parseBorderMargin(parameters.itemMargins)
|
|
106
|
+
);
|
|
107
|
+
const [state, setState] = useState(
|
|
108
|
+
Object.assign({}, parseParameters(parameters))
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
setMargins(parseBorderMargin(parameters.itemMargins));
|
|
113
|
+
setState(Object.assign({}, parseParameters(parameters)));
|
|
114
|
+
}, []);
|
|
115
|
+
|
|
116
|
+
const getPhotoUrl = (filename: string) => {
|
|
117
|
+
let mode = parameters.photosMode;
|
|
118
|
+
if (
|
|
119
|
+
mode === "zip" &&
|
|
120
|
+
parameters.photosZip &&
|
|
121
|
+
parameters.photosZip.filename !== undefined
|
|
122
|
+
) {
|
|
123
|
+
return (
|
|
124
|
+
downloadsPath +
|
|
125
|
+
"/" +
|
|
126
|
+
parameters.photosZip.filename.replace(".zip", "/") +
|
|
127
|
+
filename
|
|
128
|
+
);
|
|
129
|
+
} else {
|
|
130
|
+
return filename; //this.props.parameters.photosUrl + filename
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const separatorProps = {
|
|
135
|
+
orientation: orientation,
|
|
136
|
+
size: separatorWidth,
|
|
137
|
+
color: separatorColor,
|
|
138
|
+
margins:
|
|
139
|
+
orientation === "v"
|
|
140
|
+
? `${margins.r} 0 ${margins.l} 0`
|
|
141
|
+
: `0 ${margins.r} 0 ${margins.l}`,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<div
|
|
146
|
+
style={{
|
|
147
|
+
display: "flex",
|
|
148
|
+
flexDirection: orientation === "v" ? "column" : "row",
|
|
149
|
+
backgroundColor: "transparent",
|
|
150
|
+
overflow: "hidden",
|
|
151
|
+
alignItems: "center",
|
|
152
|
+
height: "100%",
|
|
153
|
+
width: "100%",
|
|
154
|
+
}}
|
|
155
|
+
ref={cont}
|
|
156
|
+
>
|
|
157
|
+
{state.imageEnabled && parameters.imageStyle && (
|
|
158
|
+
<div style={state.imageStyle}>
|
|
159
|
+
{
|
|
160
|
+
<AnniversaryImage
|
|
161
|
+
url={anniversary.image ? getPhotoUrl(anniversary.image) : null}
|
|
162
|
+
orientation={orientation}
|
|
163
|
+
size={imageSize}
|
|
164
|
+
borderStyle={parameters.imageStyle}
|
|
165
|
+
/>
|
|
166
|
+
}
|
|
167
|
+
</div>
|
|
168
|
+
)}
|
|
169
|
+
{state.imageEnabled && parameters.separator && (
|
|
170
|
+
<Separator order={state.imageStyle.order} {...separatorProps} />
|
|
171
|
+
)}
|
|
172
|
+
<div
|
|
173
|
+
style={{
|
|
174
|
+
...state.textStyle,
|
|
175
|
+
flexDirection: "column",
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
<FormattedText
|
|
179
|
+
text={anniversary.name}
|
|
180
|
+
format={parameters.nameFormat}
|
|
181
|
+
maxChar={Number(parameters.nameMaxChar)}
|
|
182
|
+
lineHeight={1.2}
|
|
183
|
+
/>
|
|
184
|
+
{state.descriptionEnabled && (
|
|
185
|
+
<FormattedText
|
|
186
|
+
text={anniversary.position}
|
|
187
|
+
format={parameters.descriptionFormat}
|
|
188
|
+
maxChar={Number(parameters.descriptionMaxChar)}
|
|
189
|
+
lineHeight={1.2}
|
|
190
|
+
/>
|
|
191
|
+
)}
|
|
192
|
+
{
|
|
193
|
+
state.optionalEnabled && (
|
|
194
|
+
<FormattedText
|
|
195
|
+
text={anniversary.optional}
|
|
196
|
+
format={parameters.optionalFormat}
|
|
197
|
+
maxChar={Number(parameters.descriptionMaxChar)}
|
|
198
|
+
lineHeight={1.2}
|
|
199
|
+
/>
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
</div>
|
|
203
|
+
{parameters.separator && (
|
|
204
|
+
<Separator order={state.textStyle.order} {...separatorProps} />
|
|
205
|
+
)}
|
|
206
|
+
{state.dateEnabled && parameters.dateStyle && (
|
|
207
|
+
<div style={state.dateStyle}>
|
|
208
|
+
<AnniversaryDate
|
|
209
|
+
style={parameters.dateStyle}
|
|
210
|
+
day={anniversary.day}
|
|
211
|
+
month={anniversary.month}
|
|
212
|
+
/>
|
|
213
|
+
</div>
|
|
214
|
+
)}
|
|
215
|
+
{state.dateEnabled && parameters.separator && (
|
|
216
|
+
<Separator order={state.dateStyle.order} {...separatorProps} />
|
|
217
|
+
)}
|
|
218
|
+
</div>
|
|
219
|
+
);
|
|
220
|
+
};
|