@vixoniccom/aqi 0.0.7-dev.1 → 0.0.8-dev.0

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.
@@ -5,7 +5,7 @@
5
5
  "filename": "Earthquakes.png",
6
6
  "__isAsset": true
7
7
  },
8
- "cityInput": "Concepcion",
8
+ "cityInput": "Santiago",
9
9
  "topSeparationCard": 200,
10
10
  "leftSeparationCard": 600,
11
11
  "cardWidth": 700,
package/build.zip CHANGED
Binary file
@@ -1,7 +1,7 @@
1
1
  import { Label, NumberInput, SelectAssetKna, SelectInput, TextFormat, TextInput } from '@vixoniccom/modules'
2
2
  import { ShowValidations } from '../utils'
3
3
 
4
- const { personalizado, presetActive } = ShowValidations
4
+ const { personalizado } = ShowValidations
5
5
 
6
6
  export const appeareanceInputs = [
7
7
  new Label({ label: 'Tema predefinido' }),
@@ -15,11 +15,6 @@ export const appeareanceInputs = [
15
15
  { label: 'Lateral', value: 'preset2' },
16
16
  ],
17
17
  }),
18
- new Label({ label: 'Fuentes', show: presetActive }),
19
- new TextFormat({ id: 'aqiFont', label: 'Fuente del índice de calidad del aire', show: presetActive }),
20
- new TextFormat({ id: 'stationFont', label: 'Fuente de estación que realizó la medición', show: presetActive }),
21
- new TextFormat({ id: 'qualityFont', label: 'Fuente del mensaje sobre la calidad del aire', show: presetActive }),
22
-
23
18
  new Label({ label: 'General' }),
24
19
  new SelectAssetKna({ id: 'backgroundImage', label: 'Fondo', required: false, extensions: ['jpg', 'png'] }),
25
20
  new Label({ label: 'Posición', show: personalizado }),
@@ -55,10 +50,22 @@ export const appeareanceInputs = [
55
50
  show: personalizado,
56
51
  }),
57
52
 
58
- new Label({ label: 'Textos de la tarjeta', show: personalizado }),
59
- new TextFormat({ id: 'aqiFormat', label: 'Formato del índice de calidad del aire', show: personalizado }),
60
- new TextFormat({ id: 'stationFormat', label: 'Formato de estación que realizó la medición', show: personalizado }),
61
- new TextFormat({ id: 'qualityFormat', label: 'Formato del mensaje sobre la calidad del aire', show: personalizado }),
53
+ new Label({ label: 'Textos de la tarjeta' }),
54
+ new TextFormat({
55
+ id: 'aqiFormat',
56
+ label: 'Formato del índice de calidad del aire',
57
+ description: 'Fuente, color, tamaño y alineación del índice. Por defecto, 6vh.',
58
+ }),
59
+ new TextFormat({
60
+ id: 'stationFormat',
61
+ label: 'Formato de estación que realizó la medición',
62
+ description: 'Fuente, color, tamaño y alineación de la estación. Por defecto, 3vh.',
63
+ }),
64
+ new TextFormat({
65
+ id: 'qualityFormat',
66
+ label: 'Formato del mensaje sobre la calidad del aire',
67
+ description: 'Fuente, color, tamaño y alineación del mensaje de calidad. Por defecto, 3vh.',
68
+ }),
62
69
 
63
70
  new Label({ label: 'Datos' }),
64
71
  new TextInput({
@@ -67,6 +74,14 @@ export const appeareanceInputs = [
67
74
  description:
68
75
  'Ciudad de la que se quiere medir el aire. Para ver la ciudades disponibles se puede consultar aquí: https://aqicn.org/here',
69
76
  }),
70
- new TextInput({ id: 'msj0', label: 'Mensaje sin Datos' }),
71
- new TextFormat({ id: 'formatMjs', label: 'Formato Mensaje sin Datos' }),
77
+ new TextInput({
78
+ id: 'msj0',
79
+ label: 'Mensaje sin Datos',
80
+ description: 'Texto que se muestra cuando no hay datos. Por defecto, "No hay datos para mostrar".',
81
+ }),
82
+ new TextFormat({
83
+ id: 'formatMjs',
84
+ label: 'Formato Mensaje sin Datos',
85
+ description: 'Fuente, color, tamaño y alineación del mensaje. Por defecto, 3vh.',
86
+ }),
72
87
  ]
