@bytebrand/fe-ui-core-autobahn 1.0.227 → 1.0.229

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.
@@ -31,7 +31,10 @@ const CampaignHero: React.FunctionComponent<CampaignHeroProps> = ({ campaign, t
31
31
  >
32
32
  <div>
33
33
  <div className="campaign-hero-period">{t(campaign.texts + '.period', { ...campaignPeriod(campaign) })}</div>
34
- <h2 className="campaign-hero-title">{t(campaign.texts + '.title')}</h2>
34
+ <h2 className="campaign-hero-title">
35
+ {t(campaign.texts + '.title')}
36
+ {campaign.titleNote ? <sup className="campaign-hero-note">{campaign.titleNote}</sup> : null}
37
+ </h2>
35
38
  <p className="campaign-hero-text">{t(campaign.texts + '.text')}</p>
36
39
  </div>
37
40
  <div className="campaign-hero-timer" role="timer" aria-label={t('autobahn:campaign.timeLeft', { ...left })}>
@@ -42,7 +45,6 @@ const CampaignHero: React.FunctionComponent<CampaignHeroProps> = ({ campaign, t
42
45
  </div>
43
46
  ))}
44
47
  </div>
45
- <div className="campaign-hero-legal">{t(campaign.texts + '.legal')}</div>
46
48
  </section>
47
49
  );
48
50
  };
