@vixoniccom/aniversarios 1.2.3-dev.1 → 1.2.3-dev.2
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 +2 -0
- package/build.zip +0 -0
- package/configuration/appearanceGroup/AppearanceInputs.ts +101 -0
- package/configuration/appearanceGroup/index.ts +8 -0
- package/configuration/dataGroup/DataInputs.ts +52 -0
- package/configuration/dataGroup/index.ts +8 -0
- package/configuration/index.ts +8 -0
- package/configuration/standardGroup/StandardInputs.ts +211 -0
- package/configuration/standardGroup/index.ts +8 -0
- package/configuration/utils.ts +17 -0
- package/configuration.json +186 -207
- package/package.json +2 -2
- package/src/App.tsx +14 -113
- package/src/anniversary-loader.ts +70 -0
- package/src/components/AnniversaryItem/components/AnniversaryDate/CircleDate/index.tsx +5 -6
- package/src/components/AnniversaryItem/components/AnniversaryDate/FlatDate/index.tsx +5 -6
- package/src/components/AnniversaryItem/components/AnniversaryDate/OutlineDate/index.tsx +5 -6
- package/src/components/AnniversaryItem/components/AnniversaryDate/TextCalendarDate/index.tsx +4 -5
- package/src/components/AnniversaryItem/components/AnniversaryDate/TextDate/index.tsx +4 -5
- package/src/components/AnniversaryItem/components/AnniversaryDate/index.tsx +4 -4
- package/src/components/AnniversaryItem/components/ClassicItem/index.tsx +8 -8
- package/src/components/AnniversaryItem/index.tsx +4 -4
- package/src/components/FontLoader/index.tsx +5 -10
- package/src/components/ItemsContainer/components/animation.ts +4 -6
- package/src/components/ItemsContainer/index.tsx +7 -7
- package/src/components/Render/index.tsx +12 -13
- package/src/global.d.ts +8 -0
- package/src/main.ts +46 -0
- package/src/parameters.d.ts +4 -119
- package/src/service-parsers.ts +40 -0
- package/src/test/parameters.json +3 -2
- package/src/test/services.json +158 -0
- 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/helpers/filterEmployees.ts +0 -38
- package/src/helpers/getEmployees.ts +0 -29
- package/src/helpers/utils.ts +0 -46
- package/src/main.tsx +0 -43
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixoniccom/aniversarios",
|
|
3
3
|
"alias": "Aniversarios",
|
|
4
|
-
"version": "1.2.3-dev.
|
|
4
|
+
"version": "1.2.3-dev.2",
|
|
5
5
|
"description": "Muestra el día que el trabajador está de aniversario en la empresa.",
|
|
6
6
|
"main": "main.js",
|
|
7
7
|
"author": "",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@types/react": "^18.3.23",
|
|
33
33
|
"@types/react-dom": "^18.3.7",
|
|
34
34
|
"@vixoniccom/module-packager": "2.12.0-dev.10",
|
|
35
|
-
"@vixoniccom/modules": "^2.20.3-dev.
|
|
35
|
+
"@vixoniccom/modules": "^2.20.3-dev.1",
|
|
36
36
|
"standard-version": "^9.5.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/App.tsx
CHANGED
|
@@ -1,125 +1,26 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
2
|
import { FormattedText, Render } from './components'
|
|
3
|
-
import { ConfigureContext } from "./context/configureContext/ConfigureContext"
|
|
4
|
-
import { DataContext } from "./context/dataContext/DataContex"
|
|
5
|
-
import { getEmployees, getEmployeesYearly } from "./helpers/getEmployees"
|
|
6
|
-
import { filterEmployees } from "./helpers/filterEmployees"
|
|
7
|
-
import moment from "moment"
|
|
8
|
-
import { getMonth } from "./helpers/utils"
|
|
9
|
-
import localforage from "localforage"
|
|
10
3
|
|
|
11
|
-
|
|
12
|
-
data: VixonicData
|
|
4
|
+
interface Props {
|
|
13
5
|
start: boolean
|
|
6
|
+
appData: VixonicData
|
|
7
|
+
anniversaries: Anniversary[]
|
|
14
8
|
}
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
| 'Cargando Empleados...'
|
|
18
|
-
| 'Missing google sheets'
|
|
19
|
-
| ""
|
|
20
|
-
| 'Invalid URL'
|
|
10
|
+
export const App: React.FunctionComponent<Props> = ({ start, appData, anniversaries }) => {
|
|
21
11
|
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const { addEmployee } = useContext(DataContext)
|
|
25
|
-
const [dataState, setDataState] = useState(data)
|
|
26
|
-
const [msj, setMsj] = useState<Msj>("")
|
|
27
|
-
const { apiDomain, dataMode, excludePast } = configureState.parameters
|
|
28
|
-
let updateTimer: any
|
|
29
|
-
|
|
30
|
-
const setUpdateTime = (updatedTime: number) => {
|
|
31
|
-
clearTimeout(updateTimer)
|
|
32
|
-
updateTimer = setTimeout(getData, updatedTime)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (apiDomain) localforage.config({ name: `url_request_${apiDomain}` })
|
|
37
|
-
}, [apiDomain])
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
addConfiguration(data)
|
|
41
|
-
setDataState(configureState)
|
|
42
|
-
}, [data])
|
|
12
|
+
const parameters = appData?.parameters
|
|
13
|
+
const [aniversariesElements, setAnniversariesElements] = useState<Anniversary[]>(anniversaries)
|
|
43
14
|
|
|
44
15
|
useEffect(() => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (apiDomain && dataMode) {
|
|
48
|
-
localforage.getItem<{ items: any[], date: number, mode: string }>('anniversary-docs').then((data) => {
|
|
49
|
-
if (!data || dataMode !== data.mode) {
|
|
50
|
-
getData()
|
|
51
|
-
setUpdateTime(updateTime!)
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const now = Date.now()
|
|
56
|
-
const targetDate = data?.date! + updateTime!
|
|
57
|
-
|
|
58
|
-
if (now >= targetDate) {
|
|
59
|
-
getData()
|
|
60
|
-
setUpdateTime(updateTime!)
|
|
61
|
-
} else {
|
|
62
|
-
data && addEmployee(data.items)
|
|
63
|
-
setMsj("")
|
|
64
|
-
setUpdateTime(targetDate - now)
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
if (!apiDomain) setMsj("Missing google sheets")
|
|
69
|
-
}, [dataState])
|
|
70
|
-
|
|
71
|
-
const getData = async () => {
|
|
72
|
-
const urlValid = "https://docs.google.com/spreadsheets/d/"
|
|
73
|
-
let contractEmployees: any
|
|
74
|
-
let employee: any = []
|
|
75
|
-
try {
|
|
76
|
-
if (apiDomain?.includes(urlValid)) {
|
|
77
|
-
const month = Number(moment().format("M")) - 1
|
|
78
|
-
const nextMonth = (month === 11) ? 0 : (month + 1)
|
|
79
|
-
const monthTab = getMonth(month)
|
|
80
|
-
const nextMonthTab = getMonth(nextMonth)
|
|
81
|
-
if (dataMode !== 'yearly') {
|
|
82
|
-
contractEmployees = await getEmployees(apiDomain, monthTab)
|
|
83
|
-
const { values } = contractEmployees.data
|
|
84
|
-
employee.push(...filterEmployees(values, dataMode, excludePast, month))
|
|
85
|
-
if (dataMode === 'weekly') {
|
|
86
|
-
contractEmployees = await getEmployees(apiDomain, nextMonthTab)
|
|
87
|
-
const { values: valuesnextMonth } = contractEmployees.data
|
|
88
|
-
employee.push(...filterEmployees(valuesnextMonth, dataMode, excludePast, nextMonth))
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (dataMode === 'yearly') {
|
|
93
|
-
setMsj('Cargando Empleados...')
|
|
94
|
-
for (let numberMonth: number = 0; numberMonth <= 11; numberMonth++) {
|
|
95
|
-
contractEmployees = await getEmployeesYearly(apiDomain, numberMonth)
|
|
96
|
-
const { values } = contractEmployees.data
|
|
97
|
-
employee.push(...filterEmployees(values, dataMode, excludePast, numberMonth))
|
|
98
|
-
}
|
|
99
|
-
}
|
|
16
|
+
setAnniversariesElements(anniversaries)
|
|
17
|
+
}, [anniversaries])
|
|
100
18
|
|
|
101
|
-
|
|
102
|
-
addEmployee(employee)
|
|
103
|
-
setMsj("")
|
|
104
|
-
localforage.setItem('anniversary-docs', {
|
|
105
|
-
items: employee,
|
|
106
|
-
date: Date.now() + updateTimer,
|
|
107
|
-
mode: dataMode
|
|
108
|
-
})
|
|
109
|
-
} else {
|
|
110
|
-
setMsj("Ningún ingreso que mostrar")
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
setMsj("Invalid URL")
|
|
114
|
-
}
|
|
115
|
-
} catch (error) {
|
|
116
|
-
console.log(error)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
19
|
+
if (!appData) return null
|
|
119
20
|
|
|
120
|
-
return
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
21
|
+
return (
|
|
22
|
+
(aniversariesElements.length === 0) ?
|
|
23
|
+
<FormattedText text={parameters?.defaultMessage ?? 'No hay ingresos para mostrar'} format={parameters?.defaultMessageFormat} />
|
|
24
|
+
: <Render appData={appData} start={start} anniversaries={aniversariesElements} />
|
|
124
25
|
)
|
|
125
26
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { AnniversaryServiceParsers } from "./service-parsers"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export class AnniversaryLoader {
|
|
5
|
+
|
|
6
|
+
public onData: ((birthdays: Anniversary[]) => void) | undefined = undefined
|
|
7
|
+
private updateTime: number = 86400000
|
|
8
|
+
private updateTimer: number | undefined = undefined
|
|
9
|
+
private anniversariesData: Anniversary[] = []
|
|
10
|
+
private serviceType: VixonicData['parameters']['displayService'] = 'AnniversaryAppService'
|
|
11
|
+
|
|
12
|
+
update(appData: VixonicData) {
|
|
13
|
+
console.log("🚀 ~ AnniversaryLoader ~ update ~ appData:", appData)
|
|
14
|
+
|
|
15
|
+
let selectedServiceId: string | undefined
|
|
16
|
+
if (appData.parameters.displayService === 'AnniversaryAppService') {
|
|
17
|
+
console.log("Using AnniversaryAppService")
|
|
18
|
+
selectedServiceId = appData.parameters.documentService?.id
|
|
19
|
+
} else {
|
|
20
|
+
selectedServiceId = appData.parameters.rexmasService?.id
|
|
21
|
+
}
|
|
22
|
+
if (!selectedServiceId || !appData.services[selectedServiceId]) return
|
|
23
|
+
const serviceData = appData.services[selectedServiceId].data as Anniversary[] | undefined
|
|
24
|
+
|
|
25
|
+
const serviceTypeName = appData.parameters.displayService
|
|
26
|
+
|
|
27
|
+
this.serviceType = serviceTypeName ?? 'AnniversaryAppService'
|
|
28
|
+
|
|
29
|
+
if (Array.isArray(serviceData)) {
|
|
30
|
+
const parser = AnniversaryServiceParsers.getParser(this.serviceType)
|
|
31
|
+
this.anniversariesData = parser.parse(serviceData)
|
|
32
|
+
} else {
|
|
33
|
+
this.anniversariesData = []
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this.updateTime = appData.parameters.updateTime ?? 86400000
|
|
37
|
+
this.requestBirthdays()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
stop() {
|
|
41
|
+
this.setUpdateTime(undefined)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private setUpdateTime(milliseconds: number | undefined) {
|
|
45
|
+
window.clearTimeout(this.updateTimer)
|
|
46
|
+
if (milliseconds === undefined) return
|
|
47
|
+
this.updateTimer = window.setTimeout(this.requestBirthdays, milliseconds)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private dispatchData(anniversaries: Anniversary[]) {
|
|
51
|
+
this.onData && this.onData(anniversaries)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private readonly requestBirthdays = () => {
|
|
55
|
+
|
|
56
|
+
window.clearTimeout(this.updateTimer)
|
|
57
|
+
const birthdays: Anniversary[] = []
|
|
58
|
+
|
|
59
|
+
if (Array.isArray(this.anniversariesData)) {
|
|
60
|
+
this.anniversariesData.forEach(item => {
|
|
61
|
+
birthdays.push(item)
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (birthdays.length > 0) { this.dispatchData(birthdays) }
|
|
66
|
+
|
|
67
|
+
this.setUpdateTime(this.updateTime > 10000 ? this.updateTime : 10000)
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import { AnniveraryDateUtils } from '../utils'
|
|
3
3
|
import { FormattedText } from '../../../../FormattedText'
|
|
4
|
-
import { ConfigureContext } from '../../../../../context/configureContext/ConfigureContext'
|
|
5
4
|
|
|
6
5
|
interface Props {
|
|
7
6
|
day: number,
|
|
8
|
-
month: number
|
|
7
|
+
month: number,
|
|
8
|
+
data: VixonicData
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const CircleDate: React.FunctionComponent<Props> = ({ day, month }) => {
|
|
12
|
-
const {
|
|
13
|
-
const { orientation, dateMonthFormat, datePrimaryColor, dateDayFormat } = configureState.parameters
|
|
11
|
+
export const CircleDate: React.FunctionComponent<Props> = ({ day, month, data }) => {
|
|
12
|
+
const { orientation, dateMonthFormat, datePrimaryColor, dateDayFormat } = data.parameters
|
|
14
13
|
const sizeProp = AnniveraryDateUtils.utils(orientation)
|
|
15
14
|
const daySize = (dateDayFormat?.fontSize || 100) * 400 / 100
|
|
16
15
|
const monthSize = (dateMonthFormat?.fontSize || 100) * 400 / 100
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
import { AnniveraryDateUtils } from "../utils"
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { AnniveraryDateUtils } from "../utils"
|
|
4
3
|
|
|
5
4
|
interface Props {
|
|
6
5
|
month: number
|
|
7
6
|
day: number
|
|
7
|
+
data: VixonicData
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const FlatDate: React.FunctionComponent<Props> = ({ month, day }: Props) => {
|
|
11
|
-
|
|
12
|
-
const { abbreviatedMonths, dateDayFormat, dateMonthFormat, orientation, datePrimaryColor } = configureState.parameters
|
|
10
|
+
export const FlatDate: React.FunctionComponent<Props> = ({ month, day, data }: Props) => {
|
|
11
|
+
const { abbreviatedMonths, dateDayFormat, dateMonthFormat, orientation, datePrimaryColor } = data.parameters
|
|
13
12
|
|
|
14
13
|
const sizeProp = AnniveraryDateUtils.utils(orientation)
|
|
15
14
|
const monthSize = ((dateMonthFormat?.fontSize || 18.5) * 400) / 100
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
3
|
-
import { FormattedText } from '../../../../FormattedText'
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { FormattedText } from '../../../../FormattedText'
|
|
4
3
|
import { AnniveraryDateUtils } from '../utils'
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
interface Props {
|
|
8
7
|
day: number
|
|
9
8
|
month: number
|
|
9
|
+
data: VixonicData
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const OutlineDate: React.FunctionComponent<Props> = ({ day, month }: Props) => {
|
|
13
|
-
|
|
14
|
-
const { abbreviatedMonths, dateDayFormat, dateMonthFormat, orientation, datePrimaryColor } = configureState.parameters
|
|
12
|
+
export const OutlineDate: React.FunctionComponent<Props> = ({ day, month, data }: Props) => {
|
|
13
|
+
const { abbreviatedMonths, dateDayFormat, dateMonthFormat, orientation, datePrimaryColor } = data.parameters
|
|
15
14
|
const sizeProp = AnniveraryDateUtils.utils(orientation)
|
|
16
15
|
|
|
17
16
|
const parseFormat = (format: any, defaultSize: any) => {
|
package/src/components/AnniversaryItem/components/AnniversaryDate/TextCalendarDate/index.tsx
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { ConfigureContext } from '../../../../../context/configureContext/ConfigureContext'
|
|
1
|
+
import React, { useState } from 'react'
|
|
3
2
|
import { FormattedText } from '../../../../FormattedText'
|
|
4
3
|
import { AnniveraryDateUtils } from '../utils'
|
|
5
4
|
|
|
6
5
|
interface Props {
|
|
7
6
|
day: number
|
|
8
7
|
month: number
|
|
8
|
+
data: VixonicData
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const TextCalendarDate: React.FunctionComponent<Props> = ({ day, month }: Props) => {
|
|
12
|
-
const {
|
|
13
|
-
const { dateMonthFormat, dateDayFormat, abbreviatedMonths, orientation } = configureState.parameters
|
|
11
|
+
export const TextCalendarDate: React.FunctionComponent<Props> = ({ day, month, data }: Props) => {
|
|
12
|
+
const { dateMonthFormat, dateDayFormat, abbreviatedMonths, orientation } = data.parameters
|
|
14
13
|
const sizeProp = AnniveraryDateUtils.utils(orientation, '100%')
|
|
15
14
|
|
|
16
15
|
const parseFormat = (format: any, defaultSize: any) => {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import { FormattedText } from '../../../../FormattedText'
|
|
3
|
-
import { ConfigureContext } from '../../../../../context/configureContext/ConfigureContext'
|
|
4
3
|
|
|
5
4
|
interface Props {
|
|
6
5
|
day: number
|
|
7
6
|
month: number
|
|
7
|
+
data: VixonicData
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const TextDate: React.FunctionComponent<Props> = ({ day, month }: Props) => {
|
|
11
|
-
const {
|
|
12
|
-
const { dateMonthFormat, dateDayFormat } = configureState.parameters
|
|
10
|
+
export const TextDate: React.FunctionComponent<Props> = ({ day, month, data }: Props) => {
|
|
11
|
+
const { dateMonthFormat, dateDayFormat } = data.parameters
|
|
13
12
|
|
|
14
13
|
return (
|
|
15
14
|
<div style={{ display: 'flex', alignItems: 'center' }}>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import { CircleDate } from './CircleDate'
|
|
3
2
|
import { FlatDate } from './FlatDate'
|
|
4
3
|
import { TextCalendarDate } from './TextCalendarDate'
|
|
@@ -24,12 +23,13 @@ interface itemStyles {
|
|
|
24
23
|
interface Props {
|
|
25
24
|
style: keyof typeof itemStyles,
|
|
26
25
|
day: number,
|
|
27
|
-
month: number
|
|
26
|
+
month: number,
|
|
27
|
+
data: VixonicData
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export const AnniversaryDate = ({ style, day, month }: Props) => {
|
|
30
|
+
export const AnniversaryDate = ({ style, day, month, data }: Props) => {
|
|
31
31
|
const StyledItem = itemStyles.hasOwnProperty(style) ? itemStyles[style] : itemStyles.text
|
|
32
32
|
return (
|
|
33
|
-
<StyledItem day={day} month={month} />
|
|
33
|
+
<StyledItem day={day} month={month} data={data} />
|
|
34
34
|
)
|
|
35
35
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react"
|
|
2
2
|
import { AnniversaryDate, AnniversaryImage, Separator } from '..'
|
|
3
3
|
import { FormattedText } from "../../../FormattedText"
|
|
4
|
-
import { ConfigureContext } from "../../../../context/configureContext/ConfigureContext"
|
|
5
4
|
import { getPhotoUrl, parseBorderMargin, parseParameters } from '../utils'
|
|
6
5
|
|
|
7
6
|
interface Props {
|
|
8
|
-
anniversary:
|
|
7
|
+
anniversary: Anniversary
|
|
8
|
+
data: VixonicData
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const ClassicItem: React.FunctionComponent<Props> = ({ anniversary }: Props) => {
|
|
11
|
+
export const ClassicItem: React.FunctionComponent<Props> = ({ anniversary, data }: Props) => {
|
|
12
12
|
let month = anniversary.month
|
|
13
13
|
const cont = useRef(null)
|
|
14
|
-
const {
|
|
15
|
-
const { parameters, downloadsPath } = configureState
|
|
14
|
+
const { parameters, downloadsPath } = data
|
|
16
15
|
const { orientation, separatorColor, separatorWidth, imageSize } = parameters
|
|
17
16
|
const [margins, setMargins] = useState(parseBorderMargin(parameters.itemMargins))
|
|
18
17
|
const [state, setState] = useState(Object.assign({}, parseParameters(parameters)))
|
|
@@ -73,7 +72,7 @@ export const ClassicItem: React.FunctionComponent<Props> = ({ anniversary }: Pro
|
|
|
73
72
|
/>
|
|
74
73
|
{state.descriptionEnabled && (
|
|
75
74
|
<FormattedText
|
|
76
|
-
text={anniversary.position}
|
|
75
|
+
text={anniversary.position || ''}
|
|
77
76
|
format={parameters.descriptionFormat}
|
|
78
77
|
maxChar={Number(parameters.descriptionMaxChar)}
|
|
79
78
|
lineHeight={1.2}
|
|
@@ -81,7 +80,7 @@ export const ClassicItem: React.FunctionComponent<Props> = ({ anniversary }: Pro
|
|
|
81
80
|
)}
|
|
82
81
|
{state.optionalEnabled && (
|
|
83
82
|
<FormattedText
|
|
84
|
-
text={anniversary.optional}
|
|
83
|
+
text={anniversary.optional || ''}
|
|
85
84
|
format={parameters.optionalFormat}
|
|
86
85
|
maxChar={Number(parameters.descriptionMaxChar)}
|
|
87
86
|
lineHeight={1.2}
|
|
@@ -98,6 +97,7 @@ export const ClassicItem: React.FunctionComponent<Props> = ({ anniversary }: Pro
|
|
|
98
97
|
style={parameters.dateStyle}
|
|
99
98
|
day={anniversary.day}
|
|
100
99
|
month={month}
|
|
100
|
+
data={data}
|
|
101
101
|
/>
|
|
102
102
|
</div>
|
|
103
103
|
)}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import { ClassicItem } from './components'
|
|
3
2
|
|
|
4
3
|
const itemStyles = {
|
|
@@ -7,11 +6,12 @@ const itemStyles = {
|
|
|
7
6
|
|
|
8
7
|
interface Props {
|
|
9
8
|
style: 'standard' | 'custom',
|
|
10
|
-
anniversary:
|
|
9
|
+
anniversary: Anniversary,
|
|
10
|
+
data: VixonicData
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const AnniversaryItem = ({ style, anniversary }: Props) => {
|
|
13
|
+
export const AnniversaryItem = ({ style, anniversary, data }: Props) => {
|
|
14
14
|
const StyledItem = itemStyles.hasOwnProperty(style) ? itemStyles['standard'] : itemStyles.standard
|
|
15
15
|
|
|
16
|
-
return <StyledItem anniversary={anniversary} />
|
|
16
|
+
return <StyledItem anniversary={anniversary} data={data} />
|
|
17
17
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import React, { useContext } from 'react'
|
|
2
1
|
import PropTypes from 'prop-types'
|
|
3
|
-
import { ConfigureContext } from '../../context/configureContext/ConfigureContext'
|
|
4
2
|
|
|
5
3
|
interface Props {
|
|
6
4
|
paths: Array<string>
|
|
5
|
+
data: VixonicData
|
|
7
6
|
}
|
|
8
7
|
|
|
9
|
-
export const FontLoader = ({ paths }: Props) => {
|
|
10
|
-
const {
|
|
11
|
-
const { parameters, downloadsPath } = configureState
|
|
8
|
+
export const FontLoader = ({ paths, data }: Props) => {
|
|
9
|
+
const { parameters, downloadsPath } = data
|
|
12
10
|
|
|
13
11
|
const _getValueByPath = (path: string, obj: any): any => {
|
|
14
12
|
const pathsArray = path.split('.')
|
|
@@ -44,14 +42,11 @@ export const FontLoader = ({ paths }: Props) => {
|
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
FontLoader.defaultProps = {
|
|
47
|
-
paths: []
|
|
48
|
-
parameters: {},
|
|
49
|
-
downloadsPath: ''
|
|
45
|
+
paths: []
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
FontLoader.propTypes = {
|
|
53
49
|
paths: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
54
|
-
|
|
55
|
-
downloadsPath: PropTypes.string
|
|
50
|
+
data: PropTypes.object.isRequired
|
|
56
51
|
}
|
|
57
52
|
|
|
@@ -58,7 +58,7 @@ const animationModes = {
|
|
|
58
58
|
},
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
class
|
|
61
|
+
export class AnimationController {
|
|
62
62
|
public mode: any
|
|
63
63
|
public duration: number
|
|
64
64
|
public speed: number
|
|
@@ -73,12 +73,12 @@ class Animation {
|
|
|
73
73
|
this.reverse = true
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
configure(options: Options) {
|
|
77
|
-
this.mode = animationModes.hasOwnProperty(options.mode) ? animationModes[options.mode] : animationModes.fade
|
|
76
|
+
configure(options: Partial<Options>) {
|
|
77
|
+
this.mode = options.mode && animationModes.hasOwnProperty(options.mode) ? animationModes[options.mode] : animationModes.fade
|
|
78
78
|
this.duration = options.duration || 10000
|
|
79
79
|
this.speed = 1000 * (options.speed || 1)
|
|
80
80
|
this.stagger = this.speed / (options.stagger || 4)
|
|
81
|
-
this.reverse = options.reverse
|
|
81
|
+
this.reverse = options.reverse !== undefined ? options.reverse : true
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
getInitialStyle() {
|
|
@@ -126,5 +126,3 @@ class Animation {
|
|
|
126
126
|
animation.play()
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
module.exports = exports = Animation
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState, useRef, useEffect } from 'react'
|
|
2
2
|
import { Item } from './components/Item'
|
|
3
|
-
import { ConfigureContext } from '../../context/configureContext/ConfigureContext'
|
|
4
3
|
import { useStateWithCallbackLazy } from 'use-state-with-callback'
|
|
5
4
|
import { ReactElementLike } from 'prop-types'
|
|
5
|
+
import { AnimationController } from './components/animation'
|
|
6
6
|
|
|
7
7
|
const stages = {
|
|
8
8
|
idle: 'idle',
|
|
@@ -14,20 +14,20 @@ interface Props {
|
|
|
14
14
|
items: ReactElementLike[],
|
|
15
15
|
animation: Animation,
|
|
16
16
|
animate: boolean
|
|
17
|
+
data: VixonicData
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
interface Animation {
|
|
20
|
-
mode?:
|
|
21
|
+
mode?: "fade" | "slideRight" | "slideLeft"
|
|
21
22
|
duration?: number,
|
|
22
23
|
speed?: number,
|
|
23
24
|
reverse?: boolean
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export const ItemsContainer = ({ animation, items, animate }: Props) => {
|
|
27
|
-
const {
|
|
28
|
-
const { containerColumns, containerRows, containerRowsGap, containerColumnsGap } = configureState.parameters
|
|
27
|
+
export const ItemsContainer = ({ animation, items, animate, data }: Props) => {
|
|
28
|
+
const { containerColumns, containerRows, containerRowsGap, containerColumnsGap } = data.parameters
|
|
29
29
|
const container = useRef<HTMLDivElement>(null)
|
|
30
|
-
const [animations] = useState(new (
|
|
30
|
+
const [animations] = useState(new AnimationController())
|
|
31
31
|
let itemsCount = Number(containerColumns) * Number(containerRows)
|
|
32
32
|
let columns = Number(containerColumns) || 1
|
|
33
33
|
let rows = Number(containerRows) || 1
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import React, { useContext } from 'react'
|
|
2
|
-
import { ConfigureContext } from '../../context/configureContext/ConfigureContext'
|
|
3
|
-
import { DataContext } from '../../context/dataContext/DataContex'
|
|
4
1
|
import { FontLoader } from '../FontLoader'
|
|
5
2
|
import { FormattedText } from '../FormattedText'
|
|
6
3
|
import { AnniversaryItem } from '../AnniversaryItem'
|
|
@@ -8,15 +5,16 @@ import { ItemsContainer } from '../ItemsContainer'
|
|
|
8
5
|
|
|
9
6
|
interface Props {
|
|
10
7
|
start: boolean
|
|
8
|
+
appData: VixonicData
|
|
9
|
+
anniversaries: Anniversary[]
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const {
|
|
16
|
-
const { parameters, downloadsPath } = configureState
|
|
12
|
+
|
|
13
|
+
export const Render = ({ start, appData, anniversaries }: Props) => {
|
|
14
|
+
const { parameters, downloadsPath } = appData
|
|
17
15
|
const { backgroundImage,
|
|
18
16
|
padding,
|
|
19
|
-
|
|
17
|
+
defaultMessage = '',
|
|
20
18
|
animationMode,
|
|
21
19
|
animationOrder,
|
|
22
20
|
animationSpeed,
|
|
@@ -26,8 +24,8 @@ export const Render = ({ start }: Props) => {
|
|
|
26
24
|
const backgroundImageState = backgroundImage && backgroundImage.filename
|
|
27
25
|
? `url("${downloadsPath}/${backgroundImage.filename}")` : ''
|
|
28
26
|
|
|
29
|
-
const anniversaryItems =
|
|
30
|
-
return <AnniversaryItem style={'standard'} anniversary={anniversary} />
|
|
27
|
+
const anniversaryItems = anniversaries.map((anniversary: Anniversary) => {
|
|
28
|
+
return <AnniversaryItem style={'standard'} anniversary={anniversary} data={appData} />
|
|
31
29
|
})
|
|
32
30
|
|
|
33
31
|
return (
|
|
@@ -41,8 +39,8 @@ export const Render = ({ start }: Props) => {
|
|
|
41
39
|
backgroundSize: '100% 100%',
|
|
42
40
|
padding: padding
|
|
43
41
|
}}>
|
|
44
|
-
<FontLoader paths={['nameFormat.font', 'descriptionFormat.font', 'dateDayFormat.font', 'dateMonthFormat.font', 'optionalFormat.font']} />
|
|
45
|
-
{(
|
|
42
|
+
<FontLoader paths={['nameFormat.font', 'descriptionFormat.font', 'dateDayFormat.font', 'dateMonthFormat.font', 'optionalFormat.font']} data={appData} />
|
|
43
|
+
{( anniversaries.length > 0) ?
|
|
46
44
|
<ItemsContainer
|
|
47
45
|
items={anniversaryItems}
|
|
48
46
|
animation={{
|
|
@@ -52,6 +50,7 @@ export const Render = ({ start }: Props) => {
|
|
|
52
50
|
reverse: animationOrder
|
|
53
51
|
}}
|
|
54
52
|
animate={start}
|
|
53
|
+
data={appData}
|
|
55
54
|
/> :
|
|
56
55
|
<div style={{
|
|
57
56
|
width: '100%',
|
|
@@ -60,7 +59,7 @@ export const Render = ({ start }: Props) => {
|
|
|
60
59
|
justifyContent: 'center',
|
|
61
60
|
alignItems: 'center'
|
|
62
61
|
}}>
|
|
63
|
-
<FormattedText text={
|
|
62
|
+
<FormattedText text={defaultMessage.trim() || 'Sin ingresos'} format={parameters.nameFormat || parameters.descriptionFormat} />
|
|
64
63
|
</div>
|
|
65
64
|
}
|
|
66
65
|
</div >
|
package/src/global.d.ts
ADDED
package/src/main.ts
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import ReactDOM from 'react-dom'
|
|
3
|
+
import { App } from './App'
|
|
4
|
+
import { AnniversaryLoader } from './anniversary-loader'
|
|
5
|
+
const { ipcRenderer } = require('electron')
|
|
6
|
+
|
|
7
|
+
let start: boolean = false
|
|
8
|
+
let appData: VixonicData
|
|
9
|
+
let anniversaries: Anniversary[] = []
|
|
10
|
+
|
|
11
|
+
const anniversariesLoader = new AnniversaryLoader()
|
|
12
|
+
|
|
13
|
+
anniversariesLoader.onData = (update) => {
|
|
14
|
+
anniversaries = update
|
|
15
|
+
render()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
ipcRenderer.on('preload', (_event: any, data: VixonicData) => {
|
|
19
|
+
appData = data
|
|
20
|
+
anniversariesLoader.update(data)
|
|
21
|
+
render()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
ipcRenderer.on('start', (_event: any, data: VixonicData) => {
|
|
25
|
+
appData = data
|
|
26
|
+
anniversariesLoader.update(data)
|
|
27
|
+
start = true
|
|
28
|
+
render()
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
ipcRenderer.on('update', (_event: any, data: VixonicData) => {
|
|
32
|
+
appData = data
|
|
33
|
+
anniversariesLoader.update(data)
|
|
34
|
+
render()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
ipcRenderer.on('finish', (_event: any) => {
|
|
38
|
+
anniversariesLoader.stop()
|
|
39
|
+
console.log('finish')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
function render() {
|
|
43
|
+
ReactDOM.render(
|
|
44
|
+
React.createElement(App, { start, appData, anniversaries }), document.getElementById('root')
|
|
45
|
+
)
|
|
46
|
+
}
|