@vixoniccom/aqi 0.0.1-dev.4 → 0.0.1-dev.5
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 +8 -0
- package/build/main.js +7 -7
- package/build.zip +0 -0
- package/configuration/appeareanceGroup/index.ts +4 -4
- package/package.json +1 -1
- package/src/App.tsx +3 -4
- package/src/components/Card.tsx +5 -5
- package/src/components/FontLoader.tsx +2 -2
- package/src/components/FormattedText.tsx +1 -1
- package/src/index.html +4 -4
- package/src/parameters.d.ts +33 -3
- package/src/utils.ts +14 -10
package/build.zip
CHANGED
|
Binary file
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Group } from
|
|
2
|
-
import { appeareanceInputs } from
|
|
1
|
+
import { Group } from '@vixoniccom/modules'
|
|
2
|
+
import { appeareanceInputs } from './AppeareanceInputs'
|
|
3
3
|
|
|
4
4
|
export const appeareanceGroup = new Group({
|
|
5
5
|
id: 'appeareanceGroup',
|
|
6
6
|
label: 'Apariencia',
|
|
7
|
-
items: [...appeareanceInputs]
|
|
8
|
-
})
|
|
7
|
+
items: [...appeareanceInputs],
|
|
8
|
+
})
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import axios from 'axios'
|
|
2
|
+
import localforage from 'localforage'
|
|
2
3
|
import React, { useEffect, useState } from 'react'
|
|
3
4
|
import { Card } from './components/Card'
|
|
4
5
|
import { FontLoader } from './components/FontLoader'
|
|
5
6
|
import { FormattedText } from './components/FormattedText'
|
|
6
7
|
import { AirQuality, StorageData } from './types'
|
|
7
|
-
import { API_RESPONSE_STATUS } from './utils'
|
|
8
|
-
import localforage from 'localforage'
|
|
8
|
+
import { API_RESPONSE_STATUS, TOKEN } from './utils'
|
|
9
9
|
|
|
10
10
|
interface Props {
|
|
11
11
|
data: VixonicData
|
|
@@ -34,7 +34,6 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const requestData = async (): Promise<AirQuality | null> => {
|
|
37
|
-
const TOKEN = "9fa7d8df1a621c9d518a351a13ff9b94093b9dac"
|
|
38
37
|
const URL = `https://api.waqi.info/feed/here/?token=${TOKEN}`
|
|
39
38
|
try {
|
|
40
39
|
const response = await axios.get<AirQuality>(URL)
|
|
@@ -51,7 +50,7 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
|
|
|
51
50
|
const getData = async () => {
|
|
52
51
|
const storageData: StorageData | null = await localforage.getItem('aqi')
|
|
53
52
|
let data
|
|
54
|
-
if (!storageData?.item ||
|
|
53
|
+
if (!storageData?.item || !storageData?.date || refetchData(new Date(storageData.date))) {
|
|
55
54
|
data = await requestData()
|
|
56
55
|
await localforage.setItem('aqi', { item: data, date: new Date() })
|
|
57
56
|
} else {
|
package/src/components/Card.tsx
CHANGED
|
@@ -27,24 +27,24 @@ export const Card: React.FunctionComponent<Props> = ({ data, format }) => {
|
|
|
27
27
|
padding: '1rem',
|
|
28
28
|
backgroundColor: color,
|
|
29
29
|
border: '2px solid #000',
|
|
30
|
-
// gap: format.cardGap ||
|
|
30
|
+
// gap: format.cardGap || '2rem',
|
|
31
31
|
}}>
|
|
32
32
|
<div style={{
|
|
33
33
|
textAlign: `${format.aqiFormat?.alignment?.horizontal || 'left'}`,
|
|
34
|
-
padding: `${format.cardGap ||
|
|
34
|
+
padding: `${format.cardGap || '2rem'}`
|
|
35
35
|
}}>
|
|
36
36
|
<FormattedText text={String(data?.aqi)} format={format.aqiFormat} />
|
|
37
37
|
</div>
|
|
38
38
|
<div style={{
|
|
39
39
|
textAlign: `${format.stationFormat?.alignment?.horizontal || 'left'}`,
|
|
40
|
-
padding: `${format.cardGap ||
|
|
40
|
+
padding: `${format.cardGap || '2rem'}`,
|
|
41
41
|
}}>
|
|
42
42
|
<FormattedText text={String(`Estación: ${data?.city?.name}`)} format={format.stationFormat} />
|
|
43
43
|
</div>
|
|
44
44
|
<div style={{
|
|
45
45
|
textAlign: `${format.qualityFormat?.alignment?.horizontal || 'left'}`,
|
|
46
|
-
padding: `${format.cardGap ||
|
|
47
|
-
marginTop:
|
|
46
|
+
padding: `${format.cardGap || '2rem'}`,
|
|
47
|
+
marginTop: '1rem'
|
|
48
48
|
}}>
|
|
49
49
|
<FormattedText text={data?.aqi ? quality : ''} format={format.qualityFormat} />
|
|
50
50
|
</div>
|
|
@@ -26,8 +26,8 @@ export const FontLoader: React.FunctionComponent<Props> = ({ paths, parameters,
|
|
|
26
26
|
}
|
|
27
27
|
return `
|
|
28
28
|
@font-face {
|
|
29
|
-
font-family:
|
|
30
|
-
src: url(
|
|
29
|
+
font-family: '${font.family}';
|
|
30
|
+
src: url('${font.src}');
|
|
31
31
|
}
|
|
32
32
|
`
|
|
33
33
|
} catch (err) {
|
|
@@ -61,7 +61,7 @@ export const FormattedText: React.FunctionComponent<Props> = ({ text, format, ma
|
|
|
61
61
|
<div style={containerStyle}>
|
|
62
62
|
<span style={{
|
|
63
63
|
color: format?.fontColor,
|
|
64
|
-
fontFamily: checkNested(format, 'font.filename') ? `
|
|
64
|
+
fontFamily: checkNested(format, 'font.filename') ? `'${format?.font?.filename?.replace('.', '-')}'` : '',
|
|
65
65
|
fontSize: `${format?.fontSize}${unit}`,
|
|
66
66
|
textAlign: checkNested(format, 'alignment.horizontal') ? format?.alignment?.horizontal : 'left',
|
|
67
67
|
lineHeight: lineHeight,
|
package/src/index.html
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<html style=
|
|
2
|
+
<html style='position: absolute; height:100%; width: 100%; overflow: hidden;'>
|
|
3
3
|
<head>
|
|
4
4
|
<title></title>
|
|
5
|
-
<meta charset=
|
|
5
|
+
<meta charset='utf-8'>
|
|
6
6
|
</head>
|
|
7
|
-
<body style=
|
|
8
|
-
<div id=
|
|
7
|
+
<body style='margin:0; overflow: hidden;'>
|
|
8
|
+
<div id='root' style='position: absolute; top: 0; right: 0; bottom: 0; left: 0; overflow: hidden;'>
|
|
9
9
|
</div>
|
|
10
10
|
</body>
|
|
11
11
|
</html>
|
package/src/parameters.d.ts
CHANGED
|
@@ -1,9 +1,39 @@
|
|
|
1
1
|
declare type VixonicData = {
|
|
2
2
|
downloadsPath: string
|
|
3
|
-
services: { [key: string]: { data?: any
|
|
3
|
+
services: { [key: string]: { data?: any; updatedAt?: number } }
|
|
4
4
|
parameters: VixonicParameters
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
declare type VixonicParameters = Partial<{
|
|
8
|
-
padding: string
|
|
9
|
-
}
|
|
8
|
+
padding: string
|
|
9
|
+
backgroundImage: { id?: string; filename?: string; extension?: string }
|
|
10
|
+
cardWidth: string
|
|
11
|
+
cardHeight: string
|
|
12
|
+
cardGap: string
|
|
13
|
+
aqiFormat: {
|
|
14
|
+
fontSize?: number
|
|
15
|
+
fontColor?: string
|
|
16
|
+
alignment?: { horizontal?: 'left' | 'right' | 'center' }
|
|
17
|
+
font?: { filename: string; id: string; __isAsset: true }
|
|
18
|
+
}
|
|
19
|
+
stationFormat: {
|
|
20
|
+
fontSize?: number
|
|
21
|
+
fontColor?: string
|
|
22
|
+
alignment?: { horizontal?: 'left' | 'right' | 'center' }
|
|
23
|
+
font?: { filename: string; id: string; __isAsset: true }
|
|
24
|
+
}
|
|
25
|
+
qualityFormat: {
|
|
26
|
+
fontSize?: number
|
|
27
|
+
fontColor?: string
|
|
28
|
+
alignment?: { horizontal?: 'left' | 'right' | 'center' }
|
|
29
|
+
font?: { filename: string; id: string; __isAsset: true }
|
|
30
|
+
}
|
|
31
|
+
updateData: 1 | 5 | 10 | 30 | 45 | 60
|
|
32
|
+
msj0: string
|
|
33
|
+
formatMjs: {
|
|
34
|
+
fontSize?: number
|
|
35
|
+
fontColor?: string
|
|
36
|
+
alignment?: { horizontal?: 'left' | 'right' | 'center' }
|
|
37
|
+
font?: { filename: string; id: string; __isAsset: true }
|
|
38
|
+
}
|
|
39
|
+
}>
|
package/src/utils.ts
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
|
+
const TOKEN = '9fa7d8df1a621c9d518a351a13ff9b94093b9dac'
|
|
2
|
+
|
|
1
3
|
const API_RESPONSE_STATUS = {
|
|
2
|
-
OK:
|
|
3
|
-
ERROR:
|
|
4
|
+
OK: 'ok',
|
|
5
|
+
ERROR: 'error',
|
|
4
6
|
}
|
|
5
7
|
|
|
6
|
-
const assingAirQuality = (
|
|
8
|
+
const assingAirQuality = (
|
|
9
|
+
magnitude: number
|
|
10
|
+
): { color: string; quality: string } => {
|
|
7
11
|
let color
|
|
8
12
|
let quality
|
|
9
13
|
if (0 <= magnitude && magnitude <= 50) {
|
|
10
14
|
color = '#009966'
|
|
11
|
-
quality =
|
|
15
|
+
quality = 'Buena'
|
|
12
16
|
} else if (51 <= magnitude && magnitude <= 100) {
|
|
13
17
|
color = '#FFDE33'
|
|
14
|
-
quality =
|
|
18
|
+
quality = 'Moderada'
|
|
15
19
|
} else if (101 <= magnitude && magnitude <= 150) {
|
|
16
20
|
color = '#FF9933'
|
|
17
|
-
quality =
|
|
21
|
+
quality = 'Dañina a grupos sensibles'
|
|
18
22
|
} else if (151 <= magnitude && magnitude <= 200) {
|
|
19
23
|
color = '#CC0033'
|
|
20
|
-
quality =
|
|
24
|
+
quality = 'Dañina a la salud'
|
|
21
25
|
} else if (201 <= magnitude && magnitude <= 300) {
|
|
22
26
|
color = '#660099'
|
|
23
|
-
quality =
|
|
27
|
+
quality = 'Muy dañina a la salud'
|
|
24
28
|
} else {
|
|
25
29
|
color = '#7E0023'
|
|
26
|
-
quality =
|
|
30
|
+
quality = 'Arriesgado'
|
|
27
31
|
}
|
|
28
32
|
return { color, quality }
|
|
29
33
|
}
|
|
30
34
|
|
|
31
|
-
export { API_RESPONSE_STATUS, assingAirQuality }
|
|
35
|
+
export { TOKEN, API_RESPONSE_STATUS, assingAirQuality }
|