@vixoniccom/aniversarios 1.2.1-dev.1 → 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 -14
- 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 -54
- 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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react"
|
|
2
|
+
|
|
3
|
+
type State = {
|
|
4
|
+
data: string | null
|
|
5
|
+
loading: boolean,
|
|
6
|
+
error: boolean | null
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export const useFetch = (url: string): State => {
|
|
11
|
+
|
|
12
|
+
const isMounted = useRef(true);
|
|
13
|
+
const [state, setState] = useState<State>({ data: null, loading: true, error: null })
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
return () => {
|
|
17
|
+
isMounted.current = false;
|
|
18
|
+
}
|
|
19
|
+
}, [])
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
|
|
24
|
+
setState({ data: null, loading: true, error: null });
|
|
25
|
+
|
|
26
|
+
fetch(url, {
|
|
27
|
+
headers: {
|
|
28
|
+
'Authorization': `Token`
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
.then(resp => resp.json())
|
|
32
|
+
.then(data => {
|
|
33
|
+
|
|
34
|
+
if (isMounted.current) {
|
|
35
|
+
setState({
|
|
36
|
+
loading: false,
|
|
37
|
+
error: null,
|
|
38
|
+
data
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
}, [url])
|
|
45
|
+
|
|
46
|
+
return state;
|
|
47
|
+
}
|
package/src/main.tsx
CHANGED
|
@@ -2,8 +2,8 @@ import ReactDOM from 'react-dom'
|
|
|
2
2
|
import React from 'react'
|
|
3
3
|
const { ipcRenderer } = require('electron')
|
|
4
4
|
import { App } from './App';
|
|
5
|
-
import { AnniversaryProvider } from './
|
|
6
|
-
import { DataProvider } from './
|
|
5
|
+
import { AnniversaryProvider } from './contex/configureContext/ConfigureProvider';
|
|
6
|
+
import { DataProvider } from './contex/dataContext/DataProvider';
|
|
7
7
|
|
|
8
8
|
let start: boolean = false
|
|
9
9
|
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// import moment from "moment"
|
|
2
|
+
// import _ from 'lodash'
|
|
3
|
+
|
|
4
|
+
// /**
|
|
5
|
+
// * @class Birthdays
|
|
6
|
+
// */
|
|
7
|
+
// class Income {
|
|
8
|
+
|
|
9
|
+
// public _data: any
|
|
10
|
+
// public day: any
|
|
11
|
+
|
|
12
|
+
// constructor() {
|
|
13
|
+
// /** @type {Birthday[][] | undefined} */
|
|
14
|
+
// this._data = undefined
|
|
15
|
+
// }
|
|
16
|
+
|
|
17
|
+
// /**
|
|
18
|
+
// * @type {Birthday[][]}
|
|
19
|
+
// */
|
|
20
|
+
// get data() {
|
|
21
|
+
// return this._data
|
|
22
|
+
// }
|
|
23
|
+
|
|
24
|
+
// /**
|
|
25
|
+
// * @typedef BirthdaysUpdateOptions
|
|
26
|
+
// * @property {Birthday[][]} data
|
|
27
|
+
// * @property {Birthday[][]} api
|
|
28
|
+
// */
|
|
29
|
+
// /**
|
|
30
|
+
// * @param {BirthdaysUpdateOptions} options
|
|
31
|
+
// * @param {*} callback
|
|
32
|
+
// */
|
|
33
|
+
|
|
34
|
+
// update(options : any) {
|
|
35
|
+
|
|
36
|
+
// if (options.data) {
|
|
37
|
+
// this._data = options.data
|
|
38
|
+
// } else if (options.api) {
|
|
39
|
+
// this._data = this.parseFromApi(options.api)
|
|
40
|
+
// }
|
|
41
|
+
// }
|
|
42
|
+
|
|
43
|
+
// getAnniversaryFromMonth(apiData:any, month:any) {
|
|
44
|
+
// let monthArray = []
|
|
45
|
+
// for (let i = 0; i < apiData.length; i++) {
|
|
46
|
+
// let monthA = Number(moment(apiData[i].fechaInic, 'YYYY-MM-DD').format('M')) - 1
|
|
47
|
+
// if (monthA === month) {
|
|
48
|
+
// let dayA = Number(moment(apiData[i].fechaInic, 'YYYY-MM-DD').format('D'))
|
|
49
|
+
// let income = new Ingress({
|
|
50
|
+
// day: dayA,
|
|
51
|
+
// month: month,
|
|
52
|
+
// name: `${apiData[i].nombre} ${apiData[i].apellidoPate}`,
|
|
53
|
+
// description: undefined,
|
|
54
|
+
// image: apiData[i].foto
|
|
55
|
+
// })
|
|
56
|
+
// monthArray.push(income)
|
|
57
|
+
// }
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
// monthArray.sort((a, b) => {
|
|
61
|
+
// if (a.day < b.day) return -1
|
|
62
|
+
// else if (a.day === b.day) return 0
|
|
63
|
+
// else return 1
|
|
64
|
+
// })
|
|
65
|
+
// return monthArray
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
// parseFromApi(apiData:any) {
|
|
69
|
+
// let monthsArray = []
|
|
70
|
+
// for (let month = 0; month < 12; month++) {
|
|
71
|
+
// let monthArray = this.getAnniversaryFromMonth(apiData, month)
|
|
72
|
+
// monthsArray.push(monthArray)
|
|
73
|
+
// }
|
|
74
|
+
|
|
75
|
+
// return monthsArray
|
|
76
|
+
// }
|
|
77
|
+
|
|
78
|
+
// /**
|
|
79
|
+
// * @param {string} mode
|
|
80
|
+
// * @param {boolean} excludePast
|
|
81
|
+
// */
|
|
82
|
+
// getList(mode :any, excludePast:any) {
|
|
83
|
+
|
|
84
|
+
// if (!mode) mode = 'monthly'
|
|
85
|
+
// let dd = moment()
|
|
86
|
+
// let month = Number(dd.format('M'))
|
|
87
|
+
// let today = Number(dd.format('D'))
|
|
88
|
+
|
|
89
|
+
// /**
|
|
90
|
+
// * Filter method
|
|
91
|
+
// * @param {Anniversary[]} data
|
|
92
|
+
// * @inner
|
|
93
|
+
// */
|
|
94
|
+
// let filter = (data:any) => {
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
// const filterMonthDay = excludePast ? data.filter((da:any )=> da.month >= (month - 1)).filter((da:any) => da.day >= today) : data
|
|
98
|
+
|
|
99
|
+
// return filterMonthDay
|
|
100
|
+
// }
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
// return filter(_.flatten(this._data))
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
// }
|
|
107
|
+
// }
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
// class Ingress {
|
|
111
|
+
|
|
112
|
+
// public day
|
|
113
|
+
// public month
|
|
114
|
+
// public name
|
|
115
|
+
// public description
|
|
116
|
+
// public image
|
|
117
|
+
|
|
118
|
+
// constructor(options:any) {
|
|
119
|
+
|
|
120
|
+
// this.day = options.day
|
|
121
|
+
// this.month = options.month
|
|
122
|
+
// this.name = options.name
|
|
123
|
+
// this.description = options.description
|
|
124
|
+
// this.image = options.image
|
|
125
|
+
// }
|
|
126
|
+
|
|
127
|
+
// }
|
|
128
|
+
|
|
129
|
+
// module.exports = exports = Animation
|
package/src/test/parameters.json
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
"imageStyle": "circle",
|
|
16
|
-
"nameFormat": {
|
|
17
|
-
"font": {
|
|
18
|
-
"id": "7953953c-7029-4730-ae4d-cff4abd5288f",
|
|
19
|
-
"filename": "7953953c-7029-4730-ae4d-cff4abd5288f.ttf",
|
|
20
|
-
"__isAsset": true
|
|
21
|
-
},
|
|
22
|
-
"fontSize": 3.8,
|
|
23
|
-
"alignment": {
|
|
24
|
-
"horizontal": "left"
|
|
25
|
-
},
|
|
26
|
-
"fontColor": "#585858"
|
|
27
|
-
},
|
|
28
|
-
"photosMode": "zip",
|
|
29
|
-
"updateTime": 60000,
|
|
30
|
-
"dateEnabled": true,
|
|
31
|
-
"excludePast": false,
|
|
32
|
-
"itemMargins": "5px",
|
|
33
|
-
"orientation": "h",
|
|
34
|
-
"datePosition": 1,
|
|
35
|
-
"imageEnabled": true,
|
|
36
|
-
"textPosition": 3,
|
|
37
|
-
"animationMode": "fade",
|
|
38
|
-
"animationTime": "5",
|
|
39
|
-
"containerRows": "3",
|
|
40
|
-
"dateAlignment": "center",
|
|
41
|
-
"dateDayFormat": {
|
|
42
|
-
"font": {
|
|
43
|
-
"id": "c705a739-312e-4334-9231-e73a05e9d382",
|
|
44
|
-
"filename": "c705a739-312e-4334-9231-e73a05e9d382.ttf",
|
|
45
|
-
"__isAsset": true
|
|
2
|
+
"parameters": {
|
|
3
|
+
"apiDomain": "https://docs.google.com/spreadsheets/d/1g-tvPAIk7tCXgn6DuwHp3zC8Gmx55C3wyxZkfSK4VcE/edit?usp=sharing",
|
|
4
|
+
"msj0": " No ingresos ",
|
|
5
|
+
"padding": "365px 25px 80px 40px",
|
|
6
|
+
"dataMode": "yearly",
|
|
7
|
+
"template": "standard",
|
|
8
|
+
"dateStyle": "circle",
|
|
9
|
+
"photosZip": {
|
|
10
|
+
"id": "d1093778-f3c9-42c8-9b07-9f8736390aeb",
|
|
11
|
+
"filename": "d1093778-f3c9-42c8-9b07-9f8736390aeb.zip",
|
|
12
|
+
"__isAsset": true,
|
|
13
|
+
"extension": "zip"
|
|
46
14
|
},
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
15
|
+
"imageStyle": "circle",
|
|
16
|
+
"nameFormat": {
|
|
17
|
+
"font": {
|
|
18
|
+
"id": "7953953c-7029-4730-ae4d-cff4abd5288f",
|
|
19
|
+
"filename": "7953953c-7029-4730-ae4d-cff4abd5288f.ttf",
|
|
20
|
+
"__isAsset": true
|
|
21
|
+
},
|
|
22
|
+
"fontSize": 3.8,
|
|
23
|
+
"alignment": {
|
|
24
|
+
"horizontal": "left"
|
|
25
|
+
},
|
|
26
|
+
"fontColor": "#585858"
|
|
50
27
|
},
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"
|
|
28
|
+
"photosMode": "zip",
|
|
29
|
+
"updateTime": 600000,
|
|
30
|
+
"dateEnabled": true,
|
|
31
|
+
"excludePast": false,
|
|
32
|
+
"itemMargins": "5px",
|
|
33
|
+
"orientation": "h",
|
|
34
|
+
"datePosition": 1,
|
|
35
|
+
"imageEnabled": true,
|
|
36
|
+
"textPosition": 3,
|
|
37
|
+
"animationMode": "fade",
|
|
38
|
+
"animationTime": "5",
|
|
39
|
+
"containerRows": "3",
|
|
40
|
+
"dateAlignment": "center",
|
|
41
|
+
"dateDayFormat": {
|
|
42
|
+
"font": {
|
|
43
|
+
"id": "c705a739-312e-4334-9231-e73a05e9d382",
|
|
44
|
+
"filename": "c705a739-312e-4334-9231-e73a05e9d382.ttf",
|
|
45
|
+
"__isAsset": true
|
|
46
|
+
},
|
|
47
|
+
"fontSize": 55,
|
|
48
|
+
"alignment": {
|
|
49
|
+
"horizontal": "center"
|
|
50
|
+
},
|
|
51
|
+
"fontColor": "#ffffff"
|
|
72
52
|
},
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"id": "7953953c-7029-4730-ae4d-cff4abd5288f",
|
|
82
|
-
"filename": "7953953c-7029-4730-ae4d-cff4abd5288f.ttf",
|
|
53
|
+
"imagePosition": 2,
|
|
54
|
+
"textAlignment": "center",
|
|
55
|
+
"animationOrder": false,
|
|
56
|
+
"animationSpeed": 1.5,
|
|
57
|
+
"imageAlignment": "center",
|
|
58
|
+
"backgroundImage": {
|
|
59
|
+
"id": "cumples",
|
|
60
|
+
"filename": "cumples.png",
|
|
83
61
|
"__isAsset": true
|
|
84
62
|
},
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
"
|
|
96
|
-
"filename": "7953953c-7029-4730-ae4d-cff4abd5288f.ttf",
|
|
97
|
-
"__isAsset": true
|
|
63
|
+
"dateMonthFormat": {
|
|
64
|
+
"font": {
|
|
65
|
+
"id": "7953953c-7029-4730-ae4d-cff4abd5288f",
|
|
66
|
+
"filename": "7953953c-7029-4730-ae4d-cff4abd5288f.ttf",
|
|
67
|
+
"__isAsset": true
|
|
68
|
+
},
|
|
69
|
+
"fontSize": 20,
|
|
70
|
+
"alignment": {
|
|
71
|
+
"horizontal": "center"
|
|
72
|
+
},
|
|
73
|
+
"fontColor": "#ffffff"
|
|
98
74
|
},
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
|
|
75
|
+
"containerColumns": "1",
|
|
76
|
+
"containerRowsGap": "5",
|
|
77
|
+
"datePrimaryColor": "#d13139",
|
|
78
|
+
"abbreviatedMonths": false,
|
|
79
|
+
"descriptionFormat": {
|
|
80
|
+
"font": {
|
|
81
|
+
"id": "7953953c-7029-4730-ae4d-cff4abd5288f",
|
|
82
|
+
"filename": "7953953c-7029-4730-ae4d-cff4abd5288f.ttf",
|
|
83
|
+
"__isAsset": true
|
|
84
|
+
},
|
|
85
|
+
"fontSize": 3.8,
|
|
86
|
+
"alignment": {
|
|
87
|
+
"horizontal": "left"
|
|
88
|
+
},
|
|
89
|
+
"fontColor": "#585858"
|
|
102
90
|
},
|
|
103
|
-
"
|
|
91
|
+
"descriptionEnabled": true,
|
|
92
|
+
"optionalEnabled": true,
|
|
93
|
+
"optionalFormat": {
|
|
94
|
+
"font": {
|
|
95
|
+
"id": "7953953c-7029-4730-ae4d-cff4abd5288f",
|
|
96
|
+
"filename": "7953953c-7029-4730-ae4d-cff4abd5288f.ttf",
|
|
97
|
+
"__isAsset": true
|
|
98
|
+
},
|
|
99
|
+
"fontSize": 3.8,
|
|
100
|
+
"alignment": {
|
|
101
|
+
"horizontal": "left"
|
|
102
|
+
},
|
|
103
|
+
"fontColor": "#585858"
|
|
104
|
+
}
|
|
104
105
|
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
106
|
+
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react'
|
|
2
|
-
import { AnniveraryDateUtils } from '../utils'
|
|
3
|
-
import { FormattedText } from '../../../../FormattedText'
|
|
4
|
-
import { ConfigureContext } from '../../../../../context/configureContext/ConfigureContext'
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
day: number,
|
|
8
|
-
month: number
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const CircleDate: React.FunctionComponent<Props> = ({ day, month }) => {
|
|
12
|
-
const { configureState } = useContext(ConfigureContext)
|
|
13
|
-
const { orientation, dateMonthFormat, datePrimaryColor, dateDayFormat } = configureState.parameters
|
|
14
|
-
const sizeProp = AnniveraryDateUtils.utils(orientation)
|
|
15
|
-
const daySize = (dateDayFormat?.fontSize || 100) * 400 / 100
|
|
16
|
-
const monthSize = (dateMonthFormat?.fontSize || 100) * 400 / 100
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<svg {...sizeProp} viewBox='0 0 400 400' xmlSpace='preserve'>
|
|
20
|
-
<g>
|
|
21
|
-
<circle fill={datePrimaryColor} cx='200' cy='200' r='200' />
|
|
22
|
-
<foreignObject width='400' height='400'>
|
|
23
|
-
<div style={{ height: 400, width: 400, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
|
|
24
|
-
<FormattedText text={AnniveraryDateUtils.getMonth(month, true)} format={Object.assign({}, dateMonthFormat, { fontSize: monthSize })} unit='px' />
|
|
25
|
-
<FormattedText text={AnniveraryDateUtils.getZeroLeadedText(day)} format={Object.assign({}, dateDayFormat, { fontSize: daySize })} unit='px' />
|
|
26
|
-
</div>
|
|
27
|
-
</foreignObject>
|
|
28
|
-
</g>
|
|
29
|
-
</svg>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from "react"
|
|
2
|
-
import { ConfigureContext } from "../../../../../context/configureContext/ConfigureContext"
|
|
3
|
-
import { AnniveraryDateUtils } from "../utils"
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
month: number
|
|
7
|
-
day: number
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const FlatDate: React.FunctionComponent<Props> = ({ month, day }: Props) => {
|
|
11
|
-
const { configureState } = useContext(ConfigureContext)
|
|
12
|
-
const { abbreviatedMonths, dateDayFormat, dateMonthFormat, orientation, datePrimaryColor } = configureState.parameters
|
|
13
|
-
|
|
14
|
-
const sizeProp = AnniveraryDateUtils.utils(orientation)
|
|
15
|
-
const monthSize = ((dateMonthFormat?.fontSize || 18.5) * 400) / 100
|
|
16
|
-
const daySize = ((dateDayFormat?.fontSize || 57.5) * 400) / 100
|
|
17
|
-
|
|
18
|
-
const getFontFamily = (format: any) => {
|
|
19
|
-
if (format?.font?.filename) return format.font.filename.replace('.', '-')
|
|
20
|
-
return ''
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<svg {...sizeProp} viewBox='0 0 400 400' xmlSpace='preserve'>
|
|
25
|
-
<g>
|
|
26
|
-
<path fill={datePrimaryColor} d='M349.5,393.5h-299c-24.3,0-44-19.7-44-44v-299c0-24.3,19.7-44,44-44h299c24.3,0,44,19.7,44,44v299C393.5,373.8,373.8,393.5,349.5,393.5z' />
|
|
27
|
-
<path fill='#FFFFFF' d='M349.5,389.5h-299c-22,0-40-18-40-40v-299c0-22,18-40,40-40h299c22,0,40,18,40,40v299C389.5,371.5,371.5,389.5,349.5,389.5z' />
|
|
28
|
-
<path fill={datePrimaryColor} d='M9,99.9V50.5c0-22.2,18.1-40.3,40.3-40.3h301.4c22.2,0,40.3,18.1,40.3,40.3v49.4H9z' />
|
|
29
|
-
<text fontFamily={`"${getFontFamily(dateMonthFormat)}"`}
|
|
30
|
-
textAnchor='middle'
|
|
31
|
-
alignmentBaseline='central' x='200' y='55'
|
|
32
|
-
fontSize={monthSize} preserveAspectRatio='none'
|
|
33
|
-
fill={dateMonthFormat?.fontColor || '#fff'} fontSizeAdjust=''>
|
|
34
|
-
{AnniveraryDateUtils.getMonth(month, abbreviatedMonths)}
|
|
35
|
-
</text>
|
|
36
|
-
|
|
37
|
-
<text fontFamily={`"${getFontFamily(dateDayFormat)}"`}
|
|
38
|
-
textAnchor='middle'
|
|
39
|
-
alignmentBaseline='central' x='200' y='245'
|
|
40
|
-
fontSize={daySize} preserveAspectRatio='none'
|
|
41
|
-
fill={dateDayFormat?.fontColor || '#fff'} fontSizeAdjust=''>
|
|
42
|
-
{AnniveraryDateUtils.getZeroLeadedText(day)}
|
|
43
|
-
</text>
|
|
44
|
-
</g>
|
|
45
|
-
</svg>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { utils } from '../utils'
|
|
2
|
-
|
|
3
|
-
const Months = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre']
|
|
4
|
-
|
|
5
|
-
export class AnniveraryDateUtils {
|
|
6
|
-
static getZeroLeadedText(text: any) {
|
|
7
|
-
return `0${text}`.slice(-2)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static getMonth(index: any, abbreviated: any) {
|
|
11
|
-
if (!abbreviated) return Months[index]
|
|
12
|
-
return Months[index].substring(0, 3).toUpperCase()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
static utils(orientation: any, size: any = undefined) {
|
|
16
|
-
return utils(orientation, size)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useEffect, useRef, useState } from "react"
|
|
2
|
-
import { AnniversaryDate, AnniversaryImage, Separator } from '..'
|
|
3
|
-
import { FormattedText } from "../../../FormattedText"
|
|
4
|
-
import { ConfigureContext } from "../../../../context/configureContext/ConfigureContext"
|
|
5
|
-
import { getPhotoUrl, parseBorderMargin, parseParameters } from '../utils'
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
anniversary: DataEmployee
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const ClassicItem: React.FunctionComponent<Props> = ({ anniversary }: Props) => {
|
|
12
|
-
let month = anniversary.month
|
|
13
|
-
const cont = useRef(null)
|
|
14
|
-
const { configureState } = useContext(ConfigureContext)
|
|
15
|
-
const { parameters, downloadsPath } = configureState
|
|
16
|
-
const { orientation, separatorColor, separatorWidth, imageSize } = parameters
|
|
17
|
-
const [margins, setMargins] = useState(parseBorderMargin(parameters.itemMargins))
|
|
18
|
-
const [state, setState] = useState(Object.assign({}, parseParameters(parameters)))
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
setMargins(parseBorderMargin(parameters.itemMargins))
|
|
22
|
-
setState(Object.assign({}, parseParameters(parameters)))
|
|
23
|
-
}, [])
|
|
24
|
-
|
|
25
|
-
const separatorProps = {
|
|
26
|
-
orientation: orientation,
|
|
27
|
-
size: separatorWidth,
|
|
28
|
-
color: separatorColor,
|
|
29
|
-
margins: orientation === "v"
|
|
30
|
-
? `${margins.r} 0 ${margins.l} 0`
|
|
31
|
-
: `0 ${margins.r} 0 ${margins.l}`,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div
|
|
36
|
-
style={{
|
|
37
|
-
display: "flex",
|
|
38
|
-
flexDirection: orientation === "v" ? "column" : "row",
|
|
39
|
-
backgroundColor: "transparent",
|
|
40
|
-
overflow: "hidden",
|
|
41
|
-
alignItems: "center",
|
|
42
|
-
height: "100%",
|
|
43
|
-
width: "100%",
|
|
44
|
-
}}
|
|
45
|
-
ref={cont}
|
|
46
|
-
>
|
|
47
|
-
{state.imageEnabled && parameters.imageStyle && (
|
|
48
|
-
<div style={state.imageStyle}>
|
|
49
|
-
{
|
|
50
|
-
<AnniversaryImage
|
|
51
|
-
url={anniversary.image ? getPhotoUrl(anniversary.image, parameters, downloadsPath) : null}
|
|
52
|
-
orientation={orientation}
|
|
53
|
-
size={Number(imageSize) || 100}
|
|
54
|
-
borderStyle={parameters.imageStyle}
|
|
55
|
-
/>
|
|
56
|
-
}
|
|
57
|
-
</div>
|
|
58
|
-
)}
|
|
59
|
-
{state.imageEnabled && parameters.separator && (
|
|
60
|
-
<Separator order={state.imageStyle.order} {...separatorProps} />
|
|
61
|
-
)}
|
|
62
|
-
<div
|
|
63
|
-
style={{
|
|
64
|
-
...state.textStyle,
|
|
65
|
-
flexDirection: "column",
|
|
66
|
-
}}
|
|
67
|
-
>
|
|
68
|
-
<FormattedText
|
|
69
|
-
text={anniversary.name}
|
|
70
|
-
format={parameters.nameFormat}
|
|
71
|
-
maxChar={Number(parameters.nameMaxChar)}
|
|
72
|
-
lineHeight={1.2}
|
|
73
|
-
/>
|
|
74
|
-
{state.descriptionEnabled && (
|
|
75
|
-
<FormattedText
|
|
76
|
-
text={anniversary.position}
|
|
77
|
-
format={parameters.descriptionFormat}
|
|
78
|
-
maxChar={Number(parameters.descriptionMaxChar)}
|
|
79
|
-
lineHeight={1.2}
|
|
80
|
-
/>
|
|
81
|
-
)}
|
|
82
|
-
{state.optionalEnabled && (
|
|
83
|
-
<FormattedText
|
|
84
|
-
text={anniversary.optional}
|
|
85
|
-
format={parameters.optionalFormat}
|
|
86
|
-
maxChar={Number(parameters.descriptionMaxChar)}
|
|
87
|
-
lineHeight={1.2}
|
|
88
|
-
/>
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
</div>
|
|
92
|
-
{parameters.separator && (
|
|
93
|
-
<Separator order={state.textStyle.order} {...separatorProps} />
|
|
94
|
-
)}
|
|
95
|
-
{state.dateEnabled && parameters.dateStyle && (
|
|
96
|
-
<div style={state.dateStyle}>
|
|
97
|
-
<AnniversaryDate
|
|
98
|
-
style={parameters.dateStyle}
|
|
99
|
-
day={anniversary.day}
|
|
100
|
-
month={month}
|
|
101
|
-
/>
|
|
102
|
-
</div>
|
|
103
|
-
)}
|
|
104
|
-
{state.dateEnabled && parameters.separator && (
|
|
105
|
-
<Separator order={state.dateStyle.order} {...separatorProps} />
|
|
106
|
-
)}
|
|
107
|
-
</div>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { AnniversaryDate } from './AnniversaryDate'
|
|
2
|
-
import { AnniversaryImage } from './AnniversaryImage'
|
|
3
|
-
import { ClassicItem } from './ClassicItem'
|
|
4
|
-
import { Separator } from './Separator/Separator'
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
AnniversaryDate,
|
|
8
|
-
AnniversaryImage,
|
|
9
|
-
ClassicItem,
|
|
10
|
-
Separator
|
|
11
|
-
}
|