@jjlmoya/utils-home 1.3.0 → 1.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jjlmoya/utils-home",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -17,10 +17,11 @@ export type {
17
17
 
18
18
  export { ALL_TOOLS } from './tools';
19
19
 
20
- export { QRGeneratorComponent, QRGeneratorSEO, QRGeneratorBibliography } from './tool/qrGenerator';
21
- export { SolarCalculatorComponent, SolarCalculatorSEO, SolarCalculatorBibliography } from './tool/solarCalculator';
22
- export { ProjectorCalculatorComponent, ProjectorCalculatorSEO, ProjectorCalculatorBibliography } from './tool/projectorCalculator';
23
- export { DewPointCalculatorComponent, DewPointCalculatorSEO, DewPointCalculatorBibliography } from './tool/dewPointCalculator';
24
- export { LedSavingCalculatorComponent, LedSavingCalculatorSEO, LedSavingCalculatorBibliography } from './tool/ledSavingCalculator';
25
- export { TariffComparatorComponent, TariffComparatorSEO, TariffComparatorBibliography } from './tool/tariffComparator';
20
+ export { QRGeneratorComponent, QRGeneratorSEO, QRGeneratorBibliography, QR_GENERATOR_TOOL } from './tool/qrGenerator';
21
+ export { SolarCalculatorComponent, SolarCalculatorSEO, SolarCalculatorBibliography, SOLAR_CALCULATOR_TOOL } from './tool/solarCalculator';
22
+ export { ProjectorCalculatorComponent, ProjectorCalculatorSEO, ProjectorCalculatorBibliography, PROJECTOR_CALCULATOR_TOOL } from './tool/projectorCalculator';
23
+ export { DewPointCalculatorComponent, DewPointCalculatorSEO, DewPointCalculatorBibliography, DEW_POINT_CALCULATOR_TOOL } from './tool/dewPointCalculator';
24
+ export { LedSavingCalculatorComponent, LedSavingCalculatorSEO, LedSavingCalculatorBibliography, LED_SAVING_CALCULATOR_TOOL } from './tool/ledSavingCalculator';
25
+ export { TariffComparatorComponent, TariffComparatorSEO, TariffComparatorBibliography, TARIFF_COMPARATOR_TOOL } from './tool/tariffComparator';
26
+ export { HeatingComparatorComponent, HeatingComparatorSEO, HeatingComparatorBibliography, HEATING_COMPARATOR_TOOL } from './tool/heatingComparator';
26
27
 
@@ -36,7 +36,7 @@ describe('Locale Completeness Validation', () => {
36
36
  });
37
37
 
38
38
  it('should have 6 tools registered', () => {
39
- expect(ALL_TOOLS.length).toBe(6);
39
+ expect(ALL_TOOLS.length).toBe(7);
40
40
  });
41
41
  });
42
42
 
