@bytebrand/fe-ui-core 4.6.4 → 4.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.6.4",
3
+ "version": "4.6.5",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -178,3 +178,42 @@
178
178
  background-color: #AC0A13
179
179
  .auto_de_selector_energyEfficiencyClass_g::after
180
180
  border-left-color: #AC0A13
181
+
182
+
183
+
184
+
185
+ :global
186
+ .auto_de_selector_energyEfficiencyClass_a_wltp
187
+ background-color: #4AA35A
188
+ .auto_de_selector_energyEfficiencyClass_a_wltp::after
189
+ border-left-color: #4AA35A
190
+
191
+ .auto_de_selector_energyEfficiencyClass_b_wltp
192
+ background-color: #6EBB4D
193
+ .auto_de_selector_energyEfficiencyClass_b_wltp::after
194
+ border-left-color: #6EBB4D
195
+
196
+ .auto_de_selector_energyEfficiencyClass_c_wltp
197
+ background-color: #BDDB4A
198
+ .auto_de_selector_energyEfficiencyClass_c_wltp::after
199
+ border-left-color: #BDDB4A
200
+
201
+ .auto_de_selector_energyEfficiencyClass_d_wltp
202
+ background-color: #FBF151
203
+ .auto_de_selector_energyEfficiencyClass_d_wltp::after
204
+ border-left-color: #FBF151
205
+
206
+ .auto_de_selector_energyEfficiencyClass_e_wltp
207
+ background-color: #EFB741
208
+ .auto_de_selector_energyEfficiencyClass_e_wltp::after
209
+ border-left-color: #EFB741
210
+
211
+ .auto_de_selector_energyEfficiencyClass_f_wltp
212
+ background-color: #E26733
213
+ .auto_de_selector_energyEfficiencyClass_f_wltp::after
214
+ border-left-color: #E26733
215
+
216
+ .auto_de_selector_energyEfficiencyClass_g_wltp
217
+ background-color: #DB3733
218
+ .auto_de_selector_energyEfficiencyClass_g_wltp::after
219
+ border-left-color: #DB3733
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { selectors } from '@bytebrand/car-schema-selectors';
4
+ import { WLTP_ENERGY_EFFICIENCY_CLASS } from '../../../framework/constants';
4
5
 
5
6
  import styles from './CO2Efficiency.styl';
6
7
 
@@ -14,6 +15,7 @@ interface ICO2EfficiencyProps {
14
15
  levelTitle?: string;
15
16
  wltpLevelTitle?: string;
16
17
  hybridPlugin?: boolean;
18
+ isWltp?: boolean;
17
19
  }
18
20
 
19
21
  // TODO: pass efficiency classes as a list into props.
@@ -24,7 +26,27 @@ class CO2Efficiency extends React.Component<ICO2EfficiencyProps> {
24
26
  };
25
27
 
