@bytebrand/fe-ui-core-autobahn 1.0.228 → 1.0.231
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/campaign/CampaignBand.tsx +26 -26
- package/campaign/CampaignBanner.tsx +86 -0
- package/campaign/CampaignBar.tsx +37 -0
- package/campaign/CampaignHero.tsx +56 -0
- package/campaign/CampaignSwitch.tsx +43 -0
- package/campaign/campaignVars.ts +12 -12
- package/campaign/campaigns.ts +77 -74
- package/campaign/index.ts +18 -6
- package/campaign/openInApp.ts +8 -0
- package/campaign/useCountdown.ts +28 -0
- package/cards/CarCard.tsx +407 -393
- package/cards/CarCardSkeleton.tsx +103 -0
- package/cards/CarRow.tsx +46 -22
- package/cards/CarRowSkeleton.tsx +152 -0
- package/cards/cardParts.tsx +53 -18
- package/cards/dealSignals.ts +36 -36
- package/cards/index.ts +6 -0
- package/chrome/AccountMenuIcon.tsx +109 -0
- package/chrome/Footer.tsx +16 -3
- package/chrome/TopBar.tsx +139 -266
- package/compat/CookieModal/CookieModal.tsx +20 -6
- 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/compat/Loader/Loader.tsx +1 -7
- package/compat/MdField/MdField.tsx +28 -4
- package/compat/PriceRating/PriceRating.styl +5 -7
- package/compat/PriceRatingDetailed/PriceRatingDetailed.styl +8 -6
- package/compat/TimePicker/TimePicker.tsx +12 -2
- package/compat/legacy-theme/priceReviewColors.styl +18 -5
- package/constants/autobahn.ts +39 -0
- package/data/fieldMapping.ts +3 -3
- package/data/toAutobahnCar.ts +30 -14
- package/iconsvg/IconSVG.tsx +1 -5
- package/index.ts +19 -19
- package/locales/de/autobahn.json +925 -862
- package/locales/en/autobahn.json +925 -862
- package/package.json +2 -2
- package/theme/md3.css +16518 -11808
- package/ui/Dropdown.tsx +29 -10
- package/ui/FormCheckbox.tsx +22 -2
- package/ui/FormField.tsx +2 -1
- package/ui/Icon.tsx +6 -0
- package/ui/MfieldCheckIcon.tsx +13 -0
- package/ui/Modal.tsx +84 -6
- package/ui/Skeleton.tsx +79 -20
- package/ui/Stars.tsx +36 -18
- package/ui/StatChip.tsx +8 -3
- package/ui/index.ts +3 -0
- package/ui/ratingLink.ts +36 -0
- package/ui/scrollFieldIntoView.ts +41 -0
- package/ui/usePortalMenuPosition.ts +27 -15
- package/utils/cookieConsent.ts +84 -0
- package/utils/index.ts +10 -0
- package/vdp/FinanceCalculator.tsx +162 -34
- package/vdp/VdpModules.tsx +348 -976
- package/vdp/index.ts +6 -3
- package/vdp/types.ts +25 -15
- package/vehiclesProps/accidentDisclosure.ts +25 -0
- package/vehiclesProps/decoratedLightProps.tsx +4 -0
- package/vehiclesProps/decoratedProps.tsx +4 -0
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;
|
|
@@ -59,8 +60,16 @@ export interface DropdownProps {
|
|
|
59
60
|
ariaDescribedBy?: string;
|
|
60
61
|
/** extra class on the wrapper (e.g. 'srp-sort' for width rules). */
|
|
61
62
|
className?: string;
|
|
63
|
+
/** extra class on the popover menu itself (`.mselect-menu`) — separate from `className` since
|
|
64
|
+
* with `menuPortal` the menu renders at document.body, outside the trigger wrapper's subtree,
|
|
65
|
+
* so a caller that needs to style its OWN options (`.mselect-opt`) needs this to scope there. */
|
|
66
|
+
menuClassName?: string;
|
|
62
67
|
/** align the popover to the right edge of the trigger (default left). */
|
|
63
68
|
menuAlign?: 'left' | 'right';
|
|
69
|
+
/** with `menuPortal`: 'auto' (default) flips the popover above the trigger when there's no
|
|
70
|
+
* room below; 'down' always opens below, never flips — for a trigger where an upward flip
|
|
71
|
+
* would overlap unrelated content above it. */
|
|
72
|
+
menuOpenDirection?: 'auto' | 'down';
|
|
64
73
|
/** show a text input at the top of the popover that filters `options` by label (substring, case-insensitive). */
|
|
65
74
|
searchable?: boolean;
|
|
66
75
|
/** placeholder for the search input (only used when `searchable`). */
|
|
@@ -97,7 +106,9 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
97
106
|
ariaInvalid,
|
|
98
107
|
ariaDescribedBy,
|
|
99
108
|
className,
|
|
109
|
+
menuClassName,
|
|
100
110
|
menuAlign = 'left',
|
|
111
|
+
menuOpenDirection = 'auto',
|
|
101
112
|
searchable = false,
|
|
102
113
|
searchPlaceholder,
|
|
103
114
|
numeric = false,
|
|
@@ -179,15 +190,22 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
179
190
|
if (allowCustomValue) setQuery(value || '');
|
|
180
191
|
}, [disabled, selectedIndex, allowCustomValue, value]);
|
|
181
192
|
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
//
|
|
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.
|
|
186
203
|
React.useEffect(() => {
|
|
187
|
-
if (!open
|
|
188
|
-
if (rootRef.current
|
|
189
|
-
|
|
190
|
-
|
|
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.
|
|
191
209
|
if (searchRef.current) {
|
|
192
210
|
searchRef.current.focus();
|
|
193
211
|
// pre-filled custom value (see openMenu) starts selected, so typing immediately
|
|
@@ -221,6 +239,7 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
221
239
|
open,
|
|
222
240
|
rootRef,
|
|
223
241
|
menuAlign,
|
|
242
|
+
openDirection: menuOpenDirection,
|
|
224
243
|
onCloseAway,
|
|
225
244
|
});
|
|
226
245
|
|
|
@@ -400,7 +419,7 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
400
419
|
? ReactDOM.createPortal(
|
|
401
420
|
<div
|
|
402
421
|
ref={menuElRef}
|
|
403
|
-
className={'mselect-menu mselect-menu--portal' + (searchable ? ' mselect-menu--searchable' : '')}
|
|
422
|
+
className={'mselect-menu mselect-menu--portal' + (searchable ? ' mselect-menu--searchable' : '') + (menuClassName ? ` ${menuClassName}` : '')}
|
|
404
423
|
// menuPos is null for one frame on open, before the position effect has measured
|
|
405
424
|
// the trigger — stay invisible (not just visually, via `visibility`) rather than
|
|
406
425
|
// flash at (0,0)/full-width. `position: fixed` is set UNCONDITIONALLY, in both
|
|
@@ -453,7 +472,7 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
453
472
|
: (
|
|
454
473
|
<div
|
|
455
474
|
ref={menuElRef}
|
|
456
|
-
className={'mselect-menu' + (menuAlign === 'right' ? ' mselect-menu--right' : '') + (searchable ? ' mselect-menu--searchable' : '')}
|
|
475
|
+
className={'mselect-menu' + (menuAlign === 'right' ? ' mselect-menu--right' : '') + (searchable ? ' mselect-menu--searchable' : '') + (menuClassName ? ` ${menuClassName}` : '')}
|
|
457
476
|
>
|
|
458
477
|
{renderMenuList()}
|
|
459
478
|
</div>
|
package/ui/FormCheckbox.tsx
CHANGED
|
@@ -36,12 +36,23 @@ export interface FormCheckboxProps {
|
|
|
36
36
|
/** override the field's own disabled flag. */
|
|
37
37
|
disabled?: boolean;
|
|
38
38
|
id?: string;
|
|
39
|
+
/** show a small alert-circle glyph before the error text (Figma 64670:106293's "Fehlermeldung"
|
|
40
|
+
* row) — opt-in, defaults off so every other FormCheckbox caller keeps its plain text-only
|
|
41
|
+
* error message unchanged. */
|
|
42
|
+
errorIcon?: boolean;
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
const FormCheckbox: React.FunctionComponent<FormCheckboxProps> = observer(
|
|
42
|
-
({ field, t, label, children, disabled, id }) => {
|
|
46
|
+
({ field, t, label, children, disabled, id, errorIcon }) => {
|
|
43
47
|
const isChecked = !!field.checked;
|
|
44
48
|
const isDisabled = disabled != null ? disabled : !!field.disabled;
|
|
49
|
+
// field.hasError alone is a LIVE check (mobx-react-form's Field#hasError getter re-evaluates
|
|
50
|
+
// the rule against the current value on every read) — true for an unchecked required field
|
|
51
|
+
// from initial render, before the user ever interacts. field.error is what's actually gated
|
|
52
|
+
// behind the field's showError flag (Field#error getter), which only flips true once
|
|
53
|
+
// showErrors()/an explicit validate({showErrors:true}) runs — the real "has this been
|
|
54
|
+
// submitted/touched" signal. Keep requiring both, or every required checkbox on the site
|
|
55
|
+
// renders red on page load.
|
|
45
56
|
const hasError = !!field.hasError && !!field.error;
|
|
46
57
|
|
|
47
58
|
// children (rich) > explicit label > translated field.label (legacy CheckboxMaterial behaviour).
|
|
@@ -70,7 +81,16 @@ const FormCheckbox: React.FunctionComponent<FormCheckboxProps> = observer(
|
|
|
70
81
|
</span>
|
|
71
82
|
{content != null ? <span className="mcheck-label">{content}</span> : null}
|
|
72
83
|
</label>
|
|
73
|
-
{hasError ?
|
|
84
|
+
{hasError ? (
|
|
85
|
+
errorIcon ? (
|
|
86
|
+
<span className="mcheck-error-text mcheck-error-text--icon">
|
|
87
|
+
<Icon name="alert-circle" size={16} stroke={2} cls="mcheck-error-icon" />
|
|
88
|
+
<span className="mcheck-error-msg">{field.error}</span>
|
|
89
|
+
</span>
|
|
90
|
+
) : (
|
|
91
|
+
<span className="mcheck-error-text">{field.error}</span>
|
|
92
|
+
)
|
|
93
|
+
) : null}
|
|
74
94
|
</div>
|
|
75
95
|
);
|
|
76
96
|
},
|
package/ui/FormField.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import * as React from 'react';
|
|
|
12
12
|
import { observer } from 'mobx-react';
|
|
13
13
|
|
|
14
14
|
import Icon from './Icon';
|
|
15
|
+
import MfieldCheckIcon from './MfieldCheckIcon';
|
|
15
16
|
|
|
16
17
|
export interface FormFieldProps {
|
|
17
18
|
/** mobx-react-form field (LoginForm.$('email') etc.). Typed any — the lib ships no TS types. */
|
|
@@ -82,7 +83,7 @@ const FormField: React.FunctionComponent<FormFieldProps> = observer(
|
|
|
82
83
|
<Icon name={reveal ? 'eye-off' : 'eye'} size={18} />
|
|
83
84
|
</button>
|
|
84
85
|
) : null}
|
|
85
|
-
{isValid ? <span className="mfield-ok"><
|
|
86
|
+
{isValid ? <span className="mfield-ok"><MfieldCheckIcon /></span> : null}
|
|
86
87
|
</div>
|
|
87
88
|
{hasError ? <span className="mfield-error-text">{field.error}</span> : null}
|
|
88
89
|
</div>
|
package/ui/Icon.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Activity,
|
|
4
|
+
AlertCircle,
|
|
4
5
|
Apple,
|
|
5
6
|
Armchair,
|
|
6
7
|
ArrowLeft,
|
|
@@ -51,11 +52,13 @@ import {
|
|
|
51
52
|
DoorOpen,
|
|
52
53
|
Droplet,
|
|
53
54
|
Euro,
|
|
55
|
+
ExternalLink,
|
|
54
56
|
Eye,
|
|
55
57
|
EyeOff,
|
|
56
58
|
Facebook,
|
|
57
59
|
File,
|
|
58
60
|
FileCheck,
|
|
61
|
+
FileSignature,
|
|
59
62
|
FileText,
|
|
60
63
|
Flame,
|
|
61
64
|
Fuel,
|
|
@@ -198,6 +201,7 @@ function toPascalCase(name: string): string {
|
|
|
198
201
|
*/
|
|
199
202
|
const REGISTRY: Record<string, React.ComponentType<LucideProps>> = {
|
|
200
203
|
Activity,
|
|
204
|
+
AlertCircle,
|
|
201
205
|
Apple,
|
|
202
206
|
Armchair,
|
|
203
207
|
ArrowLeft,
|
|
@@ -249,11 +253,13 @@ const REGISTRY: Record<string, React.ComponentType<LucideProps>> = {
|
|
|
249
253
|
DoorOpen,
|
|
250
254
|
Droplet,
|
|
251
255
|
Euro,
|
|
256
|
+
ExternalLink,
|
|
252
257
|
Eye,
|
|
253
258
|
EyeOff,
|
|
254
259
|
Facebook,
|
|
255
260
|
File,
|
|
256
261
|
FileCheck,
|
|
262
|
+
FileSignature,
|
|
257
263
|
FileText,
|
|
258
264
|
Flame,
|
|
259
265
|
Fuel,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
// Figma-exact valid-field checkmark (.mfield-ok, FormField/MdField's showValid) — a distinct
|
|
4
|
+
// path/stroke from the generic lucide Check that Icon name="check" renders elsewhere, so it's
|
|
5
|
+
// its own tiny component rather than a REGISTRY entry in Icon.tsx (which would change every
|
|
6
|
+
// other "check" usage in the app too).
|
|
7
|
+
const MfieldCheckIcon: React.FunctionComponent = () => (
|
|
8
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
9
|
+
<path d="M13.3334 4L6.00002 11.3333L2.66669 8" stroke="#168A45" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" />
|
|
10
|
+
</svg>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export default MfieldCheckIcon;
|
package/ui/Modal.tsx
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
// - scrim ~50% black; body scroll-locked while open; basic focus trap (Tab/Shift+Tab
|
|
16
16
|
// cycle within the surface, focus moves into the dialog on open and is restored to the
|
|
17
17
|
// previously-focused element on close).
|
|
18
|
+
// - mobile bottom sheet (≤560px): swipe down on the head row to dismiss (mirrors fe-main's
|
|
19
|
+
// BaseModal.tsx sheet), when dismissOnScrim is true.
|
|
18
20
|
// - a11y: role=dialog, aria-modal, aria-labelledby wired to the title when present.
|
|
19
21
|
//
|
|
20
22
|
// Pure/presentational — no store/API access beyond document/body (all SSR-guarded). The
|
|
@@ -44,6 +46,13 @@ export interface ModalProps {
|
|
|
44
46
|
dismissOnScrim?: boolean;
|
|
45
47
|
/** extra class(es) appended on the surface (layout hooks). */
|
|
46
48
|
className?: string;
|
|
49
|
+
/** custom close-button content, replacing the default IconButton(name="x"). When set, it
|
|
50
|
+
* renders as a plain button.mmodal-close instead (own CSS handles sizing/position — see
|
|
51
|
+
* md3.css), so callers with a specific close-icon spec (exact asset, absolute position
|
|
52
|
+
* independent of title height) aren't stuck fighting the default's flex layout. */
|
|
53
|
+
closeIcon?: React.ReactNode;
|
|
54
|
+
/** optional extra header button rendered before the close button (e.g. a download action). */
|
|
55
|
+
headerAction?: React.ReactNode;
|
|
47
56
|
}
|
|
48
57
|
|
|
49
58
|
// focusable descendants used by the basic focus trap.
|
|
@@ -59,10 +68,48 @@ const Modal: React.FunctionComponent<ModalProps> = ({
|
|
|
59
68
|
size = 'md',
|
|
60
69
|
dismissOnScrim = true,
|
|
61
70
|
className,
|
|
71
|
+
closeIcon,
|
|
72
|
+
headerAction,
|
|
62
73
|
}) => {
|
|
63
74
|
const surfaceRef = React.useRef<HTMLDivElement | null>(null);
|
|
64
75
|
// the element focused before the dialog opened, so focus can be restored on close.
|
|
65
76
|
const prevFocusRef = React.useRef<HTMLElement | null>(null);
|
|
77
|
+
// swipe-down-to-dismiss on the mobile bottom sheet (≤560px, matching the .mmodal-scrim/
|
|
78
|
+
// .mmodal breakpoint in md3.css) — same imperative-transform pattern as fe-main's
|
|
79
|
+
// BaseModal.tsx (checkout's own bottom sheet): follows the finger directly via
|
|
80
|
+
// style.transform while dragging (no re-renders), released past 90px slides out and closes,
|
|
81
|
+
// otherwise springs back. No-ops above the breakpoint and when dismissOnScrim is false (a
|
|
82
|
+
// modal that can't be scrim-dismissed shouldn't be swipe-dismissable either).
|
|
83
|
+
const dragStartY = React.useRef<number | null>(null);
|
|
84
|
+
|
|
85
|
+
const onGrabStart = (event: React.TouchEvent) => {
|
|
86
|
+
if (!dismissOnScrim) return;
|
|
87
|
+
if (typeof window !== 'undefined' && window.matchMedia('(min-width: 561px)').matches) return;
|
|
88
|
+
dragStartY.current = event.touches[0].clientY;
|
|
89
|
+
if (surfaceRef.current) surfaceRef.current.style.transition = 'none';
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const onGrabMove = (event: React.TouchEvent) => {
|
|
93
|
+
if (dragStartY.current == null || !surfaceRef.current) return;
|
|
94
|
+
const dy = event.touches[0].clientY - dragStartY.current;
|
|
95
|
+
// only follow downward drags — the sheet is already flush with the bottom of the
|
|
96
|
+
// viewport, so upward has nowhere to go.
|
|
97
|
+
surfaceRef.current.style.transform = dy > 0 ? `translateY(${dy}px)` : '';
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const onGrabEnd = (event: React.TouchEvent) => {
|
|
101
|
+
if (dragStartY.current == null || !surfaceRef.current) return;
|
|
102
|
+
const dy = event.changedTouches[0].clientY - dragStartY.current;
|
|
103
|
+
dragStartY.current = null;
|
|
104
|
+
const el = surfaceRef.current;
|
|
105
|
+
el.style.transition = 'transform 0.2s ease-out';
|
|
106
|
+
if (dy > 90) {
|
|
107
|
+
el.style.transform = 'translateY(100%)';
|
|
108
|
+
window.setTimeout(onClose, 200);
|
|
109
|
+
} else {
|
|
110
|
+
el.style.transform = '';
|
|
111
|
+
}
|
|
112
|
+
};
|
|
66
113
|
// stable id for aria-labelledby (avoids Math.random/Date.now, unavailable in this env).
|
|
67
114
|
const titleId = React.useMemo(
|
|
68
115
|
() => (title ? `mmodal-title-${Math.round((surfaceRef.current ? 1 : 0))}-${size}` : undefined),
|
|
@@ -89,11 +136,26 @@ const Modal: React.FunctionComponent<ModalProps> = ({
|
|
|
89
136
|
const prevOverflow = document.body.style.overflow;
|
|
90
137
|
document.body.style.overflow = 'hidden';
|
|
91
138
|
|
|
92
|
-
// move focus
|
|
139
|
+
// move focus to the first control in the body/footer (an input, a link, a button) so forms are
|
|
140
|
+
// ready to type into and browser autofill can offer itself; the head row (close + headerAction
|
|
141
|
+
// icons) is skipped so a header icon never takes the :focus-visible ring on open. Falls back to
|
|
142
|
+
// the surface itself when the body has nothing focusable.
|
|
143
|
+
// { preventScroll: true }: this runs at the very first animation frame of the mobile
|
|
144
|
+
// sheet's own mmodal-sheet-up entrance (md3.css) — at that instant the surface's actual
|
|
145
|
+
// computed transform is still the keyframe's `from` state (translateY(100%), pushed
|
|
146
|
+
// off-screen below the viewport), not its settled position yet. A plain .focus() on an
|
|
147
|
+
// element the browser currently considers off-screen makes it auto-scroll the nearest
|
|
148
|
+
// scrollable ancestor (.mmodal-scrim, itself overflow-y:auto) to bring it into view —
|
|
149
|
+
// fighting the CSS slide-in transform animating at the same time, which is exactly what
|
|
150
|
+
// produces a double-motion "jumps up, then settles back down" glitch on open. preventScroll
|
|
151
|
+
// skips that native auto-scroll entirely, so the CSS animation alone moves the sheet
|
|
152
|
+
// (same fix as fe-main's BaseModal.tsx, which hit this same glitch first).
|
|
93
153
|
const surface = surfaceRef.current;
|
|
94
154
|
if (surface) {
|
|
95
|
-
const first =
|
|
96
|
-
|
|
155
|
+
const first = Array.prototype.slice
|
|
156
|
+
.call(surface.querySelectorAll<HTMLElement>(FOCUSABLE))
|
|
157
|
+
.find((el: HTMLElement) => !el.closest('.mmodal-head'));
|
|
158
|
+
(first || surface).focus({ preventScroll: true });
|
|
97
159
|
}
|
|
98
160
|
|
|
99
161
|
return () => {
|
|
@@ -165,8 +227,17 @@ const Modal: React.FunctionComponent<ModalProps> = ({
|
|
|
165
227
|
tabIndex={-1}
|
|
166
228
|
onMouseDown={(e) => e.stopPropagation()}
|
|
167
229
|
>
|
|
168
|
-
{/* head row always renders so the close button is always present.
|
|
169
|
-
|
|
230
|
+
{/* head row always renders so the close button is always present. onTouch*: swipe-
|
|
231
|
+
down-to-dismiss grab zone (see onGrabStart/Move/End above) — a tap (near-zero dy)
|
|
232
|
+
never crosses the 90px threshold and nothing here calls preventDefault, so the
|
|
233
|
+
close button's own onClick still fires normally after touchend. */}
|
|
234
|
+
<div
|
|
235
|
+
className="mmodal-head"
|
|
236
|
+
onTouchStart={onGrabStart}
|
|
237
|
+
onTouchMove={onGrabMove}
|
|
238
|
+
onTouchEnd={onGrabEnd}
|
|
239
|
+
style={{ touchAction: 'none' }}
|
|
240
|
+
>
|
|
170
241
|
{title ? (
|
|
171
242
|
<h2 id={titleId} className="mmodal-title md-headline-sm">
|
|
172
243
|
{title}
|
|
@@ -174,7 +245,14 @@ const Modal: React.FunctionComponent<ModalProps> = ({
|
|
|
174
245
|
) : (
|
|
175
246
|
<span className="mmodal-title" aria-hidden="true" />
|
|
176
247
|
)}
|
|
177
|
-
|
|
248
|
+
{headerAction}
|
|
249
|
+
{closeIcon ? (
|
|
250
|
+
<button type="button" className="mmodal-close" aria-label="Schließen" onClick={onClose}>
|
|
251
|
+
{closeIcon}
|
|
252
|
+
</button>
|
|
253
|
+
) : (
|
|
254
|
+
<IconButton name="x" label="Schließen" onClick={onClose} />
|
|
255
|
+
)}
|
|
178
256
|
</div>
|
|
179
257
|
<div className="mmodal-body">{children}</div>
|
|
180
258
|
{footer ? <div className="mmodal-foot">{footer}</div> : null}
|
package/ui/Skeleton.tsx
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
// Autobahn (auto.de redesign) — md3 loading skeleton.
|
|
2
2
|
//
|
|
3
|
-
// md3.css ships no skeleton class, so this is the ONE
|
|
4
|
-
// legacy `Skeleton`/`SkeletonItem`
|
|
5
|
-
//
|
|
6
|
-
// subset fe-main
|
|
7
|
-
// `animation` is accepted and ignored — the
|
|
3
|
+
// md3.css ships no skeleton class, so this component brings its own CSS. It is the ONE
|
|
4
|
+
// skeleton for every block (and every legacy `Skeleton`/`SkeletonItem` MUI call site):
|
|
5
|
+
// a block with a light passing over it, built from --md surface tokens. Prop surface
|
|
6
|
+
// mirrors the subset fe-main used (variant / width / height / className / style;
|
|
7
|
+
// `animation` is accepted and ignored — the sweep always runs) plus `tone`.
|
|
8
8
|
// Renders correctly only inside a `<div className="md3">` subtree.
|
|
9
|
+
//
|
|
10
|
+
// - tone 'surface' (default): grey blocks on the light page surfaces.
|
|
11
|
+
// - tone 'inverse': white-alpha blocks for the brand/dark surfaces (the home hero's blue
|
|
12
|
+
// gradient, the label inside a filled button).
|
|
13
|
+
// - The base and the passing light are CSS custom properties (--mskeleton-base /
|
|
14
|
+
// --mskeleton-shine), so a block can retune both for its own background.
|
|
15
|
+
// - The light is a ::after band moved with transform only, so it runs on the compositor
|
|
16
|
+
// and stays smooth while the main thread is busy loading — exactly when skeletons show.
|
|
17
|
+
// The band is 60vw wide whatever the bar's width, so it travels at one speed: bars
|
|
18
|
+
// stacked on one left edge (a heading over copy lines) light up together.
|
|
19
|
+
// - prefers-reduced-motion: no sweep, a slow fade of the block instead.
|
|
20
|
+
// - Skeletons are aria-hidden; the region showing them carries aria-busy and a visually
|
|
21
|
+
// hidden `<span className="mskeleton-sr" role="status">…lädt…</span>` saying what loads.
|
|
9
22
|
|
|
10
23
|
import React from 'react';
|
|
11
24
|
|
|
12
25
|
export interface SkeletonProps {
|
|
13
26
|
variant?: 'text' | 'rectangular' | 'circular';
|
|
27
|
+
/** 'surface' (default) on light surfaces, 'inverse' on the brand blue / dark surfaces. */
|
|
28
|
+
tone?: 'surface' | 'inverse';
|
|
14
29
|
width?: number | string;
|
|
15
30
|
height?: number | string;
|
|
16
31
|
className?: string;
|
|
@@ -22,35 +37,78 @@ export interface SkeletonProps {
|
|
|
22
37
|
|
|
23
38
|
const SKELETON_CSS = `
|
|
24
39
|
.md3 .mskeleton {
|
|
40
|
+
--mskeleton-base: var(--md-sc);
|
|
41
|
+
--mskeleton-shine: rgba(255, 255, 255, .9);
|
|
42
|
+
position: relative;
|
|
25
43
|
display: block;
|
|
26
|
-
|
|
27
|
-
background-size: 400% 100%;
|
|
28
|
-
animation: md3-skeleton-shimmer 1.4s ease infinite;
|
|
44
|
+
overflow: hidden;
|
|
29
45
|
border-radius: var(--md-r-sm);
|
|
46
|
+
background-color: var(--mskeleton-base);
|
|
47
|
+
}
|
|
48
|
+
.md3 .mskeleton::after {
|
|
49
|
+
content: '';
|
|
50
|
+
position: absolute;
|
|
51
|
+
top: 0;
|
|
52
|
+
bottom: 0;
|
|
53
|
+
left: 0;
|
|
54
|
+
width: 60vw;
|
|
55
|
+
background: linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, var(--mskeleton-shine) 50%, rgba(255, 255, 255, 0) 70%);
|
|
56
|
+
transform: translateX(-100%);
|
|
57
|
+
animation: md3-skeleton-sweep 1.8s cubic-bezier(.4, 0, .2, 1) infinite;
|
|
58
|
+
pointer-events: none;
|
|
59
|
+
}
|
|
60
|
+
.md3 .mskeleton--inverse {
|
|
61
|
+
--mskeleton-base: rgba(255, 255, 255, .14);
|
|
62
|
+
--mskeleton-shine: rgba(255, 255, 255, .26);
|
|
30
63
|
}
|
|
31
64
|
.md3 .mskeleton--text { border-radius: var(--md-r-xs, 4px); transform: scale(1, 0.7); }
|
|
65
|
+
.md3 .mskeleton-sr {
|
|
66
|
+
position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
|
|
67
|
+
overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
|
|
68
|
+
}
|
|
32
69
|
.md3 .mskeleton--circular { border-radius: 50%; }
|
|
33
|
-
@keyframes md3-skeleton-
|
|
34
|
-
0% {
|
|
35
|
-
100% {
|
|
70
|
+
@keyframes md3-skeleton-sweep {
|
|
71
|
+
0% { transform: translateX(-100%); }
|
|
72
|
+
70%, 100% { transform: translateX(100vw); }
|
|
73
|
+
}
|
|
74
|
+
@keyframes md3-skeleton-fade {
|
|
75
|
+
50% { opacity: .55; }
|
|
76
|
+
}
|
|
77
|
+
@media (prefers-reduced-motion: reduce) {
|
|
78
|
+
.md3 .mskeleton::after { display: none; }
|
|
79
|
+
.md3 .mskeleton { animation: md3-skeleton-fade 2.4s ease-in-out infinite; }
|
|
36
80
|
}`;
|
|
37
81
|
|
|
38
82
|
const SKELETON_STYLE_ID = 'md3-skeleton-styles';
|
|
39
83
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
84
|
+
/**
|
|
85
|
+
* One <style id> in document.head per stylesheet, no matter how many components mount.
|
|
86
|
+
* Called when a module loads (and again from the component), so the very first frame of a
|
|
87
|
+
* skeleton is already styled — an unstyled <span> would render as nothing for a frame and
|
|
88
|
+
* then pop in. A stale copy (an older bundle, hot reload) is overwritten. SSR-safe.
|
|
89
|
+
* Shared with the other skeleton shapes (e.g. cards/CarCardSkeleton).
|
|
90
|
+
*/
|
|
91
|
+
export function injectStyles(id: string, css: string): void {
|
|
92
|
+
if (typeof document === 'undefined') {
|
|
44
93
|
return;
|
|
45
94
|
}
|
|
46
|
-
|
|
47
|
-
style
|
|
48
|
-
|
|
49
|
-
|
|
95
|
+
let style = document.getElementById(id);
|
|
96
|
+
if (!style) {
|
|
97
|
+
style = document.createElement('style');
|
|
98
|
+
style.id = id;
|
|
99
|
+
document.head.appendChild(style);
|
|
100
|
+
}
|
|
101
|
+
if (style.textContent !== css) {
|
|
102
|
+
style.textContent = css;
|
|
103
|
+
}
|
|
50
104
|
}
|
|
51
105
|
|
|
106
|
+
const ensureStylesInjected = (): void => injectStyles(SKELETON_STYLE_ID, SKELETON_CSS);
|
|
107
|
+
|
|
108
|
+
ensureStylesInjected();
|
|
109
|
+
|
|
52
110
|
const Skeleton: React.FunctionComponent<SkeletonProps> = ({
|
|
53
|
-
variant = 'rectangular', width, height, className, style, children,
|
|
111
|
+
variant = 'rectangular', tone = 'surface', width, height, className, style, children,
|
|
54
112
|
}) => {
|
|
55
113
|
React.useEffect(() => { ensureStylesInjected(); }, []);
|
|
56
114
|
const dims: React.CSSProperties = {};
|
|
@@ -62,6 +120,7 @@ const Skeleton: React.FunctionComponent<SkeletonProps> = ({
|
|
|
62
120
|
className={
|
|
63
121
|
'mskeleton' +
|
|
64
122
|
(variant !== 'rectangular' ? ` mskeleton--${variant}` : '') +
|
|
123
|
+
(tone !== 'surface' ? ` mskeleton--${tone}` : '') +
|
|
65
124
|
(className ? ` ${className}` : '')
|
|
66
125
|
}
|
|
67
126
|
style={{ ...dims, ...style }}
|
package/ui/Stars.tsx
CHANGED
|
@@ -3,27 +3,45 @@ import React from 'react';
|
|
|
3
3
|
import Icon from './Icon';
|
|
4
4
|
|
|
5
5
|
export interface StarsProps {
|
|
6
|
-
/** rating value 0–5; each star fills
|
|
6
|
+
/** rating value 0–5; each star fills by its exact share (4,52 → four full stars + 52 % of the fifth). */
|
|
7
7
|
value: number;
|
|
8
8
|
size?: number;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
11
|
+
const FILLED = '#F2A900';
|
|
12
|
+
const EMPTY = '#D8D6DC';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 5-star row filled to the exact value: a grey star with the gold one clipped to the star's
|
|
16
|
+
* share on top, so a site rating of 4,5 shows four and a half stars (whole-number review
|
|
17
|
+
* ratings render exactly as before).
|
|
18
|
+
*/
|
|
19
|
+
const Stars: React.FunctionComponent<StarsProps> = ({ value, size = 16 }) => {
|
|
20
|
+
const v = Math.max(0, Math.min(5, Number(value) || 0));
|
|
21
|
+
return (
|
|
22
|
+
<span
|
|
23
|
+
role="img"
|
|
24
|
+
aria-label={`${v.toLocaleString('de-DE', { maximumFractionDigits: 1 })} von 5 Sternen`}
|
|
25
|
+
style={{ display: 'inline-flex', gap: 1 }}
|
|
26
|
+
>
|
|
27
|
+
{[0, 1, 2, 3, 4].map((i) => {
|
|
28
|
+
const share = Math.max(0, Math.min(1, v - i));
|
|
29
|
+
return (
|
|
30
|
+
<span key={i} style={{ position: 'relative', display: 'inline-flex', flex: 'none' }}>
|
|
31
|
+
<Icon name="star" size={size} color={EMPTY} style={{ fill: EMPTY }} />
|
|
32
|
+
{share > 0 && (
|
|
33
|
+
<span
|
|
34
|
+
aria-hidden="true"
|
|
35
|
+
style={{ position: 'absolute', top: 0, left: 0, bottom: 0, width: `${share * 100}%`, overflow: 'hidden', display: 'flex' }}
|
|
36
|
+
>
|
|
37
|
+
<Icon name="star" size={size} color={FILLED} style={{ fill: FILLED, flex: 'none' }} />
|
|
38
|
+
</span>
|
|
39
|
+
)}
|
|
40
|
+
</span>
|
|
41
|
+
);
|
|
42
|
+
})}
|
|
43
|
+
</span>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
28
46
|
|
|
29
47
|
export default Stars;
|
package/ui/StatChip.tsx
CHANGED
|
@@ -2,17 +2,22 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import Icon from './Icon';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/** 'neutral' (grey) is for "Keine Bewertung", which is neither a good nor a warn rating. */
|
|
6
|
+
export type StatChipTone = 'good' | 'warn' | 'neutral';
|
|
6
7
|
|
|
7
8
|
export interface StatChipProps {
|
|
8
9
|
tone?: StatChipTone;
|
|
10
|
+
/** A price-rating chip: the mapRating() `rating` key ('top' … 'high', 'none'). It paints the chip
|
|
11
|
+
* in that tier's badge colours (md3.css .statchip--rating-<key>, the --rating-* palette)
|
|
12
|
+
* instead of the `tone`. */
|
|
13
|
+
rating?: string;
|
|
9
14
|
/** kebab-case lucide icon name rendered before the content. */
|
|
10
15
|
icon?: string;
|
|
11
16
|
children?: React.ReactNode;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
|
-
const StatChip: React.FunctionComponent<StatChipProps> = ({ tone = 'good', icon, children }) => (
|
|
15
|
-
<span className={`statchip statchip--${tone}`}>
|
|
19
|
+
const StatChip: React.FunctionComponent<StatChipProps> = ({ tone = 'good', rating, icon, children }) => (
|
|
20
|
+
<span className={rating ? `statchip statchip--rating statchip--rating-${rating}` : `statchip statchip--${tone}`}>
|
|
16
21
|
{icon && <Icon name={icon} size={14} />}
|
|
17
22
|
{children}
|
|
18
23
|
</span>
|
package/ui/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export type { ChipProps } from './Chip';
|
|
|
29
29
|
|
|
30
30
|
export { default as StatChip } from './StatChip';
|
|
31
31
|
export type { StatChipProps, StatChipTone } from './StatChip';
|
|
32
|
+
export { ratingLinkProps, PRICE_SECTION_ID, PRICE_SECTION_HASH } from './ratingLink';
|
|
32
33
|
|
|
33
34
|
export { default as CreditCostNotice, CREDIT_COST_WARNING_DE } from './CreditCostNotice';
|
|
34
35
|
export type { CreditCostNoticeProps, CreditCostNoticeTone, CreditCostNoticeSize } from './CreditCostNotice';
|
|
@@ -45,6 +46,8 @@ export type { FormFieldProps } from './FormField';
|
|
|
45
46
|
export { default as Dropdown } from './Dropdown';
|
|
46
47
|
export type { DropdownProps, DropdownOption } from './Dropdown';
|
|
47
48
|
|
|
49
|
+
export { scrollFieldIntoView } from './scrollFieldIntoView';
|
|
50
|
+
|
|
48
51
|
export { default as Spec } from './Spec';
|
|
49
52
|
export type { SpecProps } from './Spec';
|
|
50
53
|
|
package/ui/ratingLink.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/** id of the VDP's "Preis & Marktwert" section (fe-main PriceMarket), where a price-rating
|
|
4
|
+
* badge leads; `PRICE_SECTION_HASH` is the URL fragment that opens a VDP scrolled to it. */
|
|
5
|
+
export const PRICE_SECTION_ID = 'vdp-preis';
|
|
6
|
+
export const PRICE_SECTION_HASH = '#' + PRICE_SECTION_ID;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props that make a price-rating badge (and the bar next to it) a link to the VDP's
|
|
10
|
+
* "Preis & Marktwert" section: a click, Enter or Space calls `onActivate`. The event is stopped,
|
|
11
|
+
* so the card the badge sits in does not also run its own "open the car" click. The element
|
|
12
|
+
* gets the class `rating-link` (md3.css: pointer cursor, focus ring) — spread these onto it and
|
|
13
|
+
* add that class.
|
|
14
|
+
*/
|
|
15
|
+
export function ratingLinkProps(onActivate: () => void, ariaLabel: string): {
|
|
16
|
+
role: 'link';
|
|
17
|
+
tabIndex: number;
|
|
18
|
+
'aria-label': string;
|
|
19
|
+
onClick: (e: React.MouseEvent) => void;
|
|
20
|
+
onKeyDown: (e: React.KeyboardEvent) => void;
|
|
21
|
+
} {
|
|
22
|
+
const activate = (e: React.SyntheticEvent): void => {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
e.stopPropagation();
|
|
25
|
+
onActivate();
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
role: 'link',
|
|
29
|
+
tabIndex: 0,
|
|
30
|
+
'aria-label': ariaLabel,
|
|
31
|
+
onClick: activate,
|
|
32
|
+
onKeyDown: (e: React.KeyboardEvent) => {
|
|
33
|
+
if (e.key === 'Enter' || e.key === ' ') activate(e);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|