@bytebrand/fe-ui-core-autobahn 1.0.223 → 1.0.225

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.
@@ -0,0 +1,26 @@
1
+ // Autobahn (auto.de redesign) — the campaign band on top of a car card or the vehicle page's gallery
2
+ // (see campaigns.ts).
3
+ //
4
+ // Looks only: the colours come from the campaign as CSS variables, the size and the type from md3.css
5
+ // (.campaign-band). Renders correctly only inside a `<div className="md3">` subtree.
6
+
7
+ import React from 'react';
8
+ import { TranslationFunction } from '../types';
9
+
10
+ import { Icon } from '../ui';
11
+ import { Campaign } from './campaigns';
12
+ import { campaignVars } from './campaignVars';
13
+
14
+ export interface CampaignBandProps {
15
+ campaign: Campaign;
16
+ t: TranslationFunction;
17
+ }
18
+
19
+ const CampaignBand: React.FunctionComponent<CampaignBandProps> = ({ campaign, t }) => (
20
+ <div className={'campaign-band campaign-band--' + campaign.id} style={campaignVars(campaign)}>
21
+ {campaign.icon && <Icon name={campaign.icon} size={15} stroke={2.2} />}
22
+ <span className="campaign-band-label">{t(campaign.texts + '.label')}</span>
23
+ </div>
24
+ );
25
+
26
+ export default CampaignBand;
@@ -0,0 +1,86 @@
1
+ // Autobahn (auto.de redesign) — the campaign's banner: headline and link on the left, cut-out cars on a wedge in
2
+ // the campaign's colour on the right; the car in front reaches over the upper edge. Used on fe-main's home page.
3
+ //
4
+ // Texts, colours and dates come from the campaign, the cars from the page, the look from md3.css
5
+ // (.campaign-banner). Nothing is shown before the campaign starts and after it has ended. Renders correctly only
6
+ // inside a `<div className="md3">` subtree.
7
+
8
+ import React, { useEffect, useRef, useState } from 'react';
9
+ import { TranslationFunction } from '../types';
10
+
11
+ import { Icon } from '../ui';
12
+ import { Campaign, campaignPeriod, isCampaignRunning } from './campaigns';
13
+ import { campaignVars } from './campaignVars';
14
+ import { openInApp } from './openInApp';
15
+ import { useCountdown } from './useCountdown';
16
+
17
+ export interface CampaignBannerProps {
18
+ campaign: Campaign;
19
+ /** pictures of cars with a transparent background; the first one stands in front. */
20
+ cars: string[];
21
+ /** where the offers are; a real link (new tab, crawlers). */
22
+ href: string;
23
+ /** plain click: the app opens href itself, without loading the page anew. */
24
+ onOpen: () => void;
25
+ t: TranslationFunction;
26
+ }
27
+
28
+ /** true once a part of the element has been on screen (at once without IntersectionObserver). */
29
+ const useSeen = (ref: React.RefObject<HTMLElement | null>): boolean => {
30
+ const [seen, setSeen] = useState(false);
31
+ useEffect(() => {
32
+ const el = ref.current;
33
+ if (!el || typeof IntersectionObserver === 'undefined') {
34
+ setSeen(true);
35
+ return undefined;
36
+ }
37
+ const observer = new IntersectionObserver((entries) => {
38
+ if (!entries.some((entry) => entry.isIntersecting)) return;
39
+ setSeen(true);
40
+ observer.disconnect();
41
+ }, { threshold: 0.3 });
42
+ observer.observe(el);
43
+ return () => observer.disconnect();
44
+ }, [ref]);
45
+ return seen;
46
+ };
47
+
48
+ const CampaignBanner: React.FunctionComponent<CampaignBannerProps> = ({ campaign, cars, href, onOpen, t }) => {
49
+ const ref = useRef<HTMLAnchorElement>(null);
50
+ const seen = useSeen(ref);
51
+ const left = useCountdown(campaign.endsAt);
52
+ if (!left || !isCampaignRunning(campaign)) return null;
53
+ return (
54
+ <a
55
+ ref={ref}
56
+ className={'campaign-banner campaign-banner--' + campaign.id + (seen ? ' campaign-banner--in' : '')}
57
+ style={campaignVars(campaign)}
58
+ href={href}
59
+ onClick={openInApp(onOpen)}
60
+ >
61
+ <span className="campaign-banner-cars" aria-hidden="true">
62
+ {cars.map((src, i) => (
63
+ <img key={src} className={'campaign-banner-car campaign-banner-car--' + (i + 1)} src={src} alt="" decoding="async" />
64
+ ))}
65
+ <span className="campaign-banner-note">{t('autobahn:campaign.exampleCars')}</span>
66
+ </span>
67
+ <span className="campaign-banner-body">
68
+ <span className="campaign-banner-period">{t(campaign.texts + '.period', { ...campaignPeriod(campaign) })}</span>
69
+ <strong className="campaign-banner-title">{t(campaign.texts + '.bannerTitle')}</strong>
70
+ <span className="campaign-banner-text">{t(campaign.texts + '.text')}</span>
71
+ <span className="campaign-banner-foot">
72
+ <span className="campaign-banner-cta">
73
+ {t(campaign.texts + '.cta')}
74
+ <Icon name="arrow-right" size={18} stroke={2.2} />
75
+ </span>
76
+ <span className="campaign-banner-ends">
77
+ <Icon name="clock" size={16} stroke={2} />
78
+ {t(left.days ? 'autobahn:campaign.endsInDays' : 'autobahn:campaign.endsInHours', { ...left })}
79
+ </span>
80
+ </span>
81
+ </span>
82
+ </a>
83
+ );
84
+ };
85
+
86
+ export default CampaignBanner;
@@ -0,0 +1,37 @@
1
+ // Autobahn (auto.de redesign) — the campaign's bar right under the site header, one link to its offers
2
+ // (see campaigns.ts). Used on fe-main's home page.
3
+ //
4
+ // Texts, colours and dates come from the campaign, the look from md3.css (.campaign-bar). Nothing is shown before
5
+ // the campaign starts and after it has ended. Renders correctly only inside a `<div className="md3">` subtree.
6
+
7
+ import React from 'react';
8
+ import { TranslationFunction } from '../types';
9
+
10
+ import { Icon } from '../ui';
11
+ import { Campaign, isCampaignRunning } from './campaigns';
12
+ import { campaignVars } from './campaignVars';
13
+ import { openInApp } from './openInApp';
14
+ import { useCountdown } from './useCountdown';
15
+
16
+ export interface CampaignBarProps {
17
+ campaign: Campaign;
18
+ /** where the offers are; a real link (new tab, crawlers). */
19
+ href: string;
20
+ /** plain click: the app opens href itself, without loading the page anew. */
21
+ onOpen: () => void;
22
+ t: TranslationFunction;
23
+ }
24
+
25
+ const CampaignBar: React.FunctionComponent<CampaignBarProps> = ({ campaign, href, onOpen, t }) => {
26
+ const left = useCountdown(campaign.endsAt); // the bar goes by itself when the campaign ends
27
+ if (!left || !isCampaignRunning(campaign)) return null;
28
+ return (
29
+ <a className={'campaign-bar campaign-bar--' + campaign.id} style={campaignVars(campaign)} href={href} onClick={openInApp(onOpen)}>
30
+ {campaign.icon && <Icon name={campaign.icon} size={16} stroke={2.2} />}
31
+ <span className="campaign-bar-label">{t(campaign.texts + '.label')}:</span>
32
+ <span className="campaign-bar-offer">{t(campaign.texts + '.offer')}</span>
33
+ </a>
34
+ );
35
+ };
36
+
37
+ export default CampaignBar;
@@ -0,0 +1,50 @@
1
+ // Autobahn (auto.de redesign) — the campaign hero: period, headline and a running countdown to the end of the
2
+ // campaign (design "auto.de SRL Black Friday", A · Dark Edition). Used on fe-main's /search.
3
+ //
4
+ // Texts and dates come from the campaign (campaigns.ts), the look from md3.css (.campaign-hero). Nothing is
5
+ // shown before the campaign starts and after it has ended. Renders correctly only inside a
6
+ // `<div className="md3">` subtree.
7
+
8
+ import React from 'react';
9
+ import { TranslationFunction } from '../types';
10
+
11
+ import { Campaign, campaignPeriod, isCampaignRunning } from './campaigns';
12
+ import { campaignVars } from './campaignVars';
13
+ import { useCountdown } from './useCountdown';
14
+
15
+ export interface CampaignHeroProps {
16
+ campaign: Campaign;
17
+ t: TranslationFunction;
18
+ }
19
+
20
+ const twoDigits = (n: number): string => (n < 10 ? '0' + n : String(n));
21
+
22
+ const CampaignHero: React.FunctionComponent<CampaignHeroProps> = ({ campaign, t }) => {
23
+ const left = useCountdown(campaign.endsAt);
24
+ if (!left || !isCampaignRunning(campaign)) return null;
25
+ const units: Array<[string, number]> = [['days', left.days], ['hours', left.hours], ['minutes', left.minutes]];
26
+ return (
27
+ <section
28
+ className={'campaign-hero campaign-hero--' + campaign.id}
29
+ style={campaignVars(campaign)}
30
+ aria-label={t(campaign.texts + '.label')}
31
+ >
32
+ <div>
33
+ <div className="campaign-hero-period">{t(campaign.texts + '.period', { ...campaignPeriod(campaign) })}</div>
34
+ <h2 className="campaign-hero-title">{t(campaign.texts + '.title')}</h2>
35
+ <p className="campaign-hero-text">{t(campaign.texts + '.text')}</p>
36
+ </div>
37
+ <div className="campaign-hero-timer" role="timer" aria-label={t('autobahn:campaign.timeLeft', { ...left })}>
38
+ {units.map(([unit, value]) => (
39
+ <div key={unit} className="campaign-hero-unit" aria-hidden="true">
40
+ <b>{twoDigits(value)}</b>
41
+ <small>{t('autobahn:campaign.' + unit, { count: value })}</small>
42
+ </div>
43
+ ))}
44
+ </div>
45
+ <div className="campaign-hero-legal">{t(campaign.texts + '.legal')}</div>
46
+ </section>
47
+ );
48
+ };
49
+
50
+ export default CampaignHero;
@@ -0,0 +1,43 @@
1
+ // Autobahn (auto.de redesign) — "only the campaign's cars", the switch above the filters of /search
2
+ // (see campaigns.ts). Which search filter it turns on is the page's business.
3
+ //
4
+ // The md3 Switch on the campaign's dark card: the whole card is its label, so all of it can be clicked.
5
+ // Renders correctly only inside a `<div className="md3">` subtree.
6
+
7
+ import React from 'react';
8
+ import { TranslationFunction } from '../types';
9
+
10
+ import { Switch } from '../ui';
11
+ import { Campaign } from './campaigns';
12
+ import { campaignVars } from './campaignVars';
13
+
14
+ export interface CampaignSwitchProps {
15
+ campaign: Campaign;
16
+ checked: boolean;
17
+ onChange: (checked: boolean) => void;
18
+ /** how many cars the switch leaves; null = not known yet (the line stays free). */
19
+ count: number | null;
20
+ language: string;
21
+ t: TranslationFunction;
22
+ }
23
+
24
+ const CampaignSwitch: React.FunctionComponent<CampaignSwitchProps> = ({ campaign, checked, onChange, count, language, t }) => (
25
+ <div className={'campaign-switch campaign-switch--' + campaign.id} style={campaignVars(campaign)}>
26
+ <Switch
27
+ checked={checked}
28
+ onChange={(event) => onChange(event.target.checked)}
29
+ label={(
30
+ <>
31
+ {t(campaign.texts + '.only')}
32
+ <span className="campaign-switch-count">
33
+ {count != null
34
+ ? t('autobahn:campaign.vehicles', { count, number: count.toLocaleString(language === 'en' ? 'en-IN' : 'de-DE') })
35
+ : '\u00a0'}
36
+ </span>
37
+ </>
38
+ )}
39
+ />
40
+ </div>
41
+ );
42
+
43
+ export default CampaignSwitch;
@@ -0,0 +1,12 @@
1
+ import type React from 'react';
2
+ import { Campaign } from './campaigns';
3
+
4
+ /** .mcard--campaign uses the campaign's background as one of several layers, and only the last layer may be a
5
+ * plain colour — so a colour becomes a one-colour gradient. */
6
+ const asImage = (background: string): string =>
7
+ /gradient\(|url\(/.test(background) ? background : `linear-gradient(${background} 0 0)`;
8
+
9
+ /** A campaign's colours as CSS variables (md3.css: .campaign-band, .campaign-hero). A card sets them too (with
10
+ * .mcard--campaign), so that its border takes the band's colour and the band reaches the edge of the card. */
11
+ export const campaignVars = (campaign: Campaign): React.CSSProperties =>
12
+ ({ '--campaign-bg': asImage(campaign.background), '--campaign-fg': campaign.color || '#fff' } as React.CSSProperties);
@@ -0,0 +1,74 @@
1
+ // Autobahn (auto.de redesign) — campaigns ("Black Friday"): the band on top of the car cards and of the
2
+ // vehicle page's gallery (CampaignBand), the hero with the countdown (CampaignHero), the switch "only its cars"
3
+ // (CampaignSwitch), the bar under the site header (CampaignBar) and the banner with cars (CampaignBanner).
4
+ //
5
+ // A campaign is data; the cards and the hero do not know any campaign by name. Which campaign runs is the
6
+ // app's decision (fe-main: source/framework/constants/campaign.ts); without one nothing is shown.
7
+ //
8
+ // A new campaign (e.g. New Year) = one entry in CAMPAIGNS + its texts under "campaign" in
9
+ // locales/{de,en}/autobahn.json. The components and md3.css stay as they are.
10
+
11
+ import type { AutobahnCar } from '../cards/types';
12
+ import { dealSignals, DealSource } from '../cards/dealSignals';
13
+
14
+ /** What a campaign may look at: the part a card's AutobahnCar and the vehicle page's VehicleDetail share. */
15
+ export type CampaignCar = DealSource & Pick<AutobahnCar, 'make' | 'model' | 'trim' | 'km' | 'price' | 'fuel'>;
16
+
17
+ export interface Campaign {
18
+ /** kebab-case id; also the modifier class `campaign-band--<id>` / `campaign-hero--<id>`. */
19
+ id: string;
20
+ /** i18n path of the campaign's texts: label (band, bar), period, title, text, legal (hero), only (switch),
21
+ * offer (bar), bannerTitle, cta (banner, with the hero's period and text). */
22
+ texts: string;
23
+ /** icon in front of the label of the band and the bar — a name from the ui/Icon registry. */
24
+ icon?: string;
25
+ /** a dark colour or gradient: it carries `color` and the white text of the hero and the switch. */
26
+ background: string;
27
+ /** band label and icon, the hero's period line, the switch when it is on; white by default. */
28
+ color?: string;
29
+ /** first and last moment, with the German UTC offset. Outside of it neither the band nor the hero is shown;
30
+ * the hero's period line and its countdown come from here too. */
31
+ startsAt: string;
32
+ endsAt: string;
33
+ /** which cars carry the band. */
34
+ appliesTo: (car: CampaignCar) => boolean;
35
+ }
36
+
37
+ /** the card shows both the green "−X € zum UVP" and the red "−X %" chip. */
38
+ export const hasPriceDropChips = (car: CampaignCar): boolean => {
39
+ const { drop, percent } = dealSignals(car);
40
+ return drop && percent;
41
+ };
42
+
43
+ const blackFriday: Campaign = {
44
+ id: 'black-friday',
45
+ texts: 'autobahn:campaign.blackFriday',
46
+ icon: 'tag',
47
+ // black and gold of the Black Friday design ("auto.de SRL Black Friday", A · Dark Edition)
48
+ background: '#111317',
49
+ color: '#f7c544',
50
+ // 24.11.–01.12.2026, the last day included
51
+ startsAt: '2026-11-24T00:00:00+01:00',
52
+ endsAt: '2026-12-02T00:00:00+01:00',
53
+ appliesTo: hasPriceDropChips,
54
+ };
55
+
56
+ export const CAMPAIGNS = { blackFriday };
57
+
58
+ export const isCampaignRunning = (campaign: Campaign, now: number = Date.now()): boolean =>
59
+ now >= Date.parse(campaign.startsAt) && now < Date.parse(campaign.endsAt);
60
+
61
+ /** the campaign whose band this car carries, if any. */
62
+ export const campaignFor = (car: CampaignCar, campaign?: Campaign | null): Campaign | null =>
63
+ campaign && isCampaignRunning(campaign) && campaign.appliesTo(car) ? campaign : null;
64
+
65
+ /** first and last day as the hero shows them, e.g. { from: '24.11.', to: '01.12.2026' } — German days,
66
+ * wherever the visitor is. */
67
+ export const campaignPeriod = (campaign: Campaign): { from: string; to: string } => {
68
+ const day = (at: number, year: boolean): string =>
69
+ new Intl.DateTimeFormat('de-DE', {
70
+ day: '2-digit', month: '2-digit', year: year ? 'numeric' : undefined, timeZone: 'Europe/Berlin',
71
+ }).format(at);
72
+ // endsAt is the first moment after the campaign
73
+ return { from: day(Date.parse(campaign.startsAt), false), to: day(Date.parse(campaign.endsAt) - 1, true) };
74
+ };
@@ -0,0 +1,18 @@
1
+ export { default as CampaignBand } from './CampaignBand';
2
+ export type { CampaignBandProps } from './CampaignBand';
3
+
4
+ export { default as CampaignBanner } from './CampaignBanner';
5
+ export type { CampaignBannerProps } from './CampaignBanner';
6
+
7
+ export { default as CampaignBar } from './CampaignBar';
8
+ export type { CampaignBarProps } from './CampaignBar';
9
+
10
+ export { default as CampaignHero } from './CampaignHero';
11
+ export type { CampaignHeroProps } from './CampaignHero';
12
+
13
+ export { default as CampaignSwitch } from './CampaignSwitch';
14
+ export type { CampaignSwitchProps } from './CampaignSwitch';
15
+
16
+ export { CAMPAIGNS, campaignFor, campaignPeriod, hasPriceDropChips, isCampaignRunning } from './campaigns';
17
+ export type { Campaign, CampaignCar } from './campaigns';
18
+ export { campaignVars } from './campaignVars';
@@ -0,0 +1,8 @@
1
+ import type React from 'react';
2
+
3
+ /** Click on a campaign's link: a plain click opens it in the app, a new tab or window stays the browser's. */
4
+ export const openInApp = (onOpen: () => void) => (event: React.MouseEvent): void => {
5
+ if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
6
+ event.preventDefault();
7
+ onOpen();
8
+ };
@@ -0,0 +1,28 @@
1
+ import { useEffect, useState } from 'react';
2
+
3
+ export interface Countdown {
4
+ days: number;
5
+ hours: number;
6
+ minutes: number;
7
+ }
8
+
9
+ const MINUTE = 60 * 1000;
10
+
11
+ const minutesLeft = (endsAt: string): number => Math.floor((Date.parse(endsAt) - Date.now()) / MINUTE);
12
+
13
+ /**
14
+ * The time left until `endsAt` in whole minutes, counting down by itself; null once it is over.
15
+ * It looks at the clock every second instead of adding up minutes, so it is right again at once after the
16
+ * tab slept or the computer woke up; React renders only when the minute changes.
17
+ */
18
+ export const useCountdown = (endsAt: string): Countdown | null => {
19
+ const [left, setLeft] = useState(() => minutesLeft(endsAt));
20
+ useEffect(() => {
21
+ const tick = (): void => setLeft(minutesLeft(endsAt));
22
+ tick();
23
+ const timer = setInterval(tick, 1000);
24
+ return () => clearInterval(timer);
25
+ }, [endsAt]);
26
+ if (!(left >= 0)) return null;
27
+ return { days: Math.floor(left / 1440), hours: Math.floor(left / 60) % 24, minutes: left % 60 };
28
+ };
package/cards/CarCard.tsx CHANGED
@@ -38,9 +38,14 @@ import {
38
38
  GalleryActivityPill,
39
39
  cardSpec,
40
40
  PaymentMode,
41
+ startPaymentMode,
41
42
  callDealerSalesPhone,
42
43
  DEALER_SALES_PHONE,
43
44
  } from './cardParts';
45
+ import CampaignBand from '../campaign/CampaignBand';
46
+ import { Campaign, campaignFor } from '../campaign/campaigns';
47
+ import { campaignVars } from '../campaign/campaignVars';
48
+ import { dealSignals } from './dealSignals';
44
49
  import { AutobahnCar } from './types';
45
50
  import VdpViewer from '../vdp/VdpViewer';
46
51
 
@@ -91,7 +96,7 @@ export interface CarCardProps {
91
96
  onOpenRateAdjust?: (mode: PaymentMode) => void;
92
97
  /**
93
98
  * takes over the "Finanzierungsdetails"/"Details" link under the price row — e.g. navigate to
94
- * this car's own VDP and open its finance modal already expanded/scrolled to the breakdown,
99
+ * this car's own VDP and open its finance modal already expanded (at its top, no auto-scroll),
95
100
  * instead of the default plain onOpen(car) navigation. Receives the tab the card was showing
96
101
  * (Finanzierung/Leasing/Kaufen) so the destination modal opens on the same one. Optional/
97
102
  * page-owned like onOpenRateAdjust; the mobile CTA row's "Rate anpassen" button is untouched
@@ -104,6 +109,17 @@ export interface CarCardProps {
104
109
  * when omitted the badge is not a link (a click opens the car via onOpen, as before).
105
110
  */
106
111
  onShowPriceRating?: (car: AutobahnCar) => void;
112
+ /**
113
+ * Tab the price block opens on (default Finanzierung) — e.g. the SRP's leasing-only results
114
+ * open every card on Leasing. Ignored for a car without a lease rate (it has no Leasing tab).
115
+ */
116
+ initialMode?: PaymentMode;
117
+ /**
118
+ * The campaign (campaign/campaigns.ts), e.g. CAMPAIGNS.blackFriday: its band is put on top of the card
119
+ * while the campaign runs and applies to this car. The band takes its height from the photo, so the card is as
120
+ * tall as its neighbours and the rows of a grid stay aligned.
121
+ */
122
+ campaign?: Campaign | null;
107
123
  }
108
124
 
109
125
  const CarCard: React.FunctionComponent<CarCardProps> = ({
@@ -120,8 +136,10 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
120
136
  onOpenRateAdjust,
121
137
  onShowFinancingDetails,
122
138
  onShowPriceRating,
139
+ initialMode,
140
+ campaign,
123
141
  }) => {
124
- const [mode, setMode] = useState<PaymentMode>('financing');
142
+ const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
125
143
  const [photoIndex, setPhotoIndex] = useState(0);
126
144
  const [viewerOpen, setViewerOpen] = useState(false);
127
145
  const mediaRef = useRef<HTMLDivElement | null>(null);
@@ -153,23 +171,17 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
153
171
  observer.observe(el);
154
172
  return () => observer.disconnect();
155
173
  }, [eagerMedia]);
156
- // as-good-as-new gate (mileage < 1,000 km AND first registration unknown or < 12 months) —
157
- // undefined (older AutobahnCar producer not yet updated) fails OPEN, keeping prior behaviour.
158
- const asGoodAsNew = car.asGoodAsNew !== false;
159
- const showDrop = asGoodAsNew && car.drop != null;
160
- const showSave = asGoodAsNew && !showDrop && car.savings != null && car.savings > 600;
161
- const showPct = asGoodAsNew && car.dropPct != null && car.dropPct > 0;
162
- const showOfferBadge = !!(car.isNew || showDrop || showSave || showPct || car.zeroDown);
163
- // PM call: the badge row only fits 3 pills — when Drop/Save + Percent + ZeroDown are all
164
- // active that's already 3, so NEU is dropped rather than causing a 4th to overflow.
165
- const activeDealChips = [showDrop || showSave, showPct, !!car.zeroDown].filter(Boolean).length;
166
- const showNeu = asGoodAsNew && car.isNew && activeDealChips < 3;
174
+ const { drop: showDrop, save: showSave, percent: showPct, offer: showOfferBadge, neu: showNeu } = dealSignals(car);
175
+ const activeCampaign = campaignFor(car, campaign);
176
+ // tabs the price block can switch to (PriceTabs shows Leasing only when the car has a lease rate)
177
+ const paymentModes: PaymentMode[] = car.lease != null ? ['financing', 'leasing', 'buy'] : ['financing', 'buy'];
167
178
  return (
168
179
  <article
169
- className="mcard mcard--interactive cc-card"
180
+ className={'mcard mcard--interactive cc-card' + (activeCampaign ? ' mcard--campaign' : '')}
170
181
  onClick={() => onOpen(car)}
171
- style={{ display: 'flex', flexDirection: 'column' }}
182
+ style={{ display: 'flex', flexDirection: 'column', ...(activeCampaign ? campaignVars(activeCampaign) : {}) }}
172
183
  >
184
+ {activeCampaign && <CampaignBand campaign={activeCampaign} t={t} />}
173
185
  <div
174
186
  className="cc-media"
175
187
  ref={mediaRef}
@@ -286,21 +298,50 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
286
298
  <div className="cc-price" style={{ marginTop: 0, borderTop: '1px solid var(--md-outline-variant)' }}>
287
299
  <PriceTabs car={car} mode={mode} onModeChange={setMode} t={t} />
288
300
  <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, marginTop: 10 }}>
