@deriv-web-design/ui 0.0.12 → 0.0.13

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/dist/index.mjs CHANGED
@@ -1372,7 +1372,7 @@ var Hero = ({
1372
1372
  const variantClass = `hero--${variant}`;
1373
1373
  const textBlock = /* @__PURE__ */ jsxs17("div", { className: "hero__text", children: [
1374
1374
  subtitle && /* @__PURE__ */ jsx18("p", { className: "hero__subtitle", children: subtitle }),
1375
- /* @__PURE__ */ jsx18("p", { className: "hero__title", children: title }),
1375
+ /* @__PURE__ */ jsx18("h2", { className: "hero__title", children: title }),
1376
1376
  description && /* @__PURE__ */ jsx18("p", { className: "hero__description", children: description })
1377
1377
  ] });
1378
1378
  const buttonBlock = (primaryButton || secondaryButton) && /* @__PURE__ */ jsxs17("div", { className: "hero__buttons", children: [
@@ -2338,6 +2338,27 @@ var XMarkIcon2 = () => /* @__PURE__ */ jsx23("svg", { width: "20", height: "20",
2338
2338
  strokeLinecap: "round"
2339
2339
  }
2340
2340
  ) });
2341
+ var ChevronLeftIcon = ({ className }) => /* @__PURE__ */ jsx23(
2342
+ "svg",
2343
+ {
2344
+ className,
2345
+ width: "24",
2346
+ height: "24",
2347
+ viewBox: "0 0 24 24",
2348
+ fill: "none",
2349
+ "aria-hidden": "true",
2350
+ children: /* @__PURE__ */ jsx23(
2351
+ "path",
2352
+ {
2353
+ d: "M15 18L9 12L15 6",
2354
+ stroke: "currentColor",
2355
+ strokeWidth: "2",
2356
+ strokeLinecap: "round",
2357
+ strokeLinejoin: "round"
2358
+ }
2359
+ )
2360
+ }
2361
+ );
2341
2362
  var GlobeIcon = ({ className }) => /* @__PURE__ */ jsx23("img", { src: icon_globe_default, alt: "", "aria-hidden": "true", width: "20", height: "20", className });
2342
2363
  var DropdownPanel = ({ item, onMouseEnter, onMouseLeave }) => {
2343
2364
  const { dropdown } = item;
@@ -2469,6 +2490,9 @@ var Navbar = ({
2469
2490
  ctaHref,
2470
2491
  languageLabel,
2471
2492
  onLanguageClick,
2493
+ languageItems,
2494
+ activeLanguageCode,
2495
+ onLanguageSelect,
2472
2496
  className,
2473
2497
  ...props
2474
2498
  }) => {
@@ -2476,8 +2500,13 @@ var Navbar = ({
2476
2500
  const [mobileOpen, setMobileOpen] = useState8(false);
2477
2501
  const [mobileExpanded, setMobileExpanded] = useState8(null);
2478
2502
  const [scrolled, setScrolled] = useState8(false);
2503
+ const [langDropdownOpen, setLangDropdownOpen] = useState8(false);
2504
+ const [mobileLangOpen, setMobileLangOpen] = useState8(false);
2479
2505
  const hoverTimeoutRef = useRef7(null);
2506
+ const langHoverTimeoutRef = useRef7(null);
2480
2507
  const pillAreaRef = useRef7(null);
2508
+ const langBtnRef = useRef7(null);
2509
+ const hasLangDropdown = Boolean(languageItems && languageItems.length > 0);
2481
2510
  const resolvedLogo = theme === "light" ? logoSrcDark ?? logoSrc : logoSrc;
2482
2511
  useEffect6(() => {
2483
2512
  const onScroll = () => setScrolled(window.scrollY > 0);
@@ -2489,11 +2518,15 @@ var Navbar = ({
2489
2518
  if (e.key === "Escape") {
2490
2519
  setOpenDropdown(null);
2491
2520
  setMobileOpen(false);
2521
+ setMobileLangOpen(false);
2492
2522
  }
2493
2523
  };
2494
2524
  document.addEventListener("keydown", onKey);
2495
2525
  return () => document.removeEventListener("keydown", onKey);
2496
2526
  }, []);
2527
+ useEffect6(() => {
2528
+ if (!mobileOpen) setMobileLangOpen(false);
2529
+ }, [mobileOpen]);
2497
2530
  useEffect6(() => {
2498
2531
  document.body.style.overflow = mobileOpen ? "hidden" : "";
2499
2532
  return () => {
@@ -2516,6 +2549,25 @@ var Navbar = ({
2516
2549
  hoverTimeoutRef.current = null;
2517
2550
  }
2518
2551
  }, []);
2552
+ const clearLangHoverTimeout = useCallback2(() => {
2553
+ if (langHoverTimeoutRef.current) {
2554
+ clearTimeout(langHoverTimeoutRef.current);
2555
+ langHoverTimeoutRef.current = null;
2556
+ }
2557
+ }, []);
2558
+ const handleLangEnter = useCallback2(() => {
2559
+ clearLangHoverTimeout();
2560
+ setLangDropdownOpen(true);
2561
+ }, [clearLangHoverTimeout]);
2562
+ const handleLangLeave = useCallback2(() => {
2563
+ clearLangHoverTimeout();
2564
+ langHoverTimeoutRef.current = setTimeout(() => setLangDropdownOpen(false), 150);
2565
+ }, [clearLangHoverTimeout]);
2566
+ const handleLangSelect = useCallback2((code) => {
2567
+ setLangDropdownOpen(false);
2568
+ setMobileLangOpen(false);
2569
+ onLanguageSelect?.(code);
2570
+ }, [onLanguageSelect]);
2519
2571
  const handleNavEnter = useCallback2((label) => {
2520
2572
  clearHoverTimeout();
2521
2573
  setOpenDropdown(label);
@@ -2575,10 +2627,28 @@ var Navbar = ({
2575
2627
  }
2576
2628
  return /* @__PURE__ */ jsx23("a", { href: item.href, className: "navbar__nav-item", children: item.label }, item.label);
2577
2629
  }),
2578
- languageLabel && /* @__PURE__ */ jsxs22("button", { className: "navbar__nav-item navbar__lang-btn", onClick: onLanguageClick, children: [
2579
- /* @__PURE__ */ jsx23(GlobeIcon, { className: "navbar__lang-globe" }),
2580
- languageLabel
2581
- ] })
2630
+ languageLabel && /* @__PURE__ */ jsx23(
2631
+ "div",
2632
+ {
2633
+ className: "navbar__lang-wrapper",
2634
+ onMouseEnter: hasLangDropdown ? handleLangEnter : void 0,
2635
+ onMouseLeave: hasLangDropdown ? handleLangLeave : void 0,
2636
+ children: /* @__PURE__ */ jsxs22(
2637
+ "button",
2638
+ {
2639
+ ref: langBtnRef,
2640
+ className: "navbar__nav-item navbar__lang-btn",
2641
+ onClick: hasLangDropdown ? () => setLangDropdownOpen((o) => !o) : onLanguageClick,
2642
+ "aria-haspopup": hasLangDropdown ? "true" : void 0,
2643
+ "aria-expanded": hasLangDropdown ? langDropdownOpen : void 0,
2644
+ children: [
2645
+ /* @__PURE__ */ jsx23(GlobeIcon, { className: "navbar__lang-globe" }),
2646
+ languageLabel
2647
+ ]
2648
+ }
2649
+ )
2650
+ }
2651
+ )
2582
2652
  ] }),
2583
2653
  /* @__PURE__ */ jsxs22("div", { className: "navbar__pill-actions", children: [
2584
2654
  loginHref && /* @__PURE__ */ jsx23("a", { href: loginHref, children: /* @__PURE__ */ jsx23(Button, { colorScheme: "black", variant: "secondary", label: loginLabel }) }),
@@ -2594,6 +2664,38 @@ var Navbar = ({
2594
2664
  },
2595
2665
  "dropdown"
2596
2666
  ) }),
2667
+ /* @__PURE__ */ jsx23(AnimatePresence, { children: hasLangDropdown && langDropdownOpen && /* @__PURE__ */ jsx23(
2668
+ motion2.div,
2669
+ {
2670
+ className: "navbar__lang-dropdown",
2671
+ variants: dropdownVariants,
2672
+ initial: "hidden",
2673
+ animate: "visible",
2674
+ exit: "hidden",
2675
+ transition: { duration: 0.18, ease: EASE_OUT_EXPO },
2676
+ onMouseEnter: clearLangHoverTimeout,
2677
+ onMouseLeave: handleLangLeave,
2678
+ children: /* @__PURE__ */ jsx23(
2679
+ "div",
2680
+ {
2681
+ className: "navbar__lang-dropdown-grid",
2682
+ style: { "--lang-rows": Math.ceil(languageItems.length / 3) },
2683
+ children: languageItems.map((lang) => /* @__PURE__ */ jsx23(
2684
+ "button",
2685
+ {
2686
+ className: [
2687
+ "navbar__lang-dropdown-item",
2688
+ lang.code === activeLanguageCode ? "navbar__lang-dropdown-item--active" : ""
2689
+ ].filter(Boolean).join(" "),
2690
+ onClick: () => handleLangSelect(lang.code),
2691
+ children: lang.label
2692
+ },
2693
+ lang.code
2694
+ ))
2695
+ }
2696
+ )
2697
+ }
2698
+ ) }),
2597
2699
  /* @__PURE__ */ jsxs22("div", { className: "navbar__actions", children: [
2598
2700
  loginHref && /* @__PURE__ */ jsx23("a", { href: loginHref, className: "navbar__actions-login", children: /* @__PURE__ */ jsx23(
2599
2701
  Button,
@@ -2668,12 +2770,23 @@ var Navbar = ({
2668
2770
  item.label
2669
2771
  );
2670
2772
  }),
2671
- languageLabel && /* @__PURE__ */ jsxs22("button", { className: "navbar__drawer-lang", onClick: onLanguageClick, children: [
2773
+ languageLabel && !hasLangDropdown && /* @__PURE__ */ jsxs22("button", { className: "navbar__drawer-lang", onClick: onLanguageClick, children: [
2672
2774
  /* @__PURE__ */ jsx23(GlobeIcon, { className: "navbar__lang-globe" }),
2673
2775
  languageLabel
2674
- ] })
2776
+ ] }),
2777
+ languageLabel && hasLangDropdown && /* @__PURE__ */ jsxs22(
2778
+ "button",
2779
+ {
2780
+ className: "navbar__drawer-lang",
2781
+ onClick: () => setMobileLangOpen(true),
2782
+ children: [
2783
+ /* @__PURE__ */ jsx23(GlobeIcon, { className: "navbar__lang-globe" }),
2784
+ languageLabel
2785
+ ]
2786
+ }
2787
+ )
2675
2788
  ] }),
2676
- /* @__PURE__ */ jsxs22("div", { className: "navbar__drawer-footer", children: [
2789
+ !mobileLangOpen && /* @__PURE__ */ jsxs22("div", { className: "navbar__drawer-footer", children: [
2677
2790
  loginHref && /* @__PURE__ */ jsx23("a", { href: loginHref, style: { display: "block" }, children: /* @__PURE__ */ jsx23(
2678
2791
  Button,
2679
2792
  {
@@ -2692,7 +2805,40 @@ var Navbar = ({
2692
2805
  fullWidth: true
2693
2806
  }
2694
2807
  ) })
2695
- ] })
2808
+ ] }),
2809
+ /* @__PURE__ */ jsx23(AnimatePresence, { children: hasLangDropdown && mobileLangOpen && /* @__PURE__ */ jsxs22(
2810
+ motion2.div,
2811
+ {
2812
+ className: "navbar__drawer-lang-panel",
2813
+ initial: { y: "100%" },
2814
+ animate: { y: 0 },
2815
+ exit: { y: "100%" },
2816
+ transition: { duration: 0.25, ease: EASE_OUT_EXPO },
2817
+ children: [
2818
+ /* @__PURE__ */ jsx23(
2819
+ "button",
2820
+ {
2821
+ className: "navbar__drawer-lang-back",
2822
+ onClick: () => setMobileLangOpen(false),
2823
+ "aria-label": "Back to menu",
2824
+ children: /* @__PURE__ */ jsx23(ChevronLeftIcon, {})
2825
+ }
2826
+ ),
2827
+ /* @__PURE__ */ jsx23("div", { className: "navbar__drawer-lang-grid", children: languageItems.map((lang) => /* @__PURE__ */ jsx23(
2828
+ "button",
2829
+ {
2830
+ className: [
2831
+ "navbar__drawer-lang-item",
2832
+ lang.code === activeLanguageCode ? "navbar__drawer-lang-item--active" : ""
2833
+ ].filter(Boolean).join(" "),
2834
+ onClick: () => handleLangSelect(lang.code),
2835
+ children: lang.label
2836
+ },
2837
+ lang.code
2838
+ )) })
2839
+ ]
2840
+ }
2841
+ ) })
2696
2842
  ]
2697
2843
  }
2698
2844
  ) }) })