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

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 CHANGED
@@ -38,14 +38,9 @@ import {
38
38
  GalleryActivityPill,
39
39
  cardSpec,
40
40
  PaymentMode,
41
- startPaymentMode,
42
41
  callDealerSalesPhone,
43
42
  DEALER_SALES_PHONE,
44
43
  } 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';
49
44
  import { AutobahnCar } from './types';
50
45
  import VdpViewer from '../vdp/VdpViewer';
51
46
 
@@ -96,7 +91,7 @@ export interface CarCardProps {
96
91
  onOpenRateAdjust?: (mode: PaymentMode) => void;
97
92
  /**
98
93
  * takes over the "Finanzierungsdetails"/"Details" link under the price row — e.g. navigate to
99
- * this car's own VDP and open its finance modal already expanded (at its top, no auto-scroll),
94
+ * this car's own VDP and open its finance modal already expanded/scrolled to the breakdown,
100
95
  * instead of the default plain onOpen(car) navigation. Receives the tab the card was showing
101
96
  * (Finanzierung/Leasing/Kaufen) so the destination modal opens on the same one. Optional/
102
97
  * page-owned like onOpenRateAdjust; the mobile CTA row's "Rate anpassen" button is untouched
@@ -109,17 +104,6 @@ export interface CarCardProps {
109
104
  * when omitted the badge is not a link (a click opens the car via onOpen, as before).
110
105
  */
111
106
  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;
123
107
  }
124
108
 
125
109
  const CarCard: React.FunctionComponent<CarCardProps> = ({
@@ -136,10 +120,8 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
136
120
  onOpenRateAdjust,
137
121
  onShowFinancingDetails,
138
122
  onShowPriceRating,
139
- initialMode,
140
- campaign,
141
123
  }) => {
142
- const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
124
+ const [mode, setMode] = useState<PaymentMode>('financing');
143
125
  const [photoIndex, setPhotoIndex] = useState(0);
144
126
  const [viewerOpen, setViewerOpen] = useState(false);
145
127
  const mediaRef = useRef<HTMLDivElement | null>(null);
@@ -171,17 +153,23 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
171
153
  observer.observe(el);
172
154
  return () => observer.disconnect();
173
155
  }, [eagerMedia]);
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'];
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;
178
167
  return (
179
168
  <article
180
- className={'mcard mcard--interactive cc-card' + (activeCampaign ? ' mcard--campaign' : '')}
169
+ className="mcard mcard--interactive cc-card"
181
170
  onClick={() => onOpen(car)}
182
- style={{ display: 'flex', flexDirection: 'column', ...(activeCampaign ? campaignVars(activeCampaign) : {}) }}
171
+ style={{ display: 'flex', flexDirection: 'column' }}
183
172
  >
184
- {activeCampaign && <CampaignBand campaign={activeCampaign} t={t} />}
185
173
  <div
186
174
  className="cc-media"
187
175
  ref={mediaRef}
@@ -298,50 +286,21 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
298
286
  <div className="cc-price" style={{ marginTop: 0, borderTop: '1px solid var(--md-outline-variant)' }}>
299
287
  <PriceTabs car={car} mode={mode} onModeChange={setMode} t={t} />
300
288
  <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, marginTop: 10 }}>
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>
289
+ <PriceHero car={car} mode={mode} t={t} alwaysShowUnit />
316
290
  <PriceEvalCol car={car} t={t} onActivate={onShowPriceRating ? () => onShowPriceRating(car) : undefined} />
317
291
  </div>
318
292
  {/* same fallback CardCtaRow already uses below: pages that haven't wired a real
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>
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" />}
345
304
  </div>
346
305
  {/* Mobile-only row (CardCtaRow itself carries the show-mobile class) — always
347
306
  rendered, with real fallbacks the page can override once it wires its own
package/cards/CarRow.tsx CHANGED
@@ -42,13 +42,8 @@ import {
42
42
  ZeroDownChip,
43
43
  fmtKm,
44
44
  PaymentMode,
45
- startPaymentMode,
46
45
  ratingTone,
47
46
  } 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';
52
47
  import { AutobahnCar } from './types';
53
48
 
54
49
  export interface CarRowProps {
@@ -88,10 +83,6 @@ export interface CarRowProps {
88
83
  onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
89
84
  /** the price-rating chip + bar were clicked — see CarCard's identically-named prop. */
90
85
  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;
95
86
  }
96
87
 
97
88
  const CarRow: React.FunctionComponent<CarRowProps> = ({
@@ -105,10 +96,8 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
105
96
  adminAction,
106
97
  onShowFinancingDetails,
107
98
  onShowPriceRating,
108
- initialMode,
109
- campaign,
110
99
  }) => {
111
- const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
100
+ const [mode, setMode] = useState<PaymentMode>('financing');
112
101
  const [photoIndex, setPhotoIndex] = useState(0);
113
102
  const mediaRef = useRef<HTMLDivElement | null>(null);
114
103
  // The price-rating chip + bar link to the car's "Preis & Marktwert" section (page-owned
@@ -147,8 +136,16 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
147
136
  observer.observe(el);
148
137
  return () => observer.disconnect();
149
138
  }, [eagerMedia]);