26
28
  renderLevels = () => {
27
- const { level, wltpLevel, t, hybridPlugin } = this.props;
29
+ const { level, wltpLevel, t, hybridPlugin, isWltp = false } = this.props;
30
+
31
+ if (isWltp) {
32
+ return WLTP_ENERGY_EFFICIENCY_CLASS.map((key: string, i: number) => {
33
+ const width: string = `${(i + 1) * 10 + 13}px`; // tslint:disable-line
34
+ const isActive: boolean = key === level;
35
+ const isWltpActive: boolean = key === wltpLevel;
36
+ const className: string = classnames(styles.class, `auto_de_${key}_wltp`);
37
+ const translatedKey: string = t(`cbd:${key}`);
38
+
39
+ return key !== 'selector_unknown' ? (
40
+ <div key={key} className={styles.classContainer}>
41
+ <span className={className} style={{ width }}>
42
+ {translatedKey}
43
+ </span>
44
+ {isActive && <span className={styles.activeClass}>{translatedKey}</span>}
45
+ {isWltpActive && hybridPlugin && <span className={styles.secondActiveClass}>{translatedKey}</span>}
46
+ </div>
47
+ ) : false;
48
+ });
49
+ };
28
50
 
29
51
  return selectors.energyEfficiencyClass.map((key: string, i: number) => {
30
52
  const width: string = `${(i + 1) * 10 + 10}px`; // tslint:disable-line
@@ -54,6 +54,17 @@ export const DELIVERY_PERIODS_EXTRA = DELIVERY_PERIODS.map((val: string) => ({
54
54
  value: val
55
55
  }));
56
56
 
57
+
58
+ export const WLTP_ENERGY_EFFICIENCY_CLASS = [
59
+ "selector_energyEfficiencyClass_a",
60
+ "selector_energyEfficiencyClass_b",
61
+ "selector_energyEfficiencyClass_c",
62
+ "selector_energyEfficiencyClass_d",
63
+ "selector_energyEfficiencyClass_e",
64
+ "selector_energyEfficiencyClass_f",
65
+ "selector_energyEfficiencyClass_g"
66
+ ];
67
+
57
68
  export const offers = [
58
69
  {
59
70
  name: 'financing',
@@ -1139,10 +1139,19 @@ const getDecoratedProps = (
1139
1139
  : t('vehicleProps:value.na');
1140
1140
  }
1141
1141
  },
1142
+ wltpCo2Plugin: {
1143
+ title: t('vehicleProps:title.wltpCo2Plugin'),
1144
+ get value() {
1145
+ const c02 = car.environmentEmissions.wltpCo2;
1146
+ return Number.isFinite(c02)
1147
+ ? t('vehicleProps:value.co2', { co2: c02.toLocaleString(language) })
1148
+ : t('vehicleProps:value.na');
1149
+ }
1150
+ },
1142
1151
  wltpCo2Discharged: {
1143
1152
  title: t('vehicleProps:title.wltpCo2Discharged'),
1144
1153
  get value() {
1145
- const wltpCo2 = car.environmentEmissions.wltpCo2;
1154
+ const wltpCo2 = car.environmentEmissions.wltpCo2Discharged;
1146
1155
  return Number.isFinite(wltpCo2)
1147
1156
  ? t('vehicleProps:value.co2', { co2: wltpCo2.toLocaleString(language) })
1148
1157
  : t('vehicleProps:value.na');
@@ -1166,6 +1175,7 @@ const getDecoratedProps = (
1166
1175
  levelTitle={t('vehicleProps:title.wltpCO2WidgetComb')}
1167
1176
  wltpLevelTitle={t('vehicleProps:title.wltpCO2WidgetDischargedBattery')}
1168
1177
  hybridPlugin={hybridPlugin}
1178
+ isWltp
1169
1179
  /> : t('vehicleProps:value.na');
1170
1180
  }
1171
1181
  },
@@ -1174,7 +1184,7 @@ const getDecoratedProps = (
1174
1184
  subTitle: t('vehicleProps:title.subTitle'),
1175
1185
  get value() {
1176
1186
  const level = car.environmentEmissions.wltpDischargedEnergyEfficiencyClass;
1177
- return isPropDefined(level) ? <CO2Efficiency level={level} t={t} /> : t('vehicleProps:value.na');
1187
+ return isPropDefined(level) ? <CO2Efficiency level={level} isWltp t={t} /> : t('vehicleProps:value.na');
1178
1188
  }
1179
1189
  },
1180
1190
  wltpRange: {
@@ -1217,7 +1227,7 @@ const getDecoratedProps = (
1217
1227
  wltpWeightedCombined: {
1218
1228
  title: t('vehicleProps:title.wltpWeightedCombined'),
1219
1229
  get value() {
1220
- const wltpWeightedCombined = car.consumption && car.consumption.wltpTotalRangeCity;
1230
+ const wltpWeightedCombined = car.consumption.wltpWeightedCombined;
1221
1231
  return Number.isFinite(wltpWeightedCombined)
1222
1232
  ? t('vehicleProps:value.consumptionCombined', { consumption: wltpWeightedCombined.toLocaleString(language) })
1223
1233
  : t('vehicleProps:value.na');
@@ -1234,6 +1244,17 @@ const getDecoratedProps = (
1234
1244
  : t('vehicleProps:value.na');
1235
1245
  }
1236
1246
  },
1247
+ wltpCombinedPlugin: {
1248
+ title: t('vehicleProps:title.wltpCombinedPlugin'),
1249
+ get value() {
1250
+ const wltpCombined = car.consumption.wltpCombined;
1251
+ const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
1252
+ const translatedUnit = t(`cbd:${consumptionUnit}`);
1253
+ return Number.isFinite(wltpCombined)
1254
+ ? t('vehicleProps:value.consumption', { consumption: wltpCombined.toLocaleString(language), unit: translatedUnit })
1255
+ : t('vehicleProps:value.na');
1256
+ }
1257
+ },
1237
1258
  wltpSlow: {
1238
1259
  title: t('vehicleProps:title.wltpSlow'),
1239
1260
  get value() {
@@ -1245,6 +1266,17 @@ const getDecoratedProps = (
1245
1266
  : t('vehicleProps:value.na');
1246
1267
  }
1247
1268
  },
1269
+ wltpSlowPlugin: {
1270
+ title: t('vehicleProps:title.wltpSlowPlugin'),
1271
+ get value() {
1272
+ const wltpSlow = car.consumption.wltpSlow;
1273
+ const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
1274
+ const translatedUnit = t(`cbd:${consumptionUnit}`);
1275
+ return Number.isFinite(wltpSlow)
1276
+ ? t('vehicleProps:value.consumption', { consumption: wltpSlow.toLocaleString(language), unit: translatedUnit })
1277
+ : t('vehicleProps:value.na');
1278
+ }
1279
+ },
1248
1280
  wltpMedium: {
1249
1281
  title: t('vehicleProps:title.wltpMedium'),
1250
1282
  get value() {
@@ -1256,6 +1288,17 @@ const getDecoratedProps = (
1256
1288
  : t('vehicleProps:value.na');
1257
1289
  }
1258
1290
  },
1291
+ wltpMediumPlugin: {
1292
+ title: t('vehicleProps:title.wltpMediumPlugin'),
1293
+ get value() {
1294
+ const wltpMedium = car.consumption.wltpMedium;
1295
+ const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
1296
+ const translatedUnit = t(`cbd:${consumptionUnit}`);
1297
+ return Number.isFinite(wltpMedium)
1298
+ ? t('vehicleProps:value.consumption', { consumption: wltpMedium.toLocaleString(language), unit: translatedUnit })
1299
+ : t('vehicleProps:value.na');
1300
+ }
1301
+ },
1259
1302
  wltpFast: {
1260
1303
  title: t('vehicleProps:title.wltpFast'),
1261
1304
  get value() {
@@ -1267,6 +1310,17 @@ const getDecoratedProps = (
1267
1310
  : t('vehicleProps:value.na');
1268
1311
  }
1269
1312
  },
1313
+ wltpFastPlugin: {
1314
+ title: t('vehicleProps:title.wltpFastPlugin'),
1315
+ get value() {
1316
+ const wltpFast = car.consumption.wltpFast;
1317
+ const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
1318
+ const translatedUnit = t(`cbd:${consumptionUnit}`);
1319
+ return Number.isFinite(wltpFast)
1320
+ ? t('vehicleProps:value.consumption', { consumption: wltpFast.toLocaleString(language), unit: translatedUnit })
1321
+ : t('vehicleProps:value.na');
1322
+ }
1323
+ },
1270
1324
  wltpVeryFast: {
1271
1325
  title: t('vehicleProps:title.wltpVeryFast'),
1272
1326
  get value() {
@@ -1278,6 +1332,17 @@ const getDecoratedProps = (
1278
1332
  : t('vehicleProps:value.na');
1279
1333
  }
1280
1334
  },
1335
+ wltpVeryFastPlugin: {
1336
+ title: t('vehicleProps:title.wltpVeryFastPlugin'),
1337
+ get value() {
1338
+ const wltpVeryFast = car.consumption.wltpVeryFast;
1339
+ const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
1340
+ const translatedUnit = t(`cbd:${consumptionUnit}`);
1341
+ return Number.isFinite(wltpVeryFast)
1342
+ ? t('vehicleProps:value.consumption', { consumption: wltpVeryFast.toLocaleString(language), unit: translatedUnit })
1343
+ : t('vehicleProps:value.na');
1344
+ }
1345
+ },
1281
1346
  wltpWeightedPowerCombined: {
1282
1347
  title: t('vehicleProps:title.wltpWeightedPowerCombined'),
1283
1348
  get value() {
@@ -1344,6 +1409,61 @@ const getDecoratedProps = (
1344
1409
  : t('vehicleProps:value.na');
1345
1410
  }
1346
1411
  },
1412
+ wltpPowerCombinedPlugin: {
1413
+ title: t('vehicleProps:title.wltpPowerCombinedPlugin'),
1414
+ get value() {
1415
+ const wltpPowerCombined = car.consumption.wltpPowerCombined;
1416
+ const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
1417
+ const translatedUnit = t(`cbd:${consumptionUnit}`);
1418
+ return Number.isFinite(wltpPowerCombined)
1419
+ ? t('vehicleProps:value.consumptionPower', { consumption: wltpPowerCombined.toLocaleString(language), unit: translatedUnit })
1420
+ : t('vehicleProps:value.na');
1421
+ }
1422
+ },
1423
+ wltpPowerSlowPlugin: {
1424
+ title: t('vehicleProps:title.wltpPowerSlowPlugin'),
1425
+ get value() {
1426
+ const wltpPowerSlow = car.consumption.wltpPowerSlow;
1427
+ const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
1428
+ const translatedUnit = t(`cbd:${consumptionUnit}`);
1429
+ return Number.isFinite(wltpPowerSlow)
1430
+ ? t('vehicleProps:value.consumptionPower', { consumption: wltpPowerSlow.toLocaleString(language), unit: translatedUnit })
1431
+ : t('vehicleProps:value.na');
1432
+ }
1433
+ },
1434
+ wltpPowerMediumPlugin: {
1435
+ title: t('vehicleProps:title.wltpPowerMediumPlugin'),
1436
+ get value() {
1437
+ const wltpPowerMedium = car.consumption.wltpPowerMedium;
1438
+ const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
1439
+ const translatedUnit = t(`cbd:${consumptionUnit}`);
1440
+ return Number.isFinite(wltpPowerMedium)
1441
+ ? t('vehicleProps:value.consumptionPower', { consumption: wltpPowerMedium.toLocaleString(language), unit: translatedUnit })
1442
+ : t('vehicleProps:value.na');
1443
+ }
1444
+ },
1445
+ wltpPowerFastPlugin: {
1446
+ title: t('vehicleProps:title.wltpPowerFastPlugin'),
1447
+ get value() {
1448
+ const wltpPowerFast = car.consumption.wltpPowerFast;
1449
+ const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
1450
+ const translatedUnit = t(`cbd:${consumptionUnit}`);
1451
+ return Number.isFinite(wltpPowerFast)
1452
+ ? t('vehicleProps:value.consumptionPower', { consumption: wltpPowerFast.toLocaleString(language), unit: translatedUnit })
1453
+ : t('vehicleProps:value.na');
1454
+ }
1455
+ },
1456
+ wltpPowerVeryFastPlugin: {
1457
+ title: t('vehicleProps:title.wltpPowerVeryFastPlugin'),
1458
+ get value() {
1459
+ const wltpPowerVeryFast = car.consumption.wltpPowerVeryFast;
1460
+ const consumptionUnit = car.consumption.consumptionUnit || 'consumption_consumptionUnit_l';
1461
+ const translatedUnit = t(`cbd:${consumptionUnit}`);
1462
+ return Number.isFinite(wltpPowerVeryFast)
1463
+ ? t('vehicleProps:value.consumptionPower', { consumption: wltpPowerVeryFast.toLocaleString(language), unit: translatedUnit })
1464
+ : t('vehicleProps:value.na');
1465
+ }
1466
+ },
1347
1467
  // wltpEnergyCosts: {
1348
1468
  // title: t('vehicleProps:title.wltpEnergyCosts'),
1349
1469
  // get value() {
@@ -1386,6 +1506,33 @@ const getDecoratedProps = (
1386
1506
  : t('vehicleProps:value.na');
1387
1507
  }
1388
1508
  },
1509
+ powerPrice: {
1510
+ title: t('vehicleProps:title.powerPrice'),
1511
+ get value() {
1512
+ const { powerPrice } = car.costModel;
1513
+ return Number.isFinite(powerPrice)
1514
+ ? t('vehicleProps:value.price', { price: getFormattedPrice(powerPrice, '$,.2f') })
1515
+ : t('vehicleProps:value.na');
1516
+ }
1517
+ },
1518
+ fuelPrice: {
1519
+ title: t('vehicleProps:title.fuelPrice'),
1520
+ get value() {
1521
+ const { fuelPrice } = car.costModel;
1522
+ return Number.isFinite(fuelPrice)
1523
+ ? t('vehicleProps:value.price', { price: getFormattedPrice(fuelPrice, '$,.2f') })
1524
+ : t('vehicleProps:value.na');
1525
+ }
1526
+ },
1527
+ consumptionPriceYear: {
1528
+ title: t('vehicleProps:title.consumptionPriceYear'),
1529
+ get value() {
1530
+ const { consumptionPriceYear } = car.costModel;
1531
+ return Number.isFinite(consumptionPriceYear)
1532
+ ? t('vehicleProps:value.price', { price: getFormattedPrice(consumptionPriceYear, '$,.2f') })
1533
+ : t('vehicleProps:value.na');
1534
+ }
1535
+ },
1389
1536
  wltpCostModelTax: {
1390
1537
  title: t('vehicleProps:title.wltpVehicleTax'),
1391
1538
  get value() {