@@ -1,4 +1,3 @@
1
1
  export const ShowValidations = {
2
2
  personalizado: '({{themePreset}} === "personalizado" || !{{themePreset}})',
3
- presetActive: '{{themePreset}} && {{themePreset}} !== "personalizado"',
4
3
  }
@@ -29,29 +29,6 @@
29
29
  }
30
30
  ]
31
31
  },
32
- {
33
- "type": "label",
34
- "label": "Fuentes",
35
- "show": "{{themePreset}} && {{themePreset}} !== \"personalizado\""
36
- },
37
- {
38
- "id": "aqiFont",
39
- "label": "Fuente del índice de calidad del aire",
40
- "show": "{{themePreset}} && {{themePreset}} !== \"personalizado\"",
41
- "type": "text-format"
42
- },
43
- {
44
- "id": "stationFont",
45
- "label": "Fuente de estación que realizó la medición",
46
- "show": "{{themePreset}} && {{themePreset}} !== \"personalizado\"",
47
- "type": "text-format"
48
- },
49
- {
50
- "id": "qualityFont",
51
- "label": "Fuente del mensaje sobre la calidad del aire",
52
- "show": "{{themePreset}} && {{themePreset}} !== \"personalizado\"",
53
- "type": "text-format"
54
- },
55
32
  {
56
33
  "type": "label",
57
34
  "label": "General"
@@ -133,26 +110,25 @@
133
110
  },
134
111
  {
135
112
  "type": "label",
136
- "label": "Textos de la tarjeta",
137
- "show": "({{themePreset}} === \"personalizado\" || !{{themePreset}})"
113
+ "label": "Textos de la tarjeta"
138
114
  },
139
115
  {
140
116
  "id": "aqiFormat",
141
117
  "label": "Formato del índice de calidad del aire",
142
- "show": "({{themePreset}} === \"personalizado\" || !{{themePreset}})",
143
- "type": "text-format"
118
+ "type": "text-format",
119
+ "description": "Fuente, color, tamaño y alineación del índice. Por defecto, 6vh."
144
120
  },
145
121
  {
146
122
  "id": "stationFormat",
147
123
  "label": "Formato de estación que realizó la medición",
148
- "show": "({{themePreset}} === \"personalizado\" || !{{themePreset}})",
149
- "type": "text-format"
124
+ "type": "text-format",
125
+ "description": "Fuente, color, tamaño y alineación de la estación. Por defecto, 3vh."
150
126
  },
151
127
  {
152
128
  "id": "qualityFormat",
153
129
  "label": "Formato del mensaje sobre la calidad del aire",
154
- "show": "({{themePreset}} === \"personalizado\" || !{{themePreset}})",
155
- "type": "text-format"
130
+ "type": "text-format",
131
+ "description": "Fuente, color, tamaño y alineación del mensaje de calidad. Por defecto, 3vh."
156
132
  },
157
133
  {
158
134
  "type": "label",
@@ -167,12 +143,14 @@
167
143
  {
168
144
  "id": "msj0",
169
145
  "label": "Mensaje sin Datos",
170
- "type": "text-input"
146
+ "type": "text-input",
147
+ "description": "Texto que se muestra cuando no hay datos. Por defecto, \"No hay datos para mostrar\"."
171
148
  },
172
149
  {
173
150
  "id": "formatMjs",
174
151
  "label": "Formato Mensaje sin Datos",
175
- "type": "text-format"
152
+ "type": "text-format",
153
+ "description": "Fuente, color, tamaño y alineación del mensaje. Por defecto, 3vh."
176
154
  }
177
155
  ]