289
- <PriceHero car={car} mode={mode} t={t} alwaysShowUnit />
301
+ {/* every tab's hero stacked in one grid cell (.cc-hero-stack), only the active one
302
+ visible, bottom-aligned — Kaufen's struck list price sits on its own line above
303
+ the price, so without this the row (and the card) grew/shrank by that line on
304
+ every tab switch. Same trick as .cc-terms-stack below. */}
305
+ <div className="cc-hero-stack">
306
+ {paymentModes.map((m) => (
307
+ <div
308
+ key={m}
309
+ className={'cc-hero-slot' + (m === mode ? '' : ' cc-hero-slot--hidden')}
310
+ aria-hidden={m === mode ? undefined : true}
311
+ >
312
+ <PriceHero car={car} mode={m} t={t} alwaysShowUnit />
313
+ </div>
314
+ ))}
315
+ </div>
290
316
  <PriceEvalCol car={car} t={t} onActivate={onShowPriceRating ? () => onShowPriceRating(car) : undefined} />
291
317
  </div>
292
318
  {/* same fallback CardCtaRow already uses below: pages that haven't wired a real
293
- "Rate anpassen" sheet yet still get a working "Details" link (opens the car). */}
294
- <PriceTerms
295
- car={car}
296
- mode={mode}
297
- onOpenRateAdjust={onOpenRateAdjust || (() => onOpen(car))}
298
- onShowDetails={onShowFinancingDetails ? () => onShowFinancingDetails(car, mode) : undefined}
299
- t={t}
300
- />
301
- {/* ADV-405/407 Kreditkosten-Hinweis: below the conditions line, above the CTA row (mobile)
302
- / eco line (desktop); not on Kaufen, which shows no financing terms either. */}
303
- {mode !== 'buy' && <CreditCostNotice t={t} size="small" cls="cc-ccn" />}
319
+ "Rate anpassen" sheet yet still get a working "Details" link (opens the car).
320
+ Every tab's terms line is rendered into the same grid cell (.cc-terms-stack) and
321
+ only the active one is visible — the cell is as tall as the tallest line, so the
322
+ card keeps one height across Finanzierung/Leasing/Kaufen (Leasing's longer line
323
+ wraps to 2 lines on narrow phones). No change to the visible line itself. */}
324
+ <div className="cc-terms-stack">
325
+ {paymentModes.map((m) => (
326
+ <div
327
+ key={m}
328
+ className={'cc-terms-slot' + (m === mode ? '' : ' cc-terms-slot--hidden')}
329
+ aria-hidden={m === mode ? undefined : true}
330
+ >
331
+ <PriceTerms
332
+ car={car}
333
+ mode={m}
334
+ onOpenRateAdjust={onOpenRateAdjust || (() => onOpen(car))}
335
+ onShowDetails={onShowFinancingDetails ? () => onShowFinancingDetails(car, m) : undefined}
336
+ t={t}
337
+ />
338
+ {/* ADV-405/407 Kreditkosten-Hinweis under the financing/leasing conditions line. Inside the
339
+ slot, so the stack keeps one height across the tabs (no jump on Kaufen); hidden slots
340
+ are visibility:hidden + aria-hidden like their terms line. */}
341
+ {m !== 'buy' && <CreditCostNotice t={t} size="small" cls="cc-ccn" />}
342
+ </div>
343
+ ))}
344
+ </div>
304
345
  </div>