150
- const { drop: showDrop, save: showSave, percent: showPct, offer: showOfferBadge, neu: showNeu } = dealSignals(car);
151
- const activeCampaign = campaignFor(car, campaign);
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;
152
149
  const facts: Array<[icon: string, value: string]> = [
153
150
  ['gauge', fmtKm(car.km)],
154
151
  ['calendar', t('autobahn:card.specs.firstRegistration', { reg: car.reg })],
@@ -163,17 +160,16 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
163
160
  if (car.availability) facts.push(['circle-check', car.availability]);
164
161
  return (
165
162
  <article
166
- className={'mcard mcard--interactive listcard' + (activeCampaign ? ' mcard--campaign' : '')}
163
+ className="mcard mcard--interactive listcard"
167
164
  onClick={() => onOpen(car)}
168
- style={activeCampaign ? campaignVars(activeCampaign) : { background: 'var(--md-sc-lowest)' }}
165
+ style={{ background: 'var(--md-sc-lowest)' }}
169
166
  >
170
- {activeCampaign && <CampaignBand campaign={activeCampaign} t={t} />}
171
167
  <div className="listcard-media" ref={mediaRef} style={{ position: 'relative' }} onMouseEnter={onMediaEnter} onTouchStart={onMediaEnter}>
172
168
  {/* 'auto': desktop picks cover/contain per photo (crops only when it wouldn't lose too
173
169
  much of the shot); below 601px this is identical to 'contain', so mobile is unchanged. */}
174
170
  <CardCarousel images={car.gallery} height="100%" fit="auto" onChange={setPhotoIndex} />
175
171
  {/* deal badges — ONE compact line, Figma order: −€ (drop/save) · −% · 0 € Anz. · NEU
176
- (NEU always last, dropped first on overflow — see dealSignals.ts), plus the
172
+ (NEU always last, dropped first on overflow — see activeDealChips below), plus the
177
173
  "⚡ Angebot" badge (Figma) on its own line below. The price RATING ('Guter Preis') is
178
174
  NOT here — it lives in the price column (PriceMeter). */}
179
175
  <div
@@ -551,11 +551,6 @@ export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: Transl
551
551
 
552
552
  export type PaymentMode = 'financing' | 'leasing' | 'buy';
553
553
 
554
- /** The tab a card opens on: the requested one (default Finanzierung), but never Leasing for a car
555
- * without a lease rate — PriceTabs has no Leasing tab for it. */
556
- export const startPaymentMode = (car: AutobahnCar, requested?: PaymentMode): PaymentMode =>
557
- requested === 'leasing' && car.lease == null ? 'financing' : requested || 'financing';
558
-
559
554
  export interface PriceTabsProps {
560
555
  car: AutobahnCar;
561
556
  mode: PaymentMode;
@@ -784,18 +779,13 @@ export const PriceTerms: React.FunctionComponent<{
784
779
  mode: PaymentMode;
785
780
  onOpenRateAdjust?: (mode: PaymentMode) => void;
786
781
  /** takes over the "Finanzierungsdetails"/"Details" link's click (e.g. navigate to the VDP and
787
- * open the finance modal already expanded, at its top) — when given, it wins
782
+ * open the finance modal already expanded, scrolled to the breakdown) — when given, it wins
788
783
  * over onOpenRateAdjust for THIS link only; the mobile CTA row's own "Rate anpassen" button
789
784
  * keeps using onOpenRateAdjust regardless. */
790
785
  onShowDetails?: () => void;
791
786
  t: TranslationFunction;
792
787
  }> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
793
- // Kaufen (buy): a cash purchase has no financing terms/details link — used to `return null`
794
- // here, which collapsed .cc-terms to 0 height on that tab while Financing/Leasing rendered a
795
- // real line, jumping the price row (and everything below it: rating pill, CTA row) up/down on
796
- // every tab switch. Render an empty, still-present .cc-terms div instead — same fix as the VDP
797
- // FinanceCalculator's .fin-cond (md3.css), which reserves its line's height the same way.
798
- if (mode === 'buy') return <div className="cc-terms" />;
788
+ if (mode === 'buy') return null;
799
789
  const finFirstInstallment =
800
790
  car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
801
791
  const finMonths = car.finMonths ?? _finMonths;
package/constants/app.ts CHANGED
@@ -40,17 +40,7 @@ export const LOCAL_STORAGE_KEY = {
40
40
  i18n_KEY: 'i18nLanguage'
41
41
  };
42
42
 
43
- // ADV-284: evaluated at import time — with site storage blocked, reading localStorage throws a
44
- // SecurityError that took down the whole bundle. Blocked storage behaves like "nothing saved".
45
- const readStoredLang = (): string | null => {
46
- try {
47
- return localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY);
48
- } catch (e) {
49
- return null;
50
- }
51
- };
52
-
53
- export const DEFAULT_LANG: string = typeof window !== 'undefined' ? readStoredLang() : 'de';
43
+ export const DEFAULT_LANG: string = typeof window !== 'undefined' ? localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : 'de';
54
44
 
55
45
  // Default support contact phone
56
46
  export const CONTACT_PHONE: string = '+498004030182';
package/constants/core.ts CHANGED
@@ -35,18 +35,7 @@ export const LOCAL_STORAGE_KEY = {
35
35
  i18n_KEY: 'i18nLanguage'
36
36
  };
37
37
 
38
- // ADV-284: evaluated at import time — with site storage blocked, merely reading
39
- // window.localStorage throws a SecurityError, which took down the whole bundle (landing
40
- // page never rendered). Treat blocked storage like "no language saved".
41
- const readStoredLang = (): string | null => {
42
- try {
43
- return typeof window !== 'undefined' ? window.localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : null;
44
- } catch (e) {
45
- return null;
46
- }
47
- };
48
-
49
- export const DEFAULT_LANG: string = readStoredLang() ?? 'de';
38
+ export const DEFAULT_LANG: string = (typeof window !== 'undefined' ? window.localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : null) ?? 'de';
50
39
 
51
40
  export const ROW_STYLES = {
52
41
  marginBottom: 10
package/index.ts CHANGED
@@ -11,7 +11,6 @@
11
11
  // - navigation is injected (TopBar `onNavigate`) — no router dependency.
12
12
  export * from './ui';
13
13
  export * from './cards';
14
- export * from './campaign';
15
14
  export * from './chrome';
16
15
  export * from './vdp';
17
16
  export * from './widgets';
@@ -64,29 +64,6 @@
64
64
  "offer": "Angebot"
65
65
  }
66
66
  },
67
- "campaign": {
68
- "days": "Tag",
69
- "days_plural": "Tage",
70
- "hours": "Std",
71
- "minutes": "Min",
72
- "timeLeft": "Noch {{days}} Tage, {{hours}} Stunden und {{minutes}} Minuten",
73
- "vehicles": "{{number}} Fahrzeug",
74
- "vehicles_plural": "{{number}} Fahrzeuge",
75
- "endsInDays": "Endet in {{days}} T {{hours}} Std",
76
- "endsInHours": "Endet in {{hours}} Std {{minutes}} Min",
77
- "exampleCars": "Beispielfahrzeuge",
78
- "blackFriday": {
79
- "label": "Black Friday",
80
- "only": "Nur Black-Friday-Angebote",
81
- "offer": "Spare bis zu 35 %",
82
- "bannerTitle": "Bis zu 35 % sparen",
83
- "cta": "Angebote ansehen",
84
- "period": "Black Friday Week · {{from}}–{{to}}",
85
- "title": "Bis zu 35 % günstiger.",
86
- "text": "Ausgewählte Fahrzeuge mit reduziertem Kaufpreis. Nur solange die Aktion läuft.",
87
- "legal": "Durchgestrichene Preise zeigen den niedrigsten Gesamtpreis des jeweiligen Fahrzeugs in den letzten 30 Tagen vor der Preisermäßigung (§ 11 PAngV)."
88
- }
89
- },
90
67
  "finance": {
91
68
  "creditCostWarning": "Achtung! Kreditaufnahme kostet Geld.",
92
69
  "kfMonths": "{{months}} Mon.",
@@ -64,29 +64,6 @@
64
64
  "offer": "Offer"
65
65
  }
66
66
  },
