@bytebrand/fe-ui-core-autobahn 1.0.56 → 1.0.58

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/chrome/TopBar.tsx CHANGED
@@ -68,9 +68,19 @@ const Flag: React.FunctionComponent<{ code: string }> = ({ code }) =>
68
68
  </svg>
69
69
  );
70
70
 
71
+ /** Which reduced icon set the MOBILE header row shows (≤600px) — desktop is unaffected, it always
72
+ * shows the full search/heart/bell/lang/account set. Per the Figma mobile header spec:
73
+ * - 'default': search + account ("Globaler Default Header")
74
+ * - 'browsing': search + heart + account ("Browsing-Header")
75
+ * - 'conversion':search + phone + account ("Conversion-Header")
76
+ * No page-type → variant mapping exists yet in this codebase; the caller (App.tsx) decides. */
77
+ export type TopBarVariant = 'default' | 'browsing' | 'conversion';
78
+
71
79
  export interface TopBarProps {
72
80
  /** i18n function (drilled from the page wrapper's this.props.t). */
73
81
  t: TranslationFunction;
82
+ /** mobile-only header icon set — see TopBarVariant. Defaults to 'default'. */
83
+ variant?: TopBarVariant;
74
84
  /** real auth state (authStore.isAuthorized) — guest vs profile menu. */
75
85
  isAuthorized?: boolean;
76
86
  /** label for the authed menu header (authStore.userEmail / profile name). */
@@ -96,6 +106,10 @@ export interface TopBarProps {
96
106
  /** SPA navigation for internal routes (fe-main passes history.push). Hosts without a
97
107
  * client-side router (fe-landing, WP widgets) omit it → full page navigation. */
98
108
  onNavigate?: (to: string) => void;
109
+ /** where the mobile "conversion" variant's phone icon goes — no single real business phone
110
+ * number/tel: link was confirmed for this, so it defaults to the contact page. Pass a `tel:...`
111
+ * href here once one is confirmed. */
112
+ phoneHref?: string;
99
113
  }
100
114
 
101
115
  /**
@@ -109,6 +123,7 @@ export interface TopBarProps {
109
123
  */
110
124
  const TopBar: React.FunctionComponent<TopBarProps> = ({
111
125
  t,
126
+ variant = 'default',
112
127
  isAuthorized = false,
113
128
  userLabel,
114
129
  favoritesCount = 0,
@@ -121,6 +136,7 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
121
136
  onSignOut,
122
137
  onLangSelect,
123
138
  onNavigate,
139
+ phoneHref = '/service/kontakt/',
124
140
  }) => {
125
141
  const [menu, setMenu] = useState(false); // mobile hamburger dropdown
126
142
  const [account, setAccount] = useState(false); // account popover
@@ -199,9 +215,179 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
199
215
  <div key={key} style={{ height: 1, background: 'var(--md-outline-variant)', margin: '6px 0' }} />
200
216
  );
201
217
 
218
+ /** First letter of the email's local-part, e.g. "adminvika@…" → "A" — a placeholder single-letter
219
+ * avatar. ProfileStore already carries a real firstName/lastName (privateAddress) that isn't
220
+ * threaded down to TopBar yet; wire that through for a proper two-letter "AV"-style initial. */
221
+ const avatarInitial = (userLabel || '?').trim().charAt(0).toUpperCase() || '?';
222
+
223
+ /** one Account Layer row (mobile design): icon + label + optional badge + trailing chevron —
224
+ * distinct from the desktop popover's `row()` (no chevron, no avatar section there). */
225
+ const mrow = (key: string, label: string, onClick: () => void, opts?: { icon?: string; badge?: number }): JSX.Element => (
226
+ <button
227
+ key={key}
228
+ type="button"
229
+ className="amenu-mobile-row"
230
+ onClick={onClick}
231
+ style={{
232
+ display: 'flex',
233
+ alignItems: 'center',
234
+ gap: 12,
235
+ width: '100%',
236
+ padding: '13px 4px',
237
+ border: 0,
238
+ background: 'transparent',
239
+ color: 'var(--md-on-surface)',
240
+ cursor: 'pointer',
241
+ font: 'inherit',
242
+ fontWeight: 500,
243
+ textAlign: 'left',
244
+ }}
245
+ >
246
+ {opts && opts.icon && <Icon name={opts.icon} size={19} style={{ flex: 'none', color: 'var(--md-on-surface-variant)' }} />}
247
+ <span style={{ flex: 1, fontSize: 15 }}>{label}</span>
248
+ {opts && typeof opts.badge === 'number' && opts.badge > 0 && (
249
+ <span className="md-label-sm" style={{ fontWeight: 700 }}>{opts.badge}</span>
250
+ )}
251
+ <Icon name="chevron-right" size={18} style={{ flex: 'none', color: 'var(--md-on-surface-variant)' }} />
252
+ </button>
253
+ );
254
+
255
+ /** language row (mobile design): real flag + label, checkmark bubble on the active one — matches
256
+ * the Figma "Sprache" section exactly (the desktop popover's globe/check-icon version is left
257
+ * as-is, out of scope for this mobile-only pass). */
258
+ const mLangRow = (code: string, label: string): JSX.Element => {
259
+ const active = language === code;
260
+ return (
261
+ <button
262
+ key={`mlang-${code}`}
263
+ type="button"
264
+ onClick={() => { setAccount(false); if (onLangSelect) onLangSelect(code); }}
265
+ style={{
266
+ display: 'flex',
267
+ alignItems: 'center',
268
+ gap: 12,
269
+ width: '100%',
270
+ padding: '10px 4px',
271
+ border: 0,
272
+ background: 'transparent',
273
+ cursor: 'pointer',
274
+ font: 'inherit',
275
+ textAlign: 'left',
276
+ }}
277
+ >
278
+ <Flag code={code} />
279
+ <span style={{ flex: 1, fontSize: 15, color: 'var(--md-on-surface)' }}>{label}</span>
280
+ {active && (
281
+ <span
282
+ style={{
283
+ width: 20, height: 20, borderRadius: '50%', background: 'var(--md-primary)',
284
+ display: 'flex', alignItems: 'center', justifyContent: 'center', flex: 'none',
285
+ }}
286
+ >
287
+ <Icon name="check" size={13} color="#fff" stroke={3} />
288
+ </span>
289
+ )}
290
+ </button>
291
+ );
292
+ };
293
+
294
+ /** Mobile-only "Account Layer" — a full-width sheet under the header (Figma: "03 | Account
295
+ * Layer"), replacing the desktop popover's small 264px card on mobile widths. Shown/hidden
296
+ * purely via the `show-mobile`/`hide-mobile` CSS classes (this project's existing convention —
297
+ * see the hamburger button/topbar-menu above), not JS width checks. */
298
+ const renderMobileAccountLayer = (): JSX.Element => (
299
+ <div className="amenu-mobile show-mobile mcard" style={{ flexDirection: 'column' }}>
300
+ <div style={{ padding: '20px 20px 8px', textAlign: isAuthorized ? 'left' : 'center' }}>
301
+ {isAuthorized ? (
302
+ <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
303
+ <span
304
+ style={{
305
+ width: 44, height: 44, borderRadius: '50%', flex: 'none',
306
+ background: 'color-mix(in srgb, var(--md-primary) 15%, transparent)',
307
+ color: 'var(--md-primary)', display: 'flex', alignItems: 'center', justifyContent: 'center',
308
+ fontWeight: 700, fontSize: 16,
309
+ }}
310
+ >
311
+ {avatarInitial}
312
+ </span>
313
+ <div style={{ flex: 1, minWidth: 0 }}>
314
+ <div className="md-title-sm" style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
315
+ {userLabel}
316
+ </div>
317
+ <a
318
+ onClick={() => goRoute(R_SETTINGS)}
319
+ className="md-label"
320
+ style={{ color: 'var(--md-primary)', cursor: 'pointer', fontWeight: 600 }}
321
+ >
322
+ {t('autobahn:chrome.myProfile')} ›
323
+ </a>
324
+ </div>
325
+ </div>
326
+ ) : (
327
+ <>
328
+ <span
329
+ style={{
330
+ width: 44, height: 44, borderRadius: '50%', margin: '0 auto 14px',
331
+ background: 'var(--md-outline-variant)', color: 'var(--md-on-surface-variant)',
332
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
333
+ }}
334
+ >
335
+ <Icon name="user" size={22} />
336
+ </span>
337
+ <div className="md-headline-sm" style={{ fontWeight: 700, marginBottom: 6 }}>
338
+ {t('autobahn:chrome.welcome')}
339
+ </div>
340
+ <div className="md-body" style={{ marginBottom: 16 }}>
341
+ {t('autobahn:chrome.welcomeSubtext')}
342
+ </div>
343
+ </>
344
+ )}
345
+ </div>
346
+
347
+ <div style={{ padding: '4px 20px 8px' }}>
348
+ {isAuthorized ? (
349
+ <>
350
+ {!isDealerMain &&
351
+ mrow('m-dashboard', t('autobahn:chrome.dashboard'), () => goRoute(R_DASHBOARD), { icon: 'layout-grid' })}
352
+ {mrow('m-vehicles', t('autobahn:chrome.myVehicles'), () => goRoute(R_MY_VEHICLES), { icon: 'car' })}
353
+ {mrow('m-searches', t('autobahn:chrome.savedSearches'), () => goRoute(R_SAVED_SEARCHES), { icon: 'bell' })}
354
+ {mrow('m-favorites', t('autobahn:chrome.favorites'), () => goRoute(R_FAVOURITES), { icon: 'heart', badge: favoritesCount })}
355
+ {mrow('m-settings', t('autobahn:chrome.settings'), () => goRoute(R_SETTINGS), { icon: 'settings' })}
356
+ {mrow('m-help', t('autobahn:chrome.helpContact'), () => goRoute(R_KONTAKT), { icon: 'help-circle' })}
357
+ {isDealerMain && mrow('m-dealer', t('autobahn:chrome.dealerDashboard'), () => goRoute(R_DASHBOARD), { icon: 'store' })}
358
+ {mrow('m-signout', t('autobahn:chrome.signOut'), () => { setAccount(false); if (onSignOut) onSignOut(); }, { icon: 'log-out' })}
359
+ </>
360
+ ) : (
361
+ <>
362
+ <button
363
+ type="button"
364
+ className="mbtn mbtn--filled mbtn--block"
365
+ style={{ width: '100%', marginBottom: 4 }}
366
+ onClick={() => goRoute(R_SIGN_IN)}
367
+ >
368
+ {t('autobahn:chrome.signIn')}
369
+ </button>
370
+ {mrow('m-register', t('autobahn:chrome.register'), () => goRoute(R_SIGN_UP), { icon: 'user-plus' })}
371
+ {mrow('m-dealer-signup', t('autobahn:chrome.dealerSignUp'), () => goRoute(R_DEALER), { icon: 'store' })}
372
+ {mrow('m-favorites', t('autobahn:chrome.favorites'), () => goRoute(R_FAVOURITES), { icon: 'heart', badge: favoritesCount })}
373
+ </>
374
+ )}
375
+ </div>
376
+
377
+ {divider('m-d1')}
378
+
379
+ <div style={{ padding: '8px 20px 20px' }}>
380
+ <div className="md-label-sm" style={{ color: 'var(--md-on-surface-variant)', padding: '4px 4px 6px' }}>
381
+ {t('autobahn:chrome.language')}
382
+ </div>
383
+ {LANGS.map(([code, label]) => mLangRow(code, label))}
384
+ </div>
385
+ </div>
386
+ );
387
+
202
388
  const renderAccountMenu = (): JSX.Element => (
203
389
  <div
204
- className="amenu mcard"
390
+ className="amenu mcard hide-mobile"
205
391
  style={{
206
392
  position: 'absolute',
207
393
  top: 'calc(100% + 8px)',
@@ -308,21 +494,37 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
308
494
  <div style={{ flex: 1 }} />
309
495
 
310
496
  <IconButton name="search" label={t('autobahn:chrome.search')} onClick={goSearch} />
311
- {/* Merkliste → /favourites with a real count badge */}
312
- <span style={{ position: 'relative', display: 'inline-flex' }}>
497
+ {/* Merkliste → /favourites with a real count badge — desktop-only now; the mobile row
498
+ below shows it ONLY for the 'browsing' variant instead. */}
499
+ <span className="hide-mobile" style={{ position: 'relative', display: 'inline-flex' }}>
313
500
  <IconButton name="heart" label={t('autobahn:chrome.favorites')} onClick={() => goRoute(R_FAVOURITES)} />
314
501
  {favoritesCount > 0 && (
315
502
  <span style={badgeStyle}>{favoritesCount}</span>
316
503
  )}
317
504
  </span>
318
- {/* Suchaufträge → /my-searches (saved searches list) */}
319
- <span style={{ position: 'relative', display: 'inline-flex' }}>
505
+ {/* Suchaufträge → /my-searches (saved searches list) — desktop-only; no Figma mobile
506
+ header variant includes a bell icon. */}
507
+ <span className="hide-mobile" style={{ position: 'relative', display: 'inline-flex' }}>
320
508
  <IconButton name="bell" label={t('autobahn:chrome.savedSearches')} onClick={() => goRoute(R_SAVED_SEARCHES)} />
321
509
  {notificationCount > 0 && (
322
510
  <span style={badgeStyle}>{notificationCount}</span>
323
511
  )}
324
512
  </span>
325
513
 
514
+ {/* Mobile-only reduced icon set — which ONE extra icon (besides search+account, both
515
+ always shown) appears depends on `variant`, per the 3 Figma mobile header specs. */}
516
+ {variant === 'browsing' && (
517
+ <span className="show-mobile" style={{ position: 'relative', display: 'inline-flex' }}>
518
+ <IconButton name="heart" label={t('autobahn:chrome.favorites')} onClick={() => goRoute(R_FAVOURITES)} />
519
+ {favoritesCount > 0 && <span style={badgeStyle}>{favoritesCount}</span>}
520
+ </span>
521
+ )}
522
+ {variant === 'conversion' && (
523
+ <span className="show-mobile" style={{ position: 'relative', display: 'inline-flex' }}>
524
+ <IconButton name="phone" label={t('autobahn:chrome.callUs')} onClick={() => goNav({ href: phoneHref })} />
525
+ </span>
526
+ )}
527
+
326
528
  {/* language segmented control — hidden ≤600px (the account menu carries language rows). */}
327
529
  {onLangSelect && (
328
530
  <div className="lang-seg hide-mobile" aria-label={t('autobahn:chrome.switchLanguage')}>
@@ -331,23 +533,28 @@ const TopBar: React.FunctionComponent<TopBarProps> = ({
331
533
  </div>
332
534
  )}
333
535
 
334
- {/* Konto button + MD3 account popover — visible at EVERY width: this menu is the only
335
- place sign-out / settings / dealer switching exist, so it must never be display:none'd
336
- (the pre-cutover hide-tablet left 601–980px with no logout at all). */}
536
+ {/* Konto trigger + account layer — visible at EVERY width: this menu is the only place
537
+ sign-out / settings / dealer switching exist, so it must never be display:none'd (the
538
+ pre-cutover hide-tablet left 601–980px with no logout at all). Desktop keeps the
539
+ tonal "Konto" pill; ≤600px it collapses to a plain icon (topbar-account-btn CSS) and
540
+ opens the full-width mobile Account Layer instead of the small popover. */}
337
541
  <span style={{ position: 'relative', display: 'inline-flex' }}>
338
542
  <button
339
- className="mbtn mbtn--tonal mbtn--sm"
543
+ className="mbtn mbtn--tonal mbtn--sm topbar-account-btn"
340
544
  style={{ marginLeft: 4 }}
341
545
  onClick={() => setAccount((a) => !a)}
342
546
  aria-expanded={account}
547
+ aria-label={t('autobahn:chrome.account')}
343
548
  >
344
549
  <Icon name="user" size={18} />
345
- {t('autobahn:chrome.account')}
550
+ <span className="hide-mobile">{t('autobahn:chrome.account')}</span>
346
551
  </button>
347
552
  {account && renderAccountMenu()}
348
553
  </span>
349
554
  </div>
350
555
 
556
+ {account && renderMobileAccountLayer()}
557
+
351
558
  {/* click-away backdrop for the account popover */}
352
559
  {account && (
353
560
  <div
package/constants.ts CHANGED
@@ -1,31 +1,31 @@
1
- // Autobahn (auto.de redesign) — shared lookup constants barrel.
2
- // Pure data re-exported from ./constants/autobahn (kept import-safe for plain Node consumers,
3
- // see that file's header) plus the legacy fe-ui-core shim re-exports below.
4
- export * from './constants/autobahn';
5
-
6
- // ---------------------------------------------------------------------------
7
- // Legacy shared constants (moved here from fe-ui-core).
8
- //
9
- // This block mirrors the public symbol set of the old
10
- // `@bytebrand/fe-ui-core/constants` barrel so consumers can swap that
11
- // specifier for `@bytebrand/fe-ui-core-autobahn/constants` 1:1. The
12
- // implementations live under ./constants/ (core.ts, app.ts, price.ts,
13
- // Search.ts, …); fe-ui-core re-exports them via shims until it is deleted.
14
- // ---------------------------------------------------------------------------
15
-
16
- export {
17
- offers,
18
- checkoutOffers,
19
- checkoutWarranties,
20
- checkoutSteps,
21
- checkoutSubStep,
22
- DELIVERY_PERIODS_EXTRA,
23
- THREE,
24
- WLTP_ENERGY_EFFICIENCY_CLASS
25
- } from './constants/core';
26
-
27
- export { CUSTOM_ERROR_MESSAGES, supportPhone, supportPhoneLink } from './constants/app';
28
-
29
- export { priceRatings } from './constants/price';
30
-
31
- export { THROTTLE_DELAY } from './constants/Search';
1
+ // Autobahn (auto.de redesign) — shared lookup constants barrel.
2
+ // Pure data re-exported from ./constants/autobahn (kept import-safe for plain Node consumers,
3
+ // see that file's header) plus the legacy fe-ui-core shim re-exports below.
4
+ export * from './constants/autobahn';
5
+
6
+ // ---------------------------------------------------------------------------
7
+ // Legacy shared constants (moved here from fe-ui-core).
8
+ //
9
+ // This block mirrors the public symbol set of the old
10
+ // `@bytebrand/fe-ui-core/constants` barrel so consumers can swap that
11
+ // specifier for `@bytebrand/fe-ui-core-autobahn/constants` 1:1. The
12
+ // implementations live under ./constants/ (core.ts, app.ts, price.ts,
13
+ // Search.ts, …); fe-ui-core re-exports them via shims until it is deleted.
14
+ // ---------------------------------------------------------------------------
15
+
16
+ export {
17
+ offers,
18
+ checkoutOffers,
19
+ checkoutWarranties,
20
+ checkoutSteps,
21
+ checkoutSubStep,
22
+ DELIVERY_PERIODS_EXTRA,
23
+ THREE,
24
+ WLTP_ENERGY_EFFICIENCY_CLASS
25
+ } from './constants/core';
26
+
27
+ export { CUSTOM_ERROR_MESSAGES, supportPhone, supportPhoneLink } from './constants/app';
28
+
29
+ export { priceRatings } from './constants/price';
30
+
31
+ export { THROTTLE_DELAY } from './constants/Search';
@@ -188,7 +188,10 @@
188
188
  "requestLabel": "Jetzt Anfragen",
189
189
  "threeSixtyLabel": "360°-Ansicht",
190
190
  "counterLabel": "Bild {{current}} von {{total}}",
191
- "moreThumbsLabel": "{{count}} weitere Bilder"
191
+ "moreThumbsLabel": "{{count}} weitere Bilder",
192
+ "allPhotosTitle": "Alle {{count}} Fotos",
193
+ "allPhotosSubtitle": "Tippe auf ein Foto, um es zu öffnen.",
194
+ "allPhotosFooter": "{{count}} Fotos insgesamt"
192
195
  },
193
196
  "chrome": {
194
197
  "menu": "Menü",
@@ -204,6 +207,10 @@
204
207
  "dealerSignUp": "Als Händler anmelden",
205
208
  "language": "Sprache",
206
209
  "myAccount": "Mein Konto",
210
+ "myProfile": "Mein Profil",
211
+ "welcome": "Willkommen bei auto.de",
212
+ "welcomeSubtext": "Melde dich an oder erstelle ein Konto, um alle Vorteile zu nutzen.",
213
+ "callUs": "Anrufen",
207
214
  "usedCars": "Gebrauchtwagen",
208
215
  "newCars": "Neuwagen",
209
216
  "leasing": "Leasing",
@@ -188,7 +188,10 @@
188
188
  "requestLabel": "Enquire now",
189
189
  "threeSixtyLabel": "360° view",
190
190
  "counterLabel": "Image {{current}} of {{total}}",
191
- "moreThumbsLabel": "{{count}} more images"
191
+ "moreThumbsLabel": "{{count}} more images",
192
+ "allPhotosTitle": "All {{count}} photos",
193
+ "allPhotosSubtitle": "Tap a photo to open it.",
194
+ "allPhotosFooter": "{{count}} photos total"
192
195
  },
193
196
  "chrome": {
194
197
  "menu": "Menu",
@@ -204,6 +207,10 @@
204
207
  "dealerSignUp": "Become a dealer",
205
208
  "language": "Language",
206
209
  "myAccount": "My account",
210
+ "myProfile": "My profile",
211
+ "welcome": "Welcome to auto.de",
212
+ "welcomeSubtext": "Sign in or create an account to use all the benefits.",
213
+ "callUs": "Call us",
207
214
  "usedCars": "Used cars",
208
215
  "newCars": "New cars",
209
216
  "leasing": "Leasing",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core-autobahn",
3
- "version": "1.0.56",
3
+ "version": "1.0.58",
4
4
  "description": "auto.de md3 (Autobahn) design system — UI primitives, cards, chrome, VDP modules, theme CSS and locales. Ships raw TypeScript source (like fe-ui-core before it); each consumer's bundler compiles it.",
5
5
  "main": "index.ts",
6
6
  "license": "UNLICENSED",