305
346
  {/* Mobile-only row (CardCtaRow itself carries the show-mobile class) — always
306
347
  rendered, with real fallbacks the page can override once it wires its own
package/cards/CarRow.tsx CHANGED
@@ -42,8 +42,13 @@ import {
42
42
  ZeroDownChip,
43
43
  fmtKm,
44
44
  PaymentMode,
45
+ startPaymentMode,
45
46
  ratingTone,
46
47
  } from './cardParts';
48
+ import CampaignBand from '../campaign/CampaignBand';
49
+ import { Campaign, campaignFor } from '../campaign/campaigns';
50
+ import { campaignVars } from '../campaign/campaignVars';
51
+ import { dealSignals } from './dealSignals';
47
52
  import { AutobahnCar } from './types';
48
53
 
49
54
  export interface CarRowProps {
@@ -83,6 +88,10 @@ export interface CarRowProps {
83
88
  onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
84
89
  /** the price-rating chip + bar were clicked — see CarCard's identically-named prop. */
85
90
  onShowPriceRating?: (car: AutobahnCar) => void;
91
+ /** Tab the mobile price tabs open on — see CarCard's identically-named prop. */
92
+ initialMode?: PaymentMode;
93
+ /** The running campaign, its band spans the whole row — see CarCard's identically-named prop. */
94
+ campaign?: Campaign | null;
86
95
  }
