@bytebrand/fe-ui-core-autobahn 1.0.226 → 1.0.228
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/campaign/CampaignBand.tsx +26 -0
- package/campaign/campaignVars.ts +12 -0
- package/campaign/campaigns.ts +74 -0
- package/campaign/index.ts +6 -0
- package/cards/CarCard.tsx +393 -366
- package/cards/CarRow.tsx +8 -28
- package/cards/cardParts.tsx +23 -48
- package/cards/dealSignals.ts +36 -0
- package/cards/index.ts +0 -6
- package/chrome/Footer.tsx +3 -16
- package/chrome/TopBar.tsx +266 -139
- package/compat/CookieModal/CookieModal.tsx +6 -20
- package/compat/CookieModal/Modal.tsx +3 -6
- package/compat/CookieModal/modals/ManageCookieModal/ManageCookieModal.tsx +15 -43
- package/compat/CookieModal/modals/PreviewCookieModal/PreviewCookieModal.tsx +3 -4
- package/compat/CookieModal/useModal.ts +1 -5
- package/compat/Loader/Loader.tsx +7 -1
- package/compat/MdField/MdField.tsx +4 -28
- package/compat/PriceRating/PriceRating.styl +7 -5
- package/compat/PriceRatingDetailed/PriceRatingDetailed.styl +6 -8
- package/compat/TimePicker/TimePicker.tsx +2 -12
- package/compat/legacy-theme/priceReviewColors.styl +5 -18
- package/constants/app.ts +11 -1
- package/constants/autobahn.ts +0 -39
- package/constants/core.ts +12 -1
- package/data/fieldMapping.ts +3 -3
- package/data/toAutobahnCar.ts +14 -30
- package/iconsvg/IconSVG.tsx +5 -1
- package/index.ts +19 -18
- package/locales/de/autobahn.json +862 -903
- package/locales/en/autobahn.json +862 -903
- package/package.json +2 -2
- package/theme/md3.css +11808 -15866
- package/ui/Dropdown.tsx +10 -29
- package/ui/FormCheckbox.tsx +2 -22
- package/ui/FormField.tsx +1 -2
- package/ui/Icon.tsx +0 -6
- package/ui/Modal.tsx +6 -84
- package/ui/Skeleton.tsx +20 -79
- package/ui/Stars.tsx +18 -36
- package/ui/StatChip.tsx +3 -8
- package/ui/index.ts +0 -3
- package/ui/usePortalMenuPosition.ts +15 -27
- package/utils/index.ts +0 -10
- package/vdp/FinanceCalculator.tsx +34 -162
- package/vdp/VdpModules.tsx +976 -348
- package/vdp/index.ts +3 -6
- package/vdp/types.ts +15 -25
- package/vehiclesProps/decoratedLightProps.tsx +0 -4
- package/vehiclesProps/decoratedProps.tsx +0 -4
- package/cards/CarCardSkeleton.tsx +0 -103
- package/cards/CarRowSkeleton.tsx +0 -152
- package/chrome/AccountMenuIcon.tsx +0 -109
- package/ui/MfieldCheckIcon.tsx +0 -13
- package/ui/ratingLink.ts +0 -36
- package/ui/scrollFieldIntoView.ts +0 -41
- package/utils/cookieConsent.ts +0 -84
- package/vehiclesProps/accidentDisclosure.ts +0 -25
|
@@ -45,11 +45,6 @@ export interface UsePortalMenuPositionArgs {
|
|
|
45
45
|
/** the trigger's wrapping element — always rendered (regardless of `open`), measured for position. */
|
|
46
46
|
rootRef: React.RefObject<HTMLElement>;
|
|
47
47
|
menuAlign?: 'left' | 'right';
|
|
48
|
-
/** 'auto' (default): flips ABOVE the trigger when there isn't room below (see ESTIMATED_MENU_HEIGHT
|
|
49
|
-
* below). 'down': always opens below, never flips — for a trigger where the caller knows the
|
|
50
|
-
* page has room below and an upward flip would overlap unrelated content above it (e.g. a
|
|
51
|
-
* trigger sitting right under a sticky/close heading). */
|
|
52
|
-
openDirection?: 'auto' | 'down';
|
|
53
48
|
/** called when the trigger scrolls out of view entirely, or a real user scroll happens after
|
|
54
49
|
* the post-open grace window — the menu has nothing sensible left to anchor to or chase. */
|
|
55
50
|
onCloseAway: () => void;
|
|
@@ -76,32 +71,14 @@ export interface UsePortalMenuPositionResult<TMenuEl extends HTMLElement = HTMLD
|
|
|
76
71
|
// reasonable estimate; it decides whether to flip ABOVE the trigger. The real size is then
|
|
77
72
|
// clamped to the space actually available (see `maxHeight` above), not just guessed at.
|
|
78
73
|
const ESTIMATED_MENU_HEIGHT = 300;
|
|
79
|
-
// .mselect-menu's own padding + border (6px*2 + 1px*2) — the consumers add it back on top of
|
|
80
|
-
// `maxHeight` for the box, so the space it fits into has to leave room for it.
|
|
81
|
-
const MENU_CHROME = 14;
|
|
82
74
|
// a scroll within this window of opening REPOSITIONS instead of closing — see the effect below.
|
|
83
75
|
const SELF_SCROLL_GRACE_MS = 500;
|
|
84
76
|
|
|
85
|
-
// Module-level (not hook-local) so Dropdown.tsx's own searchable-open scroll effect can reuse the
|
|
86
|
-
// exact same measurement — the sticky app header (.topbar, position:sticky/top:0) sits over the
|
|
87
|
-
// top of the viewport on every page that uses it (TopBar's autoHideOnScroll is opt-in, off by
|
|
88
|
-
// default — most pages keep it permanently docked), so anything that scrolls/positions content
|
|
89
|
-
// near the top of the viewport needs to stop at its live bottom edge, not y=0. Reading the
|
|
90
|
-
// header's live bottom edge (0 when absent, e.g. inside a modal, or when autoHideOnScroll has slid
|
|
91
|
-
// it away) gives a correct boundary without hardcoding a pixel height that could drift from the
|
|
92
|
-
// header's own CSS.
|
|
93
|
-
export const getSafeTop = (): number => {
|
|
94
|
-
if (typeof document === 'undefined') return 0;
|
|
95
|
-
const header = document.querySelector('.topbar');
|
|
96
|
-
return header ? Math.max(0, header.getBoundingClientRect().bottom) : 0;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
77
|
export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivElement>({
|
|
100
78
|
enabled,
|
|
101
79
|
open,
|
|
102
80
|
rootRef,
|
|
103
81
|
menuAlign = 'left',
|
|
104
|
-
openDirection = 'auto',
|
|
105
82
|
onCloseAway,
|
|
106
83
|
}: UsePortalMenuPositionArgs): UsePortalMenuPositionResult<TMenuEl> {
|
|
107
84
|
const menuElRef = React.useRef<TMenuEl | null>(null);
|
|
@@ -138,6 +115,18 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
138
115
|
};
|
|
139
116
|
}, [enabled, open, portalRoot]);
|
|
140
117
|
|
|
118
|
+
// the portal menu's z-index (1400, .mselect-menu--portal) is intentionally higher than every
|
|
119
|
+
// other fixed overlay it must paint over (checkout sheets/modals) — which also means it would
|
|
120
|
+
// paint over the sticky app header (.topbar, position:sticky/top:0/z-index:50) if left
|
|
121
|
+
// unconstrained. Reading the header's live bottom edge (0 when absent, e.g. inside a modal, or
|
|
122
|
+
// when TopBar's autoHideOnScroll has slid it away) gives a correct top boundary without
|
|
123
|
+
// hardcoding a pixel height that could drift from the header's own CSS.
|
|
124
|
+
const getSafeTop = (): number => {
|
|
125
|
+
if (typeof document === 'undefined') return 0;
|
|
126
|
+
const header = document.querySelector('.topbar');
|
|
127
|
+
return header ? Math.max(0, header.getBoundingClientRect().bottom) : 0;
|
|
128
|
+
};
|
|
129
|
+
|
|
141
130
|
const [menuPos, setMenuPos] = React.useState<PortalMenuPos | null>(null);
|
|
142
131
|
|
|
143
132
|
const positionMenu = React.useCallback(() => {
|
|
@@ -155,14 +144,13 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
155
144
|
}
|
|
156
145
|
const spaceBelow = window.innerHeight - rect.bottom - GAP;
|
|
157
146
|
const spaceAbove = rect.top - safeTop - GAP;
|
|
158
|
-
const openAbove =
|
|
147
|
+
const openAbove = spaceBelow < ESTIMATED_MENU_HEIGHT && spaceAbove > spaceBelow;
|
|
159
148
|
// cap the menu to the space it ACTUALLY has in whichever direction it opens, instead of
|
|
160
149
|
// trusting a static CSS max-height on its own — near the header or viewport edge that static
|
|
161
150
|
// cap can still be taller than what's really available, which is what let the menu paint over
|
|
162
151
|
// the header in the first place. The consumer's own overflow-y:auto takes it from there once
|
|
163
152
|
// content exceeds this.
|
|
164
|
-
|
|
165
|
-
const available = Math.max(120, Math.min(ESTIMATED_MENU_HEIGHT - 12, (openAbove ? spaceAbove : spaceBelow) - MENU_CHROME));
|
|
153
|
+
const available = Math.max(120, Math.min(ESTIMATED_MENU_HEIGHT - 12, openAbove ? spaceAbove : spaceBelow));
|
|
166
154
|
setMenuPos({
|
|
167
155
|
width: rect.width,
|
|
168
156
|
left: menuAlign === 'right' ? 'auto' : rect.left,
|
|
@@ -171,7 +159,7 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
171
159
|
bottom: openAbove ? window.innerHeight - rect.top + GAP : 'auto',
|
|
172
160
|
maxHeight: available,
|
|
173
161
|
});
|
|
174
|
-
}, [enabled, menuAlign,
|
|
162
|
+
}, [enabled, menuAlign, onCloseAway, rootRef]);
|
|
175
163
|
|
|
176
164
|
// Synchronous (pre-paint) position computation. useLayoutEffect — not useEffect — matters here:
|
|
177
165
|
// it runs right after the DOM mutation that mounted the portal but BEFORE the browser paints, so
|
package/utils/index.ts
CHANGED
|
@@ -62,14 +62,6 @@ export {
|
|
|
62
62
|
updateCookieList
|
|
63
63
|
} from './CommonUtils';
|
|
64
64
|
|
|
65
|
-
export {
|
|
66
|
-
COOKIE_CONSENT_CHANGE_EVENT,
|
|
67
|
-
getCookieConsentState,
|
|
68
|
-
openCookieSettings,
|
|
69
|
-
saveCookieConfig
|
|
70
|
-
} from './cookieConsent';
|
|
71
|
-
export type { CookieCategoryState, ICookieConsentState } from './cookieConsent';
|
|
72
|
-
|
|
73
65
|
export { getEquipment, getEquipmentCount } from '../vehiclesProps/equipment';
|
|
74
66
|
|
|
75
67
|
export type { IDecoratedProps, IEquipmentProps, ICarPropElement } from '../types/types';
|
|
@@ -91,5 +83,3 @@ export type { IValues, IFilters, IQuery } from './query';
|
|
|
91
83
|
// Decorated car props (renders React UI; lives in vehiclesProps/ with its
|
|
92
84
|
// IconContainer + Co2Widget dependencies under compat/).
|
|
93
85
|
export { default as getDecoratedProps } from '../vehiclesProps/decoratedProps';
|
|
94
|
-
export { setStrictConditionOwners, isStrictConditionOwner, strictAccidentStatus } from '../vehiclesProps/accidentDisclosure';
|
|
95
|
-
export type { AccidentStatus } from '../vehiclesProps/accidentDisclosure';
|
|
@@ -13,13 +13,12 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Renders correctly only inside a `<div className="md3">` subtree.
|
|
15
15
|
|
|
16
|
-
import React, { useState
|
|
16
|
+
import React, { useState } 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';
|
|
@@ -54,18 +53,8 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
54
53
|
bubble,
|
|
55
54
|
bubblePaddingBottom = 34,
|
|
56
55
|
}) => {
|
|
57
|
-
// Local mirror of `value`, updated INSTANTLY on every native input event. Callers commonly
|
|
58
|
-
// debounce their own onChange (e.g. CheckoutFinancePanelNext's 50ms setCommonUserConfig,
|
|
59
|
-
// which also triggers a MobX-driven re-render of a much bigger subtree) — without this, the
|
|
60
|
-
// thumb still drags natively/smoothly (the browser owns that), but the gradient fill and any
|
|
61
|
-
// bubble label are driven by the `value` PROP, which only catches up once the debounced commit
|
|
62
|
-
// finally lands, so the fill visibly lags/stutters behind the thumb during a fast drag. Synced
|
|
63
|
-
// back to the prop via useEffect for externally-driven changes (e.g. a reset button).
|
|
64
|
-
const [localValue, setLocalValue] = useState(value);
|
|
65
|
-
useEffect(() => { setLocalValue(value); }, [value]);
|
|
66
|
-
|
|
67
56
|
const span = max - min;
|
|
68
|
-
const pct = span > 0 ? ((
|
|
57
|
+
const pct = span > 0 ? ((value - min) / span) * 100 : 0;
|
|
69
58
|
return (
|
|
70
59
|
<div>
|
|
71
60
|
<div style={{ position: 'relative', paddingTop: bubble ? 44 : 0, paddingBottom: bubble ? bubblePaddingBottom : 0 }}>
|
|
@@ -73,7 +62,7 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
73
62
|
// thumb is 22px wide: interpolate the bubble anchor between half-thumb insets so it
|
|
74
63
|
// tracks the thumb center (a plain pct% drifts at the rail ends)
|
|
75
64
|
<span className="slider-bubble num" style={{ left: `calc(11px + (100% - 22px) * ${pct / 100})` }}>
|
|
76
|
-
{fmt(
|
|
65
|
+
{fmt(value)}
|
|
77
66
|
</span>
|
|
78
67
|
)}
|
|
79
68
|
<input
|
|
@@ -82,12 +71,8 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
82
71
|
min={min}
|
|
83
72
|
max={max}
|
|
84
73
|
step={step}
|
|
85
|
-
value={
|
|
86
|
-
onChange={(e) =>
|
|
87
|
-
const v = Number(e.target.value);
|
|
88
|
-
setLocalValue(v);
|
|
89
|
-
onChange(v);
|
|
90
|
-
}}
|
|
74
|
+
value={value}
|
|
75
|
+
onChange={(e) => onChange(Number(e.target.value))}
|
|
91
76
|
style={{ background: `linear-gradient(90deg, var(--md-primary) ${pct}%, var(--md-sc-highest) ${pct}%)` }}
|
|
92
77
|
/>
|
|
93
78
|
</div>
|
|
@@ -104,119 +89,20 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
104
89
|
/**
|
|
105
90
|
* Segmented price-evaluation bar (Figma: 5 discrete tier segments, NOT a gradient) with a
|
|
106
91
|
* 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.
|
|
92
|
+
* it continuously); default = centered on the tier segment.
|
|
109
93
|
*/
|
|
110
|
-
export const EvalBar: React.FunctionComponent<{ tier: number
|
|
111
|
-
<div className=
|
|
94
|
+
export const EvalBar: React.FunctionComponent<{ tier: number; leftPct?: number }> = ({ tier, leftPct }) => (
|
|
95
|
+
<div className="fin-eval-bar">
|
|
112
96
|
{TIER_COLORS.map((c, i) => (
|
|
113
97
|
<span key={i} className="fin-eval-seg" style={{ background: c }} />
|
|
114
98
|
))}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
/>
|
|
120
|
-
)}
|
|
99
|
+
<div
|
|
100
|
+
className={`fin-eval-thumb${TIER_KEYS[Math.max(0, Math.min(4, tier))] === 'good' ? ' fin-eval-thumb--good' : ''}`}
|
|
101
|
+
style={{ left: `${leftPct != null ? leftPct : (tier + 0.5) * 20}%`, borderColor: TIER_COLORS[Math.max(0, Math.min(4, tier))] }}
|
|
102
|
+
/>
|
|
121
103
|
</div>
|
|
122
104
|
);
|
|
123
105
|
|
|
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
106
|
/** Figma CTA icon — document with a check-in-circle badge over its bottom-right corner
|
|
221
107
|
* (no single lucide glyph matches; composed from file-text + a knocked-out check-circle).
|
|
222
108
|
* The badge backdrop assumes a filled (primary) button. */
|
|
@@ -525,9 +411,6 @@ export interface FinanceCalculatorProps {
|
|
|
525
411
|
onCall?: () => void;
|
|
526
412
|
/** open the Finanzierungs-/Leasingdetails popup (full breakdown + legal, expanded). Omit to hide the link. */
|
|
527
413
|
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
414
|
/** mobile only: open the "Rate anpassen" / "Details anzeigen" sheet (collapsed/default view).
|
|
532
415
|
* Omit to hide the trigger row (falls back to the desktop inline expander). */
|
|
533
416
|
onOpenAdjust?: () => void;
|
|
@@ -557,29 +440,18 @@ const range = (min: number, max: number, step: number): number[] => {
|
|
|
557
440
|
return out.length ? out : [min];
|
|
558
441
|
};
|
|
559
442
|
|
|
560
|
-
export interface DetailsLinkProps {
|
|
561
|
-
label: string;
|
|
562
|
-
onClick: () => void;
|
|
563
|
-
/** only the "ⓘ": the label becomes its name and tooltip (VdpStickyBar, ADV-438). */
|
|
564
|
-
iconOnly?: boolean;
|
|
565
|
-
tabIndex?: number;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
443
|
/** quiet primary-colored text link (Finanzierungsdetails / Details anzeigen). */
|
|
569
|
-
|
|
444
|
+
const DetailsLink: React.FunctionComponent<{ label: string; onClick: () => void }> = ({ label, onClick }) => (
|
|
570
445
|
<button
|
|
571
446
|
type="button"
|
|
572
447
|
onClick={onClick}
|
|
573
|
-
tabIndex={tabIndex}
|
|
574
|
-
{...(iconOnly ? { 'aria-label': label, title: label } : {})}
|
|
575
448
|
style={{
|
|
576
449
|
display: 'inline-flex',
|
|
577
450
|
alignItems: 'center',
|
|
578
451
|
gap: 5,
|
|
579
452
|
background: 'none',
|
|
580
453
|
border: 0,
|
|
581
|
-
|
|
582
|
-
...(iconOnly ? { padding: 5, margin: -5 } : { padding: 0 }),
|
|
454
|
+
padding: 0,
|
|
583
455
|
cursor: 'pointer',
|
|
584
456
|
color: 'var(--md-primary)',
|
|
585
457
|
font: 'inherit',
|
|
@@ -588,7 +460,7 @@ export const DetailsLink: React.FunctionComponent<DetailsLinkProps> = ({ label,
|
|
|
588
460
|
}}
|
|
589
461
|
>
|
|
590
462
|
<Icon name="info" size={15} color="var(--md-primary)" />
|
|
591
|
-
{
|
|
463
|
+
{label}
|
|
592
464
|
</button>
|
|
593
465
|
);
|
|
594
466
|
|
|
@@ -644,7 +516,6 @@ const FinanceCalculator: React.FunctionComponent<FinanceCalculatorProps> = ({
|
|
|
644
516
|
secureLabel,
|
|
645
517
|
onCall,
|
|
646
518
|
onShowDetails,
|
|
647
|
-
onShowPriceRating,
|
|
648
519
|
onOpenAdjust,
|
|
649
520
|
onModeChange,
|
|
650
521
|
onDownChange,
|
|
@@ -660,9 +531,14 @@ const FinanceCalculator: React.FunctionComponent<FinanceCalculatorProps> = ({
|
|
|
660
531
|
const isLease = mode === 'leasing';
|
|
661
532
|
const terms = termOptions && termOptions.length ? termOptions : range(termMin, termMax, termStep);
|
|
662
533
|
const showStrike = listPrice != null && listPrice > price;
|
|
663
|
-
// price-evaluation
|
|
664
|
-
|
|
665
|
-
const
|
|
534
|
+
// price-evaluation tier from the rating label (defaults to 'Guter Preis' tier when unmapped).
|
|
535
|
+
const tierIdx = TIER_LABELS.indexOf(ratingLabel as (typeof TIER_LABELS)[number]);
|
|
536
|
+
const evalTier = tierIdx >= 0 ? tierIdx : 1;
|
|
537
|
+
const isGoodTier = TIER_KEYS[evalTier] === 'good';
|
|
538
|
+
// each tier shows its own real label now (Top/Guter/Fairer/Erhöht/Hoher Preis) — no more
|
|
539
|
+
// collapsing 'good' onto the "Top-Preis" claim. Pill styling (colour/class/footnote) unchanged.
|
|
540
|
+
const evalTierLabel = t('autobahn:tier.' + TIER_KEYS[evalTier]);
|
|
541
|
+
const evalPillColor = isGoodTier ? TIER_COLORS[0] : TIER_COLORS[evalTier];
|
|
666
542
|
// condition summary (current selection) + its own details link — financing: "0 € Anzahlung ·
|
|
667
543
|
// 60 Monate · Finanzierungsdetails"; leasing: "25.000 € Sonderzahlung · 60 Mon. · 10.000
|
|
668
544
|
// km/Jahr · Details" (same wording/order as CarCard's own PriceTerms leaseTerms).
|
|
@@ -990,23 +866,19 @@ const FinanceCalculator: React.FunctionComponent<FinanceCalculatorProps> = ({
|
|
|
990
866
|
</div>
|
|
991
867
|
{/* col 2: pill + eval bar grouped together (display:contents on desktop — no-op,
|
|
992
868
|
preserves the original rate|pill / cond|bar auto-placement; mobile turns this into
|
|
993
|
-
a real flex column so the two stack tight with a fixed
|
|
994
|
-
<div
|
|
995
|
-
className={ratingLabel && onShowPriceRating ? 'fin-eval-col rating-link' : 'fin-eval-col'}
|
|
996
|
-
{...(ratingLabel && onShowPriceRating
|
|
997
|
-
? ratingLinkProps(onShowPriceRating, t('autobahn:finance.priceRatingLink', { rating: evalTierLabel }))
|
|
998
|
-
: {})}
|
|
999
|
-
>
|
|
869
|
+
a real flex column so the two stack tight with a fixed 16px gap). */}
|
|
870
|
+
<div className="fin-eval-col">
|
|
1000
871
|
{/* col 2 row 1: price-rating pill (Figma: bold colored label, NO icon) */}
|
|
1001
872
|
<div className="fin-eval-pill-cell">
|
|
1002
873
|
{ratingLabel && (
|
|
1003
|
-
<
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
874
|
+
<span
|
|
875
|
+
className={`fin-eval-pill${isGoodTier ? ' fin-eval-pill--good' : ''}`}
|
|
876
|
+
style={{ color: evalPillColor, background: `color-mix(in srgb, ${evalPillColor} 16%, transparent)` }}
|
|
877
|
+
aria-label={t('autobahn:finance.priceRatingAria', { rating: evalTierLabel })}
|
|
878
|
+
>
|
|
879
|
+
{evalTierLabel}
|
|
880
|
+
{isGoodTier && <sup>4</sup>}
|
|
881
|
+
</span>
|
|
1010
882
|
)}
|
|
1011
883
|
</div>
|
|
1012
884
|
{/* segmented evaluation bar (Figma: discrete tiers, not a gradient) */}
|