@@ -17,9 +17,11 @@ export type CampaignCar = DealSource & Pick<AutobahnCar, 'make' | 'model' | 'tri
17
17
  export interface Campaign {
18
18
  /** kebab-case id; also the modifier class `campaign-band--<id>` / `campaign-hero--<id>`. */
19
19
  id: string;
20
- /** i18n path of the campaign's texts: label (band, bar), period, title, text, legal (hero), only (switch),
20
+ /** i18n path of the campaign's texts: label (band, bar), period, title, text (hero), only (switch),
21
21
  * offer (bar), bannerTitle, cta (banner, with the hero's period and text). */
22
22
  texts: string;
23
+ /** footnote mark raised after the hero's headline, e.g. '2'. */
24
+ titleNote?: string;
23
25
  /** icon in front of the label of the band and the bar — a name from the ui/Icon registry. */
24
26
  icon?: string;
25
27
  /** a dark colour or gradient: it carries `color` and the white text of the hero and the switch. */
@@ -43,6 +45,7 @@ export const hasPriceDropChips = (car: CampaignCar): boolean => {
43
45
  const blackFriday: Campaign = {
44
46
  id: 'black-friday',
45
47
  texts: 'autobahn:campaign.blackFriday',
48
+ titleNote: '2',
46
49
  icon: 'tag',
47
50
  // black and gold of the Black Friday design ("auto.de SRL Black Friday", A · Dark Edition)
48
51
  background: '#111317',
package/cards/CarCard.tsx CHANGED
@@ -38,6 +38,7 @@ import {
38
38
  GalleryActivityPill,
39
39
  cardSpec,
40
40
  PaymentMode,
41
+ startPaymentMode,
41
42
  callDealerSalesPhone,
42
43
  DEALER_SALES_PHONE,
43
44
  } from './cardParts';
@@ -95,7 +96,7 @@ export interface CarCardProps {
95
96
  onOpenRateAdjust?: (mode: PaymentMode) => void;
96
97
  /**
97
98
  * takes over the "Finanzierungsdetails"/"Details" link under the price row — e.g. navigate to
98
- * 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),
99
100
  * instead of the default plain onOpen(car) navigation. Receives the tab the card was showing
100
101
  * (Finanzierung/Leasing/Kaufen) so the destination modal opens on the same one. Optional/
101
102
  * page-owned like onOpenRateAdjust; the mobile CTA row's "Rate anpassen" button is untouched
@@ -108,6 +109,11 @@ export interface CarCardProps {
108
109
  * when omitted the badge is not a link (a click opens the car via onOpen, as before).
109
110
  */
110
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;
111
117
  /**
112
118
  * The campaign (campaign/campaigns.ts), e.g. CAMPAIGNS.blackFriday: its band is put on top of the card
113
119
  * while the campaign runs and applies to this car. The band takes its height from the photo, so the card is as
@@ -130,9 +136,10 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
130
136
  onOpenRateAdjust,
131
137
  onShowFinancingDetails,
132
138
  onShowPriceRating,
139
+ initialMode,
133
140
  campaign,
134
141
  }) => {
135
- const [mode, setMode] = useState<PaymentMode>('financing');
142
+ const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
136
143
  const [photoIndex, setPhotoIndex] = useState(0);
137
144
  const [viewerOpen, setViewerOpen] = useState(false);
138
145
  const mediaRef = useRef<HTMLDivElement | null>(null);
@@ -166,6 +173,8 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
166
173
  }, [eagerMedia]);
167
174
  const { drop: showDrop, save: showSave, percent: showPct, offer: showOfferBadge, neu: showNeu } = dealSignals(car);
168
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'];
169
178
  return (
170
179
  <article
171
180
  className={'mcard mcard--interactive cc-card' + (activeCampaign ? ' mcard--campaign' : '')}
@@ -289,21 +298,50 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
289
298
  <div className="cc-price" style={{ marginTop: 0, borderTop: '1px solid var(--md-outline-variant)' }}>
290
299
  <PriceTabs car={car} mode={mode} onModeChange={setMode} t={t} />
291
300
  <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, marginTop: 10 }}>
292
- <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>
293
316
  <PriceEvalCol car={car} t={t} onActivate={onShowPriceRating ? () => onShowPriceRating(car) : undefined} />
294
317
  </div>
295
318
  {/* same fallback CardCtaRow already uses below: pages that haven't wired a real
296
- "Rate anpassen" sheet yet still get a working "Details" link (opens the car). */}
297
- <PriceTerms
298
- car={car}
299
- mode={mode}
300
- onOpenRateAdjust={onOpenRateAdjust || (() => onOpen(car))}
301
- onShowDetails={onShowFinancingDetails ? () => onShowFinancingDetails(car, mode) : undefined}
302
- t={t}
303
- />
304
- {/* ADV-405/407 Kreditkosten-Hinweis: below the conditions line, above the CTA row (mobile)
305
- / eco line (desktop); not on Kaufen, which shows no financing terms either. */}
306
- {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>
307
345
  </div>
308
346
  {/* Mobile-only row (CardCtaRow itself carries the show-mobile class) — always
309
347
  rendered, with real fallbacks the page can override once it wires its own
package/cards/CarRow.tsx CHANGED
@@ -42,6 +42,7 @@ import {
42
42
  ZeroDownChip,
43
43
  fmtKm,
44
44
  PaymentMode,
45
+ startPaymentMode,
45
46
  ratingTone,
46
47
  } from './cardParts';
47
48
  import CampaignBand from '../campaign/CampaignBand';
@@ -87,6 +88,8 @@ export interface CarRowProps {
87
88
  onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
88
89
  /** the price-rating chip + bar were clicked — see CarCard's identically-named prop. */
89
90
  onShowPriceRating?: (car: AutobahnCar) => void;
91
+ /** Tab the mobile price tabs open on — see CarCard's identically-named prop. */
92
+ initialMode?: PaymentMode;
90
93
  /** The running campaign, its band spans the whole row — see CarCard's identically-named prop. */
91
94
  campaign?: Campaign | null;
92
95
  }
@@ -102,9 +105,10 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
102
105
  adminAction,
103
106
  onShowFinancingDetails,
104
107
  onShowPriceRating,
108
+ initialMode,
105
109
  campaign,
106
110
  }) => {
107
- const [mode, setMode] = useState<PaymentMode>('financing');
111
+ const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
108
112
  const [photoIndex, setPhotoIndex] = useState(0);
109
113
  const mediaRef = useRef<HTMLDivElement | null>(null);
110
114
  // The price-rating chip + bar link to the car's "Preis & Marktwert" section (page-owned
@@ -551,6 +551,11 @@ 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
+
554
559
  export interface PriceTabsProps {
555
560
  car: AutobahnCar;
556
561
  mode: PaymentMode;
@@ -779,13 +784,18 @@ export const PriceTerms: React.FunctionComponent<{
779
784
  mode: PaymentMode;
780
785
  onOpenRateAdjust?: (mode: PaymentMode) => void;
781
786
  /** takes over the "Finanzierungsdetails"/"Details" link's click (e.g. navigate to the VDP and
782
- * open the finance modal already expanded, scrolled to the breakdown) — when given, it wins
787
+ * open the finance modal already expanded, at its top) — when given, it wins
783
788
  * over onOpenRateAdjust for THIS link only; the mobile CTA row's own "Rate anpassen" button
784
789
  * keeps using onOpenRateAdjust regardless. */
785
790
  onShowDetails?: () => void;
786
791
  t: TranslationFunction;
787
792
  }> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
788
- if (mode === 'buy') return null;
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" />;
789
799
  const finFirstInstallment =
790
800
  car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
791
801
  const finMonths = car.finMonths ?? _finMonths;
package/constants/app.ts CHANGED
@@ -40,7 +40,17 @@ export const LOCAL_STORAGE_KEY = {
40
40
  i18n_KEY: 'i18nLanguage'
41
41
  };
42
42
 
43
- export const DEFAULT_LANG: string = typeof window !== 'undefined' ? localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : 'de';
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';
44
54
 
45
55
  // Default support contact phone
46
56
  export const CONTACT_PHONE: string = '+498004030182';
package/constants/core.ts CHANGED
@@ -35,7 +35,18 @@ export const LOCAL_STORAGE_KEY = {
35
35
  i18n_KEY: 'i18nLanguage'
36
36
  };
37
37
 
38
- export const DEFAULT_LANG: string = (typeof window !== 'undefined' ? window.localStorage.getItem(LOCAL_STORAGE_KEY.i18n_KEY) : null) ?? 'de';
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';
39
50
 
40
51
  export const ROW_STYLES = {
41
52
  marginBottom: 10
@@ -83,8 +83,7 @@
83
83
  "cta": "Angebote ansehen",
84
84
  "period": "Black Friday Week · {{from}}–{{to}}",
85
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)."
86
+ "text": "Ausgewählte Fahrzeuge mit reduziertem Kaufpreis. Nur solange die Aktion läuft."
88
87
  }
89
88
  },
90
89
  "finance": {
@@ -83,8 +83,7 @@
83
83
  "cta": "View offers",
84
84
  "period": "Black Friday Week · {{from}}–{{to}}",
85
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)."
86
+ "text": "Selected vehicles at a reduced purchase price. Only while the campaign lasts."
88
87
  }
89
88
  },