87
96
 
88
97
  const CarRow: React.FunctionComponent<CarRowProps> = ({
@@ -96,8 +105,10 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
96
105
  adminAction,
97
106
  onShowFinancingDetails,
98
107
  onShowPriceRating,
108
+ initialMode,
109
+ campaign,
99
110
  }) => {
100
- const [mode, setMode] = useState<PaymentMode>('financing');
111
+ const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
101
112
  const [photoIndex, setPhotoIndex] = useState(0);
102
113
  const mediaRef = useRef<HTMLDivElement | null>(null);
103
114
  // The price-rating chip + bar link to the car's "Preis & Marktwert" section (page-owned
@@ -136,16 +147,8 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
136
147
  observer.observe(el);
137
148
  return () => observer.disconnect();
138
149
  }, [eagerMedia]);
139
- // as-good-as-new gate (mileage < 1,000 km AND first registration unknown or < 12 months) —
140
- // undefined (older AutobahnCar producer not yet updated) fails OPEN, keeping prior behaviour.
141
- const asGoodAsNew = car.asGoodAsNew !== false;
142
- const showDrop = asGoodAsNew && car.drop != null;
143
- const showSave = asGoodAsNew && !showDrop && car.savings != null && car.savings > 600;
144
- const showPct = asGoodAsNew && car.dropPct != null && car.dropPct > 0;
145
- const showOfferBadge = !!(car.isNew || showDrop || showSave || showPct || car.zeroDown);
146
- // same overflow rule as CarCard: the row only fits 3 pills, so NEU drops when the other 3 are all active.
147
- const activeDealChips = [showDrop || showSave, showPct, !!car.zeroDown].filter(Boolean).length;
148
- const showNeu = asGoodAsNew && car.isNew && activeDealChips < 3;
150
+ const { drop: showDrop, save: showSave, percent: showPct, offer: showOfferBadge, neu: showNeu } = dealSignals(car);
151
+ const activeCampaign = campaignFor(car, campaign);
149
152
  const facts: Array<[icon: string, value: string]> = [
150
153
  ['gauge', fmtKm(car.km)],
151
154
  ['calendar', t('autobahn:card.specs.firstRegistration', { reg: car.reg })],
@@ -160,16 +163,17 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
160
163
  if (car.availability) facts.push(['circle-check', car.availability]);
161
164
  return (
162
165
  <article
163
- className="mcard mcard--interactive listcard"
166
+ className={'mcard mcard--interactive listcard' + (activeCampaign ? ' mcard--campaign' : '')}
164
167
  onClick={() => onOpen(car)}
165
- style={{ background: 'var(--md-sc-lowest)' }}
168
+ style={activeCampaign ? campaignVars(activeCampaign) : { background: 'var(--md-sc-lowest)' }}
166
169
  >
170
+ {activeCampaign && <CampaignBand campaign={activeCampaign} t={t} />}
167
171
  <div className="listcard-media" ref={mediaRef} style={{ position: 'relative' }} onMouseEnter={onMediaEnter} onTouchStart={onMediaEnter}>
168
172
  {/* 'auto': desktop picks cover/contain per photo (crops only when it wouldn't lose too
169
173
  much of the shot); below 601px this is identical to 'contain', so mobile is unchanged. */}
170
174
  <CardCarousel images={car.gallery} height="100%" fit="auto" onChange={setPhotoIndex} />
171
175
  {/* deal badges — ONE compact line, Figma order: −€ (drop/save) · −% · 0 € Anz. · NEU
172
- (NEU always last, dropped first on overflow — see activeDealChips below), plus the
176
+ (NEU always last, dropped first on overflow — see dealSignals.ts), plus the
173
177
  "⚡ Angebot" badge (Figma) on its own line below. The price RATING ('Guter Preis') is
174
178
  NOT here — it lives in the price column (PriceMeter). */}
175
179
  <div