@bytebrand/fe-ui-core-autobahn 1.0.213 → 1.0.215
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 +8 -1
- package/cards/CarRow.tsx +28 -8
- package/cards/cardParts.tsx +47 -17
- package/compat/PriceRating/PriceRating.styl +5 -7
- package/compat/PriceRatingDetailed/PriceRatingDetailed.styl +8 -6
- package/compat/legacy-theme/priceReviewColors.styl +18 -5
- package/constants/autobahn.ts +39 -0
- package/data/fieldMapping.ts +3 -3
- package/data/toAutobahnCar.ts +14 -12
- package/locales/de/autobahn.json +3 -1
- package/locales/en/autobahn.json +3 -1
- package/package.json +1 -1
- package/theme/md3.css +109 -33
- package/ui/StatChip.tsx +8 -3
- package/ui/index.ts +1 -0
- package/ui/ratingLink.ts +36 -0
- package/vdp/FinanceCalculator.tsx +130 -27
- package/vdp/VdpModules.tsx +61 -49
package/cards/CarCard.tsx
CHANGED
|
@@ -99,6 +99,12 @@ export interface CarCardProps {
|
|
|
99
99
|
* (still onOpenRateAdjust).
|
|
100
100
|
*/
|
|
101
101
|
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;
|
|
102
108
|
/**
|
|
103
109
|
* Tab the price block opens on (default Finanzierung) — e.g. the SRP's leasing-only results
|
|
104
110
|
* open every card on Leasing. Ignored for a car without a lease rate (it has no Leasing tab).
|
|
@@ -119,6 +125,7 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
119
125
|
onCall,
|
|
120
126
|
onOpenRateAdjust,
|
|
121
127
|
onShowFinancingDetails,
|
|
128
|
+
onShowPriceRating,
|
|
122
129
|
initialMode,
|
|
123
130
|
}) => {
|
|
124
131
|
const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
|
|
@@ -303,7 +310,7 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
303
310
|
</div>
|
|
304
311
|
))}
|
|
305
312
|
</div>
|
|
306
|
-
<PriceEvalCol car={car} t={t} />
|
|
313
|
+
<PriceEvalCol car={car} t={t} onActivate={onShowPriceRating ? () => onShowPriceRating(car) : undefined} />
|
|
307
314
|
</div>
|
|
308
315
|
{/* same fallback CardCtaRow already uses below: pages that haven't wired a real
|
|
309
316
|
"Rate anpassen" sheet yet still get a working "Details" link (opens the car).
|
package/cards/CarRow.tsx
CHANGED
|
@@ -24,6 +24,7 @@ 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';
|
|
27
28
|
import {
|
|
28
29
|
EcoLine,
|
|
29
30
|
PriceMeter,
|
|
@@ -81,6 +82,8 @@ export interface CarRowProps {
|
|
|
81
82
|
* links render as plain text (see PricePaths' own fallback).
|
|
82
83
|
*/
|
|
83
84
|
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;
|
|
84
87
|
/** Tab the mobile price tabs open on — see CarCard's identically-named prop. */
|
|
85
88
|
initialMode?: PaymentMode;
|
|
86
89
|
}
|
|
@@ -95,11 +98,23 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
|
95
98
|
t,
|
|
96
99
|
adminAction,
|
|
97
100
|
onShowFinancingDetails,
|
|
101
|
+
onShowPriceRating,
|
|
98
102
|
initialMode,
|
|
99
103
|
}) => {
|
|
100
104
|
const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
|
|
101
105
|
const [photoIndex, setPhotoIndex] = useState(0);
|
|
102
106
|
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
|
+
};
|
|
103
118
|
// always call the LATEST onMediaEnter without re-arming the observer on every render (the
|
|
104
119
|
// page callers construct a fresh closure each render) — the effect itself only needs to run
|
|
105
120
|
// once per mount. Identical pattern to CarCard.tsx — see its own comment for the rationale.
|
|
@@ -279,13 +294,18 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
|
279
294
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 }}>
|
|
280
295
|
<PriceHero car={car} mode={mode} t={t} alwaysShowUnit />
|
|
281
296
|
{car.rating && (
|
|
282
|
-
<
|
|
283
|
-
{
|
|
284
|
-
|
|
285
|
-
|
|
297
|
+
<span {...ratingLink('rating-link')}>
|
|
298
|
+
<StatChip rating={car.rating} icon={ratingTone(car.rating) === 'good' ? 'check' : 'minus'}>
|
|
299
|
+
{t('autobahn:tier.' + car.rating)}
|
|
300
|
+
<sup>4</sup>
|
|
301
|
+
</StatChip>
|
|
302
|
+
</span>
|
|
286
303
|
)}
|
|
287
304
|
</div>
|
|
288
|
-
|
|
305
|
+
{/* the bar is clickable too, but not a second tab stop (the chip above is the link) */}
|
|
306
|
+
<div {...ratingLink('rating-link', true)}>
|
|
307
|
+
<PriceMeter t={t} car={car} />
|
|
308
|
+
</div>
|
|
289
309
|
<div className="pp-cta">
|
|
290
310
|
<Button
|
|
291
311
|
variant="filled"
|
|
@@ -324,11 +344,11 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
|
324
344
|
/>
|
|
325
345
|
<div className="pp-purchase hide-mobile">
|
|
326
346
|
<PriceKauf car={car} t={t} />
|
|
327
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
|
|
347
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }} {...ratingLink('rating-link')}>
|
|
328
348
|
{car.rating && (
|
|
329
|
-
<StatChip
|
|
349
|
+
<StatChip rating={car.rating} icon={ratingTone(car.rating) === 'good' ? 'check' : 'minus'}>
|
|
330
350
|
{t('autobahn:tier.' + car.rating)}
|
|
331
|
-
|
|
351
|
+
<sup>4</sup>
|
|
332
352
|
</StatChip>
|
|
333
353
|
)}
|
|
334
354
|
<div style={{ flex: 1 }}>
|
package/cards/cardParts.tsx
CHANGED
|
@@ -20,8 +20,9 @@ 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 } from '../vdp/FinanceCalculator';
|
|
24
|
-
import {
|
|
23
|
+
import { EvalBar, EvalPill } from '../vdp/FinanceCalculator';
|
|
24
|
+
import { ratingLinkProps } from '../ui/ratingLink';
|
|
25
|
+
import { CO2_CLASSES, CO2_COLORS, TIER_KEYS, TIER_COLORS, NO_RATING_KEY, ratingColorsOf } from '../constants';
|
|
25
26
|
import { AutobahnCar } from './types';
|
|
26
27
|
// pure, non-React — shared with the Meta AIA marketing-image renderer (a plain Node service).
|
|
27
28
|
export { ratingTone } from '../data/toAutobahnCar';
|
|
@@ -449,6 +450,8 @@ const TONE_TO_TIER: Record<string, number> = { top: 0, good: 1, fair: 2, raised:
|
|
|
449
450
|
* Renders nothing when there is no rating/band (needs-data: we never draw a fake market position).
|
|
450
451
|
*/
|
|
451
452
|
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} />;
|
|
452
455
|
const hasMarket =
|
|
453
456
|
car.marketLow != null && car.marketAvg != null && car.marketHigh != null && car.marketHigh > car.marketLow;
|
|
454
457
|
const bar = (tier: number) => {
|
|
@@ -460,7 +463,7 @@ export const PriceMeter: React.FunctionComponent<{ car: AutobahnCar; t: Translat
|
|
|
460
463
|
<span key={i} className="fin-eval-seg" style={{ background: c }} />
|
|
461
464
|
))}
|
|
462
465
|
<div
|
|
463
|
-
className=
|
|
466
|
+
className="fin-eval-thumb"
|
|
464
467
|
style={{ left: `${leftPct}%`, borderColor: TIER_COLORS[tierIndex] }}
|
|
465
468
|
/>
|
|
466
469
|
</div>
|
|
@@ -482,9 +485,38 @@ export const PriceMeter: React.FunctionComponent<{ car: AutobahnCar; t: Translat
|
|
|
482
485
|
* Preisbewertung pill + segmented tier bar, grouped in one column exactly like the VDP
|
|
483
486
|
* finance-calculator's mobile .fin-eval-col (FinanceCalculator.tsx/EvalBar) — the grid card's
|
|
484
487
|
* replacement for the old StatChip pill + full-width gradient .pp-bar pairing. Renders nothing
|
|
485
|
-
* without a rating (needs-data: never invent a tier).
|
|
488
|
+
* without a rating (needs-data: never invent a tier). With `onActivate` the pill + bar are one link
|
|
489
|
+
* (ratingLinkProps): the page opens the car's VDP at its "Preis & Marktwert" section.
|
|
486
490
|
*/
|
|
487
|
-
export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction
|
|
491
|
+
export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: TranslationFunction; onActivate?: () => void }> = ({
|
|
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
|
+
}
|
|
488
520
|
const tier = car.rating ? TONE_TO_TIER[car.rating] : undefined;
|
|
489
521
|
if (tier == null) return null;
|
|
490
522
|
const hasMarket =
|
|
@@ -497,20 +529,18 @@ export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: Transl
|
|
|
497
529
|
// each tier shows its own real label now (Top/Guter/Fairer/Erhöht/Hoher Preis) — no more
|
|
498
530
|
// collapsing 'good' onto the "Top-Preis" claim. Pill styling (colour/class/footnote) unchanged.
|
|
499
531
|
const tierLabel = t('autobahn:tier.' + car.rating);
|
|
500
|
-
//
|
|
501
|
-
|
|
502
|
-
const pillColor = isGood ? TIER_COLORS[0] : TIER_COLORS[tier];
|
|
532
|
+
// the tier's own badge colours (--rating-*), the same as on every other page
|
|
533
|
+
const pill = ratingColorsOf(car.rating);
|
|
503
534
|
return (
|
|
504
|
-
<div
|
|
535
|
+
<div {...linkProps(tierLabel)}>
|
|
505
536
|
<div className="fin-eval-pill-cell">
|
|
506
|
-
<
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
{tierLabel}
|
|
512
|
-
|
|
513
|
-
</span>
|
|
537
|
+
<EvalPill
|
|
538
|
+
label={tierLabel}
|
|
539
|
+
color={pill.color}
|
|
540
|
+
background={pill.background}
|
|
541
|
+
good={isGood}
|
|
542
|
+
ariaLabel={t('autobahn:finance.priceRatingAria', { rating: tierLabel })}
|
|
543
|
+
/>
|
|
514
544
|
</div>
|
|
515
545
|
<div className="fin-eval-bar-cell">
|
|
516
546
|
<EvalBar tier={tier} leftPct={leftPct} />
|
|
@@ -36,12 +36,10 @@
|
|
|
36
36
|
color: $priceReviewColors[darkBackground]
|
|
37
37
|
border: 2px solid $priceReviewColors[darkBackground]
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if $color == $priceReviewColors.noRating
|
|
42
|
-
$color = $priceReviewColors[darkBackground]
|
|
43
|
-
$backgroundColor = $priceReviewColors[colorName]
|
|
39
|
+
// label: the rating's text colour; segment: its scale colour
|
|
40
|
+
for colorName in $priceReviewTextColors
|
|
44
41
|
.{colorName}
|
|
45
|
-
color: $
|
|
42
|
+
color: $priceReviewTextColors[colorName]
|
|
43
|
+
for colorName in $priceReviewColors
|
|
46
44
|
.{colorName}Background
|
|
47
|
-
border: 2px solid $
|
|
45
|
+
border: 2px solid $priceReviewColors[colorName]
|
|
@@ -71,26 +71,28 @@
|
|
|
71
71
|
|
|
72
72
|
.noRatingTooltip
|
|
73
73
|
@extends .baseTooltip
|
|
74
|
-
color:
|
|
75
|
-
border-color:
|
|
74
|
+
color: $priceReviewTextColors[noRating]
|
|
75
|
+
border-color: #C8D1DE
|
|
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
|
|
81
82
|
for colorName in $priceReviewColors
|
|
82
83
|
$color = $priceReviewColors[colorName]
|
|
84
|
+
$textColor = $priceReviewTextColors[colorName] || $color
|
|
83
85
|
.{colorName}
|
|
84
86
|
&.segment
|
|
85
87
|
background-color $color
|
|
86
88
|
.tooltipWrapper
|
|
87
89
|
&:after
|
|
88
|
-
background-color: $
|
|
90
|
+
background-color: $textColor
|
|
89
91
|
.tooltip
|
|
90
|
-
border-color: $
|
|
91
|
-
color: $
|
|
92
|
+
border-color: $textColor
|
|
93
|
+
color: $textColor
|
|
92
94
|
&:after
|
|
93
|
-
background-color: $
|
|
95
|
+
background-color: $textColor
|
|
94
96
|
|
|
95
97
|
.compact
|
|
96
98
|
& .segment
|
|
@@ -1,12 +1,25 @@
|
|
|
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.
|
|
2
6
|
$priceReviewColors = {
|
|
3
7
|
noRating: rgba(76, 78, 100, 0.22)
|
|
4
8
|
darkBackground: rgba(76, 78, 100, 0.22)
|
|
5
|
-
highPrice:
|
|
6
|
-
increasedPrice:
|
|
7
|
-
fairPrice:
|
|
8
|
-
goodPrice:
|
|
9
|
-
topPrice:
|
|
9
|
+
highPrice: #E60000
|
|
10
|
+
increasedPrice: #F26B43
|
|
11
|
+
fairPrice: #F7C544
|
|
12
|
+
goodPrice: #66B84D
|
|
13
|
+
topPrice: #168A45
|
|
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
|
|
10
23
|
}
|
|
11
24
|
|
|
12
25
|
|
package/constants/autobahn.ts
CHANGED
|
@@ -22,10 +22,49 @@ 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 */
|
|
25
26
|
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'];
|
|
26
34
|
export const TIER_BACKGROUNDS: readonly string[] = ['#DFF3E5', '#E4F3DF', '#FFF6DB', '#FFEFD5', '#FFD3D3'];
|
|
27
35
|
export type RatingTier = 0 | 1 | 2 | 3 | 4;
|
|
28
36
|
|
|
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
|
+
|
|
29
68
|
/** SRP sort options (labels match the design; mapped to real sort params by the SRP container). */
|
|
30
69
|
export const SORTS = [
|
|
31
70
|
'Relevanz',
|
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, price more than 25% above the market value)→'none' (Keine Bewertung)",
|
|
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).
|
|
233
|
+
"REAL Preisbewertung. Card only special-cases tone==='fair' → warn pill; every other tone → good/green pill (CarCard.tsx:96-97). noRating is no tier: 'none', a grey Keine Bewertung pill without a marker (it used to be folded into 'fair'). 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', or NO_RATING_LABEL 'Keine Bewertung'",
|
|
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 } from '../constants/autobahn';
|
|
32
|
+
import { TIER_LABELS, RatingTier, CO2_CLASSES, Co2Class, NO_RATING_KEY, NO_RATING_LABEL } 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
|
|
241
|
+
* noRating(0) means the price is outside the bands (more than 25% above the market value). It is
|
|
242
|
+
* no tier: it maps to NO_RATING_KEY 'none' / NO_RATING_LABEL 'Keine Bewertung', a grey pill and
|
|
243
|
+
* the usual bar without a marker. It used to be folded into 'Fairer Preis', so a car priced 57%
|
|
244
|
+
* above the market showed "Fairer Preis".
|
|
244
245
|
*
|
|
245
|
-
* AutobahnCar.rating is a free string
|
|
246
|
-
*
|
|
247
|
-
* neutral 'fair' maps to the warn pill exactly like the design intends.
|
|
246
|
+
* AutobahnCar.rating is a free string: the autobahn tier key ('top'|'good'|'fair'|'raised'|'high')
|
|
247
|
+
* or 'none'. Callers only compute it for a real, positive price; without one it stays ''.
|
|
248
248
|
*/
|
|
249
249
|
const LEGACY_TO_TIER: Record<number, RatingTier> = {
|
|
250
250
|
5: 0, // topPrice → Top Preis
|
|
@@ -263,18 +263,20 @@ 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
|
+
const tier: RatingTier | undefined = LEGACY_TO_TIER[legacy];
|
|
267
|
+
if (tier == null) return { rating: NO_RATING_KEY, ratingLabel: NO_RATING_LABEL };
|
|
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). Pure/non-React on purpose
|
|
275
|
-
*
|
|
274
|
+
* peach, not green). "Keine Bewertung" is neither: 'neutral' (grey). Pure/non-React on purpose.
|
|
275
|
+
* The rating chips take their colours per tier now (StatChip's `rating`, the --rating-* palette); this
|
|
276
|
+
* only picks their icon (check for a good deal, minus otherwise).
|
|
276
277
|
*/
|
|
277
|
-
export function ratingTone(rating: string): 'good' | 'warn' {
|
|
278
|
+
export function ratingTone(rating: string): 'good' | 'warn' | 'neutral' {
|
|
279
|
+
if (rating === NO_RATING_KEY) return 'neutral';
|
|
278
280
|
return rating === 'top' || rating === 'good' ? 'good' : 'warn';
|
|
279
281
|
}
|
|
280
282
|
|
package/locales/de/autobahn.json
CHANGED
|
@@ -95,6 +95,7 @@
|
|
|
95
95
|
"uvp": "UVP",
|
|
96
96
|
"priceRating": "Preisbewertung",
|
|
97
97
|
"priceRatingAria": "Preisbewertung: {{rating}}",
|
|
98
|
+
"priceRatingLink": "Preisbewertung: {{rating}} – zu Preis & Marktwert",
|
|
98
99
|
"detailsShow": "Details anzeigen",
|
|
99
100
|
"paymentLabel": "Zahlung",
|
|
100
101
|
"paymentValue": "Überweisung",
|
|
@@ -560,7 +561,8 @@
|
|
|
560
561
|
"good": "Guter Preis",
|
|
561
562
|
"fair": "Fairer-Preis",
|
|
562
563
|
"raised": "Erhöhter Preis",
|
|
563
|
-
"high": "Hoher Preis"
|
|
564
|
+
"high": "Hoher Preis",
|
|
565
|
+
"none": "Keine Bewertung"
|
|
564
566
|
},
|
|
565
567
|
"sort": {
|
|
566
568
|
"relevance": "Relevanz",
|
package/locales/en/autobahn.json
CHANGED
|
@@ -95,6 +95,7 @@
|
|
|
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",
|
|
98
99
|
"detailsShow": "Show details",
|
|
99
100
|
"paymentLabel": "Payment",
|
|
100
101
|
"paymentValue": "Bank transfer",
|
|
@@ -560,7 +561,8 @@
|
|
|
560
561
|
"good": "Good price",
|
|
561
562
|
"fair": "Fair price",
|
|
562
563
|
"raised": "Increased price",
|
|
563
|
-
"high": "High price"
|
|
564
|
+
"high": "High price",
|
|
565
|
+
"none": "No rating"
|
|
564
566
|
},
|
|
565
567
|
"sort": {
|
|
566
568
|
"relevance": "Relevance",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebrand/fe-ui-core-autobahn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.215",
|
|
4
4
|
"description": "auto.de md3 (Autobahn) design system — UI primitives, cards, chrome, VDP modules, theme CSS and locales. Ships raw TypeScript source (like fe-ui-core before it); each consumer's bundler compiles it.",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"license": "UNLICENSED",
|
package/theme/md3.css
CHANGED
|
@@ -55,9 +55,31 @@
|
|
|
55
55
|
--md-secondary-container: #e7e9f1;
|
|
56
56
|
--md-on-secondary-container: #3a4150;
|
|
57
57
|
|
|
58
|
-
/* price-rating
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
/* price-rating badges, the same on every page (Figma 474sauvNgCYK2mEq5iks9e 142:3643 "Die
|
|
59
|
+
auto.de Bewertungskategorien"): text (fg) on background (bg) per tier, and the bar segment
|
|
60
|
+
colour (bar). constants/autobahn.ts holds the same values (TIER_TEXT_COLORS,
|
|
61
|
+
TIER_BACKGROUNDS, TIER_COLORS, NO_RATING_*) for the inline-styled pills; fe-main's
|
|
62
|
+
ratingPalette test keeps the two in step. */
|
|
63
|
+
--rating-top-fg: #168a45;
|
|
64
|
+
--rating-top-bg: #dff3e5;
|
|
65
|
+
--rating-top-bar: #168a45;
|
|
66
|
+
--rating-good-fg: #66b84d;
|
|
67
|
+
--rating-good-bg: #e4f3df;
|
|
68
|
+
--rating-good-bar: #66b84d;
|
|
69
|
+
--rating-fair-fg: #ffb800;
|
|
70
|
+
--rating-fair-bg: #fff6db;
|
|
71
|
+
--rating-fair-bar: #f7c544;
|
|
72
|
+
--rating-raised-fg: #f26b43;
|
|
73
|
+
--rating-raised-bg: #ffefd5;
|
|
74
|
+
--rating-raised-bar: #f26b43;
|
|
75
|
+
--rating-high-fg: #e60000;
|
|
76
|
+
--rating-high-bg: #ffd3d3;
|
|
77
|
+
--rating-high-bar: #e60000;
|
|
78
|
+
--rating-none-fg: #5b6b7f;
|
|
79
|
+
--rating-none-bg: #c8d1de;
|
|
80
|
+
|
|
81
|
+
/* deal accent (green) — generic "good" chips (e.g. the price-drop chip); the price-rating
|
|
82
|
+
badges use the --rating-* colours above. */
|
|
61
83
|
--md-good: #0f7b43;
|
|
62
84
|
--md-good-container: color-mix(in srgb, #168a45 16%, transparent);
|
|
63
85
|
--md-on-good-container: #168a45;
|
|
@@ -468,6 +490,32 @@ line-height: 31px;
|
|
|
468
490
|
background: var(--md-warn-container);
|
|
469
491
|
color: var(--md-on-warn-container);
|
|
470
492
|
}
|
|
493
|
+
/* "Keine Bewertung" as a plain tone */
|
|
494
|
+
.md3 .statchip--neutral {
|
|
495
|
+
color: var(--rating-none-fg);
|
|
496
|
+
background: var(--rating-none-bg);
|
|
497
|
+
}
|
|
498
|
+
/* the price-rating chip (StatChip `rating`, VDP header + search list row): each tier its own
|
|
499
|
+
badge colours, the same as every other rating badge (--rating-*). */
|
|
500
|
+
.md3 .statchip--rating-top { color: var(--rating-top-fg); background: var(--rating-top-bg); }
|
|
501
|
+
.md3 .statchip--rating-good { color: var(--rating-good-fg); background: var(--rating-good-bg); }
|
|
502
|
+
.md3 .statchip--rating-fair { color: var(--rating-fair-fg); background: var(--rating-fair-bg); }
|
|
503
|
+
.md3 .statchip--rating-raised { color: var(--rating-raised-fg); background: var(--rating-raised-bg); }
|
|
504
|
+
.md3 .statchip--rating-high { color: var(--rating-high-fg); background: var(--rating-high-bg); }
|
|
505
|
+
.md3 .statchip--rating-none { color: var(--rating-none-fg); background: var(--rating-none-bg); }
|
|
506
|
+
/* a price-rating badge (with its bar) that opens the car's "Preis & Marktwert" section
|
|
507
|
+
(ui/ratingLink.ts ratingLinkProps): pointer cursor, and a focus ring for the keyboard */
|
|
508
|
+
.md3 .rating-link {
|
|
509
|
+
cursor: pointer;
|
|
510
|
+
}
|
|
511
|
+
.md3 span.rating-link {
|
|
512
|
+
display: inline-flex;
|
|
513
|
+
}
|
|
514
|
+
.md3 .rating-link:focus-visible {
|
|
515
|
+
outline: 2px solid var(--md-primary);
|
|
516
|
+
outline-offset: 3px;
|
|
517
|
+
border-radius: 12px;
|
|
518
|
+
}
|
|
471
519
|
/* "4" footnote (VDP header's "Guter Preis" chip) — .statchip is a flex container like
|
|
472
520
|
.fin-eval-pill, so the same position:relative/top lift technique applies, just re-tuned for
|
|
473
521
|
this chip's smaller 12px text. */
|
|
@@ -511,15 +559,6 @@ line-height: 31px;
|
|
|
511
559
|
font-size: 9px;
|
|
512
560
|
line-height: 9px;
|
|
513
561
|
}
|
|
514
|
-
/* 'good' tone here is specifically the "Guter Preis" rating (same canonical green as the
|
|
515
|
-
fin-eval-pill "good" tier elsewhere on this page) — literal color, not the --md-good-container
|
|
516
|
-
token, matching that other pill's own literal-color treatment. --warn (Fairer Preis) is
|
|
517
|
-
untouched, still tokenized. */
|
|
518
|
-
.md3 .vdp-headrow .statchip--good,
|
|
519
|
-
.md3 .listcard-price .statchip--good {
|
|
520
|
-
color: rgb(22, 138, 69);
|
|
521
|
-
background: color-mix(in srgb, rgb(22, 138, 69) 16%, transparent);
|
|
522
|
-
}
|
|
523
562
|
|
|
524
563
|
/* small image label (views, photo count) */
|
|
525
564
|
.md3 .imglabel {
|
|
@@ -2078,10 +2117,10 @@ line-height: 31px;
|
|
|
2078
2117
|
gap: 8px;
|
|
2079
2118
|
flex: none;
|
|
2080
2119
|
align-items: stretch;
|
|
2081
|
-
/* Figma 64860-62117: fixed
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
width:
|
|
2120
|
+
/* Figma 64860-62117: fixed column so the pill and the bar (width:100%) span the same width
|
|
2121
|
+
instead of shrink-wrapping to whichever tier label happens to be widest. 108 (not the frame's
|
|
2122
|
+
106) since the pill is now 108×28 everywhere (EvalPill). */
|
|
2123
|
+
width: 108px;
|
|
2085
2124
|
}
|
|
2086
2125
|
@media (max-width: 600px) {
|
|
2087
2126
|
.md3 .cf-panel .fin-eval-col {
|
|
@@ -9120,7 +9159,7 @@ line-height: 31px;
|
|
|
9120
9159
|
.md3 .cc-price .fin-eval-col {
|
|
9121
9160
|
display: flex;
|
|
9122
9161
|
flex-direction: column;
|
|
9123
|
-
gap:
|
|
9162
|
+
gap: 13px; /* pill → bar, Figma */
|
|
9124
9163
|
width: 112px;
|
|
9125
9164
|
flex: none;
|
|
9126
9165
|
}
|
|
@@ -9128,8 +9167,8 @@ line-height: 31px;
|
|
|
9128
9167
|
.cc-price, incl. the VDP "Ähnliche Fahrzeuge" rail; .fin-calc-card; .fin-modal) — one shared
|
|
9129
9168
|
rule instead of three copies. `background`/`color` are deliberately NOT set here: they stay
|
|
9130
9169
|
driven by the tier-color inline style each render site sets (see PriceEvalCol in
|
|
9131
|
-
cardParts.tsx / FinanceCalculator.tsx / VdpModules.tsx,
|
|
9132
|
-
|
|
9170
|
+
cardParts.tsx / FinanceCalculator.tsx / VdpModules.tsx: evalPillOf, the --rating-* badge
|
|
9171
|
+
colours) — a `!important` used to hardcode this pill's
|
|
9133
9172
|
background to a fixed #dff3e5 here, silently overriding that inline value regardless of tier. */
|
|
9134
9173
|
.md3 .cc-price .fin-eval-pill,
|
|
9135
9174
|
.md3 .fin-calc-card .fin-eval-pill,
|
|
@@ -9165,9 +9204,9 @@ line-height: 31px;
|
|
|
9165
9204
|
line-height: 9px;
|
|
9166
9205
|
}
|
|
9167
9206
|
.md3 .cc-price .fin-eval-bar {
|
|
9168
|
-
/*
|
|
9169
|
-
|
|
9170
|
-
width:
|
|
9207
|
+
/* the full 112px .fin-eval-col, exactly as wide as the pill right above it (which fills the
|
|
9208
|
+
column too, .fin-eval-pill--fit) */
|
|
9209
|
+
width: 100%;
|
|
9171
9210
|
height: 7px;
|
|
9172
9211
|
}
|
|
9173
9212
|
.md3 .cc-price .fin-eval-seg:first-child {
|
|
@@ -9176,15 +9215,13 @@ line-height: 31px;
|
|
|
9176
9215
|
.md3 .cc-price .fin-eval-seg:last-of-type {
|
|
9177
9216
|
border-radius: 0 4px 4px 0;
|
|
9178
9217
|
}
|
|
9218
|
+
/* the ring takes its segment's colour (EvalBar's inline TIER_COLORS), Guter Preis included */
|
|
9179
9219
|
.md3 .cc-price .fin-eval-thumb {
|
|
9180
9220
|
width: 18px;
|
|
9181
9221
|
height: 18px;
|
|
9182
9222
|
border-width: 2px;
|
|
9183
9223
|
border-radius: 9px;
|
|
9184
9224
|
}
|
|
9185
|
-
.md3 .cc-price .fin-eval-thumb--good {
|
|
9186
|
-
border-color: #168a45 !important;
|
|
9187
|
-
}
|
|
9188
9225
|
/* financing/leasing terms line + "Finanzierungsdetails"/"Leasingdetails" link (PriceTerms in
|
|
9189
9226
|
cardParts.tsx), full-width under the price/rating row. Same quiet typography as .pp-hero-terms
|
|
9190
9227
|
(PricePaths); the link resets button chrome and reuses the primary color so it reads as tappable. */
|
|
@@ -9455,7 +9492,7 @@ line-height: 31px;
|
|
|
9455
9492
|
.md3 .fin-calc-card .fin-eval-col {
|
|
9456
9493
|
display: flex;
|
|
9457
9494
|
flex-direction: column;
|
|
9458
|
-
gap:
|
|
9495
|
+
gap: 13px; /* pill → bar, Figma */
|
|
9459
9496
|
grid-area: evalcol;
|
|
9460
9497
|
width: 112px;
|
|
9461
9498
|
justify-self: end;
|
|
@@ -9471,7 +9508,7 @@ line-height: 31px;
|
|
|
9471
9508
|
.md3 .fin-modal .fin-eval-col {
|
|
9472
9509
|
display: flex;
|
|
9473
9510
|
flex-direction: column;
|
|
9474
|
-
gap:
|
|
9511
|
+
gap: 13px; /* pill → bar, Figma */
|
|
9475
9512
|
grid-area: evalcol;
|
|
9476
9513
|
width: 112px;
|
|
9477
9514
|
justify-self: end;
|
|
@@ -9504,6 +9541,40 @@ line-height: 31px;
|
|
|
9504
9541
|
.md3 .fin-eval-pill .lucide {
|
|
9505
9542
|
flex: none;
|
|
9506
9543
|
}
|
|
9544
|
+
/* EvalPill (FinanceCalculator.tsx): the price-rating pill is always 108×28 whatever the rating
|
|
9545
|
+
(Figma "Guter-Preis⁴", 108 Fill × 28 Hug), in the offer card, the finance sheet, the car cards
|
|
9546
|
+
and the checkout. The label keeps 20px either side; EvalPill steps the font size down from this
|
|
9547
|
+
12px until a long label ("Keine Bewertung⁴", "Erhöhter Preis⁴") fits. Later in the file and as
|
|
9548
|
+
specific as the per-location .fin-eval-pill / --good rules above, so it wins over them. */
|
|
9549
|
+
/* "Fill": exactly as wide as the bar below it (PM 2026-11-20) — the column's width (112 in the offer
|
|
9550
|
+
card, the finance sheet and the car cards, 108 in the checkout), the pill-cell stretching to it */
|
|
9551
|
+
.md3 .fin-eval-pill-cell .fin-eval-pill--fit {
|
|
9552
|
+
flex: none;
|
|
9553
|
+
width: 100%;
|
|
9554
|
+
height: 28px;
|
|
9555
|
+
box-sizing: border-box;
|
|
9556
|
+
padding: 0 20px;
|
|
9557
|
+
display: flex;
|
|
9558
|
+
align-items: center;
|
|
9559
|
+
justify-content: center;
|
|
9560
|
+
gap: 0;
|
|
9561
|
+
border-radius: 16px;
|
|
9562
|
+
font-family: 'Arial', 'Arimo', sans-serif;
|
|
9563
|
+
font-weight: 700;
|
|
9564
|
+
font-size: 12px;
|
|
9565
|
+
line-height: 14px;
|
|
9566
|
+
white-space: nowrap;
|
|
9567
|
+
}
|
|
9568
|
+
/* the "4" scales with the fitted label: 9px at the full 12px, raised to the cap height */
|
|
9569
|
+
.md3 .fin-eval-pill-cell .fin-eval-pill--fit .fin-eval-pill-text sup {
|
|
9570
|
+
position: relative;
|
|
9571
|
+
top: -0.3em;
|
|
9572
|
+
left: 0;
|
|
9573
|
+
margin-left: 0.1em;
|
|
9574
|
+
font-size: 0.75em;
|
|
9575
|
+
line-height: 0;
|
|
9576
|
+
vertical-align: baseline;
|
|
9577
|
+
}
|
|
9507
9578
|
/* gradient spectrum bar + circle thumb — replaces opacity-segment design */
|
|
9508
9579
|
/* segmented evaluation bar (Figma round 12/13: discrete tier segments, CONTINUOUS —
|
|
9509
9580
|
no gaps; only the outer corners are rounded so the thumb can overflow) */
|
|
@@ -10075,6 +10146,14 @@ line-height: 31px;
|
|
|
10075
10146
|
padding: 4px 10px;
|
|
10076
10147
|
font-size: 11.5px;
|
|
10077
10148
|
}
|
|
10149
|
+
/* the "4" footnote, raised like on the offer card's pill (the pill is a flex container) */
|
|
10150
|
+
.md3 .bb-eval .fin-eval-pill sup {
|
|
10151
|
+
position: relative;
|
|
10152
|
+
top: -3px;
|
|
10153
|
+
left: -4px;
|
|
10154
|
+
font-size: 9px;
|
|
10155
|
+
line-height: 9px;
|
|
10156
|
+
}
|
|
10078
10157
|
.md3 .bb-cta-row {
|
|
10079
10158
|
display: flex;
|
|
10080
10159
|
gap: 3px;
|
|
@@ -12958,7 +13037,7 @@ color: #005CFF;
|
|
|
12958
13037
|
}
|
|
12959
13038
|
/* narrower rating column (figma bar is 115px) frees room for the bigger rate; let the
|
|
12960
13039
|
€ /mtl. suffix wrap under the number instead of pushing the grid wide on 4-digit rates.
|
|
12961
|
-
fin-eval-col becomes a real flex column here (pill above bar, fixed
|
|
13040
|
+
fin-eval-col becomes a real flex column here (pill above bar, fixed 13px gap — see the
|
|
12962
13041
|
shared .fin-eval-col rule below), spanning both grid rows on the right. */
|
|
12963
13042
|
.md3 .fin-price-grid {
|
|
12964
13043
|
grid-template-columns: minmax(0, 1fr) 112px;
|
|
@@ -12994,13 +13073,13 @@ color: #005CFF;
|
|
|
12994
13073
|
.md3 .fin-eval-col {
|
|
12995
13074
|
display: flex;
|
|
12996
13075
|
flex-direction: column;
|
|
12997
|
-
gap:
|
|
13076
|
+
gap: 13px; /* pill → bar, Figma */
|
|
12998
13077
|
grid-area: evalcol;
|
|
12999
13078
|
}
|
|
13000
13079
|
/* box sizing for this pill (all three of its locations) lives in the shared, higher-specificity
|
|
13001
13080
|
.cc-price/.fin-calc-card/.fin-modal rule near the top of this file — this generic, unscoped
|
|
13002
13081
|
copy used to ALSO force `background: #dff3e5 !important`, silently overriding every tier's
|
|
13003
|
-
real inline color
|
|
13082
|
+
real inline color at this breakpoint. */
|
|
13004
13083
|
.md3 .fin-eval-bar {
|
|
13005
13084
|
height: 7px;
|
|
13006
13085
|
}
|
|
@@ -13016,9 +13095,6 @@ color: #005CFF;
|
|
|
13016
13095
|
border-width: 2px;
|
|
13017
13096
|
border-radius: 9px;
|
|
13018
13097
|
}
|
|
13019
|
-
.md3 .fin-eval-thumb--good {
|
|
13020
|
-
border-color: #168a45 !important;
|
|
13021
|
-
}
|
|
13022
13098
|
.md3 .fin-cond {
|
|
13023
13099
|
font-family: Arial, Helvetica, Arimo, sans-serif;
|
|
13024
13100
|
font-style: normal;
|
package/ui/StatChip.tsx
CHANGED
|
@@ -2,17 +2,22 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import Icon from './Icon';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/** 'neutral' (grey) is for "Keine Bewertung", which is neither a good nor a warn rating. */
|
|
6
|
+
export type StatChipTone = 'good' | 'warn' | 'neutral';
|
|
6
7
|
|
|
7
8
|
export interface StatChipProps {
|
|
8
9
|
tone?: StatChipTone;
|
|
10
|
+
/** A price-rating chip: the mapRating() `rating` key ('top' … 'high', 'none'). It paints the chip
|
|
11
|
+
* in that tier's badge colours (md3.css .statchip--rating-<key>, the --rating-* palette)
|
|
12
|
+
* instead of the `tone`. */
|
|
13
|
+
rating?: string;
|
|
9
14
|
/** kebab-case lucide icon name rendered before the content. */
|
|
10
15
|
icon?: string;
|
|
11
16
|
children?: React.ReactNode;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
|
-
const StatChip: React.FunctionComponent<StatChipProps> = ({ tone = 'good', icon, children }) => (
|
|
15
|
-
<span className={`statchip statchip--${tone}`}>
|
|
19
|
+
const StatChip: React.FunctionComponent<StatChipProps> = ({ tone = 'good', rating, icon, children }) => (
|
|
20
|
+
<span className={rating ? `statchip statchip--rating statchip--rating-${rating}` : `statchip statchip--${tone}`}>
|
|
16
21
|
{icon && <Icon name={icon} size={14} />}
|
|
17
22
|
{children}
|
|
18
23
|
</span>
|
package/ui/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export type { ChipProps } from './Chip';
|
|
|
29
29
|
|
|
30
30
|
export { default as StatChip } from './StatChip';
|
|
31
31
|
export type { StatChipProps, StatChipTone } from './StatChip';
|
|
32
|
+
export { ratingLinkProps, PRICE_SECTION_ID, PRICE_SECTION_HASH } from './ratingLink';
|
|
32
33
|
|
|
33
34
|
export { default as CreditCostNotice, CREDIT_COST_WARNING_DE } from './CreditCostNotice';
|
|
34
35
|
export type { CreditCostNoticeProps, CreditCostNoticeTone, CreditCostNoticeSize } from './CreditCostNotice';
|
package/ui/ratingLink.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/** id of the VDP's "Preis & Marktwert" section (fe-main PriceMarket), where a price-rating
|
|
4
|
+
* badge leads; `PRICE_SECTION_HASH` is the URL fragment that opens a VDP scrolled to it. */
|
|
5
|
+
export const PRICE_SECTION_ID = 'vdp-preis';
|
|
6
|
+
export const PRICE_SECTION_HASH = '#' + PRICE_SECTION_ID;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props that make a price-rating badge (and the bar next to it) a link to the VDP's
|
|
10
|
+
* "Preis & Marktwert" section: a click, Enter or Space calls `onActivate`. The event is stopped,
|
|
11
|
+
* so the card the badge sits in does not also run its own "open the car" click. The element
|
|
12
|
+
* gets the class `rating-link` (md3.css: pointer cursor, focus ring) — spread these onto it and
|
|
13
|
+
* add that class.
|
|
14
|
+
*/
|
|
15
|
+
export function ratingLinkProps(onActivate: () => void, ariaLabel: string): {
|
|
16
|
+
role: 'link';
|
|
17
|
+
tabIndex: number;
|
|
18
|
+
'aria-label': string;
|
|
19
|
+
onClick: (e: React.MouseEvent) => void;
|
|
20
|
+
onKeyDown: (e: React.KeyboardEvent) => void;
|
|
21
|
+
} {
|
|
22
|
+
const activate = (e: React.SyntheticEvent): void => {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
e.stopPropagation();
|
|
25
|
+
onActivate();
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
role: 'link',
|
|
29
|
+
tabIndex: 0,
|
|
30
|
+
'aria-label': ariaLabel,
|
|
31
|
+
onClick: activate,
|
|
32
|
+
onKeyDown: (e: React.KeyboardEvent) => {
|
|
33
|
+
if (e.key === 'Enter' || e.key === ' ') activate(e);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -13,12 +13,13 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Renders correctly only inside a `<div className="md3">` subtree.
|
|
15
15
|
|
|
16
|
-
import React, { useState, useEffect } from 'react';
|
|
16
|
+
import React, { useState, useEffect, useLayoutEffect, useRef } from 'react';
|
|
17
17
|
import { TranslationFunction } from '../types';
|
|
18
18
|
|
|
19
19
|
import { Button, Icon, Switch, CreditCostNotice, CreditKeyFigures, hasCreditKeyFigures } from '../ui';
|
|
20
20
|
import type { CreditKeyFiguresData } from '../ui';
|
|
21
|
-
import {
|
|
21
|
+
import { ratingLinkProps } from '../ui/ratingLink';
|
|
22
|
+
import { TIER_KEYS, TIER_COLORS, TIER_TEXT_COLORS, TIER_BACKGROUNDS, NO_RATING_KEY, NO_RATING_COLOR, NO_RATING_BACKGROUND, evalTierOf } from '../constants';
|
|
22
23
|
|
|
23
24
|
/** Payment mode segment keys. Mirrors the design's ['fin','leasing','cash']. */
|
|
24
25
|
export type FinanceMode = 'fin' | 'leasing' | 'cash';
|
|
@@ -103,20 +104,119 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
103
104
|
/**
|
|
104
105
|
* Segmented price-evaluation bar (Figma: 5 discrete tier segments, NOT a gradient) with a
|
|
105
106
|
* white ring marker. `leftPct` overrides the marker position (the Marktwert gauge positions
|
|
106
|
-
* it continuously); default = centered on the tier segment.
|
|
107
|
+
* it continuously); default = centered on the tier segment. `tier` null = "Keine Bewertung":
|
|
108
|
+
* the usual colours but no marker, since the price has no place on the scale.
|
|
107
109
|
*/
|
|
108
|
-
export const EvalBar: React.FunctionComponent<{ tier: number; leftPct?: number }> = ({ tier, leftPct }) => (
|
|
109
|
-
<div className=
|
|
110
|
+
export const EvalBar: React.FunctionComponent<{ tier: number | null; leftPct?: number }> = ({ tier, leftPct }) => (
|
|
111
|
+
<div className={`fin-eval-bar${tier == null ? ' fin-eval-bar--none' : ''}`}>
|
|
110
112
|
{TIER_COLORS.map((c, i) => (
|
|
111
113
|
<span key={i} className="fin-eval-seg" style={{ background: c }} />
|
|
112
114
|
))}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
{tier != null && (
|
|
116
|
+
<div
|
|
117
|
+
className="fin-eval-thumb"
|
|
118
|
+
style={{ left: `${leftPct != null ? leftPct : (tier + 0.5) * 20}%`, borderColor: TIER_COLORS[Math.max(0, Math.min(4, tier))] }}
|
|
119
|
+
/>
|
|
120
|
+
)}
|
|
117
121
|
</div>
|
|
118
122
|
);
|
|
119
123
|
|
|
124
|
+
/** The price-rating pill's state for a mapRating() `ratingLabel`, shared by every pill + EvalBar
|
|
125
|
+
* pair: the tier (null = "Keine Bewertung"), its translated label and its badge colours (text
|
|
126
|
+
* `color` on `background`, TIER_TEXT_COLORS / TIER_BACKGROUNDS: each tier its own, the same on
|
|
127
|
+
* every page). Every pill carries the "4" footnote (the footer's Preisbewertung note), whatever
|
|
128
|
+
* the rating, as on fe-landing's cards. */
|
|
129
|
+
export function evalPillOf(ratingLabel: string | undefined, t: (key: string) => string): {
|
|
130
|
+
tier: number | null;
|
|
131
|
+
isGood: boolean;
|
|
132
|
+
label: string;
|
|
133
|
+
color: string;
|
|
134
|
+
background: string;
|
|
135
|
+
} {
|
|
136
|
+
const tier = evalTierOf(ratingLabel);
|
|
137
|
+
if (tier == null) {
|
|
138
|
+
return { tier, isGood: false, label: t('autobahn:tier.' + NO_RATING_KEY), color: NO_RATING_COLOR, background: NO_RATING_BACKGROUND };
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
tier,
|
|
142
|
+
isGood: TIER_KEYS[tier] === 'good',
|
|
143
|
+
label: t('autobahn:tier.' + TIER_KEYS[tier]),
|
|
144
|
+
color: TIER_TEXT_COLORS[tier],
|
|
145
|
+
background: TIER_BACKGROUNDS[tier],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** the smallest font size (px) the pill's label is fitted down to */
|
|
150
|
+
const EVAL_PILL_MIN_FONT = 7;
|
|
151
|
+
const useIsoLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The price-rating pill: always 108×28 whatever the rating (Figma "Guter-Preis⁴", 108 Fill × 28 Hug;
|
|
155
|
+
* md3.css .fin-eval-pill--fit), with the label and its "4" on one line between ~20px side paddings.
|
|
156
|
+
* A long label ("Keine Bewertung", "Erhöhter Preis", the English ones) steps the font size down
|
|
157
|
+
* from the CSS 12px until it fits, the way CreditKeyFigures fits its lines. It is fitted again when
|
|
158
|
+
* the label changes (language), when the pill first gets a width (a hidden tab or sheet), and once
|
|
159
|
+
* the fonts are ready (Arimo loads late where Arial is missing).
|
|
160
|
+
*/
|
|
161
|
+
export const EvalPill: React.FunctionComponent<{
|
|
162
|
+
label: string;
|
|
163
|
+
/** text colour and background: evalPillOf's (the tier's badge colours) */
|
|
164
|
+
color: string;
|
|
165
|
+
background?: string;
|
|
166
|
+
good?: boolean;
|
|
167
|
+
ariaLabel?: string;
|
|
168
|
+
}> = ({ label, color, background, good, ariaLabel }) => {
|
|
169
|
+
const ref = useRef<HTMLSpanElement>(null);
|
|
170
|
+
useIsoLayoutEffect(() => {
|
|
171
|
+
const el = ref.current;
|
|
172
|
+
if (!el || typeof window === 'undefined') return undefined;
|
|
173
|
+
const fit = (): void => {
|
|
174
|
+
el.style.fontSize = '';
|
|
175
|
+
const text = el.firstElementChild as HTMLElement | null;
|
|
176
|
+
if (!text || !el.clientWidth) return;
|
|
177
|
+
const style = window.getComputedStyle(el);
|
|
178
|
+
const room = el.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);
|
|
179
|
+
let size = parseFloat(style.fontSize) || 12;
|
|
180
|
+
for (let i = 0; i < 40 && size > EVAL_PILL_MIN_FONT && text.getBoundingClientRect().width > room + 0.5; i += 1) {
|
|
181
|
+
size = Math.max(EVAL_PILL_MIN_FONT, size - 0.25);
|
|
182
|
+
el.style.fontSize = `${size}px`;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
fit();
|
|
186
|
+
let alive = true;
|
|
187
|
+
const fonts = (document as any).fonts;
|
|
188
|
+
if (fonts && fonts.ready) fonts.ready.then(() => alive && fit());
|
|
189
|
+
const RO = (window as any).ResizeObserver;
|
|
190
|
+
let width = el.clientWidth;
|
|
191
|
+
const ro = RO
|
|
192
|
+
? new RO(() => {
|
|
193
|
+
if (el.clientWidth !== width) {
|
|
194
|
+
width = el.clientWidth;
|
|
195
|
+
fit();
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
: null;
|
|
199
|
+
if (ro) ro.observe(el);
|
|
200
|
+
return () => {
|
|
201
|
+
alive = false;
|
|
202
|
+
if (ro) ro.disconnect();
|
|
203
|
+
};
|
|
204
|
+
}, [label]);
|
|
205
|
+
return (
|
|
206
|
+
<span
|
|
207
|
+
ref={ref}
|
|
208
|
+
className={`fin-eval-pill fin-eval-pill--fit${good ? ' fin-eval-pill--good' : ''}`}
|
|
209
|
+
style={{ color, background: background || `color-mix(in srgb, ${color} 16%, transparent)` }}
|
|
210
|
+
aria-label={ariaLabel}
|
|
211
|
+
>
|
|
212
|
+
<span className="fin-eval-pill-text">
|
|
213
|
+
{label}
|
|
214
|
+
<sup>4</sup>
|
|
215
|
+
</span>
|
|
216
|
+
</span>
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
|
|
120
220
|
/** Figma CTA icon — document with a check-in-circle badge over its bottom-right corner
|
|
121
221
|
* (no single lucide glyph matches; composed from file-text + a knocked-out check-circle).
|
|
122
222
|
* The badge backdrop assumes a filled (primary) button. */
|
|
@@ -425,6 +525,9 @@ export interface FinanceCalculatorProps {
|
|
|
425
525
|
onCall?: () => void;
|
|
426
526
|
/** open the Finanzierungs-/Leasingdetails popup (full breakdown + legal, expanded). Omit to hide the link. */
|
|
427
527
|
onShowDetails?: () => void;
|
|
528
|
+
/** the price-rating badge + bar were clicked: the page scrolls to its "Preis & Marktwert"
|
|
529
|
+
* section (#vdp-preis). Omit and they are not a link. */
|
|
530
|
+
onShowPriceRating?: () => void;
|
|
428
531
|
/** mobile only: open the "Rate anpassen" / "Details anzeigen" sheet (collapsed/default view).
|
|
429
532
|
* Omit to hide the trigger row (falls back to the desktop inline expander). */
|
|
430
533
|
onOpenAdjust?: () => void;
|
|
@@ -530,6 +633,7 @@ const FinanceCalculator: React.FunctionComponent<FinanceCalculatorProps> = ({
|
|
|
530
633
|
secureLabel,
|
|
531
634
|
onCall,
|
|
532
635
|
onShowDetails,
|
|
636
|
+
onShowPriceRating,
|
|
533
637
|
onOpenAdjust,
|
|
534
638
|
onModeChange,
|
|
535
639
|
onDownChange,
|
|
@@ -545,14 +649,9 @@ const FinanceCalculator: React.FunctionComponent<FinanceCalculatorProps> = ({
|
|
|
545
649
|
const isLease = mode === 'leasing';
|
|
546
650
|
const terms = termOptions && termOptions.length ? termOptions : range(termMin, termMax, termStep);
|
|
547
651
|
const showStrike = listPrice != null && listPrice > price;
|
|
548
|
-
// price-evaluation
|
|
549
|
-
|
|
550
|
-
const evalTier
|
|
551
|
-
const isGoodTier = TIER_KEYS[evalTier] === 'good';
|
|
552
|
-
// each tier shows its own real label now (Top/Guter/Fairer/Erhöht/Hoher Preis) — no more
|
|
553
|
-
// collapsing 'good' onto the "Top-Preis" claim. Pill styling (colour/class/footnote) unchanged.
|
|
554
|
-
const evalTierLabel = t('autobahn:tier.' + TIER_KEYS[evalTier]);
|
|
555
|
-
const evalPillColor = isGoodTier ? TIER_COLORS[0] : TIER_COLORS[evalTier];
|
|
652
|
+
// price-evaluation pill + bar from the rating label: each tier its own label and colour,
|
|
653
|
+
// "Keine Bewertung" grey without a marker (an unknown label defaults to 'Guter Preis').
|
|
654
|
+
const { tier: evalTier, isGood: isGoodTier, label: evalTierLabel, color: evalPillColor, background: evalPillBackground } = evalPillOf(ratingLabel, t);
|
|
556
655
|
// condition summary (current selection) + its own details link — financing: "0 € Anzahlung ·
|
|
557
656
|
// 60 Monate · Finanzierungsdetails"; leasing: "25.000 € Sonderzahlung · 60 Mon. · 10.000
|
|
558
657
|
// km/Jahr · Details" (same wording/order as CarCard's own PriceTerms leaseTerms).
|
|
@@ -880,19 +979,23 @@ const FinanceCalculator: React.FunctionComponent<FinanceCalculatorProps> = ({
|
|
|
880
979
|
</div>
|
|
881
980
|
{/* col 2: pill + eval bar grouped together (display:contents on desktop — no-op,
|
|
882
981
|
preserves the original rate|pill / cond|bar auto-placement; mobile turns this into
|
|
883
|
-
a real flex column so the two stack tight with a fixed
|
|
884
|
-
<div
|
|
982
|
+
a real flex column so the two stack tight with a fixed 13px gap). */}
|
|
983
|
+
<div
|
|
984
|
+
className={ratingLabel && onShowPriceRating ? 'fin-eval-col rating-link' : 'fin-eval-col'}
|
|
985
|
+
{...(ratingLabel && onShowPriceRating
|
|
986
|
+
? ratingLinkProps(onShowPriceRating, t('autobahn:finance.priceRatingLink', { rating: evalTierLabel }))
|
|
987
|
+
: {})}
|
|
988
|
+
>
|
|
885
989
|
{/* col 2 row 1: price-rating pill (Figma: bold colored label, NO icon) */}
|
|
886
990
|
<div className="fin-eval-pill-cell">
|
|
887
991
|
{ratingLabel && (
|
|
888
|
-
<
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
{evalTierLabel}
|
|
894
|
-
|
|
895
|
-
</span>
|
|
992
|
+
<EvalPill
|
|
993
|
+
label={evalTierLabel}
|
|
994
|
+
color={evalPillColor}
|
|
995
|
+
background={evalPillBackground}
|
|
996
|
+
good={isGoodTier}
|
|
997
|
+
ariaLabel={t('autobahn:finance.priceRatingAria', { rating: evalTierLabel })}
|
|
998
|
+
/>
|
|
896
999
|
)}
|
|
897
1000
|
</div>
|
|
898
1001
|
{/* segmented evaluation bar (Figma: discrete tiers, not a gradient) */}
|
package/vdp/VdpModules.tsx
CHANGED
|
@@ -27,9 +27,11 @@ import { TranslationFunction } from '../types';
|
|
|
27
27
|
|
|
28
28
|
import { Button, CreditCostNotice, CreditKeyFigures, Dropdown, DropdownOption, hasCreditKeyFigures, Icon, Modal, Spec, StatChip, Stars } from '../ui';
|
|
29
29
|
import type { CreditKeyFiguresData } from '../ui';
|
|
30
|
-
import { CO2_CLASSES, CO2_COLORS
|
|
30
|
+
import { CO2_CLASSES, CO2_COLORS } from '../constants';
|
|
31
|
+
import { ratingTone } from '../data/toAutobahnCar';
|
|
32
|
+
import { ratingLinkProps } from '../ui/ratingLink';
|
|
31
33
|
import { defaultVdpSpecs, EquipmentGroups, VehicleDetail, VdpSpec, VdpReview, RatingPortal, RunningCostRow, EnergyTaxSummary } from './types';
|
|
32
|
-
import { AddServicesTooltipBody, CalcRow, DocCheckIcon, EvalBar, expanderBtnStyle, FinanceMode, Slider, TermChips, ToggleRow } from './FinanceCalculator';
|
|
34
|
+
import { AddServicesTooltipBody, CalcRow, DocCheckIcon, EvalBar, EvalPill, evalPillOf, expanderBtnStyle, FinanceMode, Slider, TermChips, ToggleRow } from './FinanceCalculator';
|
|
33
35
|
import { formatEur as eur, formatEurCents as eurCents, formatPct as pct } from '../utils/financeFormat';
|
|
34
36
|
|
|
35
37
|
/** mileage → 'X.XXX km' (de-DE grouping). */
|
|
@@ -59,6 +61,9 @@ function extractPS(s: string): string {
|
|
|
59
61
|
|
|
60
62
|
export interface VdpHeaderCardProps {
|
|
61
63
|
vehicle: VehicleDetail;
|
|
64
|
+
/** VdpHeaderSummary: the rating chip was clicked — the page scrolls to its "Preis & Marktwert"
|
|
65
|
+
* section (#vdp-preis). Omit and the chip is not a link. */
|
|
66
|
+
onShowPriceRating?: () => void;
|
|
62
67
|
/** i18n function (drilled from the page). */
|
|
63
68
|
t: TranslationFunction;
|
|
64
69
|
}
|
|
@@ -66,7 +71,7 @@ export interface VdpHeaderCardProps {
|
|
|
66
71
|
/** headline + trim/power + rating pill, then the dot-separated fact line — the vehicle's
|
|
67
72
|
* identity block. Split out so the mobile-only layout can show this BEFORE the finance
|
|
68
73
|
* card (see VdpTrustRow) while the highlights/condition tiles move after it. */
|
|
69
|
-
export const VdpHeaderSummary: React.FunctionComponent<VdpHeaderCardProps> = ({ vehicle, t }) => {
|
|
74
|
+
export const VdpHeaderSummary: React.FunctionComponent<VdpHeaderCardProps> = ({ vehicle, onShowPriceRating, t }) => {
|
|
70
75
|
// Order: Mileage, First Registration, Horsepower, Fuel Type, Gearbox, then owners last
|
|
71
76
|
// (unchanged position) — per request, desktop + mobile both use this order.
|
|
72
77
|
const factLine: ReadonlyArray<readonly [string, string]> = [
|
|
@@ -92,13 +97,23 @@ export const VdpHeaderSummary: React.FunctionComponent<VdpHeaderCardProps> = ({
|
|
|
92
97
|
{/* BL-08: no chip at all when there's no real rating (empty/broken price) — never a
|
|
93
98
|
fabricated "Top Preis"-shaped badge for `rating === ''`. */}
|
|
94
99
|
{vehicle.rating && (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
// the same chip as the SRP list row: each tier in its own badge colours (--rating-*),
|
|
101
|
+
// "Keine Bewertung" grey; check icon for a good deal (Top/Guter Preis); the "4" footnote on all.
|
|
102
|
+
// A link to the page's "Preis & Marktwert" section when the page passes onShowPriceRating.
|
|
103
|
+
<span
|
|
104
|
+
className={onShowPriceRating ? 'vdp-rating-chip rating-link' : 'vdp-rating-chip'}
|
|
105
|
+
{...(onShowPriceRating
|
|
106
|
+
? ratingLinkProps(onShowPriceRating, t('autobahn:finance.priceRatingLink', { rating: t('autobahn:tier.' + vehicle.rating) }))
|
|
107
|
+
: {})}
|
|
98
108
|
>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
109
|
+
<StatChip
|
|
110
|
+
rating={vehicle.rating}
|
|
111
|
+
icon={ratingTone(vehicle.rating) === 'good' ? 'check' : 'minus'}
|
|
112
|
+
>
|
|
113
|
+
{t('autobahn:tier.' + vehicle.rating)}
|
|
114
|
+
<sup>4</sup>
|
|
115
|
+
</StatChip>
|
|
116
|
+
</span>
|
|
102
117
|
)}
|
|
103
118
|
</div>
|
|
104
119
|
|
|
@@ -249,9 +264,9 @@ export const VdpHeaderCondition: React.FunctionComponent<VdpHeaderCardProps> = (
|
|
|
249
264
|
* is just the textual header card that sits beneath it. Desktop-only usage (mobile
|
|
250
265
|
* splits these 3 pieces across the "before/after finance card" layout — see the page).
|
|
251
266
|
*/
|
|
252
|
-
export const VdpHeaderCard: React.FunctionComponent<VdpHeaderCardProps> = ({ vehicle, t }) => (
|
|
267
|
+
export const VdpHeaderCard: React.FunctionComponent<VdpHeaderCardProps> = ({ vehicle, onShowPriceRating, t }) => (
|
|
253
268
|
<div className="mcard" style={{ marginTop: 16, padding: '18px 14px 18px' }}>
|
|
254
|
-
<VdpHeaderSummary vehicle={vehicle} t={t} />
|
|
269
|
+
<VdpHeaderSummary vehicle={vehicle} onShowPriceRating={onShowPriceRating} t={t} />
|
|
255
270
|
<div style={{ marginTop: 14 }}>
|
|
256
271
|
<VdpHeaderHighlights vehicle={vehicle} t={t} />
|
|
257
272
|
</div>
|
|
@@ -1094,6 +1109,9 @@ export interface VdpBottomBarProps {
|
|
|
1094
1109
|
leasingKeyFigures?: CreditKeyFiguresData;
|
|
1095
1110
|
/** opens the Finanzierungs-/Leasingdetails popup (expanded); when omitted the link is hidden. */
|
|
1096
1111
|
onShowDetails?: () => void;
|
|
1112
|
+
/** the price-rating badge + bar were clicked: the page scrolls to its "Preis & Marktwert"
|
|
1113
|
+
* section (#vdp-preis). Omit and they are not a link. */
|
|
1114
|
+
onShowPriceRating?: () => void;
|
|
1097
1115
|
/** whether leasing is actually offered for this car — see FinanceCalculatorProps.leasingAvailable
|
|
1098
1116
|
* for the full rationale. Default true keeps existing callers' behavior. */
|
|
1099
1117
|
leasingAvailable?: boolean;
|
|
@@ -1123,6 +1141,7 @@ export const VdpBottomBar: React.FunctionComponent<VdpBottomBarProps> = ({
|
|
|
1123
1141
|
creditKeyFigures,
|
|
1124
1142
|
leasingKeyFigures,
|
|
1125
1143
|
onShowDetails,
|
|
1144
|
+
onShowPriceRating,
|
|
1126
1145
|
leasingAvailable = true,
|
|
1127
1146
|
t,
|
|
1128
1147
|
}) => {
|
|
@@ -1137,14 +1156,9 @@ export const VdpBottomBar: React.FunctionComponent<VdpBottomBarProps> = ({
|
|
|
1137
1156
|
const tallBar =
|
|
1138
1157
|
!!(creditKeyFigures && hasCreditKeyFigures(creditKeyFigures)) || !!(leasingAvailable && leasingKeyFigures && hasCreditKeyFigures(leasingKeyFigures));
|
|
1139
1158
|
const rate = monthly != null ? monthly : vehicle.monthly;
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
const
|
|
1143
|
-
// each tier shows its own real label now (Top/Guter/Fairer/Erhöht/Hoher Preis) — no more
|
|
1144
|
-
// collapsing 'good' onto the "Top-Preis" claim. Pill styling (colour/bg/class/footnote) unchanged.
|
|
1145
|
-
const evalTierLabel = t('autobahn:tier.' + TIER_KEYS[evalTier]);
|
|
1146
|
-
const evalPillColor = isGoodTier ? TIER_COLORS[0] : TIER_COLORS[evalTier];
|
|
1147
|
-
const evalPillBackground = isGoodTier ? TIER_BACKGROUNDS[0] : TIER_BACKGROUNDS[evalTier];
|
|
1159
|
+
// each tier shows its own real label (Top/Guter/Fairer/Erhöht/Hoher Preis), "Keine Bewertung"
|
|
1160
|
+
// grey without a marker; same derivation as FinanceCalculator (evalPillOf).
|
|
1161
|
+
const { tier: evalTier, label: evalTierLabel, color: evalPillColor, background: evalPillBackground } = evalPillOf(ratingLabel, t);
|
|
1148
1162
|
// condition summary — same wording/order as FinanceCalculator's own .fin-cond (financing
|
|
1149
1163
|
// "0 € Anzahlung · 60 Monate", leasing "0 € Sonderzahlung · 36 Mon. · 10.000 km/Jahr").
|
|
1150
1164
|
const condParts: string[] = [];
|
|
@@ -1316,7 +1330,12 @@ export const VdpBottomBar: React.FunctionComponent<VdpBottomBarProps> = ({
|
|
|
1316
1330
|
</div>
|
|
1317
1331
|
</div>
|
|
1318
1332
|
{ratingLabel && (
|
|
1319
|
-
<div
|
|
1333
|
+
<div
|
|
1334
|
+
className={onShowPriceRating ? 'bb-eval rating-link' : 'bb-eval'}
|
|
1335
|
+
{...(onShowPriceRating
|
|
1336
|
+
? ratingLinkProps(onShowPriceRating, t('autobahn:finance.priceRatingLink', { rating: evalTierLabel }))
|
|
1337
|
+
: {})}
|
|
1338
|
+
>
|
|
1320
1339
|
<span
|
|
1321
1340
|
className="fin-eval-pill"
|
|
1322
1341
|
style={{
|
|
@@ -1339,7 +1358,7 @@ export const VdpBottomBar: React.FunctionComponent<VdpBottomBarProps> = ({
|
|
|
1339
1358
|
}}
|
|
1340
1359
|
>
|
|
1341
1360
|
{evalTierLabel}
|
|
1342
|
-
|
|
1361
|
+
<sup>4</sup>
|
|
1343
1362
|
</span>
|
|
1344
1363
|
<EvalBar tier={evalTier} />
|
|
1345
1364
|
</div>
|
|
@@ -1560,6 +1579,9 @@ export interface FinanceDetailsModalProps {
|
|
|
1560
1579
|
onTermChange?: (term: number) => void;
|
|
1561
1580
|
onAnnualMileageChange?: (km: number) => void;
|
|
1562
1581
|
onClose: () => void;
|
|
1582
|
+
/** the price-rating badge + bar were clicked: the page closes the modal and scrolls to its
|
|
1583
|
+
* "Preis & Marktwert" section (#vdp-preis). Omit and they are not a link. */
|
|
1584
|
+
onShowPriceRating?: () => void;
|
|
1563
1585
|
/** opened directly via the page's Finanzierungs-/Leasingdetails link — the sheet opens
|
|
1564
1586
|
* scrolled to the breakdown instead of the "Rate anpassen" controls at its top. */
|
|
1565
1587
|
initialShowBreakdown?: boolean;
|
|
@@ -1643,6 +1665,7 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
1643
1665
|
onTermChange,
|
|
1644
1666
|
onAnnualMileageChange,
|
|
1645
1667
|
onClose,
|
|
1668
|
+
onShowPriceRating,
|
|
1646
1669
|
initialShowBreakdown,
|
|
1647
1670
|
skipInitialScroll,
|
|
1648
1671
|
ratingLabel,
|
|
@@ -1844,18 +1867,9 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
1844
1867
|
: isLease
|
|
1845
1868
|
? t('autobahn:modal.sheetTitleLeasing')
|
|
1846
1869
|
: t('autobahn:modal.sheetTitleFinancing');
|
|
1847
|
-
// price-evaluation
|
|
1848
|
-
|
|
1849
|
-
const evalTier
|
|
1850
|
-
const evalTierLabel = t('autobahn:tier.' + TIER_KEYS[evalTier]);
|
|
1851
|
-
// 'good' ("Guter Preis") always paints with the TOP tier's brighter green (TIER_COLORS[0]),
|
|
1852
|
-
// not its own dimmer TIER_COLORS[1] — same rule FinanceCalculator's collapsed card already
|
|
1853
|
-
// applies (FinanceCalculator.tsx's evalPillColor). The two render blocks below (desktop +
|
|
1854
|
-
// mobile sheet) used TIER_COLORS[evalTier] directly, which for the 'good' tier painted this
|
|
1855
|
-
// modal's pill a visibly different, dimmer green than the same-labeled pill on the card that
|
|
1856
|
-
// opened it — same text, two colors.
|
|
1857
|
-
const isGoodTier = TIER_KEYS[evalTier] === 'good';
|
|
1858
|
-
const evalPillColor = isGoodTier ? TIER_COLORS[0] : TIER_COLORS[evalTier];
|
|
1870
|
+
// price-evaluation pill + bar — identical derivation to the collapsed card (FinanceCalculator's
|
|
1871
|
+
// evalPillOf), so the modal's pill has the same label and colour as the card that opened it.
|
|
1872
|
+
const { tier: evalTier, isGood: isGoodTier, label: evalTierLabel, color: evalPillColor, background: evalPillBackground } = evalPillOf(ratingLabel, t);
|
|
1859
1873
|
// adjustable only for fin/leasing, and only when the page supplies the change handlers + bounds.
|
|
1860
1874
|
const adjustable = mode !== 'cash' && !!onDownChange && downMin != null && downMax != null && termMin != null && termMax != null;
|
|
1861
1875
|
// discrete term chip values (supplied periods, else derived from the bounds).
|
|
@@ -2215,16 +2229,15 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2215
2229
|
)}
|
|
2216
2230
|
</div>
|
|
2217
2231
|
</div>
|
|
2218
|
-
<div
|
|
2232
|
+
<div
|
|
2233
|
+
className={ratingLabel && onShowPriceRating ? 'fin-eval-col rating-link' : 'fin-eval-col'}
|
|
2234
|
+
{...(ratingLabel && onShowPriceRating
|
|
2235
|
+
? ratingLinkProps(onShowPriceRating, t('autobahn:finance.priceRatingLink', { rating: evalTierLabel }))
|
|
2236
|
+
: {})}
|
|
2237
|
+
>
|
|
2219
2238
|
<div className="fin-eval-pill-cell">
|
|
2220
2239
|
{ratingLabel && (
|
|
2221
|
-
<
|
|
2222
|
-
className={`fin-eval-pill${isGoodTier ? ' fin-eval-pill--good' : ''}`}
|
|
2223
|
-
style={{ color: evalPillColor, background: `color-mix(in srgb, ${evalPillColor} 16%, transparent)` }}
|
|
2224
|
-
>
|
|
2225
|
-
{evalTierLabel}
|
|
2226
|
-
{isGoodTier && <sup>4</sup>}
|
|
2227
|
-
</span>
|
|
2240
|
+
<EvalPill label={evalTierLabel} color={evalPillColor} background={evalPillBackground} good={isGoodTier} />
|
|
2228
2241
|
)}
|
|
2229
2242
|
</div>
|
|
2230
2243
|
<div className="fin-eval-bar-cell">{ratingLabel && <EvalBar tier={evalTier} />}</div>
|
|
@@ -2752,16 +2765,15 @@ export const FinanceDetailsModal: React.FunctionComponent<FinanceDetailsModalPro
|
|
|
2752
2765
|
)}
|
|
2753
2766
|
</div>
|
|
2754
2767
|
</div>
|
|
2755
|
-
<div
|
|
2768
|
+
<div
|
|
2769
|
+
className={ratingLabel && onShowPriceRating ? 'fin-eval-col rating-link' : 'fin-eval-col'}
|
|
2770
|
+
{...(ratingLabel && onShowPriceRating
|
|
2771
|
+
? ratingLinkProps(onShowPriceRating, t('autobahn:finance.priceRatingLink', { rating: evalTierLabel }))
|
|
2772
|
+
: {})}
|
|
2773
|
+
>
|
|
2756
2774
|
<div className="fin-eval-pill-cell">
|
|
2757
2775
|
{ratingLabel && (
|
|
2758
|
-
<
|
|
2759
|
-
className={`fin-eval-pill${isGoodTier ? ' fin-eval-pill--good' : ''}`}
|
|
2760
|
-
style={{ color: evalPillColor, background: `color-mix(in srgb, ${evalPillColor} 16%, transparent)` }}
|
|
2761
|
-
>
|
|
2762
|
-
{evalTierLabel}
|
|
2763
|
-
{isGoodTier && <sup>4</sup>}
|
|
2764
|
-
</span>
|
|
2776
|
+
<EvalPill label={evalTierLabel} color={evalPillColor} background={evalPillBackground} good={isGoodTier} />
|
|
2765
2777
|
)}
|
|
2766
2778
|
</div>
|
|
2767
2779
|
<div className="fin-eval-bar-cell">{ratingLabel && <EvalBar tier={evalTier} />}</div>
|