@@ -5,7 +5,7 @@ import { homeCategory } from '../data';
5
5
  describe('Tool Validation Suite', () => {
6
6
  describe('Library Registration', () => {
7
7
  it('should have 6 tools in ALL_TOOLS', () => {
8
- expect(ALL_TOOLS.length).toBe(6);
8
+ expect(ALL_TOOLS.length).toBe(7);
9
9
  });
10
10
 
11
11
  it('homeCategory should be defined', () => {
@@ -0,0 +1,14 @@
1
+ ---
2
+ import { Bibliography as SharedBibliography } from '@jjlmoya/utils-shared';
3
+ import { heatingComparator } from './index';
4
+ import type { KnownLocale } from '../../types';
5
+
6
+ interface Props {
7
+ locale?: KnownLocale;
8
+ }
9
+
10
+ const { locale = 'es' } = Astro.props;
11
+ const content = await heatingComparator.i18n[locale]?.();
12
+ ---
13
+
14
+ {content && <SharedBibliography links={content.bibliography} />}
@@ -0,0 +1,496 @@
1
+ ---
2
+ import { Icon } from 'astro-icon/components';
3
+ import type { HeatingComparatorUI } from './ui';
4
+
5
+ interface Props {
6
+ ui?: Record<string, unknown>;
7
+ }
8
+
9
+ const { ui = {} } = Astro.props;
10
+ const compUI = ui as HeatingComparatorUI;
11
+ ---
12
+
13
+ <div class="heating-wrapper">
14
+ <div class="main-card">
15
+ <div class="config-section">
16
+ <div class="section-header">
17
+ <h3 class="section-title">{compUI.titleVivienda}</h3>
18
+ <p class="section-desc">{compUI.helperVivienda}</p>
19
+ </div>
20
+
21
+ <div class="config-grid">
22
+ <div class="input-group">
23
+ <label for="house-m2">{compUI.labelM2}</label>
24
+ <p class="input-helper">{compUI.helperM2}</p>
25
+ <div class="input-wrapper">
26
+ <input type="number" id="house-m2" value="100" min="10" step="5" />
27
+ <span class="input-unit">m²</span>
28
+ </div>
29
+ </div>
30
+
31
+ <div class="input-group">
32
+ <label for="insulation-level">{compUI.labelAislamiento}</label>
33
+ <p class="input-helper">{compUI.helperAislamiento}</p>
34
+ <div class="input-wrapper">
35
+ <select id="insulation-level">
36
+ <option value="40">{compUI.optExcelent}</option>
37
+ <option value="70" selected>{compUI.optMedium}</option>
38
+ <option value="110">{compUI.optPoor}</option>
39
+ </select>
40
+ </div>
41
+ </div>
42
+ </div>
43
+
44
+ <div class="section-header">
45
+ <h3 class="section-title">{compUI.titleCoste}</h3>
46
+ <p class="section-desc">{compUI.descCoste}</p>
47
+ </div>
48
+
49
+ <div class="config-grid">
50
+ <div class="input-group">
51
+ <label for="price-gas">{compUI.labelGasPrice}</label>
52
+ <p class="input-helper">{compUI.helperGasPrice}</p>
53
+ <div class="input-wrapper">
54
+ <input type="number" id="price-gas" value="0.08" step="0.001" />
55
+ <span class="input-unit">{compUI.unitCurrency}/kWh</span>
56
+ </div>
57
+ </div>
58
+
59
+ <div class="input-group">
60
+ <label for="price-elec">{compUI.labelElecPrice}</label>
61
+ <p class="input-helper">{compUI.helperElecPrice}</p>
62
+ <div class="input-wrapper">
63
+ <input type="number" id="price-elec" value="0.18" step="0.001" />
64
+ <span class="input-unit">{compUI.unitCurrency}/kWh</span>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+
70
+ <div class="results-section">
71
+ <div class="results-header">
72
+ <h3 class="section-title">{compUI.titleComparison}</h3>
73
+ <p class="section-desc">{compUI.descComparison}</p>
74
+ </div>
75
+
76
+ <div class="comparison-grid">
77
+ <div class="system-card gas" id="card-gas">
78
+ <div class="card-header">
79
+ <div class="icon-box">
80
+ <Icon name="mdi:fire" size={24} />
81
+ </div>
82
+ <span class="card-title">{compUI.systemGas}</span>
83
+ </div>
84
+ <div class="cost-display">
85
+ <span class="cost-label">{compUI.labelAnnualCost}</span>
86
+ <span class="annual-cost" id="gas-cost">0,00 {compUI.unitCurrency}</span>
87
+ </div>
88
+ <div class="specs-list">
89
+ <div class="spec-item">
90
+ <span class="spec-label">{compUI.labelEfficiency}</span>
91
+ <span class="spec-value">95%</span>
92
+ </div>
93
+ <div class="spec-item">
94
+ <span class="spec-label">{compUI.labelSource}</span>
95
+ <span class="spec-value">{compUI.valGasSource}</span>
96
+ </div>
97
+ </div>
98
+ </div>
99
+
100
+ <div class="system-card aero" id="card-aero">
101
+ <div class="saving-badge" id="aero-winner">{compUI.winnerBadge}</div>
102
+ <div class="card-header">
103
+ <div class="icon-box">
104
+ <Icon name="mdi:leaf" size={24} />
105
+ </div>
106
+ <span class="card-title">{compUI.systemAero}</span>
107
+ </div>
108
+ <div class="cost-display">
109
+ <span class="cost-label">{compUI.labelAnnualCost}</span>
110
+ <span class="annual-cost" id="aero-cost">0,00 {compUI.unitCurrency}</span>
111
+ </div>
112
+ <div class="specs-list">
113
+ <div class="spec-item">
114
+ <span class="spec-label">{compUI.labelEfficiency}</span>
115
+ <span class="spec-value">4.0 (400%)</span>
116
+ </div>
117
+ <div class="spec-item">
118
+ <span class="spec-label">{compUI.labelEnergy}</span>
119
+ <span class="spec-value">{compUI.valAeroEnergy}</span>
120
+ </div>
121
+ </div>
122
+ </div>
123
+
124
+ <div class="system-card air" id="card-air">
125
+ <div class="card-header">
126
+ <div class="icon-box">
127
+ <Icon name="mdi:air-conditioner" size={24} />
128
+ </div>
129
+ <span class="card-title">{compUI.systemAir}</span>
130
+ </div>
131
+ <div class="cost-display">
132
+ <span class="cost-label">{compUI.labelAnnualCost}</span>
133
+ <span class="annual-cost" id="air-cost">0,00 {compUI.unitCurrency}</span>
134
+ </div>
135
+ <div class="specs-list">
136
+ <div class="spec-item">
137
+ <span class="spec-label">{compUI.labelEfficiency}</span>
138
+ <span class="spec-value">3.2 (320%)</span>
139
+ </div>
140
+ <div class="spec-item">
141
+ <span class="spec-label">{compUI.labelInstallation}</span>
142
+ <span class="spec-value">{compUI.valAirInstall}</span>
143
+ </div>
144
+ </div>
145
+ </div>
146
+ </div>
147
+ </div>
148
+ </div>
149
+ </div>
150
+
151
+ <script is:inline define:vars={{ unitCurrency: compUI.unitCurrency }}>
152
+ const CURRENCY_CODES = { '€': 'EUR', '$': 'USD' };
153
+
154
+ function formatCurrency(val) {
155
+ return new Intl.NumberFormat(undefined, {
156
+ style: 'currency',
157
+ currency: CURRENCY_CODES[unitCurrency] || 'EUR',
158
+ }).format(val);
159
+ }
160
+
161
+ function getInputValues(inputs) {
162
+ const { m2Input, gasPriceInput, elecPriceInput, insulationInput } = inputs;
163
+ const required = [m2Input, gasPriceInput, elecPriceInput, insulationInput];
164
+ if (required.some((el) => !el)) return null;
165
+ return {
166
+ m2: parseFloat(m2Input.value) || 0,
167
+ gasPrice: parseFloat(gasPriceInput.value) || 0,
168
+ elecPrice: parseFloat(elecPriceInput.value) || 0,
169
+ demandPerM2: parseFloat(insulationInput.value) || 70,
170
+ };
171
+ }
172
+
173
+ function updateWinner(aeroWinner, costAero, winner) {
174
+ if (!aeroWinner) return;
175
+ if (costAero === winner) {
176
+ aeroWinner.classList.add('visible');
177
+ } else {
178
+ aeroWinner.classList.remove('visible');
179
+ }
180
+ }
181
+
182
+ function updateDisplays(displays, costs) {
183
+ const { gasCostDisplay, aeroCostDisplay, airCostDisplay, aeroWinner } = displays;
184
+ if (gasCostDisplay) gasCostDisplay.innerText = formatCurrency(costs.costGas);
185
+ if (aeroCostDisplay) aeroCostDisplay.innerText = formatCurrency(costs.costAero);
186
+ if (airCostDisplay) airCostDisplay.innerText = formatCurrency(costs.costAir);
187
+ updateWinner(aeroWinner, costs.costAero, Math.min(costs.costGas, costs.costAero, costs.costAir));
188
+ [gasCostDisplay, aeroCostDisplay, airCostDisplay].forEach((el) => {
189
+ el?.classList.add('animate-pop');
190
+ setTimeout(() => el?.classList.remove('animate-pop'), 200);
191
+ });
192
+ }
193
+
194
+ function calculate(inputs, displays) {
195
+ const values = getInputValues(inputs);
196
+ if (!values) return;
197
+ const totalDemand = values.m2 * values.demandPerM2;
198
+ updateDisplays(displays, {
199
+ costGas: (totalDemand / 0.95) * values.gasPrice,
200
+ costAero: (totalDemand / 4.0) * values.elecPrice,
201
+ costAir: (totalDemand / 3.2) * values.elecPrice,
202
+ });
203
+ }
204
+
205
+ function init() {
206
+ const inputs = {
207
+ m2Input: document.getElementById('house-m2'),
208
+ insulationInput: document.getElementById('insulation-level'),
209
+ gasPriceInput: document.getElementById('price-gas'),
210
+ elecPriceInput: document.getElementById('price-elec'),
211
+ };
212
+ const displays = {
213
+ gasCostDisplay: document.getElementById('gas-cost'),
214
+ aeroCostDisplay: document.getElementById('aero-cost'),
215
+ airCostDisplay: document.getElementById('air-cost'),
216
+ aeroWinner: document.getElementById('aero-winner'),
217
+ };
218
+ Object.values(inputs).forEach((el) => {
219
+ el?.addEventListener('input', () => calculate(inputs, displays));
220
+ });
221
+ calculate(inputs, displays);
222
+ }
223
+
224
+ init();
225
+ document.addEventListener('astro:page-load', init);
226
+ </script>
227
+
228
+ <style>
229
+ .heating-wrapper {
230
+ --p: #6366f1;
231
+ --gas: #f97316;
232
+ --aero: #10b981;
233
+ --air: #3b82f6;
234
+
235
+ width: 100%;
236
+ max-width: 1000px;
237
+ margin: 2rem auto;
238
+ padding: 0 1rem;
239
+ color: var(--text-main);
240
+ }
241
+
242
+ .main-card {
243
+ background: var(--bg-surface);
244
+ border: 1px solid var(--border-color);
245
+ border-radius: 32px;
246
+ padding: 2.5rem;
247
+ box-shadow: 0 20px 50px rgba(0, 0, 0, 0.05);
248
+ }
249
+
250
+ .section-header {
251
+ margin-bottom: 2rem;
252
+ }
253
+
254
+ .section-title {
255
+ font-size: 1.25rem;
256
+ font-weight: 900;
257
+ margin: 0;
258
+ }
259
+
260
+ .section-desc {
261
+ font-size: 0.9rem;
262
+ color: var(--text-muted);
263
+ margin: 0.5rem 0 0;
264
+ }
265
+
266
+ .config-grid {
267
+ display: grid;
268
+ grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
269
+ gap: 2rem;
270
+ margin-bottom: 3rem;
271
+ }
272
+
273
+ .input-group {
274
+ display: flex;
275
+ flex-direction: column;
276
+ gap: 0.75rem;
277
+ }
278
+
279
+ .input-group label {
280
+ font-size: 0.75rem;
281
+ font-weight: 800;
282
+ text-transform: uppercase;
283
+ letter-spacing: 0.05em;
284
+ color: var(--text-muted);
285
+ }
286
+
287
+ .input-helper {
288
+ font-size: 0.75rem;
289
+ color: var(--text-muted);
290
+ margin: -0.25rem 0 0.25rem;
291
+ opacity: 0.8;
292
+ }
293
+
294
+ .input-wrapper {
295
+ position: relative;
296
+ display: flex;
297
+ align-items: center;
298
+ }
299
+
300
+ .input-wrapper input,
301
+ .input-wrapper select {
302
+ width: 100%;
303
+ padding: 1rem 1.25rem;
304
+ border-radius: 16px;
305
+ border: 2px solid var(--border-color);
306
+ background: var(--bg-muted);
307
+ color: var(--text-main);
308
+ font-size: 1rem;
309
+ font-weight: 700;
310
+ outline: none;
311
+ transition: all 0.2s;
312
+ appearance: none;
313
+ }
314
+
315
+ .input-wrapper select {
316
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
317
+ background-repeat: no-repeat;
318
+ background-position: right 1.25rem center;
319
+ background-size: 1.25rem;
320
+ }
321
+
322
+ .input-wrapper input:focus,
323
+ .input-wrapper select:focus {
324
+ border-color: var(--p);
325
+ box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
326
+ }
327
+
328
+ .input-unit {
329
+ position: absolute;
330
+ right: 1.25rem;
331
+ font-weight: 700;
332
+ color: var(--text-muted);
333
+ font-size: 0.85rem;
334
+ pointer-events: none;
335
+ }
336
+
337
+ .results-section {
338
+ padding-top: 3rem;
339
+ border-top: 1px solid var(--border-color);
340
+ }
341
+
342
+ .comparison-grid {
343
+ display: grid;
344
+ grid-template-columns: repeat(3, 1fr);
345
+ gap: 1.5rem;
346
+ margin-top: 2rem;
347
+ }
348
+
349
+ @media (max-width: 900px) {
350
+ .comparison-grid {
351
+ grid-template-columns: 1fr;
352
+ }
353
+ }
354
+
355
+ .system-card {
356
+ background: var(--bg-muted);
357
+ border-radius: 24px;
358
+ padding: 2rem;
359
+ border: 1px solid var(--border-color);
360
+ position: relative;
361
+ overflow: hidden;
362
+ transition: transform 0.3s;
363
+ }
364
+
365
+ .system-card:hover {
366
+ transform: translateY(-4px);
367
+ }
368
+
369
+ .system-card::before {
370
+ content: '';
371
+ position: absolute;
372
+ top: 0; left: 0; right: 0;
373
+ height: 4px;
374
+ }
375
+
376
+ .system-card.gas::before { background: var(--gas); }
377
+ .system-card.aero::before { background: var(--aero); }
378
+ .system-card.air::before { background: var(--air); }
379
+
380
+ .saving-badge {
381
+ position: absolute;
382
+ top: 1rem;
383
+ right: 1rem;
384
+ background: var(--aero);
385
+ color: white;
386
+ padding: 0.25rem 0.75rem;
387
+ border-radius: 100px;
388
+ font-size: 0.65rem;
389
+ font-weight: 800;
390
+ text-transform: uppercase;
391
+ display: none;
392
+ }
393
+
394
+ .saving-badge.visible {
395
+ display: block;
396
+ animation: bounce-in 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
397
+ }
398
+
399
+ .card-header {
400
+ display: flex;
401
+ align-items: center;
402
+ gap: 1rem;
403
+ margin-bottom: 2rem;
404
+ }
405
+
406
+ .icon-box {
407
+ width: 44px;
408
+ height: 44px;
409
+ border-radius: 12px;
410
+ display: flex;
411
+ align-items: center;
412
+ justify-content: center;
413
+ }
414
+
415
+ .gas .icon-box {
416
+ background: rgba(249, 115, 22, 0.1);
417
+ color: var(--gas);
418
+ }
419
+ .aero .icon-box {
420
+ background: rgba(16, 185, 129, 0.1);
421
+ color: var(--aero);
422
+ }
423
+ .air .icon-box {
424
+ background: rgba(59, 130, 246, 0.1);
425
+ color: var(--air);
426
+ }
427
+
428
+ .card-title {
429
+ font-weight: 800;
430
+ font-size: 1.1rem;
431
+ }
432
+
433
+ .cost-display {
434
+ text-align: center;
435
+ margin-bottom: 2rem;
436
+ }
437
+
438
+ .cost-label {
439
+ display: block;
440
+ font-size: 0.7rem;
441
+ font-weight: 700;
442
+ color: var(--text-muted);
443
+ text-transform: uppercase;
444
+ margin-bottom: 0.5rem;
445
+ }
446
+
447
+ .annual-cost {
448
+ font-size: 2.25rem;
449
+ font-weight: 900;
450
+ letter-spacing: -0.02em;
451
+ }
452
+
453
+ .specs-list {
454
+ display: flex;
455
+ flex-direction: column;
456
+ gap: 0.75rem;
457
+ padding-top: 1.5rem;
458
+ border-top: 1px dashed var(--border-color);
459
+ }
460
+
461
+ .spec-item {
462
+ display: flex;
463
+ justify-content: space-between;
464
+ font-size: 0.85rem;
465
+ }
466
+
467
+ .spec-label {
468
+ color: var(--text-muted);
469
+ }
470
+ .spec-value {
471
+ font-weight: 700;
472
+ }
473
+
474
+ @keyframes pop {
475
+ 0% { transform: scale(1); }
476
+ 50% { transform: scale(1.05); }
477
+ 100% { transform: scale(1); }
478
+ }
479
+
480
+ .animate-pop {
481
+ animation: pop 0.2s ease-out;
482
+ }
483
+
484
+ @keyframes bounce-in {
485
+ 0% {
486
+ transform: scale(0.3);
487
+ opacity: 0;
488
+ }
489
+ 50% {
490
+ transform: scale(1.05);
491
+ opacity: 1;
492
+ }
493
+ 70% { transform: scale(0.9); }
494
+ 100% { transform: scale(1); }
495
+ }
496
+ </style>