@bytebrand/fe-ui-core-autobahn 1.0.176 → 1.0.177
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 +47 -10
- package/cards/CarRow.tsx +5 -1
- package/cards/cardParts.tsx +11 -1
- package/chrome/TopBar.tsx +29 -10
- package/compat/CookieModal/CookieModal.tsx +20 -2
- package/compat/CookieModal/Modal.tsx +6 -3
- package/compat/CookieModal/modals/ManageCookieModal/ManageCookieModal.tsx +43 -15
- package/compat/CookieModal/modals/PreviewCookieModal/PreviewCookieModal.tsx +4 -3
- package/compat/CookieModal/useModal.ts +5 -1
- package/constants/app.ts +11 -1
- package/constants/core.ts +12 -1
- package/locales/de/autobahn.json +22 -1
- package/locales/en/autobahn.json +22 -1
- package/package.json +1 -1
- package/theme/md3.css +17 -7
- package/ui/Dropdown.tsx +16 -8
- package/ui/index.ts +2 -0
- package/ui/scrollFieldIntoView.ts +41 -0
- package/ui/usePortalMenuPosition.ts +19 -13
- package/utils/cookieConsent.ts +84 -0
- package/utils/index.ts +8 -0
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';
|
|
@@ -98,6 +99,11 @@ export interface CarCardProps {
|
|
|
98
99
|
* (still onOpenRateAdjust).
|
|
99
100
|
*/
|
|
100
101
|
onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
|
|
102
|
+
/**
|
|
103
|
+
* Tab the price block opens on (default Finanzierung) — e.g. the SRP's leasing-only results
|
|
104
|
+
* open every card on Leasing. Ignored for a car without a lease rate (it has no Leasing tab).
|
|
105
|
+
*/
|
|
106
|
+
initialMode?: PaymentMode;
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
@@ -113,8 +119,9 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
113
119
|
onCall,
|
|
114
120
|
onOpenRateAdjust,
|
|
115
121
|
onShowFinancingDetails,
|
|
122
|
+
initialMode,
|
|
116
123
|
}) => {
|
|
117
|
-
const [mode, setMode] = useState<PaymentMode>(
|
|
124
|
+
const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
|
|
118
125
|
const [photoIndex, setPhotoIndex] = useState(0);
|
|
119
126
|
const [viewerOpen, setViewerOpen] = useState(false);
|
|
120
127
|
const mediaRef = useRef<HTMLDivElement | null>(null);
|
|
@@ -157,6 +164,8 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
157
164
|
// active that's already 3, so NEU is dropped rather than causing a 4th to overflow.
|
|
158
165
|
const activeDealChips = [showDrop || showSave, showPct, !!car.zeroDown].filter(Boolean).length;
|
|
159
166
|
const showNeu = asGoodAsNew && car.isNew && activeDealChips < 3;
|
|
167
|
+
// tabs the price block can switch to (PriceTabs shows Leasing only when the car has a lease rate)
|
|
168
|
+
const paymentModes: PaymentMode[] = car.lease != null ? ['financing', 'leasing', 'buy'] : ['financing', 'buy'];
|
|
160
169
|
return (
|
|
161
170
|
<article
|
|
162
171
|
className="mcard mcard--interactive cc-card"
|
|
@@ -277,18 +286,46 @@ const CarCard: React.FunctionComponent<CarCardProps> = ({
|
|
|
277
286
|
<div className="cc-price" style={{ marginTop: 0, borderTop: '1px solid var(--md-outline-variant)' }}>
|
|
278
287
|
<PriceTabs car={car} mode={mode} onModeChange={setMode} t={t} />
|
|
279
288
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8, marginTop: 10 }}>
|
|
280
|
-
|
|
289
|
+
{/* every tab's hero stacked in one grid cell (.cc-hero-stack), only the active one
|
|
290
|
+
visible, bottom-aligned — Kaufen's struck list price sits on its own line above
|
|
291
|
+
the price, so without this the row (and the card) grew/shrank by that line on
|
|
292
|
+
every tab switch. Same trick as .cc-terms-stack below. */}
|
|
293
|
+
<div className="cc-hero-stack">
|
|
294
|
+
{paymentModes.map((m) => (
|
|
295
|
+
<div
|
|
296
|
+
key={m}
|
|
297
|
+
className={'cc-hero-slot' + (m === mode ? '' : ' cc-hero-slot--hidden')}
|
|
298
|
+
aria-hidden={m === mode ? undefined : true}
|
|
299
|
+
>
|
|
300
|
+
<PriceHero car={car} mode={m} t={t} alwaysShowUnit />
|
|
301
|
+
</div>
|
|
302
|
+
))}
|
|
303
|
+
</div>
|
|
281
304
|
<PriceEvalCol car={car} t={t} />
|
|
282
305
|
</div>
|
|
283
306
|
{/* same fallback CardCtaRow already uses below: pages that haven't wired a real
|
|
284
|
-
"Rate anpassen" sheet yet still get a working "Details" link (opens the car).
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
307
|
+
"Rate anpassen" sheet yet still get a working "Details" link (opens the car).
|
|
308
|
+
Every tab's terms line is rendered into the same grid cell (.cc-terms-stack) and
|
|
309
|
+
only the active one is visible — the cell is as tall as the tallest line, so the
|
|
310
|
+
card keeps one height across Finanzierung/Leasing/Kaufen (Leasing's longer line
|
|
311
|
+
wraps to 2 lines on narrow phones). No change to the visible line itself. */}
|
|
312
|
+
<div className="cc-terms-stack">
|
|
313
|
+
{paymentModes.map((m) => (
|
|
314
|
+
<div
|
|
315
|
+
key={m}
|
|
316
|
+
className={'cc-terms-slot' + (m === mode ? '' : ' cc-terms-slot--hidden')}
|
|
317
|
+
aria-hidden={m === mode ? undefined : true}
|
|
318
|
+
>
|
|
319
|
+
<PriceTerms
|
|
320
|
+
car={car}
|
|
321
|
+
mode={m}
|
|
322
|
+
onOpenRateAdjust={onOpenRateAdjust || (() => onOpen(car))}
|
|
323
|
+
onShowDetails={onShowFinancingDetails ? () => onShowFinancingDetails(car, m) : undefined}
|
|
324
|
+
t={t}
|
|
325
|
+
/>
|
|
326
|
+
</div>
|
|
327
|
+
))}
|
|
328
|
+
</div>
|
|
292
329
|
</div>
|
|
293
330
|
{/* Mobile-only row (CardCtaRow itself carries the show-mobile class) — always
|
|
294
331
|
rendered, with real fallbacks the page can override once it wires its own
|
package/cards/CarRow.tsx
CHANGED
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
ZeroDownChip,
|
|
42
42
|
fmtKm,
|
|
43
43
|
PaymentMode,
|
|
44
|
+
startPaymentMode,
|
|
44
45
|
ratingTone,
|
|
45
46
|
} from './cardParts';
|
|
46
47
|
import { AutobahnCar } from './types';
|
|
@@ -80,6 +81,8 @@ export interface CarRowProps {
|
|
|
80
81
|
* links render as plain text (see PricePaths' own fallback).
|
|
81
82
|
*/
|
|
82
83
|
onShowFinancingDetails?: (car: AutobahnCar, mode: PaymentMode) => void;
|
|
84
|
+
/** Tab the mobile price tabs open on — see CarCard's identically-named prop. */
|
|
85
|
+
initialMode?: PaymentMode;
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
@@ -92,8 +95,9 @@ const CarRow: React.FunctionComponent<CarRowProps> = ({
|
|
|
92
95
|
t,
|
|
93
96
|
adminAction,
|
|
94
97
|
onShowFinancingDetails,
|
|
98
|
+
initialMode,
|
|
95
99
|
}) => {
|
|
96
|
-
const [mode, setMode] = useState<PaymentMode>(
|
|
100
|
+
const [mode, setMode] = useState<PaymentMode>(() => startPaymentMode(car, initialMode));
|
|
97
101
|
const [photoIndex, setPhotoIndex] = useState(0);
|
|
98
102
|
const mediaRef = useRef<HTMLDivElement | null>(null);
|
|
99
103
|
// always call the LATEST onMediaEnter without re-arming the observer on every render (the
|
package/cards/cardParts.tsx
CHANGED
|
@@ -489,6 +489,11 @@ export const PriceEvalCol: React.FunctionComponent<{ car: AutobahnCar; t: Transl
|
|
|
489
489
|
|
|
490
490
|
export type PaymentMode = 'financing' | 'leasing' | 'buy';
|
|
491
491
|
|
|
492
|
+
/** The tab a card opens on: the requested one (default Finanzierung), but never Leasing for a car
|
|
493
|
+
* without a lease rate — PriceTabs has no Leasing tab for it. */
|
|
494
|
+
export const startPaymentMode = (car: AutobahnCar, requested?: PaymentMode): PaymentMode =>
|
|
495
|
+
requested === 'leasing' && car.lease == null ? 'financing' : requested || 'financing';
|
|
496
|
+
|
|
492
497
|
export interface PriceTabsProps {
|
|
493
498
|
car: AutobahnCar;
|
|
494
499
|
mode: PaymentMode;
|
|
@@ -710,7 +715,12 @@ export const PriceTerms: React.FunctionComponent<{
|
|
|
710
715
|
onShowDetails?: () => void;
|
|
711
716
|
t: TranslationFunction;
|
|
712
717
|
}> = ({ car, mode, onOpenRateAdjust, onShowDetails, t }) => {
|
|
713
|
-
|
|
718
|
+
// Kaufen (buy): a cash purchase has no financing terms/details link — used to `return null`
|
|
719
|
+
// here, which collapsed .cc-terms to 0 height on that tab while Financing/Leasing rendered a
|
|
720
|
+
// real line, jumping the price row (and everything below it: rating pill, CTA row) up/down on
|
|
721
|
+
// every tab switch. Render an empty, still-present .cc-terms div instead — same fix as the VDP
|
|
722
|
+
// FinanceCalculator's .fin-cond (md3.css), which reserves its line's height the same way.
|
|
723
|
+
if (mode === 'buy') return <div className="cc-terms" />;
|
|
714
724
|
const finFirstInstallment =
|
|
715
725
|
car.finFirstInstallment != null ? car.finFirstInstallment.toLocaleString('de-DE') : _finFirstInstallment;
|
|
716
726
|
const finMonths = car.finMonths ?? _finMonths;
|
package/chrome/TopBar.tsx
CHANGED
|
@@ -170,8 +170,14 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
170
170
|
}) => {
|
|
171
171
|
const [menu, setMenu] = useState(false); // mobile hamburger dropdown
|
|
172
172
|
const [account, setAccount] = useState(false); // account popover
|
|
173
|
+
const [dealersOpen, setDealersOpen] = useState(false); // Konto menu: "Meine Händler" expanded
|
|
173
174
|
const [hidden, setHidden] = useState(false); // autoHideOnScroll: header slid out of view
|
|
174
175
|
|
|
176
|
+
// the dealer list opens collapsed every time the Konto menu opens
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
if (!account) setDealersOpen(false);
|
|
179
|
+
}, [account]);
|
|
180
|
+
|
|
175
181
|
// scroll-direction tracking for autoHideOnScroll — down hides, up shows, and it never hides
|
|
176
182
|
// near the very top (HIDE_AT) so the header doesn't disappear on the first tiny scroll nudge.
|
|
177
183
|
const lastScrollY = useRef(0);
|
|
@@ -228,14 +234,15 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
228
234
|
|
|
229
235
|
/** one Konto-menu row (Figma "acct-row"): 22px icon, label, count badge when above 0. `icon` is a
|
|
230
236
|
* menu glyph; `lucide` is a lib Icon for the guest rows Figma doesn't draw. `checked` (dealer rows)
|
|
231
|
-
* marks the active choice with the same check as the language rows
|
|
237
|
+
* marks the active choice with the same check as the language rows; `nested` rows sit under an
|
|
238
|
+
* expanded row, their label in line with its label. */
|
|
232
239
|
const acctRow = (
|
|
233
240
|
key: string,
|
|
234
241
|
label: string,
|
|
235
242
|
onClick: () => void,
|
|
236
|
-
opts: { icon?: AccountMenuIconName; lucide?: string; badge?: number; checked?: boolean } = {},
|
|
243
|
+
opts: { icon?: AccountMenuIconName; lucide?: string; badge?: number; checked?: boolean; nested?: boolean } = {},
|
|
237
244
|
): JSX.Element => (
|
|
238
|
-
<button key={key} type="button" className=
|
|
245
|
+
<button key={key} type="button" className={opts.nested ? 'acct-row acct-row--nested' : 'acct-row'} onClick={onClick} aria-pressed={opts.checked}>
|
|
239
246
|
{opts.icon && <AccountMenuIcon name={opts.icon} />}
|
|
240
247
|
{opts.lucide && <Icon name={opts.lucide} size={22} stroke={ACCT_ICON_STROKE} cls="acct-icon" />}
|
|
241
248
|
<span className="acct-label">{label}</span>
|
|
@@ -297,15 +304,27 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
|
|
|
297
304
|
<div className="acct-list">
|
|
298
305
|
{isDealer &&
|
|
299
306
|
acctRow('myVehicles', t('autobahn:chrome.myVehicles'), () => goRoute(R_MY_VEHICLES), { lucide: 'car' })}
|
|
307
|
+
{/* ADV-271 (comment of 01.11.2026): one "Meine Händler" row; a click expands the
|
|
308
|
+
dealers to pick from (the active one checked) and collapses them again */}
|
|
300
309
|
{showDealers && (
|
|
301
310
|
<>
|
|
302
|
-
<
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
311
|
+
<button
|
|
312
|
+
type="button"
|
|
313
|
+
className="acct-row"
|
|
314
|
+
aria-expanded={dealersOpen}
|
|
315
|
+
onClick={() => setDealersOpen((open) => !open)}
|
|
316
|
+
>
|
|
317
|
+
<AccountMenuIcon name="store" />
|
|
318
|
+
<span className="acct-label">{t('autobahn:chrome.myDealers')} ({dealers.length})</span>
|
|
319
|
+
<Icon name="chevron-down" size={20} cls={dealersOpen ? 'acct-chevron acct-chevron--open' : 'acct-chevron'} />
|
|
320
|
+
</button>
|
|
321
|
+
{dealersOpen &&
|
|
322
|
+
dealers.map((d) =>
|
|
323
|
+
acctRow(`dealer-${d.dealer.id}`, d.dealer.email, () => {
|
|
324
|
+
setAccount(false);
|
|
325
|
+
if (!d.isActive && onDealerSelect) onDealerSelect(d.dealer.id);
|
|
326
|
+
}, { checked: d.isActive, nested: true }),
|
|
327
|
+
)}
|
|
309
328
|
</>
|
|
310
329
|
)}
|
|
311
330
|
{isDealerOrAdmin &&
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import useModal from './useModal';
|
|
3
3
|
import { updateCookieList } from '../../utils/CommonUtils';
|
|
4
|
+
import { OPEN_COOKIE_SETTINGS_EVENT } from '../../utils/cookieConsent';
|
|
4
5
|
import Modal from './Modal';
|
|
6
|
+
import { TranslationFunction } from '../../types';
|
|
5
7
|
|
|
6
8
|
export interface ICookieModal {
|
|
7
9
|
handleSentryInit?: () => void;
|
|
10
|
+
/** the host's `t` with the `autobahn` namespace (`cookieModal.*`); without it the dialog is German */
|
|
11
|
+
t?: TranslationFunction;
|
|
8
12
|
}
|
|
9
13
|
|
|
10
|
-
const CookieModal = ({ handleSentryInit = () => {} }: ICookieModal) => {
|
|
11
|
-
const { isVisible, toggleModal } = useModal();
|
|
14
|
+
const CookieModal = ({ handleSentryInit = () => {}, t }: ICookieModal) => {
|
|
15
|
+
const { isVisible, toggleModal, openModal } = useModal();
|
|
12
16
|
const [modal, setModal] = useState('');
|
|
13
17
|
|
|
14
18
|
useEffect(
|
|
@@ -22,6 +26,19 @@ const CookieModal = ({ handleSentryInit = () => {} }: ICookieModal) => {
|
|
|
22
26
|
[]
|
|
23
27
|
);
|
|
24
28
|
|
|
29
|
+
// ADV-268: "Cookie-Einstellungen ändern" (account page) reopens the settings dialog
|
|
30
|
+
useEffect(
|
|
31
|
+
() => {
|
|
32
|
+
const onOpenSettings = () => {
|
|
33
|
+
setModal('MANAGE_COOKIE_MODAL');
|
|
34
|
+
openModal();
|
|
35
|
+
};
|
|
36
|
+
window.addEventListener(OPEN_COOKIE_SETTINGS_EVENT, onOpenSettings);
|
|
37
|
+
return () => window.removeEventListener(OPEN_COOKIE_SETTINGS_EVENT, onOpenSettings);
|
|
38
|
+
},
|
|
39
|
+
[]
|
|
40
|
+
);
|
|
41
|
+
|
|
25
42
|
useEffect(
|
|
26
43
|
() => {
|
|
27
44
|
if (!isVisible) return undefined;
|
|
@@ -45,6 +62,7 @@ const CookieModal = ({ handleSentryInit = () => {} }: ICookieModal) => {
|
|
|
45
62
|
? <Modal
|
|
46
63
|
isVisible={isVisible}
|
|
47
64
|
handleSentryInit={handleSentryInit}
|
|
65
|
+
t={t}
|
|
48
66
|
toggleModal={toggleModal}
|
|
49
67
|
name={modal}
|
|
50
68
|
modalProps={modalProps}
|
|
@@ -16,6 +16,7 @@ import * as React from 'react';
|
|
|
16
16
|
import * as ReactDOM from 'react-dom';
|
|
17
17
|
|
|
18
18
|
import ModalsConfig from './ModalsConfig';
|
|
19
|
+
import { TranslationFunction } from '../../types';
|
|
19
20
|
import styles from './Modal.styl';
|
|
20
21
|
|
|
21
22
|
interface IBasicModal {
|
|
@@ -24,6 +25,7 @@ interface IBasicModal {
|
|
|
24
25
|
handleSentryInit?: () => void;
|
|
25
26
|
name: string;
|
|
26
27
|
modalProps?: any;
|
|
28
|
+
t?: TranslationFunction;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
const OVERLAY: React.CSSProperties = {
|
|
@@ -40,16 +42,17 @@ const SURFACE: React.CSSProperties = {
|
|
|
40
42
|
maxWidth: 640, width: '100%', maxHeight: '92vh', overflowY: 'auto'
|
|
41
43
|
};
|
|
42
44
|
|
|
43
|
-
const BasicModal = ({ isVisible, toggleModal, name, modalProps, handleSentryInit }: IBasicModal) => {
|
|
45
|
+
const BasicModal = ({ isVisible, toggleModal, name, modalProps, handleSentryInit, t }: IBasicModal) => {
|
|
44
46
|
if (!isVisible || typeof document === 'undefined') return null;
|
|
47
|
+
const label = t ? t('autobahn:cookieModal.dialogLabel') : '';
|
|
45
48
|
return ReactDOM.createPortal(
|
|
46
49
|
// wrapped in .md3: autobahn.css scopes every token/utility class (incl.
|
|
47
50
|
// .mbtn used by the modal buttons) under `.md3` and intentionally does
|
|
48
51
|
// nothing outside it — a bare document.body portal loses the theme.
|
|
49
52
|
<div className='md3'>
|
|
50
|
-
<div className={styles.overlay} style={OVERLAY} role='dialog' aria-modal='true' aria-label='Cookie-Einstellungen'>
|
|
53
|
+
<div className={styles.overlay} style={OVERLAY} role='dialog' aria-modal='true' aria-label={label && !label.endsWith('cookieModal.dialogLabel') ? label : 'Cookie-Einstellungen'}>
|
|
51
54
|
<div className={styles.surface} style={SURFACE}>
|
|
52
|
-
{ModalsConfig[name] && ModalsConfig[name]({ ...modalProps, toggleModal, handleSentryInit })}
|
|
55
|
+
{ModalsConfig[name] && ModalsConfig[name]({ ...modalProps, toggleModal, handleSentryInit, t })}
|
|
53
56
|
</div>
|
|
54
57
|
</div>
|
|
55
58
|
</div>,
|
|
@@ -8,19 +8,43 @@ import MaterialAccordionGroup from '../../../MdAccordionGroup/MdAccordionGroup';
|
|
|
8
8
|
import MaterialSwitch from '../../../MdSwitch/MdSwitch';
|
|
9
9
|
import { COOKIE_SCHEMA, COOKIE_SCHEMA_LINKS } from '../../../../constants/common';
|
|
10
10
|
import { updateCookieList } from '../../../../utils/CommonUtils';
|
|
11
|
+
import { saveCookieConfig } from '../../../../utils/cookieConsent';
|
|
12
|
+
import { TranslationFunction } from '../../../../types';
|
|
11
13
|
|
|
12
14
|
import styles from './ManageCookieModal.styl';
|
|
13
15
|
|
|
14
16
|
interface IManageCookieModal {
|
|
15
17
|
toggleModal: () => void;
|
|
16
18
|
handleSentryInit?: () => void;
|
|
19
|
+
/** the host's `t` with the `autobahn` namespace loaded; without it the dialog stays German (fe-landing) */
|
|
20
|
+
t?: TranslationFunction;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
interface IMarketingSwitches {
|
|
20
24
|
[key: string]: any;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
// the German copy (locales/de/autobahn.json `cookieModal`), used as is when the host passes no `t`
|
|
28
|
+
const DE: Record<string, string> = {
|
|
29
|
+
title: 'Nach den Cookies geht die Fahrt weiter.',
|
|
30
|
+
manageText: 'Für ein bestmögliches Nutzererlebnis setzen wir Cookies und andere Technologien ein. Diese können Sie hier verwalten.',
|
|
31
|
+
'necessary.title': 'Notwendig',
|
|
32
|
+
'necessary.text': 'Wir verwenden Browser-Cookies, die notwendig sind, damit die Website wie vorgesehen funktioniert. Beispiel: Wir speichern Ihre Präferenzen bei der Datenerfassung auf der Website, damit wir sie berücksichtigen können, wenn Sie auf unsere Website zurückkehren. Sie können diese Cookies in den Einstellungen Ihres Browsers deaktivieren, aber wenn Sie dies tun, funktioniert die Website möglicherweise nicht wie vorgesehen.',
|
|
33
|
+
'analytics.title': 'Analytisch',
|
|
34
|
+
'analytics.text': 'Um das Nutzerverhalten zu verstehen und Ihnen ein relevanteres Surferlebnis zu bieten oder den Inhalt unserer Website zu personalisieren. Beispiel: Wir sammeln Informationen darüber, welche Seiten Sie besuchen, damit wir Ihnen relevantere Informationen präsentieren können.',
|
|
35
|
+
'marketing.title': 'Marketing',
|
|
36
|
+
'marketing.text': 'Zur Personalisierung und Messung der Effektivität von Werbung auf unserer Website und anderen Websites. Beispiel: Wir können Ihnen eine personalisierte Werbung auf der Grundlage der von Ihnen besuchten Seiten auf unserer Website anzeigen.',
|
|
37
|
+
privacyPolicy: 'Datenschutzbestimmungen',
|
|
38
|
+
saveSelection: 'Auswahl speichern',
|
|
39
|
+
acceptAll: 'Alles akzeptieren'
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const ManageCookieModal = ({ toggleModal, handleSentryInit, t } : IManageCookieModal) => {
|
|
43
|
+
// a key the host can't resolve (namespace not loaded) comes back as the key itself
|
|
44
|
+
const tr = (key: string) => {
|
|
45
|
+
const text = t ? t(`autobahn:cookieModal.${key}`) : '';
|
|
46
|
+
return text && !text.endsWith(`cookieModal.${key}`) ? text : DE[key];
|
|
47
|
+
};
|
|
24
48
|
const [analytcisMasterSwitch, setAnalyticsMasterSwitch] = useState(false);
|
|
25
49
|
const [marketingMasterSwitch, setMarketingMasterSwitch] = useState(false);
|
|
26
50
|
const [analyticsSwitches, setAnalyticsSwitches] = useState<IMarketingSwitches>({});
|
|
@@ -44,6 +68,10 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
44
68
|
.reduce((acc, item) => ({ ...acc, [item]: !!savedConfig && !savedDisabledMarketing.includes(item) }), {});
|
|
45
69
|
setAnalyticsSwitches(newAnalyticsSwitches);
|
|
46
70
|
setMarketingSwitches(newMarketingSwitches);
|
|
71
|
+
// ADV-268: reopened from the account page, a category whose cookies are all allowed shows
|
|
72
|
+
// its master switch on (it always started off)
|
|
73
|
+
setAnalyticsMasterSwitch(Object.values(newAnalyticsSwitches).every(Boolean));
|
|
74
|
+
setMarketingMasterSwitch(Object.values(newMarketingSwitches).every(Boolean));
|
|
47
75
|
},
|
|
48
76
|
[]
|
|
49
77
|
);
|
|
@@ -86,7 +114,7 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
86
114
|
marketing: Object.keys(marketingSwitches).filter(i => !marketingSwitches[i]) || [],
|
|
87
115
|
analytics: Object.keys(analyticsSwitches).filter(i => !analyticsSwitches[i]) || []
|
|
88
116
|
};
|
|
89
|
-
|
|
117
|
+
saveCookieConfig(cookieConfig);
|
|
90
118
|
updateCookieList(handleSentryInit);
|
|
91
119
|
toggleModal();
|
|
92
120
|
};
|
|
@@ -110,34 +138,34 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
110
138
|
return (
|
|
111
139
|
<div className={styles.modalWrapper}>
|
|
112
140
|
<IconSVG name='autodeLogo' customDimensions />
|
|
113
|
-
<div className={styles.modalTitle}>
|
|
114
|
-
<div className={styles.modalContent}>
|
|
141
|
+
<div className={styles.modalTitle}>{tr('title')}</div>
|
|
142
|
+
<div className={styles.modalContent}>{tr('manageText')}</div>
|
|
115
143
|
<div className={styles.accordions}>
|
|
116
144
|
<MaterialAccordionGroup
|
|
117
|
-
title='
|
|
145
|
+
title={tr('necessary.title')}
|
|
118
146
|
// tooltipText='Notwendig'
|
|
119
147
|
withSwitch
|
|
120
148
|
switchProps={necessarySwitchProps}
|
|
121
149
|
>
|
|
122
|
-
<span className={styles.accordionDescription}>
|
|
150
|
+
<span className={styles.accordionDescription}>{tr('necessary.text')}</span>
|
|
123
151
|
{Object.keys(COOKIE_SCHEMA.necessary).map(cookie => {
|
|
124
152
|
const getLinkFromCategory = _get(COOKIE_SCHEMA_LINKS, [cookie], '');
|
|
125
153
|
return (
|
|
126
154
|
<div className={styles.switchBlock} key={cookie} >
|
|
127
155
|
<span className={styles.switchBlockTitle}>{cookie}</span>
|
|
128
|
-
<a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>
|
|
156
|
+
<a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>{tr('privacyPolicy')}</a>
|
|
129
157
|
<MaterialSwitch sx={{ marginLeft: 'auto' }} disabled={true} value={true} onChange={() => {}} />
|
|
130
158
|
</div>
|
|
131
159
|
);
|
|
132
160
|
})}
|
|
133
161
|
</MaterialAccordionGroup>
|
|
134
162
|
<MaterialAccordionGroup
|
|
135
|
-
title='
|
|
163
|
+
title={tr('analytics.title')}
|
|
136
164
|
withSwitch
|
|
137
165
|
// tooltipText='Analytisch'
|
|
138
166
|
switchProps={analyticsSwitchProps}
|
|
139
167
|
>
|
|
140
|
-
<span className={styles.accordionDescription}>
|
|
168
|
+
<span className={styles.accordionDescription}>{tr('analytics.text')}</span>
|
|
141
169
|
{Object.keys(COOKIE_SCHEMA.analytics).map(cookie => {
|
|
142
170
|
const getItemsFromCategory = _get(COOKIE_SCHEMA, `analytics['${cookie}']`, null);
|
|
143
171
|
const getLinkFromCategory = _get(COOKIE_SCHEMA_LINKS, [cookie], '');
|
|
@@ -145,7 +173,7 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
145
173
|
return (
|
|
146
174
|
<div className={styles.switchBlock} key={cookie} >
|
|
147
175
|
<span className={styles.switchBlockTitle}>{cookie}</span>
|
|
148
|
-
<a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>
|
|
176
|
+
<a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>{tr('privacyPolicy')}</a>
|
|
149
177
|
<MaterialSwitch
|
|
150
178
|
sx={{ marginLeft: 'auto' }}
|
|
151
179
|
value={isChecked}
|
|
@@ -156,12 +184,12 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
156
184
|
})}
|
|
157
185
|
</MaterialAccordionGroup>
|
|
158
186
|
<MaterialAccordionGroup
|
|
159
|
-
title='
|
|
187
|
+
title={tr('marketing.title')}
|
|
160
188
|
withSwitch
|
|
161
189
|
// tooltipText='Marketing'
|
|
162
190
|
switchProps={marketingSwitchProps}
|
|
163
191
|
>
|
|
164
|
-
<span className={styles.accordionDescription}>
|
|
192
|
+
<span className={styles.accordionDescription}>{tr('marketing.text')}</span>
|
|
165
193
|
{Object.keys(COOKIE_SCHEMA.marketing).map(cookie => {
|
|
166
194
|
const getItemsFromCategory = _get(COOKIE_SCHEMA, `marketing['${cookie}']`, null);
|
|
167
195
|
const getLinkFromCategory = _get(COOKIE_SCHEMA_LINKS, [cookie], '');
|
|
@@ -169,7 +197,7 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
169
197
|
return (
|
|
170
198
|
<div className={styles.switchBlock} key={cookie} >
|
|
171
199
|
<span className={styles.switchBlockTitle}>{cookie}</span>
|
|
172
|
-
<a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>
|
|
200
|
+
<a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>{tr('privacyPolicy')}</a>
|
|
173
201
|
<MaterialSwitch
|
|
174
202
|
sx={{ marginLeft: 'auto' }}
|
|
175
203
|
value={isChecked}
|
|
@@ -181,8 +209,8 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
|
|
|
181
209
|
</MaterialAccordionGroup>
|
|
182
210
|
</div>
|
|
183
211
|
<div className={styles.buttonsContainer}>
|
|
184
|
-
<Button onClick={() => onAccept()} className={classNames(styles.modalBtn, styles.outlinedBtn, styles.zustimmenBtn)} >
|
|
185
|
-
<Button onClick={() => onAccept({ marketing: [], analytics: [] })} className={classNames(styles.modalBtn, styles.zustimmenBtn)}>
|
|
212
|
+
<Button onClick={() => onAccept()} className={classNames(styles.modalBtn, styles.outlinedBtn, styles.zustimmenBtn)} >{tr('saveSelection')}</Button>
|
|
213
|
+
<Button onClick={() => onAccept({ marketing: [], analytics: [] })} className={classNames(styles.modalBtn, styles.zustimmenBtn)}>{tr('acceptAll')}</Button>
|
|
186
214
|
</div>
|
|
187
215
|
</div>
|
|
188
216
|
);
|
|
@@ -3,6 +3,7 @@ import IconSVG from '../../../../iconsvg/IconSVG';
|
|
|
3
3
|
import Button from '../../../Button/Button';
|
|
4
4
|
import styles from './PreviewCookieModal.styl';
|
|
5
5
|
import { updateCookieList } from '../../../../utils/CommonUtils';
|
|
6
|
+
import { saveCookieConfig } from '../../../../utils/cookieConsent';
|
|
6
7
|
import { COOKIE_SCHEMA } from '../../../../constants/common';
|
|
7
8
|
|
|
8
9
|
interface IPreviewCookieModal {
|
|
@@ -14,16 +15,16 @@ interface IPreviewCookieModal {
|
|
|
14
15
|
const PreviewCookieModal = ({ toggleModal, setModal, handleSentryInit } : IPreviewCookieModal) => {
|
|
15
16
|
const environment = window.location.origin;
|
|
16
17
|
const onAcceptAll = () => {
|
|
17
|
-
|
|
18
|
+
saveCookieConfig({ marketing: [], analytics: [] });
|
|
18
19
|
updateCookieList(handleSentryInit);
|
|
19
20
|
toggleModal();
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
const onDisableAll = () => {
|
|
23
|
-
|
|
24
|
+
saveCookieConfig({
|
|
24
25
|
marketing: Object.values(COOKIE_SCHEMA.marketing).reduce((acc: string[], val: string[]) => acc.concat(val), []),
|
|
25
26
|
analytics: Object.values(COOKIE_SCHEMA.analytics).reduce((acc: string[], val: string[]) => acc.concat(val), [])
|
|
26
|
-
})
|
|
27
|
+
});
|
|
27
28
|
updateCookieList(handleSentryInit);
|
|
28
29
|
toggleModal();
|
|
29
30
|
};
|
package/constants/app.ts
CHANGED
|
@@ -40,7 +40,17 @@ export const LOCAL_STORAGE_KEY = {
|
|
|
40
40
|
i18n_KEY: 'i18nLanguage'
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
|
|
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
|
-
|
|
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
|
package/locales/de/autobahn.json
CHANGED
|
@@ -494,7 +494,8 @@
|
|
|
494
494
|
"ratings": "Bewertungen"
|
|
495
495
|
},
|
|
496
496
|
"section": {
|
|
497
|
-
"similar": "Ähnliche Fahrzeuge"
|
|
497
|
+
"similar": "Ähnliche Fahrzeuge",
|
|
498
|
+
"unavailableSimilar": "Ähnliche / vergleichbare Fahrzeuge"
|
|
498
499
|
},
|
|
499
500
|
"breadcrumb": {
|
|
500
501
|
"home": "Start",
|
|
@@ -854,5 +855,25 @@
|
|
|
854
855
|
"captionSlices": "Scheiben",
|
|
855
856
|
"captionSteeringWheel": "Lenkrad",
|
|
856
857
|
"captionWheelsLandingGear": "Räder | Fahrwerk"
|
|
858
|
+
},
|
|
859
|
+
"cookieModal": {
|
|
860
|
+
"dialogLabel": "Cookie-Einstellungen",
|
|
861
|
+
"title": "Nach den Cookies geht die Fahrt weiter.",
|
|
862
|
+
"manageText": "Für ein bestmögliches Nutzererlebnis setzen wir Cookies und andere Technologien ein. Diese können Sie hier verwalten.",
|
|
863
|
+
"necessary": {
|
|
864
|
+
"title": "Notwendig",
|
|
865
|
+
"text": "Wir verwenden Browser-Cookies, die notwendig sind, damit die Website wie vorgesehen funktioniert. Beispiel: Wir speichern Ihre Präferenzen bei der Datenerfassung auf der Website, damit wir sie berücksichtigen können, wenn Sie auf unsere Website zurückkehren. Sie können diese Cookies in den Einstellungen Ihres Browsers deaktivieren, aber wenn Sie dies tun, funktioniert die Website möglicherweise nicht wie vorgesehen."
|
|
866
|
+
},
|
|
867
|
+
"analytics": {
|
|
868
|
+
"title": "Analytisch",
|
|
869
|
+
"text": "Um das Nutzerverhalten zu verstehen und Ihnen ein relevanteres Surferlebnis zu bieten oder den Inhalt unserer Website zu personalisieren. Beispiel: Wir sammeln Informationen darüber, welche Seiten Sie besuchen, damit wir Ihnen relevantere Informationen präsentieren können."
|
|
870
|
+
},
|
|
871
|
+
"marketing": {
|
|
872
|
+
"title": "Marketing",
|
|
873
|
+
"text": "Zur Personalisierung und Messung der Effektivität von Werbung auf unserer Website und anderen Websites. Beispiel: Wir können Ihnen eine personalisierte Werbung auf der Grundlage der von Ihnen besuchten Seiten auf unserer Website anzeigen."
|
|
874
|
+
},
|
|
875
|
+
"privacyPolicy": "Datenschutzbestimmungen",
|
|
876
|
+
"saveSelection": "Auswahl speichern",
|
|
877
|
+
"acceptAll": "Alles akzeptieren"
|
|
857
878
|
}
|
|
858
879
|
}
|
package/locales/en/autobahn.json
CHANGED
|
@@ -494,7 +494,8 @@
|
|
|
494
494
|
"ratings": "Ratings"
|
|
495
495
|
},
|
|
496
496
|
"section": {
|
|
497
|
-
"similar": "Similar vehicles"
|
|
497
|
+
"similar": "Similar vehicles",
|
|
498
|
+
"unavailableSimilar": "Similar / comparable vehicles"
|
|
498
499
|
},
|
|
499
500
|
"breadcrumb": {
|
|
500
501
|
"home": "Home",
|
|
@@ -854,5 +855,25 @@
|
|
|
854
855
|
"captionSlices": "Slices",
|
|
855
856
|
"captionSteeringWheel": "Steering wheel",
|
|
856
857
|
"captionWheelsLandingGear": "Wheels | landing gear"
|
|
858
|
+
},
|
|
859
|
+
"cookieModal": {
|
|
860
|
+
"dialogLabel": "Cookie settings",
|
|
861
|
+
"title": "Cookies first, then we are back on the road.",
|
|
862
|
+
"manageText": "We use cookies and other technologies to give you the best possible experience. You can manage them here.",
|
|
863
|
+
"necessary": {
|
|
864
|
+
"title": "Necessary",
|
|
865
|
+
"text": "We use browser cookies that are necessary for the website to work as intended. Example: we store your data collection preferences on the website so that we can respect them when you return to our website. You can disable these cookies in your browser settings, but if you do, the website may not work as intended."
|
|
866
|
+
},
|
|
867
|
+
"analytics": {
|
|
868
|
+
"title": "Analytics",
|
|
869
|
+
"text": "To understand user behaviour and give you a more relevant browsing experience or personalise the content of our website. Example: we collect information about which pages you visit so that we can show you more relevant information."
|
|
870
|
+
},
|
|
871
|
+
"marketing": {
|
|
872
|
+
"title": "Marketing",
|
|
873
|
+
"text": "To personalise advertising and measure its effectiveness on our website and other websites. Example: we may show you personalised advertising based on the pages you have visited on our website."
|
|
874
|
+
},
|
|
875
|
+
"privacyPolicy": "Privacy policy",
|
|
876
|
+
"saveSelection": "Save selection",
|
|
877
|
+
"acceptAll": "Accept all"
|
|
857
878
|
}
|
|
858
879
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebrand/fe-ui-core-autobahn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.177",
|
|
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",
|
package/theme/md3.css
CHANGED
|
@@ -10100,7 +10100,8 @@ line-height: 31px;
|
|
|
10100
10100
|
z-index: 71;
|
|
10101
10101
|
background: var(--md-surface);
|
|
10102
10102
|
border-radius: var(--md-r-xl) var(--md-r-xl) 0 0;
|
|
10103
|
-
|
|
10103
|
+
/* % 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. */
|
|
10104
|
+
max-height: 92%;
|
|
10104
10105
|
display: flex;
|
|
10105
10106
|
flex-direction: column;
|
|
10106
10107
|
box-shadow: 0 -8px 30px rgba(16, 22, 42, 0.22);
|
|
@@ -10471,11 +10472,18 @@ line-height: 31px;
|
|
|
10471
10472
|
border-radius: 50%;
|
|
10472
10473
|
background: #005cff;
|
|
10473
10474
|
}
|
|
10474
|
-
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
|
|
10475
|
+
/* "Meine Händler": the chevron of the row that expands the dealer list, and the dealer rows under
|
|
10476
|
+
it, their label in line with the row's label (18px inset + 22px icon + 14px gap) */
|
|
10477
|
+
.md3 .acct-chevron {
|
|
10478
|
+
flex: none;
|
|
10478
10479
|
color: #5b6b7f;
|
|
10480
|
+
transition: transform 0.2s ease;
|
|
10481
|
+
}
|
|
10482
|
+
.md3 .acct-chevron--open {
|
|
10483
|
+
transform: rotate(180deg);
|
|
10484
|
+
}
|
|
10485
|
+
.md3 .acct-row--nested {
|
|
10486
|
+
padding-left: 54px;
|
|
10479
10487
|
}
|
|
10480
10488
|
.md3 .acct-cta {
|
|
10481
10489
|
padding: 6px 18px 4px;
|
|
@@ -14251,7 +14259,8 @@ color: #005CFF;
|
|
|
14251
14259
|
flex-direction: column;
|
|
14252
14260
|
width: 100%;
|
|
14253
14261
|
max-width: 560px;
|
|
14254
|
-
|
|
14262
|
+
/* % of the scrim (fixed, inset 0, 16px padding) instead of calc(100vh - 32px): see the iOS note on the mobile .mmodal below */
|
|
14263
|
+
max-height: 100%;
|
|
14255
14264
|
background: var(--md-sc-lowest, #fff);
|
|
14256
14265
|
color: var(--md-on-surface);
|
|
14257
14266
|
border-radius: var(--md-r-lg);
|
|
@@ -14397,7 +14406,8 @@ color: #005CFF;
|
|
|
14397
14406
|
}
|
|
14398
14407
|
.md3 .mmodal {
|
|
14399
14408
|
max-width: 100%;
|
|
14400
|
-
|
|
14409
|
+
/* % 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. */
|
|
14410
|
+
max-height: 92%;
|
|
14401
14411
|
border-radius: var(--md-r-lg) var(--md-r-lg) 0 0;
|
|
14402
14412
|
border-bottom: 0;
|
|
14403
14413
|
animation: mmodal-sheet-up 0.25s ease-out;
|
package/ui/Dropdown.tsx
CHANGED
|
@@ -22,6 +22,7 @@ import * as ReactDOM from 'react-dom';
|
|
|
22
22
|
|
|
23
23
|
import Icon from './Icon';
|
|
24
24
|
import { usePortalMenuPosition } from './usePortalMenuPosition';
|
|
25
|
+
import { scrollFieldIntoView } from './scrollFieldIntoView';
|
|
25
26
|
|
|
26
27
|
export interface DropdownOption {
|
|
27
28
|
value: string;
|
|
@@ -189,15 +190,22 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
189
190
|
if (allowCustomValue) setQuery(value || '');
|
|
190
191
|
}, [disabled, selectedIndex, allowCustomValue, value]);
|
|
191
192
|
|
|
192
|
-
//
|
|
193
|
-
//
|
|
194
|
-
//
|
|
195
|
-
//
|
|
193
|
+
// Scroll the trigger (searchable or not) to the top of the page on open, THEN — searchable
|
|
194
|
+
// only — focus the search input instead of leaving focus on the trigger. Every Dropdown shares
|
|
195
|
+
// this, not just searchable ones: on mobile a trigger sitting mid-page can open a menu that
|
|
196
|
+
// runs off the bottom of the viewport with no way to see the rest of it, same underlying
|
|
197
|
+
// problem a searchable trigger has with the keyboard eating the space below it. A plain
|
|
198
|
+
// `scrollIntoView({block:'center'})` used to run here (searchable-only) — "center" only moves
|
|
199
|
+
// the trigger when it's already near a viewport edge, so on a trigger that's roughly mid-page
|
|
200
|
+
// already (the common case) it was a near no-op, leaving a few hundred px of dead space above
|
|
201
|
+
// the trigger that the keyboard (searchable) or the menu's own bottom edge (any dropdown) then
|
|
202
|
+
// ran into.
|
|
196
203
|
React.useEffect(() => {
|
|
197
|
-
if (!open
|
|
198
|
-
if (rootRef.current
|
|
199
|
-
|
|
200
|
-
|
|
204
|
+
if (!open) return;
|
|
205
|
+
if (rootRef.current) scrollFieldIntoView(rootRef.current);
|
|
206
|
+
// searchRef is only ever attached in the searchable+open (editing) render branch, so this
|
|
207
|
+
// naturally no-ops for a non-searchable dropdown — nothing else to focus there, the trigger
|
|
208
|
+
// <button> already has focus from the click/keypress that opened it.
|
|
201
209
|
if (searchRef.current) {
|
|
202
210
|
searchRef.current.focus();
|
|
203
211
|
// pre-filled custom value (see openMenu) starts selected, so typing immediately
|
package/ui/index.ts
CHANGED
|
@@ -39,6 +39,8 @@ export type { FormFieldProps } from './FormField';
|
|
|
39
39
|
export { default as Dropdown } from './Dropdown';
|
|
40
40
|
export type { DropdownProps, DropdownOption } from './Dropdown';
|
|
41
41
|
|
|
42
|
+
export { scrollFieldIntoView } from './scrollFieldIntoView';
|
|
43
|
+
|
|
42
44
|
export { default as Spec } from './Spec';
|
|
43
45
|
export type { SpecProps } from './Spec';
|
|
44
46
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Autobahn (auto.de redesign) — shared "scroll a just-opened/just-focused field to the top of the
|
|
2
|
+
// page" behaviour, used by Dropdown.tsx and by fe-main's DualRange/RateSlider (FilterContent.tsx)
|
|
3
|
+
// text fields on /search/detailed. On mobile, opening a dropdown's menu or focusing a text field
|
|
4
|
+
// brings the on-screen keyboard up and/or needs room for a popover below the field — if the field
|
|
5
|
+
// is sitting mid-page, there may not be enough space left below it once the keyboard/menu takes
|
|
6
|
+
// its share. Scrolling the field to the very top of the page first maximizes what's available.
|
|
7
|
+
//
|
|
8
|
+
// Extracted out of Dropdown.tsx so it can be shared verbatim with fe-main's non-Dropdown form
|
|
9
|
+
// fields (DualRange/RateSlider's text inputs) — same problem, same fix, one place to keep them
|
|
10
|
+
// from drifting apart. See Dropdown.tsx's own call site for the original reasoning this was
|
|
11
|
+
// pulled from.
|
|
12
|
+
export function scrollFieldIntoView(field: HTMLElement): void {
|
|
13
|
+
if (typeof window === 'undefined') return;
|
|
14
|
+
// Mobile-only: the on-screen-keyboard/popover space problem this fixes doesn't exist on
|
|
15
|
+
// desktop, where there's no keyboard pushing the viewport around. Same breakpoint + matchMedia
|
|
16
|
+
// pattern as Modal.tsx/CardCarousel.tsx elsewhere in this lib.
|
|
17
|
+
if (window.matchMedia('(min-width: 601px)').matches) return;
|
|
18
|
+
// Anchor on whichever is higher up: the field itself, or a short field label/caption sitting
|
|
19
|
+
// directly above it (own previous sibling, or — the common "label above a row of controls"
|
|
20
|
+
// shape, e.g. "Marke & Modell" above the Make/Model row on /search/detailed — the wrapping
|
|
21
|
+
// row's previous sibling). Checked by height, not by class name, so this works for ANY
|
|
22
|
+
// caller's label without this needing to know that call site's specific markup.
|
|
23
|
+
const MAX_LABEL_HEIGHT = 30;
|
|
24
|
+
const asLabel = (el: Element | null): HTMLElement | null => {
|
|
25
|
+
if (!(el instanceof HTMLElement)) return null;
|
|
26
|
+
const h = el.getBoundingClientRect().height;
|
|
27
|
+
return h > 0 && h <= MAX_LABEL_HEIGHT ? el : null;
|
|
28
|
+
};
|
|
29
|
+
const anchor =
|
|
30
|
+
asLabel(field.previousElementSibling) ||
|
|
31
|
+
asLabel(field.parentElement && field.parentElement.previousElementSibling) ||
|
|
32
|
+
field;
|
|
33
|
+
// No sticky-header reservation here: every current caller (NewMainPage '/', FilterContent on
|
|
34
|
+
// '/search*') sits on a page where TopBar's own autoHideOnScroll is on (App.tsx: isHomePage ||
|
|
35
|
+
// isSearchPage) — the header slides itself out of the way the instant this scroll starts,
|
|
36
|
+
// independently of this call, so reserving space for it here would double-count.
|
|
37
|
+
const GAP = 8;
|
|
38
|
+
const rect = anchor.getBoundingClientRect();
|
|
39
|
+
const targetY = window.scrollY + rect.top - GAP;
|
|
40
|
+
window.scrollTo({ top: Math.max(0, targetY), behavior: 'smooth' });
|
|
41
|
+
}
|
|
@@ -76,9 +76,26 @@ export interface UsePortalMenuPositionResult<TMenuEl extends HTMLElement = HTMLD
|
|
|
76
76
|
// reasonable estimate; it decides whether to flip ABOVE the trigger. The real size is then
|
|
77
77
|
// clamped to the space actually available (see `maxHeight` above), not just guessed at.
|
|
78
78
|
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;
|
|
79
82
|
// a scroll within this window of opening REPOSITIONS instead of closing — see the effect below.
|
|
80
83
|
const SELF_SCROLL_GRACE_MS = 500;
|
|
81
84
|
|
|
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
|
+
|
|
82
99
|
export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivElement>({
|
|
83
100
|
enabled,
|
|
84
101
|
open,
|
|
@@ -121,18 +138,6 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
121
138
|
};
|
|
122
139
|
}, [enabled, open, portalRoot]);
|
|
123
140
|
|
|
124
|
-
// the portal menu's z-index (1400, .mselect-menu--portal) is intentionally higher than every
|
|
125
|
-
// other fixed overlay it must paint over (checkout sheets/modals) — which also means it would
|
|
126
|
-
// paint over the sticky app header (.topbar, position:sticky/top:0/z-index:50) if left
|
|
127
|
-
// unconstrained. Reading the header's live bottom edge (0 when absent, e.g. inside a modal, or
|
|
128
|
-
// when TopBar's autoHideOnScroll has slid it away) gives a correct top boundary without
|
|
129
|
-
// hardcoding a pixel height that could drift from the header's own CSS.
|
|
130
|
-
const getSafeTop = (): number => {
|
|
131
|
-
if (typeof document === 'undefined') return 0;
|
|
132
|
-
const header = document.querySelector('.topbar');
|
|
133
|
-
return header ? Math.max(0, header.getBoundingClientRect().bottom) : 0;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
141
|
const [menuPos, setMenuPos] = React.useState<PortalMenuPos | null>(null);
|
|
137
142
|
|
|
138
143
|
const positionMenu = React.useCallback(() => {
|
|
@@ -156,7 +161,8 @@ export function usePortalMenuPosition<TMenuEl extends HTMLElement = HTMLDivEleme
|
|
|
156
161
|
// cap can still be taller than what's really available, which is what let the menu paint over
|
|
157
162
|
// the header in the first place. The consumer's own overflow-y:auto takes it from there once
|
|
158
163
|
// content exceeds this.
|
|
159
|
-
|
|
164
|
+
// `available` is the LIST's height: the box (list + MENU_CHROME) must end inside the viewport.
|
|
165
|
+
const available = Math.max(120, Math.min(ESTIMATED_MENU_HEIGHT - 12, (openAbove ? spaceAbove : spaceBelow) - MENU_CHROME));
|
|
160
166
|
setMenuPos({
|
|
161
167
|
width: rect.width,
|
|
162
168
|
left: menuAlign === 'right' ? 'auto' : rect.left,
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// ADV-268 — the cookie consent store (`localStorage['cookieConfig']`: per category the DISABLED
|
|
2
|
+
// vendor-cookie names, see COOKIE_SCHEMA) plus what the account page needs on top of it:
|
|
3
|
+
// - when the choice last changed (`cookieConfigChangedAt`, ISO), written on every save that
|
|
4
|
+
// changes it — the consent dialogs save through saveCookieConfig;
|
|
5
|
+
// - a window event after each save, so a page showing the state can update live;
|
|
6
|
+
// - openCookieSettings(), which makes the mounted CookieModal show its settings dialog again.
|
|
7
|
+
// Storage access is guarded: with site storage blocked every read returns "no choice yet".
|
|
8
|
+
|
|
9
|
+
import { COOKIE_SCHEMA } from '../constants/common';
|
|
10
|
+
|
|
11
|
+
export const COOKIE_CONFIG_KEY = 'cookieConfig';
|
|
12
|
+
export const COOKIE_CONFIG_CHANGED_AT_KEY = 'cookieConfigChangedAt';
|
|
13
|
+
export const COOKIE_CONSENT_CHANGE_EVENT = 'autode:cookie-consent-change';
|
|
14
|
+
export const OPEN_COOKIE_SETTINGS_EVENT = 'autode:open-cookie-settings';
|
|
15
|
+
|
|
16
|
+
export interface ICookieConfig {
|
|
17
|
+
marketing: string[];
|
|
18
|
+
analytics: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type CookieCategoryState = 'on' | 'partial' | 'off';
|
|
22
|
+
|
|
23
|
+
export interface ICookieConsentState {
|
|
24
|
+
/** false until the visitor saved a choice in the cookie dialog */
|
|
25
|
+
decided: boolean;
|
|
26
|
+
/** ISO date of the last change, null when unknown (no choice yet, or saved before it was recorded) */
|
|
27
|
+
changedAt: string | null;
|
|
28
|
+
analytics: CookieCategoryState;
|
|
29
|
+
marketing: CookieCategoryState;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const vendorCookies = (category: 'analytics' | 'marketing'): string[] =>
|
|
33
|
+
Object.values(COOKIE_SCHEMA[category]).reduce((acc: string[], val: string[]) => acc.concat(val), []);
|
|
34
|
+
|
|
35
|
+
const readStorage = (key: string): string | null => {
|
|
36
|
+
try {
|
|
37
|
+
return localStorage.getItem(key);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const saveCookieConfig = (config: ICookieConfig | Record<string, string[]>) => {
|
|
44
|
+
const next = JSON.stringify(config);
|
|
45
|
+
try {
|
|
46
|
+
const previous = localStorage.getItem(COOKIE_CONFIG_KEY);
|
|
47
|
+
localStorage.setItem(COOKIE_CONFIG_KEY, next);
|
|
48
|
+
if (previous !== next || !localStorage.getItem(COOKIE_CONFIG_CHANGED_AT_KEY)) {
|
|
49
|
+
localStorage.setItem(COOKIE_CONFIG_CHANGED_AT_KEY, new Date().toISOString());
|
|
50
|
+
}
|
|
51
|
+
} catch (e) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
window.dispatchEvent(new Event(COOKIE_CONSENT_CHANGE_EVENT));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const getCookieConsentState = (): ICookieConsentState => {
|
|
58
|
+
let config: Partial<ICookieConfig> | null = null;
|
|
59
|
+
try {
|
|
60
|
+
config = JSON.parse(readStorage(COOKIE_CONFIG_KEY));
|
|
61
|
+
} catch (e) {
|
|
62
|
+
config = null;
|
|
63
|
+
}
|
|
64
|
+
if (!config) return { decided: false, changedAt: null, analytics: 'off', marketing: 'off' };
|
|
65
|
+
|
|
66
|
+
const categoryState = (category: 'analytics' | 'marketing'): CookieCategoryState => {
|
|
67
|
+
const disabled = Array.isArray(config[category]) ? config[category] : [];
|
|
68
|
+
const all = vendorCookies(category);
|
|
69
|
+
const allowed = all.filter((cookie) => !disabled.includes(cookie)).length;
|
|
70
|
+
if (allowed === all.length) return 'on';
|
|
71
|
+
return allowed ? 'partial' : 'off';
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
decided: true,
|
|
76
|
+
changedAt: readStorage(COOKIE_CONFIG_CHANGED_AT_KEY),
|
|
77
|
+
analytics: categoryState('analytics'),
|
|
78
|
+
marketing: categoryState('marketing')
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const openCookieSettings = () => {
|
|
83
|
+
window.dispatchEvent(new Event(OPEN_COOKIE_SETTINGS_EVENT));
|
|
84
|
+
};
|
package/utils/index.ts
CHANGED
|
@@ -62,6 +62,14 @@ 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
|
+
|
|
65
73
|
export { getEquipment, getEquipmentCount } from '../vehiclesProps/equipment';
|
|
66
74
|
|
|
67
75
|
export type { IDecoratedProps, IEquipmentProps, ICarPropElement } from '../types/types';
|