67
- "campaign": {
68
- "days": "Day",
69
- "days_plural": "Days",
70
- "hours": "Hrs",
71
- "minutes": "Min",
72
- "timeLeft": "{{days}} days, {{hours}} hours and {{minutes}} minutes left",
73
- "vehicles": "{{number}} vehicle",
74
- "vehicles_plural": "{{number}} vehicles",
75
- "endsInDays": "Ends in {{days}}d {{hours}}h",
76
- "endsInHours": "Ends in {{hours}}h {{minutes}}m",
77
- "exampleCars": "Example vehicles",
78
- "blackFriday": {
79
- "label": "Black Friday",
80
- "only": "Black Friday offers only",
81
- "offer": "Save up to 35%",
82
- "bannerTitle": "Save up to 35%",
83
- "cta": "View offers",
84
- "period": "Black Friday Week · {{from}}–{{to}}",
85
- "title": "Save up to 35%.",
86
- "text": "Selected vehicles at a reduced purchase price. Only while the campaign lasts.",
87
- "legal": "Struck-through prices show the lowest total price of the respective vehicle in the 30 days before the price reduction (Section 11 PAngV)."
88
- }
89
- },
90
67
  "finance": {
91
68
  "creditCostWarning": "Warning! Financing comes at a cost.",
92
69
  "kfMonths": "{{months}} mo.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core-autobahn",
3
- "version": "1.0.225",
3
+ "version": "1.0.226",
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",
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "@bytebrand/car-schema-selectors": "^2.0.7",
13
- "@bytebrand/fe-financing": "^5.14.30",
13
+ "@bytebrand/fe-financing": "^5.14.31",
14
14
  "classnames": "2.2.6",
15
15
  "clsx": "^2.1.1",
16
16
  "d3-format": "1.4.5",