90
89
  "finance": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core-autobahn",
3
- "version": "1.0.227",
3
+ "version": "1.0.229",
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.31",
13
+ "@bytebrand/fe-financing": "^5.14.30",
14
14
  "classnames": "2.2.6",
15
15
  "clsx": "^2.1.1",
16
16
  "d3-format": "1.4.5",
package/theme/md3.css CHANGED
@@ -8578,13 +8578,12 @@ line-height: 31px;
8578
8578
  letter-spacing: 0.6px;
8579
8579
  text-transform: uppercase;
8580
8580
  }
8581
- .md3 .campaign-hero-legal {
8582
- grid-column: 1 / -1;
8583
- padding-top: 12px;
8584
- border-top: 1px solid rgba(214, 226, 255, 0.14);
8585
- color: #9aa0ac;
8586
- font-size: 11px;
8587
- line-height: 14px;
8581
+ .md3 .campaign-hero-note {
8582
+ margin-left: 2px;
8583
+ font-size: 0.5em;
8584
+ line-height: 0;
8585
+ letter-spacing: 0;
8586
+ vertical-align: 0.45em;
8588
8587
  }
8589
8588
  @media (max-width: 900px) {
8590
8589
  .md3 .campaign-hero {
@@ -10770,7 +10769,8 @@ line-height: 31px;
10770
10769
  z-index: 71;
10771
10770
  background: var(--md-surface);
10772
10771
  border-radius: var(--md-r-xl) var(--md-r-xl) 0 0;
10773
- max-height: 92vh;
10772
+ /* % of the fixed containing block, not vh/dvh: on iOS vh is the toolbars-collapsed height, and Chrome on iOS does not shrink dvh while its toolbars are shown either, so a 92vh/92dvh bottom sheet grew under the address bar and hid its own header (title, download, close). The fixed box itself always matches the visible area. */
10773
+ max-height: 92%;
10774
10774
  display: flex;
10775
10775
  flex-direction: column;
10776
10776
  box-shadow: 0 -8px 30px rgba(16, 22, 42, 0.22);
@@ -14758,7 +14758,8 @@ color: #005CFF;
14758
14758
  flex-direction: column;
14759
14759
  width: 100%;
14760
14760
  max-width: 560px;
14761
- max-height: calc(100vh - 32px);
14761
+ /* % of the scrim (fixed, inset 0, 16px padding) instead of calc(100vh - 32px): see the iOS note on the mobile .mmodal below */
14762
+ max-height: 100%;
14762
14763
  background: var(--md-sc-lowest, #fff);
14763
14764
  color: var(--md-on-surface);
14764
14765
  border-radius: var(--md-r-lg);
@@ -14904,7 +14905,8 @@ color: #005CFF;
14904
14905
  }
14905
14906
  .md3 .mmodal {
14906
14907
  max-width: 100%;
14907
- max-height: 92vh;
14908
+ /* % of the fixed containing block, not vh/dvh: on iOS vh is the toolbars-collapsed height, and Chrome on iOS does not shrink dvh while its toolbars are shown either, so a 92vh/92dvh bottom sheet grew under the address bar and hid its own header (title, download, close). The fixed box itself always matches the visible area. */
14909
+ max-height: 92%;
14908
14910
  border-radius: var(--md-r-lg) var(--md-r-lg) 0 0;
14909
14911
  border-bottom: 0;
14910
14912
  animation: mmodal-sheet-up 0.25s ease-out;