178
156
  }
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "author": {
9
9
  "name": "Daniel Alvayay"
10
10
  },
11
- "version": "0.0.7-dev.1",
11
+ "version": "0.0.8-dev.0",
12
12
  "scripts": {
13
13
  "prepublish": "vixonic-module-packager --mode=build",
14
14
  "watch": "vixonic-module-packager --mode=watch",
package/src/App.tsx CHANGED
@@ -4,10 +4,8 @@ import { FontLoader } from './components/FontLoader'
4
4
  import { FormattedText } from './components/FormattedText'
5
5
  import { AqiData } from './types'
6
6
  import { getData } from './services'
7
- import preset1 from './presets/preset1.json'
8
- import preset2 from './presets/preset2.json'
9
-
10
- const PRESETS = { preset1, preset2 } as Record<string, Partial<VixonicParameters>>
7
+ import { PRESETS } from './presets'
8
+ import { DEFAULT_EMPTY_MESSAGE, DEFAULT_EMPTY_MESSAGE_FONT_SIZE, withFontSize } from './components/textFormatDefaults'
11
9
 
12
10
  interface Props {
13
11
  data: VixonicData
@@ -17,29 +15,27 @@ interface Props {
17
15
  export const App: React.FunctionComponent<Props> = ({ data, start }) => {
18
16
  const { parameters: rawParameters, downloadsPath } = data
19
17
 
20
- const withFont = (format: VixonicParameters['aqiFormat'], fontFormat: VixonicParameters['aqiFont']) => {
21
- if (!fontFormat) return format
22
- const { font, fontColor } = fontFormat
23
- return { ...format, ...(font ? { font } : {}), ...(fontColor ? { fontColor } : {}) }
24
- }
25
-
26
18
  const activePreset = rawParameters.themePreset && rawParameters.themePreset !== 'personalizado'
27
19
  ? PRESETS[rawParameters.themePreset]
28
20
  : undefined
29
21
 
30
22
  const parameters: VixonicParameters = activePreset
31
- ? {
32
- ...rawParameters,
23
+ ? ({
33
24
  ...activePreset,
34
- aqiFormat: withFont(activePreset.aqiFormat, rawParameters.aqiFont),
35
- stationFormat: withFont(activePreset.stationFormat, rawParameters.stationFont),
36
- qualityFormat: withFont(activePreset.qualityFormat, rawParameters.qualityFont),
37
- }
25
+ themePreset: rawParameters.themePreset,
26
+ backgroundImage: rawParameters.backgroundImage,
27
+ cityInput: rawParameters.cityInput,
28
+ msj0: rawParameters.msj0,
29
+ formatMjs: rawParameters.formatMjs,
30
+ aqiFormat: rawParameters.aqiFormat,
31
+ stationFormat: rawParameters.stationFormat,
32
+ qualityFormat: rawParameters.qualityFormat,
33
+ } as VixonicParameters)
38
34
  : rawParameters
39
35
  const backgroundImageState = parameters.backgroundImage ? `url('${downloadsPath}/${parameters.backgroundImage.filename}')` : ''
40
36
  const [formattedData, setFormattedData] = useState<AqiData>()
41
37
  const cityInput = parameters?.cityInput || "Santiago"
42
- const msj0 = parameters?.msj0 || 'No hay datos para mostrar'
38
+ const msj0 = parameters?.msj0 || DEFAULT_EMPTY_MESSAGE
43
39
  const updateTime = 600000
44
40
 
45
41
  useEffect(() => {
@@ -103,7 +99,7 @@ export const App: React.FunctionComponent<Props> = ({ data, start }) => {
103
99
  }}>
104
100
  <FontLoader paths={['formatMjs.font']} parameters={parameters} downloadsPath={downloadsPath} />
105
101
  <div style={{ display: 'flex', position: 'relative', flex: '1 1 0%', flexDirection: 'column' }}>
106
- <FormattedText text={msj0} format={parameters?.formatMjs} />
102
+ <FormattedText text={msj0} format={withFontSize(parameters?.formatMjs, DEFAULT_EMPTY_MESSAGE_FONT_SIZE)} />
107
103
  </div>
108
104
  </div>
109
105
  )}
@@ -3,6 +3,12 @@ import { assingAirQuality } from '../utils';
3
3
  import { AqiData } from '../types';
4
4
  import { TextFormat } from '@vixoniccom/modules';
5
5
  import { FormattedText } from './FormattedText';
6
+ import {
7
+ DEFAULT_AQI_FONT_SIZE,
8
+ DEFAULT_QUALITY_FONT_SIZE,
9
+ DEFAULT_STATION_FONT_SIZE,
10
+ withFontSize,
11
+ } from './textFormatDefaults';
6
12
 
7
13
  interface Props {
8
14
  data: AqiData;
@@ -36,21 +42,21 @@ export const Card: React.FunctionComponent<Props> = ({ data, format }) => {
36
42
  textAlign: `${format.aqiFormat?.alignment?.horizontal || 'left'}`,
37
43
  padding: `${format.cardGap || 2}rem`
38
44
  }}>
39
- <FormattedText text={String(data?.aqi)} format={format.aqiFormat} />
45
+ <FormattedText text={String(data?.aqi)} format={withFontSize(format.aqiFormat, DEFAULT_AQI_FONT_SIZE)} />
40
46
  </div>
41
47
  )}
42
48
  <div style={{
43
49
  textAlign: `${format.stationFormat?.alignment?.horizontal || 'left'}`,
44
50
  padding: `${format.cardGap || 2}rem`,
45
51
  }}>
46
- <FormattedText text={city} format={format.stationFormat} />
52
+ <FormattedText text={city} format={withFontSize(format.stationFormat, DEFAULT_STATION_FONT_SIZE)} />
47
53
  </div>
48
54
  <div style={{
49
55
  textAlign: `${format.qualityFormat?.alignment?.horizontal || 'left'}`,
50
56
  padding: `${format.cardGap || 2}rem`,
51
57
  marginTop: format.positionCard === 'horizontal' ? undefined : '1rem'
52
58
  }}>
53
- <FormattedText text={data?.aqi ? quality : ''} format={format.qualityFormat} />
59
+ <FormattedText text={data?.aqi ? quality : ''} format={withFontSize(format.qualityFormat, DEFAULT_QUALITY_FONT_SIZE)} />
54
60
  </div>
55
61
  </div>
56
62
  )
