@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
|
@@ -13,13 +13,12 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Renders correctly only inside a `<div className="md3">` subtree.
|
|
15
15
|
|
|
16
|
-
import React, { useState, useEffect
|
|
16
|
+
import React, { useState, useEffect } 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 {
|
|
22
|
-
import { TIER_KEYS, TIER_COLORS, TIER_TEXT_COLORS, TIER_BACKGROUNDS, NO_RATING_KEY, NO_RATING_COLOR, NO_RATING_BACKGROUND, evalTierOf } from '../constants';
|
|
21
|
+
import { TIER_LABELS, TIER_KEYS, TIER_COLORS } from '../constants';
|
|
23
22
|
|
|
24
23
|
/** Payment mode segment keys. Mirrors the design's ['fin','leasing','cash']. */
|
|
25
24
|
export type FinanceMode = 'fin' | 'leasing' | 'cash';
|
|
@@ -104,119 +103,20 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
104
103
|
/**
|
|
105
104
|
* Segmented price-evaluation bar (Figma: 5 discrete tier segments, NOT a gradient) with a
|
|
106
105
|
* white ring marker. `leftPct` overrides the marker position (the Marktwert gauge positions
|
|
107
|
-
* it continuously); default = centered on the tier segment.
|
|
108
|
-
* the usual colours but no marker, since the price has no place on the scale.
|
|
106
|
+
* it continuously); default = centered on the tier segment.
|
|
109
107
|
*/
|
|
110
|
-
export const EvalBar: React.FunctionComponent<{ tier: number
|
|
111
|
-
<div className=
|
|
108
|
+
export const EvalBar: React.FunctionComponent<{ tier: number; leftPct?: number }> = ({ tier, leftPct }) => (
|
|
109
|
+
<div className="fin-eval-bar">
|
|
112
110
|
{TIER_COLORS.map((c, i) => (
|
|
113
111
|
<span key={i} className="fin-eval-seg" style={{ background: c }} />
|
|
114
112
|
))}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
/>
|
|
120
|
-
)}
|
|
113
|
+
<div
|
|
114
|
+
className={`fin-eval-thumb${TIER_KEYS[Math.max(0, Math.min(4, tier))] === 'good' ? ' fin-eval-thumb--good' : ''}`}
|
|
115
|
+
style={{ left: `${leftPct != null ? leftPct : (tier + 0.5) * 20}%`, borderColor: TIER_COLORS[Math.max(0, Math.min(4, tier))] }}
|
|
116
|
+
/>
|
|
121
117
|
</div>
|
|
122
118
|
);
|
|
123
119
|
|
|
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
|
-
|
|
220
120
|
/** Figma CTA icon — document with a check-in-circle badge over its bottom-right corner
|
|
221
121
|
* (no single lucide glyph matches; composed from file-text + a knocked-out check-circle).
|
|
222
122
|
* The badge backdrop assumes a filled (primary) button. */
|
|
@@ -525,9 +425,6 @@ export interface FinanceCalculatorProps {
|
|
|
525
425
|
onCall?: () => void;
|
|
526
426
|
/** open the Finanzierungs-/Leasingdetails popup (full breakdown + legal, expanded). Omit to hide the link. */
|
|
527
427
|
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;
|
|
531
428
|
/** mobile only: open the "Rate anpassen" / "Details anzeigen" sheet (collapsed/default view).
|
|
532
429
|
* Omit to hide the trigger row (falls back to the desktop inline expander). */
|
|
533
430
|
onOpenAdjust?: () => void;
|
|
@@ -633,7 +530,6 @@ const FinanceCalculator: React.FunctionComponent<FinanceCalculatorProps> = ({
|
|
|
633
530
|
secureLabel,
|
|
634
531
|
onCall,
|
|
635
532
|
onShowDetails,
|
|
636
|
-
onShowPriceRating,
|
|
637
533
|
onOpenAdjust,
|
|
638
534
|
onModeChange,
|
|
639
535
|
onDownChange,
|
|
@@ -649,9 +545,14 @@ const FinanceCalculator: React.FunctionComponent<FinanceCalculatorProps> = ({
|
|
|
649
545
|
const isLease = mode === 'leasing';
|
|
650
546
|
const terms = termOptions && termOptions.length ? termOptions : range(termMin, termMax, termStep);
|
|
651
547
|
const showStrike = listPrice != null && listPrice > price;
|
|
652
|
-
// price-evaluation
|
|
653
|
-
|
|
654
|
-
const
|
|
548
|
+
// price-evaluation tier from the rating label (defaults to 'Guter Preis' tier when unmapped).
|
|
549
|
+
const tierIdx = TIER_LABELS.indexOf(ratingLabel as (typeof TIER_LABELS)[number]);
|
|
550
|
+
const evalTier = tierIdx >= 0 ? tierIdx : 1;
|
|
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];
|
|
655
556
|
// condition summary (current selection) + its own details link — financing: "0 € Anzahlung ·
|
|
656
557
|
// 60 Monate · Finanzierungsdetails"; leasing: "25.000 € Sonderzahlung · 60 Mon. · 10.000
|
|
657
558
|
// km/Jahr · Details" (same wording/order as CarCard's own PriceTerms leaseTerms).
|
|
@@ -979,23 +880,19 @@ const FinanceCalculator: React.FunctionComponent<FinanceCalculatorProps> = ({
|
|
|
979
880
|
</div>
|
|
980
881
|
{/* col 2: pill + eval bar grouped together (display:contents on desktop — no-op,
|
|
981
882
|
preserves the original rate|pill / cond|bar auto-placement; mobile turns this into
|
|
982
|
-
a real flex column so the two stack tight with a fixed
|
|
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
|
-
>
|
|
883
|
+
a real flex column so the two stack tight with a fixed 16px gap). */}
|
|
884
|
+
<div className="fin-eval-col">
|
|
989
885
|
{/* col 2 row 1: price-rating pill (Figma: bold colored label, NO icon) */}
|
|
990
886
|
<div className="fin-eval-pill-cell">
|
|
991
887
|
{ratingLabel && (
|
|
992
|
-
<
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
888
|
+
<span
|
|
889
|
+
className={`fin-eval-pill${isGoodTier ? ' fin-eval-pill--good' : ''}`}
|
|
890
|
+
style={{ color: evalPillColor, background: `color-mix(in srgb, ${evalPillColor} 16%, transparent)` }}
|
|
891
|
+
aria-label={t('autobahn:finance.priceRatingAria', { rating: evalTierLabel })}
|
|
892
|
+
>
|
|
893
|
+
{evalTierLabel}
|
|
894
|
+
{isGoodTier && <sup>4</sup>}
|
|
895
|
+
</span>
|
|
999
896
|
)}
|
|
1000
897
|
</div>
|
|
1001
898
|
{/* segmented evaluation bar (Figma: discrete tiers, not a gradient) */}
|