@bytebrand/fe-ui-core-autobahn 1.0.216 → 1.0.217
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/cards/CarCard.tsx +14 -59
- package/cards/CarRow.tsx +9 -33
- package/cards/cardParts.tsx +18 -58
- package/compat/PriceRating/PriceRating.styl +7 -5
- package/compat/PriceRatingDetailed/PriceRatingDetailed.styl +6 -8
- package/compat/legacy-theme/priceReviewColors.styl +5 -18
- package/constants/app.ts +1 -11
- package/constants/autobahn.ts +0 -39
- package/constants/core.ts +1 -12
- package/data/fieldMapping.ts +3 -3
- package/data/toAutobahnCar.ts +12 -14
- package/locales/de/autobahn.json +1 -3
- package/locales/en/autobahn.json +1 -3
- package/package.json +2 -2
- package/theme/md3.css +218 -115
- package/ui/StatChip.tsx +3 -8
- package/ui/index.ts +0 -1
- package/vdp/FinanceCalculator.tsx +27 -130
- package/vdp/VdpModules.tsx +665 -66
- package/vdp/index.ts +3 -0
- package/vdp/types.ts +12 -2
- package/ui/ratingLink.ts +0 -36
package/cards/CarCard.tsx
CHANGED
|
@@ -38,7 +38,6 @@ import {
|
|
|
38
38
|
GalleryActivityPill,
|
|
39
39
|
cardSpec,
|
|
40
40
|
PaymentMode,
|
|
41
|
-
startPaymentMode,
|
|
42
41
|
callDealerSalesPhone,
|
|
43
42
|
DEALER_SALES_PHONE,
|
|
44
43
|
} from './cardParts';
|
|
@@ -99,17 +98,6 @@ export interface CarCardProps {
|
|
|
99
98
|
* (still onOpenRateAdjust).
|
|
100
99
|
*/
|
|
101
100
|
onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
|
|
102
|
-
/**
|
|
103
|
-
* the price-rating badge + bar were clicked — open this car's VDP at its "Preis & Marktwert"
|
|
104
|
-
* section (URL fragment PRICE_SECTION_HASH, #vdp-preis). Page-owned like onShowFinancingDetails;
|
|
105
|
-
* when omitted the badge is not a link (a click opens the car via onOpen, as before).
|
|
106
|
-
*/
|
|
107
|
-
onShowPriceRating?: (car: AutobahnCar) => void;
|
|
108
|
-
/**
|
|
109
|
-
* Tab the price block opens on (default Finanzierung) — e.g. the SRP's leasing-only results
|
|
110
|
-
* open every card on Leasing. Ignored for a car without a lease rate (it has no Leasing tab).
|
|
111
|
-
*/
|
|
112
|
-
initialMode?: PaymentMode;
|
|
113
101
|
}
|
|
114
102
|
|
|
115
103
|
const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
@@ -125,10 +113,8 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
125
113
|
onCall,
|
|
126
114
|
onOpenRateAdjust,
|
|
127
115
|
onShowFinancingDetails,
|
|
128
|
-
onShowPriceRating,
|
|
129
|
-
initialMode,
|
|
130
116
|
}) => {
|
|
131
|
-
const [mode, setMode] = useState<PaymentMode>(
|
|
117
|
+
const [mode, setMode] = useState<PaymentMode>('financing');
|
|
132
118
|
const [photoIndex, setPhotoIndex] = useState(0);
|
|
133
119
|
const [viewerOpen, setViewerOpen] = useState(false);
|
|
134
120
|
const mediaRef = useRef<HTMLDivElement | null>(null);
|
|
@@ -171,8 +157,6 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
171
157
|
// active that's already 3, so NEU is dropped rather than causing a 4th to overflow.
|
|
172
158
|
const activeDealChips = [showDrop || showSave, showPct, !!car.zeroDown].filter(Boolean).length;
|
|
173
159
|
const showNeu = asGoodAsNew && car.isNew && activeDealChips < 3;
|
|
174
|
-
// tabs the price block can switch to (PriceTabs shows Leasing only when the car has a lease rate)
|
|
175
|
-
const paymentModes: PaymentMode[] = car.lease != null ? ['financing', 'leasing', 'buy'] : ['financing', 'buy'];
|
|
176
160
|
return (
|
|
177
161
|
<article
|
|
178
162
|
className="mcard mcard--interactive cc-card"
|
|
@@ -295,50 +279,21 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
295
279
|
<div className="cc-price" style={{ marginTop: 0, borderTop: '1px solid var(--md-outline-variant)' }}>
|
|
296
280
|
<PriceTabs car={car} mode={mode} onModeChange={setMode} t={t} />
|
|
297
281
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, marginTop: 10 }}>
|
|
298
|
-
{
|
|
299
|
-
|
|
300
|
-
the price, so without this the row (and the card) grew/shrank by that line on
|
|
301
|
-
every tab switch. Same trick as .cc-terms-stack below. */}
|
|
302
|
-
<div className="cc-hero-stack">
|
|
303
|
-
{paymentModes.map((m) => (
|
|
304
|
-
<div
|
|
305
|
-
key={m}
|
|
306
|
-
className={'cc-hero-slot' + (m === mode ? '' : ' cc-hero-slot--hidden')}
|
|
307
|
-
aria-hidden={m === mode ? undefined : true}
|
|
308
|
-
>
|
|
309
|
-
<PriceHero car={car} mode={m} t={t} alwaysShowUnit />
|
|
310
|
-
</div>
|
|
311
|
-
))}
|
|
312
|
-
</div>
|
|
313
|
-
<PriceEvalCol car={car} t={t} onActivate={onShowPriceRating ? () => onShowPriceRating(car) : undefined} />
|
|
282
|
+
<PriceHero car={car} mode={mode} t={t} alwaysShowUnit />
|
|
283
|
+
<PriceEvalCol car={car} t={t} />
|
|
314
284
|
</div>
|
|
315
285
|
{/* same fallback CardCtaRow already uses below: pages that haven't wired a real
|
|
316
|
-
"Rate anpassen" sheet yet still get a working "Details" link (opens the car).
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
{
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
>
|
|
328
|
-
<PriceTerms
|
|
329
|
-
car={car}
|
|
330
|
-
mode={m}
|
|
331
|
-
onOpenRateAdjust={onOpenRateAdjust || (() => onOpen(car))}
|
|
332
|
-
onShowDetails={onShowFinancingDetails ? () => onShowFinancingDetails(car, m) : undefined}
|
|
333
|
-
t={t}
|
|
334
|
-
/>
|
|
335
|
-
{/* ADV-405/407 Kreditkosten-Hinweis under the financing/leasing conditions line. Inside the
|
|
336
|
-
slot, so the stack keeps one height across the tabs (no jump on Kaufen); hidden slots
|
|
337
|
-
are visibility:hidden + aria-hidden like their terms line. */}
|
|
338
|
-
{m !== 'buy' && <CreditCostNotice t={t} size="small" cls="cc-ccn" />}
|
|
339
|
-
</div>
|
|
340
|
-
))}
|
|
341
|
-
</div>
|
|
286
|
+
"Rate anpassen" sheet yet still get a working "Details" link (opens the car). */}
|
|
287
|
+
<PriceTerms
|
|
288
|
+
car={car}
|
|
289
|
+
mode={mode}
|
|
290
|
+
onOpenRateAdjust={onOpenRateAdjust || (() => onOpen(car))}
|
|
291
|
+
onShowDetails={onShowFinancingDetails ? () => onShowFinancingDetails(car, mode) : undefined}
|
|
292
|
+
t={t}
|
|
293
|
+
/>
|
|
294
|
+
{/* ADV-405/407 Kreditkosten-Hinweis: below the conditions line, above the CTA row (mobile)
|
|
295
|
+
/ eco line (desktop); not on Kaufen, which shows no financing terms either. */}
|
|
296
|
+
{mode !== 'buy' && <CreditCostNotice t={t} size="small" cls="cc-ccn" />}
|
|
342
297
|
</div>
|
|
343
298
|
{/* Mobile-only row (CardCtaRow itself carries the show-mobile class) — always
|
|
344
299
|
rendered, with real fallbacks the page can override once it wires its own
|
package/cards/CarRow.tsx
CHANGED
|
@@ -24,7 +24,6 @@ import React, { useState, useEffect, useRef } from 'react';
|
|
|
24
24
|
import { TranslationFunction } from '../types';
|
|
25
25
|
|
|
26
26
|
import { CardCarousel, IconButton, SaveChip, Button, Icon, StatChip } from '../ui';
|
|
27
|
-
import { ratingLinkProps } from '../ui/ratingLink';
|
|
28
27
|
import {
|
|
29
28
|
EcoLine,
|
|
30
29
|
PriceMeter,
|
|
@@ -42,7 +41,6 @@ import {
|
|
|
42
41
|
ZeroDownChip,
|
|
43
42
|
fmtKm,
|
|
44
43
|
PaymentMode,
|
|
45
|
-
startPaymentMode,
|
|
46
44
|
ratingTone,
|
|
47
45
|
} from './cardParts';
|
|
48
46
|
import { AutobahnCar } from './types';
|
|
@@ -82,10 +80,6 @@ export interface CarRowProps {
|
|
|
82
80
|
* links render as plain text (see PricePaths' own fallback).
|
|
83
81
|
*/
|
|
84
82
|
onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
|
|
85
|
-
/** the price-rating chip + bar were clicked — see CarCard's identically-named prop. */
|
|
86
|
-
onShowPriceRating?: (car: AutobahnCar) => void;
|
|
87
|
-
/** Tab the mobile price tabs open on — see CarCard's identically-named prop. */
|
|
88
|
-
initialMode?: PaymentMode;
|
|
89
83
|
}
|
|
90
84
|
|
|
91
85
|
const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
@@ -98,23 +92,10 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
|
98
92
|
t,
|
|
99
93
|
adminAction,
|
|
100
94
|
onShowFinancingDetails,
|
|
101
|
-
onShowPriceRating,
|
|
102
|
-
initialMode,
|
|
103
95
|
}) => {
|
|
104
|
-
const [mode, setMode] = useState<PaymentMode>(
|
|
96
|
+
const [mode, setMode] = useState<PaymentMode>('financing');
|
|
105
97
|
const [photoIndex, setPhotoIndex] = useState(0);
|
|
106
98
|
const mediaRef = useRef<HTMLDivElement | null>(null);
|
|
107
|
-
// The price-rating chip + bar link to the car's "Preis & Marktwert" section (page-owned
|
|
108
|
-
// onShowPriceRating, ratingLinkProps). Without it they stay plain: a click opens the car, as
|
|
109
|
-
// before. `noTabStop`: clickable, but not a second tab stop next to the chip.
|
|
110
|
-
const ratingLink = (className: string, noTabStop: boolean = false): React.HTMLAttributes<HTMLElement> => {
|
|
111
|
-
if (!onShowPriceRating || !car.rating) return {};
|
|
112
|
-
const props = ratingLinkProps(
|
|
113
|
-
() => onShowPriceRating(car),
|
|
114
|
-
t('autobahn:finance.priceRatingLink', { rating: t('autobahn:tier.' + car.rating) }),
|
|
115
|
-
);
|
|
116
|
-
return noTabStop ? { className, onClick: props.onClick, 'aria-hidden': true } : { className, ...props };
|
|
117
|
-
};
|
|
118
99
|
// always call the LATEST onMediaEnter without re-arming the observer on every render (the
|
|
119
100
|
// page callers construct a fresh closure each render) — the effect itself only needs to run
|
|
120
101
|
// once per mount. Identical pattern to CarCard.tsx — see its own comment for the rationale.
|
|
@@ -294,18 +275,13 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
|
294
275
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 }}>
|
|
295
276
|
<PriceHero car={car} mode={mode} t={t} alwaysShowUnit />
|
|
296
277
|
{car.rating && (
|
|
297
|
-
<
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
</StatChip>
|
|
302
|
-
</span>
|
|
278
|
+
<StatChip tone={ratingTone(car.rating)} icon={ratingTone(car.rating) === 'good' ? 'check' : 'minus'}>
|
|
279
|
+
{t('autobahn:tier.' + car.rating)}
|
|
280
|
+
{ratingTone(car.rating) === 'good' && <sup>4</sup>}
|
|
281
|
+
</StatChip>
|
|
303
282
|
)}
|
|
304
283
|
</div>
|
|
305
|
-
{
|
|
306
|
-
<div {...ratingLink('rating-link', true)}>
|
|
307
|
-
<PriceMeter t={t} car={car} />
|
|
308
|
-
</div>
|
|
284
|
+
<PriceMeter t={t} car={car} />
|
|
309
285
|
<div className="pp-cta">
|
|
310
286
|
<Button
|
|
311
287
|
variant="filled"
|
|
@@ -344,11 +320,11 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
|
344
320
|
/>
|
|
345
321
|
<div className="pp-purchase hide-mobile">
|
|
346
322
|
<PriceKauf car={car} t={t} />
|
|
347
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}
|
|
323
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
|
|
348
324
|
{car.rating && (
|
|
349
|
-
<StatChip
|
|
325
|
+
<StatChip tone={ratingTone(car.rating)} icon={ratingTone(car.rating) === 'good' ? 'check' : 'minus'}>
|
|
350
326
|
{t('autobahn:tier.' + car.rating)}
|
|
351
|
-
<sup>4</sup>
|
|
327
|
+
{ratingTone(car.rating) === 'good' && <sup>4</sup>}
|
|
352
328
|
</StatChip>
|
|
353
329
|
)}
|
|
354
330
|
<div style={{ flex: 1 }}>
|
package/cards/cardParts.tsx
CHANGED
|
@@ -20,9 +20,8 @@ import { defaultConfig } from '@bytebrand/fe-financing';
|
|
|
20
20
|
|
|
21
21
|
import { Icon, Button, CreditCostNotice, CreditKeyFigures, hasCreditKeyFigures } from '../ui';
|
|
22
22
|
import type { CreditKeyFiguresData } from '../ui';
|
|
23
|
-
import { EvalBar
|
|
24
|
-
import {
|
|
25
|
-
import { CO2_CLASSES, CO2_COLORS, TIER_KEYS, TIER_COLORS, NO_RATING_KEY, ratingColorsOf } from '../constants';
|
|
23
|
+
import { EvalBar } from '../vdp/FinanceCalculator';
|
|
24
|
+
import { CO2_CLASSES, CO2_COLORS, TIER_KEYS, TIER_COLORS } from '../constants';
|
|
26
25
|
import { AutobahnCar } from './types';
|
|
27
26
|
// pure, non-React — shared with the Meta AIA marketing-image renderer (a plain Node service).
|
|
28
27
|
export { ratingTone } from '../data/toAutobahnCar';
|
|
@@ -450,8 +449,6 @@ const TONE_TO_TIER: Record<string, number> = { top: 0, good: 1, fair: 2, raised:
|
|
|
450
449
|
* Renders nothing when there is no rating/band (needs-data: we never draw a fake market position).
|
|
451
450
|
*/
|
|
452
451
|
export const PriceMeter: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction }> = ({ car }) => {
|
|
453
|
-
// "Keine Bewertung": the price is outside the bands, so no marker anywhere on the scale
|
|
454
|
-
if (car.rating === NO_RATING_KEY) return <EvalBar tier={null} />;
|
|
455
452
|
const hasMarket =
|
|
456
453
|
car.marketLow != null && car.marketAvg != null && car.marketHigh != null && car.marketHigh > car.marketLow;
|
|
457
454
|
const bar = (tier: number) => {
|
|
@@ -463,7 +460,7 @@ export const PriceMeter: React.FunctionComponent<{ car: AutobahnCar; t: Translat
|
|
|
463
460
|
<span key={i} className="fin-eval-seg" style={{ background: c }} />
|
|
464
461
|
))}
|
|
465
462
|
<div
|
|
466
|
-
className=
|
|
463
|
+
className={`fin-eval-thumb${TIER_KEYS[tierIndex] === 'good' ? ' fin-eval-thumb--good' : ''}`}
|
|
467
464
|
style={{ left: `${leftPct}%`, borderColor: TIER_COLORS[tierIndex] }}
|
|
468
465
|
/>
|
|
469
466
|
</div>
|
|
@@ -485,38 +482,9 @@ export const PriceMeter: React.FunctionComponent<{ car: AutobahnCar; t: Translat
|
|
|
485
482
|
* Preisbewertung pill + segmented tier bar, grouped in one column exactly like the VDP
|
|
486
483
|
* finance-calculator's mobile .fin-eval-col (FinanceCalculator.tsx/EvalBar) — the grid card's
|
|
487
484
|
* replacement for the old StatChip pill + full-width gradient .pp-bar pairing. Renders nothing
|
|
488
|
-
* without a rating (needs-data: never invent a tier).
|
|
489
|
-
* (ratingLinkProps): the page opens the car's VDP at its "Preis & Marktwert" section.
|
|
485
|
+
* without a rating (needs-data: never invent a tier).
|
|
490
486
|
*/
|
|
491
|
-
export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction
|
|
492
|
-
car,
|
|
493
|
-
t,
|
|
494
|
-
onActivate,
|
|
495
|
-
}) => {
|
|
496
|
-
const linkProps = (label: string) =>
|
|
497
|
-
onActivate
|
|
498
|
-
? { className: 'fin-eval-col rating-link', ...ratingLinkProps(onActivate, t('autobahn:finance.priceRatingLink', { rating: label })) }
|
|
499
|
-
: { className: 'fin-eval-col' };
|
|
500
|
-
if (car.rating === NO_RATING_KEY) {
|
|
501
|
-
// "Keine Bewertung": grey pill, the usual bar without a marker
|
|
502
|
-
const noRatingLabel = t('autobahn:tier.' + NO_RATING_KEY);
|
|
503
|
-
const noRating = ratingColorsOf(NO_RATING_KEY);
|
|
504
|
-
return (
|
|
505
|
-
<div {...linkProps(noRatingLabel)}>
|
|
506
|
-
<div className="fin-eval-pill-cell">
|
|
507
|
-
<EvalPill
|
|
508
|
-
label={noRatingLabel}
|
|
509
|
-
color={noRating.color}
|
|
510
|
-
background={noRating.background}
|
|
511
|
-
ariaLabel={t('autobahn:finance.priceRatingAria', { rating: noRatingLabel })}
|
|
512
|
-
/>
|
|
513
|
-
</div>
|
|
514
|
-
<div className="fin-eval-bar-cell">
|
|
515
|
-
<EvalBar tier={null} />
|
|
516
|
-
</div>
|
|
517
|
-
</div>
|
|
518
|
-
);
|
|
519
|
-
}
|
|
487
|
+
export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction }> = ({ car, t }) => {
|
|
520
488
|
const tier = car.rating ? TONE_TO_TIER[car.rating] : undefined;
|
|
521
489
|
if (tier == null) return null;
|
|
522
490
|
const hasMarket =
|
|
@@ -529,18 +497,20 @@ export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: Transl
|
|
|
529
497
|
// each tier shows its own real label now (Top/Guter/Fairer/Erhöht/Hoher Preis) — no more
|
|
530
498
|
// collapsing 'good' onto the "Top-Preis" claim. Pill styling (colour/class/footnote) unchanged.
|
|
531
499
|
const tierLabel = t('autobahn:tier.' + car.rating);
|
|
532
|
-
// the tier's own
|
|
533
|
-
|
|
500
|
+
// 'good' collapses onto the 'top' tier's own color too (#168a45), matching the fixed
|
|
501
|
+
// "Top-Preis" text above rather than tier 1's lighter TIER_COLORS[1] green.
|
|
502
|
+
const pillColor = isGood ? TIER_COLORS[0] : TIER_COLORS[tier];
|
|
534
503
|
return (
|
|
535
|
-
<div
|
|
504
|
+
<div className="fin-eval-col">
|
|
536
505
|
<div className="fin-eval-pill-cell">
|
|
537
|
-
<
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
506
|
+
<span
|
|
507
|
+
className={`fin-eval-pill${isGood ? ' fin-eval-pill--good' : ''}`}
|
|
508
|
+
style={{ color: pillColor, background: `color-mix(in srgb, ${pillColor} 16%, transparent)` }}
|
|
509
|
+
aria-label={t('autobahn:finance.priceRatingAria', { rating: tierLabel })}
|
|
510
|
+
>
|
|
511
|
+
{tierLabel}
|
|
512
|
+
{isGood && <sup>4</sup>}
|
|
513
|
+
</span>
|
|
544
514
|
</div>
|
|
545
515
|
<div className="fin-eval-bar-cell">
|
|
546
516
|
<EvalBar tier={tier} leftPct={leftPct} />
|
|
@@ -551,11 +521,6 @@ export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: Transl
|
|
|
551
521
|
|
|
552
522
|
export type PaymentMode = 'financing' | 'leasing' | 'buy';
|
|
553
523
|
|
|
554
|
-
/** The tab a card opens on: the requested one (default Finanzierung), but never Leasing for a car
|
|
555
|
-
* without a lease rate — PriceTabs has no Leasing tab for it. */
|
|
556
|
-
export const startPaymentMode = (car: AutobahnCar, requested?: PaymentMode): PaymentMode =>
|
|
557
|
-
requested === 'leasing' && car.lease == null ? 'financing' : requested || 'financing';
|
|
558
|
-
|
|
559
524
|
export interface PriceTabsProps {
|
|
560
525
|
car: AutobahnCar;
|
|
561
526
|
mode: PaymentMode;
|
|
@@ -790,12 +755,7 @@ export const PriceTerms: React.FunctionComponent<{
|
|
|
790
755
|
onShowDetails?: () => void;
|
|
791
756
|
t: TranslationFunction;
|
|
792
757
|
}> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
|
|
793
|
-
|
|
794
|
-
// here, which collapsed .cc-terms to 0 height on that tab while Financing/Leasing rendered a
|
|
795
|
-
// real line, jumping the price row (and everything below it: rating pill, CTA row) up/down on
|
|
796
|
-
// every tab switch. Render an empty, still-present .cc-terms div instead — same fix as the VDP
|
|
797
|
-
// FinanceCalculator's .fin-cond (md3.css), which reserves its line's height the same way.
|
|
798
|
-
if (mode === 'buy') return <div className="cc-terms" />;
|
|
758
|
+
if (mode === 'buy') return null;
|
|
799
759
|
const finFirstInstallment =
|
|
800
760
|
car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
|
|
801
761
|
const finMonths = car.finMonths ?? _finMonths;
|
|
@@ -36,10 +36,12 @@
|
|
|
36
36
|
color: $priceReviewColors[darkBackground]
|
|
37
37
|
border: 2px solid $priceReviewColors[darkBackground]
|
|
38
38
|
|
|
39
|
-
// label: the rating's text colour; segment: its scale colour
|
|
40
|
-
for colorName in $priceReviewTextColors
|
|
41
|
-
.{colorName}
|
|
42
|
-
color: $priceReviewTextColors[colorName]
|
|
43
39
|
for colorName in $priceReviewColors
|
|
40
|
+
$color = $priceReviewColors[colorName]
|
|
41
|
+
if $color == $priceReviewColors.noRating
|
|
42
|
+
$color = $priceReviewColors[darkBackground]
|
|
43
|
+
$backgroundColor = $priceReviewColors[colorName]
|
|
44
|
+
.{colorName}
|
|
45
|
+
color: $color
|
|
44
46
|
.{colorName}Background
|
|
45
|
-
border: 2px solid $
|
|
47
|
+
border: 2px solid $backgroundColor
|
|
@@ -71,28 +71,26 @@
|
|
|
71
71
|
|
|
72
72
|
.noRatingTooltip
|
|
73
73
|
@extends .baseTooltip
|
|
74
|
-
color:
|
|
75
|
-
border-color:
|
|
74
|
+
color: black
|
|
75
|
+
border-color: $priceReviewColors[darkBackground]
|
|
76
76
|
|
|
77
77
|
.tooltip
|
|
78
78
|
@extends .baseTooltip
|
|
79
79
|
color: white
|
|
80
80
|
|
|
81
|
-
// segment: the rating's scale colour; tooltip (text on white): its text colour
|
|
82
81
|
for colorName in $priceReviewColors
|
|
83
82
|
$color = $priceReviewColors[colorName]
|
|
84
|
-
$textColor = $priceReviewTextColors[colorName] || $color
|
|
85
83
|
.{colorName}
|
|
86
84
|
&.segment
|
|
87
85
|
background-color $color
|
|
88
86
|
.tooltipWrapper
|
|
89
87
|
&:after
|
|
90
|
-
background-color: $
|
|
88
|
+
background-color: $color
|
|
91
89
|
.tooltip
|
|
92
|
-
border-color: $
|
|
93
|
-
color: $
|
|
90
|
+
border-color: $color
|
|
91
|
+
color: $color
|
|
94
92
|
&:after
|
|
95
|
-
background-color: $
|
|
93
|
+
background-color: $color
|
|
96
94
|
|
|
97
95
|
.compact
|
|
98
96
|
& .segment
|
|
@@ -1,25 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
// The old Preisbewertung popup (PriceRating, PriceRatingDetailed) in the price-rating colours every
|
|
3
|
-
// other page uses (Figma 474sauvNgCYK2mEq5iks9e 142:3643; the lib's constants/autobahn.ts and md3.css
|
|
4
|
-
// --rating-*). $priceReviewColors: the scale (TIER_COLORS, --rating-*-bar); noRating/darkBackground
|
|
5
|
-
// stay the empty-segment grey.
|
|
6
2
|
$priceReviewColors = {
|
|
7
3
|
noRating: rgba(76, 78, 100, 0.22)
|
|
8
4
|
darkBackground: rgba(76, 78, 100, 0.22)
|
|
9
|
-
highPrice:
|
|
10
|
-
increasedPrice:
|
|
11
|
-
fairPrice:
|
|
12
|
-
goodPrice:
|
|
13
|
-
topPrice:
|
|
14
|
-
}
|
|
15
|
-
// the rating labels' text (TIER_TEXT_COLORS / NO_RATING_COLOR, --rating-*-fg)
|
|
16
|
-
$priceReviewTextColors = {
|
|
17
|
-
noRating: #5B6B7F
|
|
18
|
-
highPrice: #E60000
|
|
19
|
-
increasedPrice: #F26B43
|
|
20
|
-
fairPrice: #FFB800
|
|
21
|
-
goodPrice: #66B84D
|
|
22
|
-
topPrice: #168A45
|
|
5
|
+
highPrice: rgba(226, 108, 0, 1)
|
|
6
|
+
increasedPrice: rgba(237, 157, 55, 1)
|
|
7
|
+
fairPrice: rgba(173, 208, 66, 1)
|
|
8
|
+
goodPrice: rgba(102, 212, 102, 1)
|
|
9
|
+
topPrice: rgba(31, 193, 31, 1)
|
|
23
10
|
}
|
|
24
11
|
|
|
25
12
|
|
package/constants/app.ts
CHANGED
|
@@ -40,17 +40,7 @@ export const LOCAL_STORAGE_KEY = {
|
|
|
40
40
|
i18n_KEY: 'i18nLanguage'
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
// SecurityError that took down the whole bundle. Blocked storage behaves like "nothing saved".
|
|
45
|
-
const readStoredLang = (): string | null => {
|
|
46
|
-
try {
|
|
47
|
-
return localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY);
|
|
48
|
-
} catch (e) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const DEFAULT_LANG: string = typeof window !== 'undefined' ? readStoredLang() : 'de';
|
|
43
|
+
export const DEFAULT_LANG: string = typeof window !== 'undefined' ? localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : 'de';
|
|
54
44
|
|
|
55
45
|
// Default support contact phone
|
|
56
46
|
export const CONTACT_PHONE: string = '+498004030182';
|
package/constants/autobahn.ts
CHANGED
|
@@ -22,49 +22,10 @@ export const TIER_LABELS = ['Top Preis', 'Guter Preis', 'Fairer Preis', 'Erhöht
|
|
|
22
22
|
// i18n key suffixes parallel to TIER_LABELS — components render t('autobahn:tier.<key>') so the
|
|
23
23
|
// Preisbewertung label localizes (TIER_LABELS stays the German source-of-truth used for tier→index logic).
|
|
24
24
|
export const TIER_KEYS = ['top', 'good', 'fair', 'raised', 'high'] as const;
|
|
25
|
-
/** the five segments (and the marker ring) of the price-rating bar */
|
|
26
25
|
export const TIER_COLORS: readonly string[] = ['#168A45', '#66B84D', '#F7C544', '#F26B43', '#E60000'];
|
|
27
|
-
/**
|
|
28
|
-
* Price-rating badge colours, the same on every page (Figma 474sauvNgCYK2mEq5iks9e 142:3643
|
|
29
|
-
* "Die auto.de Bewertungskategorien"): the label's text colour on its background, per tier.
|
|
30
|
-
* md3.css repeats them as --rating-<key>-fg / --rating-<key>-bg for the CSS-only badges; fe-main's
|
|
31
|
-
* ratingPalette test keeps the two in step.
|
|
32
|
-
*/
|
|
33
|
-
export const TIER_TEXT_COLORS: readonly string[] = ['#168A45', '#66B84D', '#FFB800', '#F26B43', '#E60000'];
|
|
34
26
|
export const TIER_BACKGROUNDS: readonly string[] = ['#DFF3E5', '#E4F3DF', '#FFF6DB', '#FFEFD5', '#FFD3D3'];
|
|
35
27
|
export type RatingTier = 0 | 1 | 2 | 3 | 4;
|
|
36
28
|
|
|
37
|
-
/**
|
|
38
|
-
* "Keine Bewertung": getPriceRating returned 0 for a real price, because the price is outside the
|
|
39
|
-
* rating bands (more than 25% above the market value). That is no tier, so it is never shown as
|
|
40
|
-
* one. It is a grey "Keine Bewertung" pill; the bar keeps its usual colours but has no marker,
|
|
41
|
-
* since the price has no place on the scale.
|
|
42
|
-
* mapRating emits NO_RATING_KEY as `rating` and NO_RATING_LABEL as `ratingLabel`; the label key is
|
|
43
|
-
* t('autobahn:tier.none').
|
|
44
|
-
*/
|
|
45
|
-
export const NO_RATING_KEY = 'none';
|
|
46
|
-
export const NO_RATING_LABEL = 'Keine Bewertung';
|
|
47
|
-
/** "Keine Bewertung" badge text and background (Figma 142:3643, like TIER_TEXT_COLORS) */
|
|
48
|
-
export const NO_RATING_COLOR = '#5B6B7F';
|
|
49
|
-
export const NO_RATING_BACKGROUND = '#C8D1DE';
|
|
50
|
-
|
|
51
|
-
/** Badge text colour and background of a mapRating() `rating` key ('top' … 'high', or
|
|
52
|
-
* NO_RATING_KEY). An unknown key falls back to 'good', as evalTierOf does. */
|
|
53
|
-
export function ratingColorsOf(rating?: string): { color: string; background: string } {
|
|
54
|
-
if (rating === NO_RATING_KEY) return { color: NO_RATING_COLOR, background: NO_RATING_BACKGROUND };
|
|
55
|
-
const index = TIER_KEYS.indexOf(rating as (typeof TIER_KEYS)[number]);
|
|
56
|
-
const tier = index >= 0 ? index : 1;
|
|
57
|
-
return { color: TIER_TEXT_COLORS[tier], background: TIER_BACKGROUNDS[tier] };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** Tier index (0 Top … 4 Hoch) of a mapRating() `ratingLabel`, or null for "Keine Bewertung".
|
|
61
|
-
* An unknown label falls back to 1, as the components always did. */
|
|
62
|
-
export function evalTierOf(ratingLabel?: string): RatingTier | null {
|
|
63
|
-
if (ratingLabel === NO_RATING_LABEL) return null;
|
|
64
|
-
const index = TIER_LABELS.indexOf(ratingLabel as (typeof TIER_LABELS)[number]);
|
|
65
|
-
return (index >= 0 ? index : 1) as RatingTier;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
29
|
/** SRP sort options (labels match the design; mapped to real sort params by the SRP container). */
|
|
69
30
|
export const SORTS = [
|
|
70
31
|
'Relevanz',
|
package/constants/core.ts
CHANGED
|
@@ -35,18 +35,7 @@ export const LOCAL_STORAGE_KEY = {
|
|
|
35
35
|
i18n_KEY: 'i18nLanguage'
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
// window.localStorage throws a SecurityError, which took down the whole bundle (landing
|
|
40
|
-
// page never rendered). Treat blocked storage like "no language saved".
|
|
41
|
-
const readStoredLang = (): string | null => {
|
|
42
|
-
try {
|
|
43
|
-
return typeof window !== 'undefined' ? window.localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : null;
|
|
44
|
-
} catch (e) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const DEFAULT_LANG: string = readStoredLang() ?? 'de';
|
|
38
|
+
export const DEFAULT_LANG: string = (typeof window !== 'undefined' ? window.localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : null) ?? 'de';
|
|
50
39
|
|
|
51
40
|
export const ROW_STYLES = {
|
|
52
41
|
marginBottom: 10
|
package/data/fieldMapping.ts
CHANGED
|
@@ -226,18 +226,18 @@ export const FIELD_MAPPINGS: readonly FieldMapping[] = [
|
|
|
226
226
|
status: 'wired',
|
|
227
227
|
source: 'price.currentSalesPrice + price.mlCurrentSalesPricePredicted',
|
|
228
228
|
transform:
|
|
229
|
-
"getPriceRating(sale, predicted) [0..5] → autobahn tone: 5→'top' 4→'good' 3→'fair' 2→'raised' 1→'high'; 0(noRating
|
|
229
|
+
"getPriceRating(sale, predicted) [0..5] → autobahn tone: 5→'top' 4→'good' 3→'fair' 2→'raised' 1→'high'; 0(noRating)→neutral 'fair'",
|
|
230
230
|
confirmedAt:
|
|
231
231
|
'VehicleInfo.tsx:160 (SRP card renders getPriceRating(currentSalesPrice, mlCurrentSalesPricePredicted)) · CommonUtils.ts:353-373 (getPriceRating) · price.ts:1 (priceRatings order) · DataTransformers.ts:354 (mlCurrentSalesPricePredicted)',
|
|
232
232
|
notes:
|
|
233
|
-
"REAL Preisbewertung. Card only special-cases tone==='fair' → warn pill; every other tone → good/green pill (CarCard.tsx:96-97). noRating
|
|
233
|
+
"REAL Preisbewertung. Card only special-cases tone==='fair' → warn pill; every other tone → good/green pill (CarCard.tsx:96-97). For noRating we pick the NEUTRAL middle tier, never a flattering one. predicted falls back to sale*1.07814 (PREDICTABLE_PRICE_INDEX) inside getPriceRating, exactly like the live card.",
|
|
234
234
|
},
|
|
235
235
|
{
|
|
236
236
|
field: 'ratingLabel',
|
|
237
237
|
required: true,
|
|
238
238
|
status: 'wired',
|
|
239
239
|
source: 'derived from the rating tier',
|
|
240
|
-
transform: "TIER_LABELS[tier] → 'Top Preis'|'Guter Preis'|'Fairer Preis'|'Erhöht'|'Hoher Preis'
|
|
240
|
+
transform: "TIER_LABELS[tier] → 'Top Preis'|'Guter Preis'|'Fairer Preis'|'Erhöht'|'Hoher Preis'",
|
|
241
241
|
confirmedAt:
|
|
242
242
|
'autobahn/constants.ts:17 (TIER_LABELS) · fe-ui-core locales/priceRating.ts:2-9 (legacy German labels: TOP/GUTER/FAIRER/ERHÖHTER/HOHER PREIS)',
|
|
243
243
|
notes:
|
package/data/toAutobahnCar.ts
CHANGED
|
@@ -29,7 +29,7 @@ import { getPowerLabel } from '../utils/power';
|
|
|
29
29
|
|
|
30
30
|
import { AutobahnCar, AutobahnPhev } from '../cards/types';
|
|
31
31
|
import { leasingKeyFigures } from '../ui/CreditKeyFigures';
|
|
32
|
-
import { TIER_LABELS, RatingTier, CO2_CLASSES, Co2Class
|
|
32
|
+
import { TIER_LABELS, RatingTier, CO2_CLASSES, Co2Class } from '../constants/autobahn';
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Last-resort placeholder shown in the carousel until the real images for a car
|
|
@@ -238,13 +238,13 @@ export function co2ClassLetter(code: any): Co2Class | '' {
|
|
|
238
238
|
* topPrice(5)→0 'Top Preis' · goodPrice(4)→1 'Guter Preis' ·
|
|
239
239
|
* fairPrice(3)→2 'Fairer Preis' · increasedPrice(2)→3 'Erhöht' ·
|
|
240
240
|
* highPrice(1)→4 'Hoher Preis'.
|
|
241
|
-
* noRating(0)
|
|
242
|
-
*
|
|
243
|
-
* the
|
|
244
|
-
* above the market showed "Fairer Preis".
|
|
241
|
+
* noRating(0) has no real comparison → neutral 'Fairer Preis' (tier 2) WITHOUT a
|
|
242
|
+
* flattering label (documented in fieldMapping.ts). The card only special-cases
|
|
243
|
+
* the 'fair' tone (warn pill); every other tone is the good/green pill.
|
|
245
244
|
*
|
|
246
|
-
* AutobahnCar.rating is a free string
|
|
247
|
-
*
|
|
245
|
+
* AutobahnCar.rating is a free string; CarCard does `rating === 'fair' ? warn : good`.
|
|
246
|
+
* We emit the autobahn tier key ('top'|'good'|'fair'|'raised'|'high') so the
|
|
247
|
+
* neutral 'fair' maps to the warn pill exactly like the design intends.
|
|
248
248
|
*/
|
|
249
249
|
const LEGACY_TO_TIER: Record<number, RatingTier> = {
|
|
250
250
|
5: 0, // topPrice → Top Preis
|
|
@@ -263,20 +263,18 @@ const TIER_TONE: Record<RatingTier, string> = {
|
|
|
263
263
|
|
|
264
264
|
export function mapRating(currentSalesPrice?: number, predicted?: number): { rating: string; ratingLabel: string } {
|
|
265
265
|
const legacy = getPriceRating(currentSalesPrice as number, predicted as number); // 0..5
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
// 0 = noRating: keep neutral (tier 2) — never invent a flattering rating.
|
|
267
|
+
const tier: RatingTier = legacy === 0 ? 2 : LEGACY_TO_TIER[legacy] ?? 2;
|
|
268
268
|
return { rating: TIER_TONE[tier], ratingLabel: TIER_LABELS[tier] };
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
/**
|
|
272
272
|
* Map the 5-tier rating to a 2-tone signal — only 'top'/'good' read as a genuinely good deal
|
|
273
273
|
* (green); 'fair'/'raised'/'high' all get the warn/peach tone (Figma: "Erhöhter-Preis" is
|
|
274
|
-
* peach, not green).
|
|
275
|
-
*
|
|
276
|
-
* only picks their icon (check for a good deal, minus otherwise).
|
|
274
|
+
* peach, not green). Pure/non-React on purpose: shared by the web card's StatChip via
|
|
275
|
+
* cards/cardParts.tsx's re-export.
|
|
277
276
|
*/
|
|
278
|
-
export function ratingTone(rating: string): 'good' | 'warn'
|
|
279
|
-
if (rating === NO_RATING_KEY) return 'neutral';
|
|
277
|
+
export function ratingTone(rating: string): 'good' | 'warn' {
|
|
280
278
|
return rating === 'top' || rating === 'good' ? 'good' : 'warn';
|
|
281
279
|
}
|
|
282
280
|
|
package/locales/de/autobahn.json
CHANGED
|
@@ -95,7 +95,6 @@
|
|
|
95
95
|
"uvp": "UVP",
|
|
96
96
|
"priceRating": "Preisbewertung",
|
|
97
97
|
"priceRatingAria": "Preisbewertung: {{rating}}",
|
|
98
|
-
"priceRatingLink": "Preisbewertung: {{rating}} – zu Preis & Marktwert",
|
|
99
98
|
"detailsShow": "Details anzeigen",
|
|
100
99
|
"paymentLabel": "Zahlung",
|
|
101
100
|
"paymentValue": "Überweisung",
|
|
@@ -560,8 +559,7 @@
|
|
|
560
559
|
"good": "Guter Preis",
|
|
561
560
|
"fair": "Fairer-Preis",
|
|
562
561
|
"raised": "Erhöhter Preis",
|
|
563
|
-
"high": "Hoher Preis"
|
|
564
|
-
"none": "Keine Bewertung"
|
|
562
|
+
"high": "Hoher Preis"
|
|
565
563
|
},
|
|
566
564
|
"sort": {
|
|
567
565
|
"relevance": "Relevanz",
|
package/locales/en/autobahn.json
CHANGED
|
@@ -95,7 +95,6 @@
|
|
|
95
95
|
"uvp": "RRP",
|
|
96
96
|
"priceRating": "Price rating",
|
|
97
97
|
"priceRatingAria": "Price rating: {{rating}}",
|
|
98
|
-
"priceRatingLink": "Price rating: {{rating}} – go to price & market value",
|
|
99
98
|
"detailsShow": "Show details",
|
|
100
99
|
"paymentLabel": "Payment",
|
|
101
100
|
"paymentValue": "Bank transfer",
|
|
@@ -560,8 +559,7 @@
|
|
|
560
559
|
"good": "Good price",
|
|
561
560
|
"fair": "Fair price",
|
|
562
561
|
"raised": "Increased price",
|
|
563
|
-
"high": "High price"
|
|
564
|
-
"none": "No rating"
|
|
562
|
+
"high": "High price"
|
|
565
563
|
},
|
|
566
564
|
"sort": {
|
|
567
565
|
"relevance": "Relevance",
|