@bytebrand/fe-ui-core-autobahn 1.0.227 → 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 -26
- package/campaign/campaignVars.ts +12 -12
- package/campaign/campaigns.ts +74 -74
- package/campaign/index.ts +6 -18
- package/cards/CarCard.tsx +393 -369
- package/cards/CarRow.tsx +21 -41
- package/cards/cardParts.tsx +23 -48
- package/cards/dealSignals.ts +36 -36
- 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 -19
- package/locales/de/autobahn.json +862 -926
- package/locales/en/autobahn.json +862 -926
- package/package.json +2 -2
- package/theme/md3.css +11808 -16516
- 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/campaign/CampaignBanner.tsx +0 -86
- package/campaign/CampaignBar.tsx +0 -37
- package/campaign/CampaignHero.tsx +0 -50
- package/campaign/CampaignSwitch.tsx +0 -43
- package/campaign/openInApp.ts +0 -8
- package/campaign/useCountdown.ts +0 -28
- 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/vdp/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ export {
|
|
|
35
35
|
Co2Label,
|
|
36
36
|
VehicleDescription,
|
|
37
37
|
TrustStrip,
|
|
38
|
+
PriceHistory,
|
|
38
39
|
ProtectionProducts,
|
|
39
40
|
VdpAnchors,
|
|
40
41
|
VdpStickyBar,
|
|
@@ -43,9 +44,6 @@ export {
|
|
|
43
44
|
HowItWorks,
|
|
44
45
|
ReviewsTeaser,
|
|
45
46
|
CustomerRatings,
|
|
46
|
-
RatingSourcesInfo,
|
|
47
|
-
ReviewSourceCaption,
|
|
48
|
-
REVIEW_LINK_REL,
|
|
49
47
|
VdpEnquiry,
|
|
50
48
|
FinanceDetailsModal,
|
|
51
49
|
} from './VdpModules';
|
|
@@ -60,6 +58,7 @@ export type {
|
|
|
60
58
|
VehicleDescriptionProps,
|
|
61
59
|
TrustStripProps,
|
|
62
60
|
TrustItem,
|
|
61
|
+
PriceHistoryProps,
|
|
63
62
|
ProtectionProductsProps,
|
|
64
63
|
ProtectionProduct,
|
|
65
64
|
VdpAnchorsProps,
|
|
@@ -71,8 +70,6 @@ export type {
|
|
|
71
70
|
HowItWorksStep,
|
|
72
71
|
ReviewsTeaserProps,
|
|
73
72
|
CustomerRatingsProps,
|
|
74
|
-
RatingSourcesInfoProps,
|
|
75
|
-
ReviewSourceCaptionProps,
|
|
76
73
|
VdpEnquiryProps,
|
|
77
74
|
FinanceDetailsModalProps,
|
|
78
75
|
} from './VdpModules';
|
|
@@ -87,9 +84,9 @@ export type {
|
|
|
87
84
|
EnergyTaxSummary,
|
|
88
85
|
Co2CostsSummary,
|
|
89
86
|
EquipmentGroups,
|
|
87
|
+
PriceHistoryPoint,
|
|
90
88
|
PriceRatingBand,
|
|
91
89
|
PriceRatingBands,
|
|
92
90
|
VdpReview,
|
|
93
|
-
RatingPortal,
|
|
94
91
|
AutobahnPhev,
|
|
95
92
|
} from './types';
|
package/vdp/types.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
// (`?`) fields are ones we have NO real source for yet; they are optional ON
|
|
11
11
|
// PURPOSE so the components can detect their absence and render the
|
|
12
12
|
// NEEDS_DATA_LABEL ('Daten folgt') marker instead of a fabricated value. Never
|
|
13
|
-
// default these to placeholder numbers.
|
|
14
|
-
// marketHigh)
|
|
13
|
+
// default these to placeholder numbers. priceHistory + the market band
|
|
14
|
+
// (marketLow / marketAvg / marketHigh) are needs-data by default.
|
|
15
15
|
|
|
16
16
|
import type { AutobahnPhev } from '../cards/types';
|
|
17
17
|
|
|
@@ -111,8 +111,8 @@ export interface Co2CostsSummary {
|
|
|
111
111
|
export interface VehicleCondition {
|
|
112
112
|
/** TÜV/HU validity, e.g. '03/2027' — or 'Neu' for a new HU. */
|
|
113
113
|
hu: string;
|
|
114
|
-
/** accident-free flag (Unfallfrei)
|
|
115
|
-
unfallfrei: boolean
|
|
114
|
+
/** accident-free flag (Unfallfrei). */
|
|
115
|
+
unfallfrei: boolean;
|
|
116
116
|
/** full service history (Scheckheftgepflegt). */
|
|
117
117
|
scheckheft: boolean;
|
|
118
118
|
/** warranty label, e.g. '12 Monate inkl.'. */
|
|
@@ -136,26 +136,14 @@ export interface VdpReview {
|
|
|
136
136
|
review: string;
|
|
137
137
|
/** star rating 1–5. */
|
|
138
138
|
rating: number;
|
|
139
|
-
/** portal the review was written on, e.g. "Trustpilot" (Bewertung Welt feed only). */
|
|
140
|
-
source?: string;
|
|
141
|
-
/** review date, ISO yyyy-mm-dd (Bewertung Welt feed only). */
|
|
142
|
-
date?: string;
|
|
143
|
-
/** the review on its portal (Bewertung Welt feed only; '' when unknown). */
|
|
144
|
-
url?: string;
|
|
145
139
|
}
|
|
146
140
|
|
|
147
|
-
/**
|
|
148
|
-
export interface
|
|
149
|
-
/**
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
|
|
153
|
-
/** the portal's own average (null when unknown). */
|
|
154
|
-
average: number | null;
|
|
155
|
-
/** number of reviews on the portal. */
|
|
156
|
-
total: number;
|
|
157
|
-
/** the portal's public auto.de profile — "all reviews" ('' when unknown). */
|
|
158
|
-
url?: string;
|
|
141
|
+
/** One point on the price-history sparkline. */
|
|
142
|
+
export interface PriceHistoryPoint {
|
|
143
|
+
/** x-axis label, e.g. 'vor 6 Wo.' / 'heute'. */
|
|
144
|
+
label: string;
|
|
145
|
+
/** price in EUR at that point. */
|
|
146
|
+
price: number;
|
|
159
147
|
}
|
|
160
148
|
|
|
161
149
|
/** One [min,max] EUR band of the 5-tier Preisbewertung (mirrors legacy IRatingConfig). */
|
|
@@ -203,8 +191,8 @@ export interface VehicleDetail {
|
|
|
203
191
|
fuel: string;
|
|
204
192
|
/** gearbox label, e.g. 'Automatik' / 'Schaltgetriebe'. */
|
|
205
193
|
gear: string;
|
|
206
|
-
/** number of previous owners (rendered as 'N. Hand')
|
|
207
|
-
owners: number
|
|
194
|
+
/** number of previous owners (rendered as 'N. Hand'). */
|
|
195
|
+
owners: number;
|
|
208
196
|
/** number of seats. */
|
|
209
197
|
seats: number;
|
|
210
198
|
/** number of doors. */
|
|
@@ -279,6 +267,8 @@ export interface VehicleDetail {
|
|
|
279
267
|
// --- NEEDS DATA: no real source yet (NEVER fabricate) ---
|
|
280
268
|
/** original list price (for the struck-through reference + history endpoint). */
|
|
281
269
|
listPrice?: number;
|
|
270
|
+
/** price-history points (sparkline). Needs-data by default. */
|
|
271
|
+
priceHistory?: PriceHistoryPoint[];
|
|
282
272
|
/** lowest comparable market price in EUR (market band lower bound). */
|
|
283
273
|
marketLow?: number;
|
|
284
274
|
/** average comparable market price in EUR (market band reference). */
|
|
@@ -312,7 +302,7 @@ export function defaultVdpSpecs(v: VehicleDetail): VdpSpec[] {
|
|
|
312
302
|
[['cog', 'Getriebe', v.gear], true],
|
|
313
303
|
[['users', 'Sitze', `${v.seats} Sitze`], false],
|
|
314
304
|
[['door-open', 'Türen', `${v.doors} Türen`], false],
|
|
315
|
-
|
|
305
|
+
[['user', 'Halter', `${v.owners}. Hand`], true], // 0 Vorbesitzer is valid
|
|
316
306
|
[['palette', 'Außenfarbe', v.color], true],
|
|
317
307
|
[['car-front', 'Karosserie', v.body], true],
|
|
318
308
|
[['droplet', 'Verbrauch komb.', v.cons], true], // Pkw-EnVKV — exempt from this rule
|
|
@@ -6,7 +6,6 @@ import { formatTimestamp } from '../utils/DateUtils';
|
|
|
6
6
|
import { DELIVERY_PERIODS_EXTRA } from '../constants/core';
|
|
7
7
|
import moment from 'moment';
|
|
8
8
|
import { IDecoratedProp } from '../types/types';
|
|
9
|
-
import { strictAccidentStatus } from './accidentDisclosure';
|
|
10
9
|
import { gasConsumptionTemplate } from './cbdSelectors';
|
|
11
10
|
|
|
12
11
|
interface IDecoratedProps {
|
|
@@ -521,9 +520,6 @@ const getDecoratedLightProps = (
|
|
|
521
520
|
title: t('cbd:mainData_accidentDamaged'),
|
|
522
521
|
icon: 'wrench',
|
|
523
522
|
get value() {
|
|
524
|
-
const strict = strictAccidentStatus(car);
|
|
525
|
-
if (strict === 'notSpecified') return t('vehicleProps:value.na');
|
|
526
|
-
if (strict) return strict === 'accident' ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
|
|
527
523
|
return damaged ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
|
|
528
524
|
}
|
|
529
525
|
},
|
|
@@ -9,7 +9,6 @@ import { EMISSION_STICKERS_ICONS, WP_EMISSION_STICKERS_ICONS } from '../constant
|
|
|
9
9
|
import { DELIVERY_PERIODS_EXTRA } from '../constants';
|
|
10
10
|
import { IDecoratedProp, ICar, IFinancingUtils } from '../types/types';
|
|
11
11
|
import { getFormattedPrice } from '../utils/CommonUtils';
|
|
12
|
-
import { strictAccidentStatus } from './accidentDisclosure';
|
|
13
12
|
import { gasConsumptionTemplate } from './cbdSelectors';
|
|
14
13
|
|
|
15
14
|
const formatDeliveryPeriod = (t: (key: string, options?: object) => string, deliveryPeriod: string) => {
|
|
@@ -197,9 +196,6 @@ const getDecoratedProps = (
|
|
|
197
196
|
title: t('cbd:mainData_accidentDamaged'),
|
|
198
197
|
icon: 'wrench',
|
|
199
198
|
get value() {
|
|
200
|
-
const strict = strictAccidentStatus(car);
|
|
201
|
-
if (strict === 'notSpecified') return t('vehicleProps:value.na');
|
|
202
|
-
if (strict) return strict === 'accident' ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
|
|
203
199
|
return damaged ? t('vehicleProps:value.damaged') : t('vehicleProps:value.accidentFree');
|
|
204
200
|
}
|
|
205
201
|
},
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// Autobahn (auto.de redesign) — the campaign's banner: headline and link on the left, cut-out cars on a wedge in
|
|
2
|
-
// the campaign's colour on the right; the car in front reaches over the upper edge. Used on fe-main's home page.
|
|
3
|
-
//
|
|
4
|
-
// Texts, colours and dates come from the campaign, the cars from the page, the look from md3.css
|
|
5
|
-
// (.campaign-banner). Nothing is shown before the campaign starts and after it has ended. Renders correctly only
|
|
6
|
-
// inside a `<div className="md3">` subtree.
|
|
7
|
-
|
|
8
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
9
|
-
import { TranslationFunction } from '../types';
|
|
10
|
-
|
|
11
|
-
import { Icon } from '../ui';
|
|
12
|
-
import { Campaign, campaignPeriod, isCampaignRunning } from './campaigns';
|
|
13
|
-
import { campaignVars } from './campaignVars';
|
|
14
|
-
import { openInApp } from './openInApp';
|
|
15
|
-
import { useCountdown } from './useCountdown';
|
|
16
|
-
|
|
17
|
-
export interface CampaignBannerProps {
|
|
18
|
-
campaign: Campaign;
|
|
19
|
-
/** pictures of cars with a transparent background; the first one stands in front. */
|
|
20
|
-
cars: string[];
|
|
21
|
-
/** where the offers are; a real link (new tab, crawlers). */
|
|
22
|
-
href: string;
|
|
23
|
-
/** plain click: the app opens href itself, without loading the page anew. */
|
|
24
|
-
onOpen: () => void;
|
|
25
|
-
t: TranslationFunction;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** true once a part of the element has been on screen (at once without IntersectionObserver). */
|
|
29
|
-
const useSeen = (ref: React.RefObject<HTMLElement | null>): boolean => {
|
|
30
|
-
const [seen, setSeen] = useState(false);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
const el = ref.current;
|
|
33
|
-
if (!el || typeof IntersectionObserver === 'undefined') {
|
|
34
|
-
setSeen(true);
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
const observer = new IntersectionObserver((entries) => {
|
|
38
|
-
if (!entries.some((entry) => entry.isIntersecting)) return;
|
|
39
|
-
setSeen(true);
|
|
40
|
-
observer.disconnect();
|
|
41
|
-
}, { threshold: 0.3 });
|
|
42
|
-
observer.observe(el);
|
|
43
|
-
return () => observer.disconnect();
|
|
44
|
-
}, [ref]);
|
|
45
|
-
return seen;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const CampaignBanner: React.FunctionComponent<CampaignBannerProps> = ({ campaign, cars, href, onOpen, t }) => {
|
|
49
|
-
const ref = useRef<HTMLAnchorElement>(null);
|
|
50
|
-
const seen = useSeen(ref);
|
|
51
|
-
const left = useCountdown(campaign.endsAt);
|
|
52
|
-
if (!left || !isCampaignRunning(campaign)) return null;
|
|
53
|
-
return (
|
|
54
|
-
<a
|
|
55
|
-
ref={ref}
|
|
56
|
-
className={'campaign-banner campaign-banner--' + campaign.id + (seen ? ' campaign-banner--in' : '')}
|
|
57
|
-
style={campaignVars(campaign)}
|
|
58
|
-
href={href}
|
|
59
|
-
onClick={openInApp(onOpen)}
|
|
60
|
-
>
|
|
61
|
-
<span className="campaign-banner-cars" aria-hidden="true">
|
|
62
|
-
{cars.map((src, i) => (
|
|
63
|
-
<img key={src} className={'campaign-banner-car campaign-banner-car--' + (i + 1)} src={src} alt="" decoding="async" />
|
|
64
|
-
))}
|
|
65
|
-
<span className="campaign-banner-note">{t('autobahn:campaign.exampleCars')}</span>
|
|
66
|
-
</span>
|
|
67
|
-
<span className="campaign-banner-body">
|
|
68
|
-
<span className="campaign-banner-period">{t(campaign.texts + '.period', { ...campaignPeriod(campaign) })}</span>
|
|
69
|
-
<strong className="campaign-banner-title">{t(campaign.texts + '.bannerTitle')}</strong>
|
|
70
|
-
<span className="campaign-banner-text">{t(campaign.texts + '.text')}</span>
|
|
71
|
-
<span className="campaign-banner-foot">
|
|
72
|
-
<span className="campaign-banner-cta">
|
|
73
|
-
{t(campaign.texts + '.cta')}
|
|
74
|
-
<Icon name="arrow-right" size={18} stroke={2.2} />
|
|
75
|
-
</span>
|
|
76
|
-
<span className="campaign-banner-ends">
|
|
77
|
-
<Icon name="clock" size={16} stroke={2} />
|
|
78
|
-
{t(left.days ? 'autobahn:campaign.endsInDays' : 'autobahn:campaign.endsInHours', { ...left })}
|
|
79
|
-
</span>
|
|
80
|
-
</span>
|
|
81
|
-
</span>
|
|
82
|
-
</a>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export default CampaignBanner;
|
package/campaign/CampaignBar.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Autobahn (auto.de redesign) — the campaign's bar right under the site header, one link to its offers
|
|
2
|
-
// (see campaigns.ts). Used on fe-main's home page.
|
|
3
|
-
//
|
|
4
|
-
// Texts, colours and dates come from the campaign, the look from md3.css (.campaign-bar). Nothing is shown before
|
|
5
|
-
// the campaign starts and after it has ended. Renders correctly only inside a `<div className="md3">` subtree.
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { TranslationFunction } from '../types';
|
|
9
|
-
|
|
10
|
-
import { Icon } from '../ui';
|
|
11
|
-
import { Campaign, isCampaignRunning } from './campaigns';
|
|
12
|
-
import { campaignVars } from './campaignVars';
|
|
13
|
-
import { openInApp } from './openInApp';
|
|
14
|
-
import { useCountdown } from './useCountdown';
|
|
15
|
-
|
|
16
|
-
export interface CampaignBarProps {
|
|
17
|
-
campaign: Campaign;
|
|
18
|
-
/** where the offers are; a real link (new tab, crawlers). */
|
|
19
|
-
href: string;
|
|
20
|
-
/** plain click: the app opens href itself, without loading the page anew. */
|
|
21
|
-
onOpen: () => void;
|
|
22
|
-
t: TranslationFunction;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const CampaignBar: React.FunctionComponent<CampaignBarProps> = ({ campaign, href, onOpen, t }) => {
|
|
26
|
-
const left = useCountdown(campaign.endsAt); // the bar goes by itself when the campaign ends
|
|
27
|
-
if (!left || !isCampaignRunning(campaign)) return null;
|
|
28
|
-
return (
|
|
29
|
-
<a className={'campaign-bar campaign-bar--' + campaign.id} style={campaignVars(campaign)} href={href} onClick={openInApp(onOpen)}>
|
|
30
|
-
{campaign.icon && <Icon name={campaign.icon} size={16} stroke={2.2} />}
|
|
31
|
-
<span className="campaign-bar-label">{t(campaign.texts + '.label')}:</span>
|
|
32
|
-
<span className="campaign-bar-offer">{t(campaign.texts + '.offer')}</span>
|
|
33
|
-
</a>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default CampaignBar;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// Autobahn (auto.de redesign) — the campaign hero: period, headline and a running countdown to the end of the
|
|
2
|
-
// campaign (design "auto.de SRL Black Friday", A · Dark Edition). Used on fe-main's /search.
|
|
3
|
-
//
|
|
4
|
-
// Texts and dates come from the campaign (campaigns.ts), the look from md3.css (.campaign-hero). Nothing is
|
|
5
|
-
// shown before the campaign starts and after it has ended. Renders correctly only inside a
|
|
6
|
-
// `<div className="md3">` subtree.
|
|
7
|
-
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import { TranslationFunction } from '../types';
|
|
10
|
-
|
|
11
|
-
import { Campaign, campaignPeriod, isCampaignRunning } from './campaigns';
|
|
12
|
-
import { campaignVars } from './campaignVars';
|
|
13
|
-
import { useCountdown } from './useCountdown';
|
|
14
|
-
|
|
15
|
-
export interface CampaignHeroProps {
|
|
16
|
-
campaign: Campaign;
|
|
17
|
-
t: TranslationFunction;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const twoDigits = (n: number): string => (n < 10 ? '0' + n : String(n));
|
|
21
|
-
|
|
22
|
-
const CampaignHero: React.FunctionComponent<CampaignHeroProps> = ({ campaign, t }) => {
|
|
23
|
-
const left = useCountdown(campaign.endsAt);
|
|
24
|
-
if (!left || !isCampaignRunning(campaign)) return null;
|
|
25
|
-
const units: Array<[string, number]> = [['days', left.days], ['hours', left.hours], ['minutes', left.minutes]];
|
|
26
|
-
return (
|
|
27
|
-
<section
|
|
28
|
-
className={'campaign-hero campaign-hero--' + campaign.id}
|
|
29
|
-
style={campaignVars(campaign)}
|
|
30
|
-
aria-label={t(campaign.texts + '.label')}
|
|
31
|
-
>
|
|
32
|
-
<div>
|
|
33
|
-
<div className="campaign-hero-period">{t(campaign.texts + '.period', { ...campaignPeriod(campaign) })}</div>
|
|
34
|
-
<h2 className="campaign-hero-title">{t(campaign.texts + '.title')}</h2>
|
|
35
|
-
<p className="campaign-hero-text">{t(campaign.texts + '.text')}</p>
|
|
36
|
-
</div>
|
|
37
|
-
<div className="campaign-hero-timer" role="timer" aria-label={t('autobahn:campaign.timeLeft', { ...left })}>
|
|
38
|
-
{units.map(([unit, value]) => (
|
|
39
|
-
<div key={unit} className="campaign-hero-unit" aria-hidden="true">
|
|
40
|
-
<b>{twoDigits(value)}</b>
|
|
41
|
-
<small>{t('autobahn:campaign.' + unit, { count: value })}</small>
|
|
42
|
-
</div>
|
|
43
|
-
))}
|
|
44
|
-
</div>
|
|
45
|
-
<div className="campaign-hero-legal">{t(campaign.texts + '.legal')}</div>
|
|
46
|
-
</section>
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default CampaignHero;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Autobahn (auto.de redesign) — "only the campaign's cars", the switch above the filters of /search
|
|
2
|
-
// (see campaigns.ts). Which search filter it turns on is the page's business.
|
|
3
|
-
//
|
|
4
|
-
// The md3 Switch on the campaign's dark card: the whole card is its label, so all of it can be clicked.
|
|
5
|
-
// Renders correctly only inside a `<div className="md3">` subtree.
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { TranslationFunction } from '../types';
|
|
9
|
-
|
|
10
|
-
import { Switch } from '../ui';
|
|
11
|
-
import { Campaign } from './campaigns';
|
|
12
|
-
import { campaignVars } from './campaignVars';
|
|
13
|
-
|
|
14
|
-
export interface CampaignSwitchProps {
|
|
15
|
-
campaign: Campaign;
|
|
16
|
-
checked: boolean;
|
|
17
|
-
onChange: (checked: boolean) => void;
|
|
18
|
-
/** how many cars the switch leaves; null = not known yet (the line stays free). */
|
|
19
|
-
count: number | null;
|
|
20
|
-
language: string;
|
|
21
|
-
t: TranslationFunction;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const CampaignSwitch: React.FunctionComponent<CampaignSwitchProps> = ({ campaign, checked, onChange, count, language, t }) => (
|
|
25
|
-
<div className={'campaign-switch campaign-switch--' + campaign.id} style={campaignVars(campaign)}>
|
|
26
|
-
<Switch
|
|
27
|
-
checked={checked}
|
|
28
|
-
onChange={(event) => onChange(event.target.checked)}
|
|
29
|
-
label={(
|
|
30
|
-
<>
|
|
31
|
-
{t(campaign.texts + '.only')}
|
|
32
|
-
<span className="campaign-switch-count">
|
|
33
|
-
{count != null
|
|
34
|
-
? t('autobahn:campaign.vehicles', { count, number: count.toLocaleString(language === 'en' ? 'en-IN' : 'de-DE') })
|
|
35
|
-
: '\u00a0'}
|
|
36
|
-
</span>
|
|
37
|
-
</>
|
|
38
|
-
)}
|
|
39
|
-
/>
|
|
40
|
-
</div>
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
export default CampaignSwitch;
|
package/campaign/openInApp.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
|
|
3
|
-
/** Click on a campaign's link: a plain click opens it in the app, a new tab or window stays the browser's. */
|
|
4
|
-
export const openInApp = (onOpen: () => void) => (event: React.MouseEvent): void => {
|
|
5
|
-
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
6
|
-
event.preventDefault();
|
|
7
|
-
onOpen();
|
|
8
|
-
};
|
package/campaign/useCountdown.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
export interface Countdown {
|
|
4
|
-
days: number;
|
|
5
|
-
hours: number;
|
|
6
|
-
minutes: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const MINUTE = 60 * 1000;
|
|
10
|
-
|
|
11
|
-
const minutesLeft = (endsAt: string): number => Math.floor((Date.parse(endsAt) - Date.now()) / MINUTE);
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The time left until `endsAt` in whole minutes, counting down by itself; null once it is over.
|
|
15
|
-
* It looks at the clock every second instead of adding up minutes, so it is right again at once after the
|
|
16
|
-
* tab slept or the computer woke up; React renders only when the minute changes.
|
|
17
|
-
*/
|
|
18
|
-
export const useCountdown = (endsAt: string): Countdown | null => {
|
|
19
|
-
const [left, setLeft] = useState(() => minutesLeft(endsAt));
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
const tick = (): void => setLeft(minutesLeft(endsAt));
|
|
22
|
-
tick();
|
|
23
|
-
const timer = setInterval(tick, 1000);
|
|
24
|
-
return () => clearInterval(timer);
|
|
25
|
-
}, [endsAt]);
|
|
26
|
-
if (!(left >= 0)) return null;
|
|
27
|
-
return { days: Math.floor(left / 1440), hours: Math.floor(left / 60) % 24, minutes: left % 60 };
|
|
28
|
-
};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
// Autobahn (auto.de redesign) — CarCard loading placeholder.
|
|
2
|
-
//
|
|
3
|
-
// The shape of a CarCard while its data is on the way: the same card chrome (.mcard
|
|
4
|
-
// .cc-card — border, 18px radius, shadow) and, inside it, the card's own parts as
|
|
5
|
-
// skeleton bars on the line boxes CarCard's CSS gives them, so a grid of these is as
|
|
6
|
-
// tall as the grid of cards that replaces it and nothing below jumps:
|
|
7
|
-
// - photo: 4:3 plus the carousel's 14px (that's how tall .cc-media really renders), on
|
|
8
|
-
// the lighter --md-sc-low so the big area stays calm and the text bars read as content
|
|
9
|
-
// - title 24/27 (+6), trim 13/17 (+6), spec line 11/15 (+10)
|
|
10
|
-
// - price block on its hairline: tabs (39, +12), rate + price rating (58), terms (2 × 17)
|
|
11
|
-
// - phones (≤600, .show-mobile): the CTA row (9 + 40)
|
|
12
|
-
// - eco line (8 + 3 × 11) pinned to the bottom, like the card's
|
|
13
|
-
// Measured against real cards at 1467 / 768 / 390 px (571 / 541 / 593 tall).
|
|
14
|
-
//
|
|
15
|
-
// Decorative only (aria-hidden): the grid that shows these says what is loading.
|
|
16
|
-
// Renders correctly only inside a `<div className="md3">` subtree.
|
|
17
|
-
|
|
18
|
-
import React from 'react';
|
|
19
|
-
|
|
20
|
-
import Skeleton, { injectStyles } from '../ui/Skeleton';
|
|
21
|
-
|
|
22
|
-
export interface CarCardSkeletonProps {
|
|
23
|
-
className?: string;
|
|
24
|
-
style?: React.CSSProperties;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const CARD_SKELETON_CSS = `
|
|
28
|
-
.md3 .cc-skel { display: flex; flex-direction: column; pointer-events: none; }
|
|
29
|
-
.md3 .cc-skel .cc-skel-photo { height: 0; padding-bottom: calc(75% + 14px); border-radius: 0; --mskeleton-base: var(--md-sc-low); }
|
|
30
|
-
.md3 .cc-skel .cc-skel-body { flex: 1; display: flex; flex-direction: column; align-items: flex-start; padding: 0 18px 8px; margin-top: -3px; }
|
|
31
|
-
.md3 .cc-skel .cc-skel-title { width: 62%; height: 20px; margin: 4px 0 9px; border-radius: var(--md-r-xs); }
|
|
32
|
-
.md3 .cc-skel .cc-skel-trim { width: 82%; height: 11px; margin: 3px 0 9px; border-radius: var(--md-r-full); }
|
|
33
|
-
.md3 .cc-skel .cc-skel-spec { width: 92%; height: 9px; margin: 3px 0 13px; border-radius: var(--md-r-full); }
|
|
34
|
-
.md3 .cc-skel .cc-skel-price { align-self: stretch; border-top: 1px solid var(--md-outline-variant); }
|
|
35
|
-
.md3 .cc-skel .cc-skel-tabs { display: grid; grid-template-columns: repeat(3, 1fr); align-items: center; justify-items: center; height: 39px; margin-bottom: 12px; }
|
|
36
|
-
.md3 .cc-skel .cc-skel-tabs .mskeleton { width: 56%; height: 12px; border-radius: var(--md-r-full); }
|
|
37
|
-
.md3 .cc-skel .cc-skel-hero { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 58px; }
|
|
38
|
-
.md3 .cc-skel .cc-skel-rate { width: 46%; height: 42px; border-radius: var(--md-r-xs); }
|
|
39
|
-
.md3 .cc-skel .cc-skel-eval { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; width: 112px; flex: none; }
|
|
40
|
-
.md3 .cc-skel .cc-skel-eval .mskeleton:first-child { width: 72px; height: 12px; border-radius: var(--md-r-full); }
|
|
41
|
-
.md3 .cc-skel .cc-skel-eval .mskeleton:last-child { width: 100%; height: 7px; border-radius: var(--md-r-full); }
|
|
42
|
-
.md3 .cc-skel .cc-skel-terms,
|
|
43
|
-
.md3 .cc-skel .cc-skel-eco { display: flex; flex-direction: column; }
|
|
44
|
-
.md3 .cc-skel .cc-skel-terms .mskeleton { width: 94%; height: 9px; margin: 4px 0; border-radius: var(--md-r-full); }
|
|
45
|
-
.md3 .cc-skel .cc-skel-terms .mskeleton:last-child { width: 60%; }
|
|
46
|
-
.md3 .cc-skel .cc-skel-cta { align-self: stretch; gap: 6px; margin-top: 9px; }
|
|
47
|
-
.md3 .cc-skel .cc-skel-cta .mskeleton { flex: 1.3 1 0; height: 40px; border-radius: var(--md-r-full); }
|
|
48
|
-
.md3 .cc-skel .cc-skel-cta .mskeleton:nth-child(2) { flex: none; width: 40px; }
|
|
49
|
-
.md3 .cc-skel .cc-skel-cta .mskeleton:last-child { flex: 1 1 0; }
|
|
50
|
-
.md3 .cc-skel .cc-skel-eco { align-self: stretch; margin-top: auto; padding-top: 8px; }
|
|
51
|
-
.md3 .cc-skel .cc-skel-eco .mskeleton { height: 7px; margin: 2px 0; border-radius: var(--md-r-full); }
|
|
52
|
-
.md3 .cc-skel .cc-skel-eco .mskeleton:last-child { width: 66%; }
|
|
53
|
-
@media (max-width: 1024px) {
|
|
54
|
-
.md3 .cc-skel .cc-skel-tabs { height: 38px; }
|
|
55
|
-
}`;
|
|
56
|
-
|
|
57
|
-
const CARD_SKELETON_STYLE_ID = 'md3-card-skeleton-styles';
|
|
58
|
-
|
|
59
|
-
injectStyles(CARD_SKELETON_STYLE_ID, CARD_SKELETON_CSS);
|
|
60
|
-
|
|
61
|
-
const CarCardSkeleton: React.FunctionComponent<CarCardSkeletonProps> = ({ className, style }) => {
|
|
62
|
-
React.useEffect(() => { injectStyles(CARD_SKELETON_STYLE_ID, CARD_SKELETON_CSS); }, []);
|
|
63
|
-
return (
|
|
64
|
-
<div className={'mcard cc-card cc-skel' + (className ? ` ${className}` : '')} style={style} aria-hidden="true">
|
|
65
|
-
<Skeleton className="cc-skel-photo" />
|
|
66
|
-
<div className="cc-skel-body">
|
|
67
|
-
<Skeleton className="cc-skel-title" />
|
|
68
|
-
<Skeleton className="cc-skel-trim" />
|
|
69
|
-
<Skeleton className="cc-skel-spec" />
|
|
70
|
-
<div className="cc-skel-price">
|
|
71
|
-
<div className="cc-skel-tabs">
|
|
72
|
-
<Skeleton />
|
|
73
|
-
<Skeleton />
|
|
74
|
-
<Skeleton />
|
|
75
|
-
</div>
|
|
76
|
-
<div className="cc-skel-hero">
|
|
77
|
-
<Skeleton className="cc-skel-rate" />
|
|
78
|
-
<div className="cc-skel-eval">
|
|
79
|
-
<Skeleton />
|
|
80
|
-
<Skeleton />
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
<div className="cc-skel-terms">
|
|
84
|
-
<Skeleton />
|
|
85
|
-
<Skeleton />
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
<div className="cc-skel-cta show-mobile">
|
|
89
|
-
<Skeleton />
|
|
90
|
-
<Skeleton />
|
|
91
|
-
<Skeleton />
|
|
92
|
-
</div>
|
|
93
|
-
<div className="cc-skel-eco">
|
|
94
|
-
<Skeleton />
|
|
95
|
-
<Skeleton />
|
|
96
|
-
<Skeleton />
|
|
97
|
-
</div>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export default CarCardSkeleton;
|