@bytebrand/fe-ui-core-autobahn 1.0.226 → 1.0.228
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 -0
- package/campaign/campaignVars.ts +12 -0
- package/campaign/campaigns.ts +74 -0
- package/campaign/index.ts +6 -0
- package/cards/CarCard.tsx +393 -366
- package/cards/CarRow.tsx +8 -28
- package/cards/cardParts.tsx +23 -48
- package/cards/dealSignals.ts +36 -0
- package/cards/index.ts +0 -6
- package/chrome/Footer.tsx +3 -16
- package/chrome/TopBar.tsx +266 -139
- package/compat/CookieModal/CookieModal.tsx +6 -20
- package/compat/CookieModal/Modal.tsx +3 -6
- package/compat/CookieModal/modals/ManageCookieModal/ManageCookieModal.tsx +15 -43
- package/compat/CookieModal/modals/PreviewCookieModal/PreviewCookieModal.tsx +3 -4
- package/compat/CookieModal/useModal.ts +1 -5
- package/compat/Loader/Loader.tsx +7 -1
- package/compat/MdField/MdField.tsx +4 -28
- package/compat/PriceRating/PriceRating.styl +7 -5
- package/compat/PriceRatingDetailed/PriceRatingDetailed.styl +6 -8
- package/compat/TimePicker/TimePicker.tsx +2 -12
- package/compat/legacy-theme/priceReviewColors.styl +5 -18
- package/constants/app.ts +11 -1
- package/constants/autobahn.ts +0 -39
- package/constants/core.ts +12 -1
- package/data/fieldMapping.ts +3 -3
- package/data/toAutobahnCar.ts +14 -30
- package/iconsvg/IconSVG.tsx +5 -1
- package/index.ts +19 -18
- package/locales/de/autobahn.json +862 -903
- package/locales/en/autobahn.json +862 -903
- package/package.json +2 -2
- package/theme/md3.css +11808 -15866
- package/ui/Dropdown.tsx +10 -29
- package/ui/FormCheckbox.tsx +2 -22
- package/ui/FormField.tsx +1 -2
- package/ui/Icon.tsx +0 -6
- package/ui/Modal.tsx +6 -84
- package/ui/Skeleton.tsx +20 -79
- package/ui/Stars.tsx +18 -36
- package/ui/StatChip.tsx +3 -8
- package/ui/index.ts +0 -3
- package/ui/usePortalMenuPosition.ts +15 -27
- package/utils/index.ts +0 -10
- package/vdp/FinanceCalculator.tsx +34 -162
- package/vdp/VdpModules.tsx +976 -348
- package/vdp/index.ts +3 -6
- package/vdp/types.ts +15 -25
- package/vehiclesProps/decoratedLightProps.tsx +0 -4
- package/vehiclesProps/decoratedProps.tsx +0 -4
- package/cards/CarCardSkeleton.tsx +0 -103
- package/cards/CarRowSkeleton.tsx +0 -152
- package/chrome/AccountMenuIcon.tsx +0 -109
- package/ui/MfieldCheckIcon.tsx +0 -13
- package/ui/ratingLink.ts +0 -36
- package/ui/scrollFieldIntoView.ts +0 -41
- package/utils/cookieConsent.ts +0 -84
- package/vehiclesProps/accidentDisclosure.ts +0 -25
package/ui/Dropdown.tsx
CHANGED
|
@@ -22,7 +22,6 @@ 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';
|
|
26
25
|
|
|
27
26
|
export interface DropdownOption {
|
|
28
27
|
value: string;
|
|
@@ -60,16 +59,8 @@ export interface DropdownProps {
|
|
|
60
59
|
ariaDescribedBy?: string;
|
|
61
60
|
/** extra class on the wrapper (e.g. 'srp-sort' for width rules). */
|
|
62
61
|
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;
|
|
67
62
|
/** align the popover to the right edge of the trigger (default left). */
|
|
68
63
|
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';
|
|
73
64
|
/** show a text input at the top of the popover that filters `options` by label (substring, case-insensitive). */
|
|
74
65
|
searchable?: boolean;
|
|
75
66
|
/** placeholder for the search input (only used when `searchable`). */
|
|
@@ -106,9 +97,7 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
106
97
|
ariaInvalid,
|
|
107
98
|
ariaDescribedBy,
|
|
108
99
|
className,
|
|
109
|
-
menuClassName,
|
|
110
100
|
menuAlign = 'left',
|
|
111
|
-
menuOpenDirection = 'auto',
|
|
112
101
|
searchable = false,
|
|
113
102
|
searchPlaceholder,
|
|
114
103
|
numeric = false,
|
|
@@ -190,22 +179,15 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
190
179
|
if (allowCustomValue) setQuery(value || '');
|
|
191
180
|
}, [disabled, selectedIndex, allowCustomValue, value]);
|
|
192
181
|
|
|
193
|
-
//
|
|
194
|
-
//
|
|
195
|
-
//
|
|
196
|
-
//
|
|
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.
|
|
182
|
+
// when opened searchable, focus the search input instead of leaving focus on the trigger.
|
|
183
|
+
// scrollIntoView first: on mobile the keyboard is about to eat ~40% of the viewport, so the
|
|
184
|
+
// trigger (and the popover below it) needs to already be scrolled above the fold before focus
|
|
185
|
+
// fires, or the popover can end up hidden behind the keyboard with no way to see it open.
|
|
203
186
|
React.useEffect(() => {
|
|
204
|
-
if (!open) return;
|
|
205
|
-
if (rootRef.current
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
// <button> already has focus from the click/keypress that opened it.
|
|
187
|
+
if (!open || !searchable) return;
|
|
188
|
+
if (rootRef.current && rootRef.current.scrollIntoView) {
|
|
189
|
+
rootRef.current.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
190
|
+
}
|
|
209
191
|
if (searchRef.current) {
|
|
210
192
|
searchRef.current.focus();
|
|
211
193
|
// pre-filled custom value (see openMenu) starts selected, so typing immediately
|
|
@@ -239,7 +221,6 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
239
221
|
open,
|
|
240
222
|
rootRef,
|
|
241
223
|
menuAlign,
|
|
242
|
-
openDirection: menuOpenDirection,
|
|
243
224
|
onCloseAway,
|
|
244
225
|
});
|
|
245
226
|
|
|
@@ -419,7 +400,7 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
419
400
|
? ReactDOM.createPortal(
|
|
420
401
|
<div
|
|
421
402
|
ref={menuElRef}
|
|
422
|
-
className={'mselect-menu mselect-menu--portal' + (searchable ? ' mselect-menu--searchable' : '')
|
|
403
|
+
className={'mselect-menu mselect-menu--portal' + (searchable ? ' mselect-menu--searchable' : '')}
|
|
423
404
|
// menuPos is null for one frame on open, before the position effect has measured
|
|
424
405
|
// the trigger — stay invisible (not just visually, via `visibility`) rather than
|
|
425
406
|
// flash at (0,0)/full-width. `position: fixed` is set UNCONDITIONALLY, in both
|
|
@@ -472,7 +453,7 @@ const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
472
453
|
: (
|
|
473
454
|
<div
|
|
474
455
|
ref={menuElRef}
|
|
475
|
-
className={'mselect-menu' + (menuAlign === 'right' ? ' mselect-menu--right' : '') + (searchable ? ' mselect-menu--searchable' : '')
|
|
456
|
+
className={'mselect-menu' + (menuAlign === 'right' ? ' mselect-menu--right' : '') + (searchable ? ' mselect-menu--searchable' : '')}
|
|
476
457
|
>
|
|
477
458
|
{renderMenuList()}
|
|
478
459
|
</div>
|
package/ui/FormCheckbox.tsx
CHANGED
|
@@ -36,23 +36,12 @@ 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;
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
const FormCheckbox: React.FunctionComponent<FormCheckboxProps> = observer(
|
|
46
|
-
({ field, t, label, children, disabled, id
|
|
42
|
+
({ field, t, label, children, disabled, id }) => {
|
|
47
43
|
const isChecked = !!field.checked;
|
|
48
44
|
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.
|
|
56
45
|
const hasError = !!field.hasError && !!field.error;
|
|
57
46
|
|
|
58
47
|
// children (rich) > explicit label > translated field.label (legacy CheckboxMaterial behaviour).
|
|
@@ -81,16 +70,7 @@ const FormCheckbox: React.FunctionComponent<FormCheckboxProps> = observer(
|
|
|
81
70
|
</span>
|
|
82
71
|
{content != null ? <span className="mcheck-label">{content}</span> : null}
|
|
83
72
|
</label>
|
|
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}
|
|
73
|
+
{hasError ? <span className="mcheck-error-text">{field.error}</span> : null}
|
|
94
74
|
</div>
|
|
95
75
|
);
|
|
96
76
|
},
|
package/ui/FormField.tsx
CHANGED
|
@@ -12,7 +12,6 @@ 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';
|
|
16
15
|
|
|
17
16
|
export interface FormFieldProps {
|
|
18
17
|
/** mobx-react-form field (LoginForm.$('email') etc.). Typed any — the lib ships no TS types. */
|
|
@@ -83,7 +82,7 @@ const FormField: React.FunctionComponent<FormFieldProps> = observer(
|
|
|
83
82
|
<Icon name={reveal ? 'eye-off' : 'eye'} size={18} />
|
|
84
83
|
</button>
|
|
85
84
|
) : null}
|
|
86
|
-
{isValid ? <span className="mfield-ok"><
|
|
85
|
+
{isValid ? <span className="mfield-ok"><Icon name="check" size={18} /></span> : null}
|
|
87
86
|
</div>
|
|
88
87
|
{hasError ? <span className="mfield-error-text">{field.error}</span> : null}
|
|
89
88
|
</div>
|
package/ui/Icon.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Activity,
|
|
4
|
-
AlertCircle,
|
|
5
4
|
Apple,
|
|
6
5
|
Armchair,
|
|
7
6
|
ArrowLeft,
|
|
@@ -52,13 +51,11 @@ import {
|
|
|
52
51
|
DoorOpen,
|
|
53
52
|
Droplet,
|
|
54
53
|
Euro,
|
|
55
|
-
ExternalLink,
|
|
56
54
|
Eye,
|
|
57
55
|
EyeOff,
|
|
58
56
|
Facebook,
|
|
59
57
|
File,
|
|
60
58
|
FileCheck,
|
|
61
|
-
FileSignature,
|
|
62
59
|
FileText,
|
|
63
60
|
Flame,
|
|
64
61
|
Fuel,
|
|
@@ -201,7 +198,6 @@ function toPascalCase(name: string): string {
|
|
|
201
198
|
*/
|
|
202
199
|
const REGISTRY: Record<string, React.ComponentType<LucideProps>> = {
|
|
203
200
|
Activity,
|
|
204
|
-
AlertCircle,
|
|
205
201
|
Apple,
|
|
206
202
|
Armchair,
|
|
207
203
|
ArrowLeft,
|
|
@@ -253,13 +249,11 @@ const REGISTRY: Record<string, React.ComponentType<LucideProps>> = {
|
|
|
253
249
|
DoorOpen,
|
|
254
250
|
Droplet,
|
|
255
251
|
Euro,
|
|
256
|
-
ExternalLink,
|
|
257
252
|
Eye,
|
|
258
253
|
EyeOff,
|
|
259
254
|
Facebook,
|
|
260
255
|
File,
|
|
261
256
|
FileCheck,
|
|
262
|
-
FileSignature,
|
|
263
257
|
FileText,
|
|
264
258
|
Flame,
|
|
265
259
|
Fuel,
|
package/ui/Modal.tsx
CHANGED
|
@@ -15,8 +15,6 @@
|
|
|
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.
|
|
20
18
|
// - a11y: role=dialog, aria-modal, aria-labelledby wired to the title when present.
|
|
21
19
|
//
|
|
22
20
|
// Pure/presentational — no store/API access beyond document/body (all SSR-guarded). The
|
|
@@ -46,13 +44,6 @@ export interface ModalProps {
|
|
|
46
44
|
dismissOnScrim?: boolean;
|
|
47
45
|
/** extra class(es) appended on the surface (layout hooks). */
|
|
48
46
|
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;
|
|
56
47
|
}
|
|
57
48
|
|
|
58
49
|
// focusable descendants used by the basic focus trap.
|
|
@@ -68,48 +59,10 @@ const Modal: React.FunctionComponent<ModalProps> = ({
|
|
|
68
59
|
size = 'md',
|
|
69
60
|
dismissOnScrim = true,
|
|
70
61
|
className,
|
|
71
|
-
closeIcon,
|
|
72
|
-
headerAction,
|
|
73
62
|
}) => {
|
|
74
63
|
const surfaceRef = React.useRef<HTMLDivElement | null>(null);
|
|
75
64
|
// the element focused before the dialog opened, so focus can be restored on close.
|
|
76
65
|
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
|
-
};
|
|
113
66
|
// stable id for aria-labelledby (avoids Math.random/Date.now, unavailable in this env).
|
|
114
67
|
const titleId = React.useMemo(
|
|
115
68
|
() => (title ? `mmodal-title-${Math.round((surfaceRef.current ? 1 : 0))}-${size}` : undefined),
|
|
@@ -136,26 +89,11 @@ const Modal: React.FunctionComponent<ModalProps> = ({
|
|
|
136
89
|
const prevOverflow = document.body.style.overflow;
|
|
137
90
|
document.body.style.overflow = 'hidden';
|
|
138
91
|
|
|
139
|
-
// move focus
|
|
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).
|
|
92
|
+
// move focus into the dialog (first focusable, else the surface itself).
|
|
153
93
|
const surface = surfaceRef.current;
|
|
154
94
|
if (surface) {
|
|
155
|
-
const first =
|
|
156
|
-
|
|
157
|
-
.find((el: HTMLElement) => !el.closest('.mmodal-head'));
|
|
158
|
-
(first || surface).focus({ preventScroll: true });
|
|
95
|
+
const first = surface.querySelector<HTMLElement>(FOCUSABLE);
|
|
96
|
+
(first || surface).focus();
|
|
159
97
|
}
|
|
160
98
|
|
|
161
99
|
return () => {
|
|
@@ -227,17 +165,8 @@ const Modal: React.FunctionComponent<ModalProps> = ({
|
|
|
227
165
|
tabIndex={-1}
|
|
228
166
|
onMouseDown={(e) => e.stopPropagation()}
|
|
229
167
|
>
|
|
230
|
-
{/* head row always renders so the close button is always present.
|
|
231
|
-
|
|
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
|
-
>
|
|
168
|
+
{/* head row always renders so the close button is always present. */}
|
|
169
|
+
<div className="mmodal-head">
|
|
241
170
|
{title ? (
|
|
242
171
|
<h2 id={titleId} className="mmodal-title md-headline-sm">
|
|
243
172
|
{title}
|
|
@@ -245,14 +174,7 @@ const Modal: React.FunctionComponent<ModalProps> = ({
|
|
|
245
174
|
) : (
|
|
246
175
|
<span className="mmodal-title" aria-hidden="true" />
|
|
247
176
|
)}
|
|
248
|
-
{
|
|
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
|
-
)}
|
|
177
|
+
<IconButton name="x" label="Schließen" onClick={onClose} />
|
|
256
178
|
</div>
|
|
257
179
|
<div className="mmodal-body">{children}</div>
|
|
258
180
|
{footer ? <div className="mmodal-foot">{footer}</div> : null}
|
package/ui/Skeleton.tsx
CHANGED
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
// Autobahn (auto.de redesign) — md3 loading skeleton.
|
|
2
2
|
//
|
|
3
|
-
// md3.css ships no skeleton class, so this
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// `animation` is accepted and ignored — the
|
|
3
|
+
// md3.css ships no skeleton class, so this is the ONE addition covering every
|
|
4
|
+
// legacy `Skeleton`/`SkeletonItem` (MUI) call site: a div with an animated
|
|
5
|
+
// gradient shimmer built from --md surface tokens. Prop surface mirrors the
|
|
6
|
+
// subset fe-main actually used (variant / width / height / className / style;
|
|
7
|
+
// `animation` is accepted and ignored — the shimmer always runs).
|
|
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.
|
|
22
9
|
|
|
23
10
|
import React from 'react';
|
|
24
11
|
|
|
25
12
|
export interface SkeletonProps {
|
|
26
13
|
variant?: 'text' | 'rectangular' | 'circular';
|
|
27
|
-
/** 'surface' (default) on light surfaces, 'inverse' on the brand blue / dark surfaces. */
|
|
28
|
-
tone?: 'surface' | 'inverse';
|
|
29
14
|
width?: number | string;
|
|
30
15
|
height?: number | string;
|
|
31
16
|
className?: string;
|
|
@@ -37,78 +22,35 @@ export interface SkeletonProps {
|
|
|
37
22
|
|
|
38
23
|
const SKELETON_CSS = `
|
|
39
24
|
.md3 .mskeleton {
|
|
40
|
-
--mskeleton-base: var(--md-sc);
|
|
41
|
-
--mskeleton-shine: rgba(255, 255, 255, .9);
|
|
42
|
-
position: relative;
|
|
43
25
|
display: block;
|
|
44
|
-
|
|
26
|
+
background: linear-gradient(90deg, var(--md-sc) 25%, var(--md-sc-high, var(--md-sc-lowest)) 37%, var(--md-sc) 63%);
|
|
27
|
+
background-size: 400% 100%;
|
|
28
|
+
animation: md3-skeleton-shimmer 1.4s ease infinite;
|
|
45
29
|
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);
|
|
63
30
|
}
|
|
64
31
|
.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
|
-
}
|
|
69
32
|
.md3 .mskeleton--circular { border-radius: 50%; }
|
|
70
|
-
@keyframes md3-skeleton-
|
|
71
|
-
0% {
|
|
72
|
-
|
|
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; }
|
|
33
|
+
@keyframes md3-skeleton-shimmer {
|
|
34
|
+
0% { background-position: 100% 50%; }
|
|
35
|
+
100% { background-position: 0 50%; }
|
|
80
36
|
}`;
|
|
81
37
|
|
|
82
38
|
const SKELETON_STYLE_ID = 'md3-skeleton-styles';
|
|
83
39
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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') {
|
|
40
|
+
// one <style id> in document.head no matter how many skeletons mount — the same
|
|
41
|
+
// pattern fe-main's VehicleSmallCardMd3 uses. SSR-safe (guarded document access).
|
|
42
|
+
function ensureStylesInjected(): void {
|
|
43
|
+
if (typeof document === 'undefined' || document.getElementById(SKELETON_STYLE_ID)) {
|
|
93
44
|
return;
|
|
94
45
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
document.head.appendChild(style);
|
|
100
|
-
}
|
|
101
|
-
if (style.textContent !== css) {
|
|
102
|
-
style.textContent = css;
|
|
103
|
-
}
|
|
46
|
+
const style = document.createElement('style');
|
|
47
|
+
style.id = SKELETON_STYLE_ID;
|
|
48
|
+
style.innerHTML = SKELETON_CSS;
|
|
49
|
+
document.head.appendChild(style);
|
|
104
50
|
}
|
|
105
51
|
|
|
106
|
-
const ensureStylesInjected = (): void => injectStyles(SKELETON_STYLE_ID, SKELETON_CSS);
|
|
107
|
-
|
|
108
|
-
ensureStylesInjected();
|
|
109
|
-
|
|
110
52
|
const Skeleton: React.FunctionComponent<SkeletonProps> = ({
|
|
111
|
-
variant = 'rectangular',
|
|
53
|
+
variant = 'rectangular', width, height, className, style, children,
|
|
112
54
|
}) => {
|
|
113
55
|
React.useEffect(() => { ensureStylesInjected(); }, []);
|
|
114
56
|
const dims: React.CSSProperties = {};
|
|
@@ -120,7 +62,6 @@ const Skeleton: React.FunctionComponent<SkeletonProps> = ({
|
|
|
120
62
|
className={
|
|
121
63
|
'mskeleton' +
|
|
122
64
|
(variant !== 'rectangular' ? ` mskeleton--${variant}` : '') +
|
|
123
|
-
(tone !== 'surface' ? ` mskeleton--${tone}` : '') +
|
|
124
65
|
(className ? ` ${className}` : '')
|
|
125
66
|
}
|
|
126
67
|
style={{ ...dims, ...style }}
|
package/ui/Stars.tsx
CHANGED
|
@@ -3,45 +3,27 @@ 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 when value − index >= 0.5. */
|
|
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
|
-
|
|
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
|
-
};
|
|
11
|
+
/** 5-star row (rounded to nearest .5). */
|
|
12
|
+
const Stars: React.FunctionComponent<StarsProps> = ({ value, size = 16 }) => (
|
|
13
|
+
<span style={{ display: 'inline-flex', gap: 1 }}>
|
|
14
|
+
{[0, 1, 2, 3, 4].map((i) => {
|
|
15
|
+
const fill = value - i;
|
|
16
|
+
return (
|
|
17
|
+
<Icon
|
|
18
|
+
key={i}
|
|
19
|
+
name={fill >= 0.5 ? 'star' : 'star'}
|
|
20
|
+
size={size}
|
|
21
|
+
color={fill >= 0.5 ? '#F2A900' : '#D8D6DC'}
|
|
22
|
+
style={{ fill: fill >= 0.5 ? '#F2A900' : '#D8D6DC' }}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
})}
|
|
26
|
+
</span>
|
|
27
|
+
);
|
|
46
28
|
|
|
47
29
|
export default Stars;
|
package/ui/StatChip.tsx
CHANGED
|
@@ -2,22 +2,17 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import Icon from './Icon';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
export type StatChipTone = 'good' | 'warn' | 'neutral';
|
|
5
|
+
export type StatChipTone = 'good' | 'warn';
|
|
7
6
|
|
|
8
7
|
export interface StatChipProps {
|
|
9
8
|
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;
|
|
14
9
|
/** kebab-case lucide icon name rendered before the content. */
|
|
15
10
|
icon?: string;
|
|
16
11
|
children?: React.ReactNode;
|
|
17
12
|
}
|
|
18
13
|
|
|
19
|
-
const StatChip: React.FunctionComponent<StatChipProps> = ({ tone = 'good',
|
|
20
|
-
<span className={
|
|
14
|
+
const StatChip: React.FunctionComponent<StatChipProps> = ({ tone = 'good', icon, children }) => (
|
|
15
|
+
<span className={`statchip statchip--${tone}`}>
|
|
21
16
|
{icon && <Icon name={icon} size={14} />}
|
|
22
17
|
{children}
|
|
23
18
|
</span>
|
package/ui/index.ts
CHANGED
|
@@ -29,7 +29,6 @@ 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';
|
|
33
32
|
|
|
34
33
|
export { default as CreditCostNotice, CREDIT_COST_WARNING_DE } from './CreditCostNotice';
|
|
35
34
|
export type { CreditCostNoticeProps, CreditCostNoticeTone, CreditCostNoticeSize } from './CreditCostNotice';
|
|
@@ -46,8 +45,6 @@ export type { FormFieldProps } from './FormField';
|
|
|
46
45
|
export { default as Dropdown } from './Dropdown';
|
|
47
46
|
export type { DropdownProps, DropdownOption } from './Dropdown';
|
|
48
47
|
|
|
49
|
-
export { scrollFieldIntoView } from './scrollFieldIntoView';
|
|
50
|
-
|
|
51
48
|
export { default as Spec } from './Spec';
|
|
52
49
|
export type { SpecProps } from './Spec';
|
|
53
50
|
|