@@ -61,7 +61,7 @@ export const FormattedText: React.FunctionComponent<Props> = ({ text, format, ma
61
61
  <span style={{
62
62
  color: format?.fontColor,
63
63
  fontFamily: checkNested(format, 'font.filename') ? `'${format?.font?.filename?.replace('.', '-')}'` : '',
64
- fontSize: `${format?.fontSize}${unit}`,
64
+ fontSize: format?.fontSize ? `${format.fontSize}${unit}` : undefined,
65
65
  textAlign: checkNested(format, 'alignment.horizontal') ? format?.alignment?.horizontal : 'left',
66
66
  lineHeight: lineHeight,
67
67
  paddingBottom: paddingBottom,
@@ -0,0 +1,12 @@
1
+ export const DEFAULT_AQI_FONT_SIZE = 6
2
+ export const DEFAULT_STATION_FONT_SIZE = 3
3
+ export const DEFAULT_QUALITY_FONT_SIZE = 3
4
+ export const DEFAULT_EMPTY_MESSAGE_FONT_SIZE = 3
5
+ export const DEFAULT_EMPTY_MESSAGE = 'No hay datos para mostrar'
6
+
7
+ type TextFormatValue = VixonicParameters['aqiFormat']
8
+
9
+ export const withFontSize = (format: TextFormatValue, defaultFontSize: number): TextFormatValue => ({
10
+ ...format,
11
+ fontSize: format?.fontSize || defaultFontSize,
12
+ })
@@ -5,5 +5,5 @@ declare type VixonicData = {
5
5
  }
6
6
 
7
7
  declare type VixonicParameters = Partial<{
8
- themePreset: 'personalizado' | 'preset1' | 'preset2', aqiFont: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, stationFont: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, qualityFont: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, backgroundImage: {id?: string, filename?: string, extension?: string}, positionCard: 'horizontal' | 'vertical', topSeparationCard: number, leftSeparationCard: number, cardWidth: number, cardHeight: number, cardGap: number, aqiFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, stationFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, qualityFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, cityInput: string, msj0: string, formatMjs: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }
8
+ themePreset: 'personalizado' | 'preset1' | 'preset2', backgroundImage: {id?: string, filename?: string, extension?: string}, positionCard: 'horizontal' | 'vertical', topSeparationCard: number, leftSeparationCard: number, cardWidth: number, cardHeight: number, cardGap: number, aqiFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, stationFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, qualityFormat: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }, cityInput: string, msj0: string, formatMjs: { fontSize?: number, fontColor?: string, alignment?: { horizontal?: 'left' | 'right' | 'center' }, font?: { filename: string, id: string, __isAsset: true } }
9
9
  }>
@@ -0,0 +1,19 @@
1
+ import preset1Json from './preset1.json'
2
+ import preset2Json from './preset2.json'
3
+
4
+ type PresetStyleKey =
5
+ | 'positionCard'
6
+ | 'topSeparationCard'
7
+ | 'leftSeparationCard'
8
+ | 'cardWidth'
9
+ | 'cardHeight'
10
+ | 'cardGap'
11
+
12
+ type PresetCompleteness = Record<PresetStyleKey, unknown>
13
+
14
+ const assertPresetComplete = <T extends PresetCompleteness>(preset: T): T => preset
15
+
16
+ const preset1 = assertPresetComplete(preset1Json)
17
+ const preset2 = assertPresetComplete(preset2Json)
18
+
19
+ export const PRESETS = { preset1, preset2 } as Record<string, Partial<VixonicParameters>>
@@ -4,19 +4,5 @@
4
4
  "leftSeparationCard": 400,
5
5
  "cardWidth": 700,
6
6
  "cardHeight": 120,
7
- "aqiFormat": {
8
- "fontSize": 25,
9
- "fontColor": "#ffffff",
10
- "alignment": { "horizontal": "center" }
11
- },
12
- "stationFormat": {
13
- "fontSize": 16,
14
- "fontColor": "#ffffff",
15
- "alignment": { "horizontal": "center" }
16
- },
17
- "qualityFormat": {
18
- "fontSize": 20,
19
- "fontColor": "#ffffff",
20
- "alignment": { "horizontal": "center" }
21
- }
7
+ "cardGap": 2
22
8
  }
@@ -4,20 +4,5 @@
4
4
  "leftSeparationCard": 116,
5
5
  "cardWidth": 194,
6
6
  "cardHeight": 316,
7
- "cardGap": 1,
8
- "aqiFormat": {
9
- "fontSize": 10,
10
- "fontColor": "#ffffff",
11
- "alignment": { "horizontal": "center" }
12
- },
13
- "stationFormat": {
14
- "fontSize": 4,
15
- "fontColor": "#ffffff",
16
- "alignment": { "horizontal": "center" }
17
- },
18
- "qualityFormat": {
19
- "fontSize": 3,
20
- "fontColor": "#ffffff",
21
- "alignment": { "horizontal": "center" }
22
- }
7
+ "cardGap": 1
23
8
  }
@@ -5,7 +5,7 @@
5
5
  "filename": "Earthquakes.png",
6
6
  "__isAsset": true
7
7
  },
8
- "cityInput": "Concepcion",
8
+ "cityInput": "Santiago",
9
9
  "topSeparationCard": 200,
10
10
  "leftSeparationCard": 600,
11
11
  "cardWidth": 700,