@stackshift-ui/navigation 6.0.13 → 6.1.0-alpha.1

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.
Files changed (56) hide show
  1. package/dist/chunk-4N6ET2I6.mjs +1 -0
  2. package/dist/{chunk-YNDJK4RH.mjs → chunk-67XVPRGX.mjs} +1 -1
  3. package/dist/chunk-6QSBJPEW.mjs +1 -0
  4. package/dist/{chunk-6XDFQS4J.mjs → chunk-EASZP4S2.mjs} +1 -1
  5. package/dist/{chunk-DJV2UTMZ.mjs → chunk-LBUYM4NV.mjs} +1 -1
  6. package/dist/chunk-MSVUIX4E.mjs +1 -0
  7. package/dist/chunk-OXF5VEOU.mjs +1 -0
  8. package/dist/chunk-P3TZNIE6.mjs +1 -0
  9. package/dist/chunk-PCTXJCVP.mjs +1 -0
  10. package/dist/{chunk-KB2HS5UA.mjs → chunk-SVLHEWIY.mjs} +1 -1
  11. package/dist/chunk-V7KKZJMX.mjs +1 -0
  12. package/dist/context/megaNavContext.d.ts +14 -0
  13. package/dist/context/megaNavContext.mjs +1 -0
  14. package/dist/helper/index.d.ts +2 -1
  15. package/dist/helper/index.mjs +1 -1
  16. package/dist/helper.d.ts +6 -0
  17. package/dist/helper.mjs +1 -0
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.mjs +1 -1
  20. package/dist/navigation.d.ts +9 -1
  21. package/dist/navigation.mjs +1 -1
  22. package/dist/navigation_a.mjs +1 -1
  23. package/dist/navigation_b.mjs +1 -1
  24. package/dist/navigation_c.mjs +1 -1
  25. package/dist/navigation_d.mjs +1 -1
  26. package/dist/navigation_e.mjs +1 -1
  27. package/dist/navigation_f.d.ts +3 -0
  28. package/dist/navigation_f.mjs +1 -0
  29. package/dist/navigation_g.d.ts +3 -0
  30. package/dist/navigation_g.mjs +1 -0
  31. package/dist/navigation_h.d.ts +3 -0
  32. package/dist/navigation_h.mjs +1 -0
  33. package/dist/types.d.ts +104 -1
  34. package/package.json +16 -8
  35. package/src/context/megaNavContext.tsx +78 -0
  36. package/src/helper/index.tsx +130 -0
  37. package/src/helper.ts +14 -0
  38. package/src/index.ts +3 -0
  39. package/src/navigation.tsx +29 -1
  40. package/src/navigation_f.tsx +531 -0
  41. package/src/navigation_g.tsx +607 -0
  42. package/src/navigation_h.tsx +742 -0
  43. package/src/types.ts +113 -1
  44. package/dist/chunk-KQFO7OZP.mjs +0 -1
  45. package/dist/chunk-TTJMPYYC.mjs +0 -1
  46. package/dist/helper/blockStyle.js +0 -1
  47. package/dist/helper/index.js +0 -1
  48. package/dist/index.js +0 -2
  49. package/dist/navigation.js +0 -1
  50. package/dist/navigation_a.js +0 -1
  51. package/dist/navigation_b.js +0 -1
  52. package/dist/navigation_c.js +0 -1
  53. package/dist/navigation_d.js +0 -1
  54. package/dist/navigation_e.js +0 -1
  55. package/dist/types.js +0 -1
  56. package/src/helper/index.ts +0 -14
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stackshift-ui/navigation",
3
3
  "description": "",
4
- "version": "6.0.13",
4
+ "version": "6.1.0-alpha.1",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
@@ -29,20 +29,28 @@
29
29
  "typescript": "^5.6.2",
30
30
  "vite-tsconfig-paths": "^5.0.1",
31
31
  "vitest": "^2.1.1",
32
- "@stackshift-ui/typescript-config": "6.0.10",
33
- "@stackshift-ui/eslint-config": "6.0.10"
32
+ "@stackshift-ui/eslint-config": "6.0.10",
33
+ "@stackshift-ui/typescript-config": "6.0.10"
34
34
  },
35
35
  "dependencies": {
36
+ "classnames": "^2.5.1",
36
37
  "@portabletext/react": "^3.1.0",
37
- "@stackshift-ui/text": "6.0.11",
38
+ "@react-spring/web": "^10.0.1",
39
+ "@uidotdev/usehooks": "^2.4.1",
40
+ "react-icons": "^5.3.0",
41
+ "react-sticky-el": "^2.1.1",
42
+ "@stackshift-ui/container": "6.0.11",
38
43
  "@stackshift-ui/button": "6.0.11",
39
44
  "@stackshift-ui/scripts": "6.0.10",
40
45
  "@stackshift-ui/link": "6.0.11",
41
- "@stackshift-ui/image": "6.0.11",
42
- "@stackshift-ui/section": "6.0.11",
43
46
  "@stackshift-ui/flex": "6.0.11",
44
- "@stackshift-ui/container": "6.0.11",
45
- "@stackshift-ui/system": "6.0.11"
47
+ "@stackshift-ui/section": "6.0.11",
48
+ "@stackshift-ui/text": "6.0.11",
49
+ "@stackshift-ui/grid": "6.0.11",
50
+ "@stackshift-ui/image": "6.0.11",
51
+ "@stackshift-ui/system": "6.0.11",
52
+ "@stackshift-ui/heading": "6.0.11",
53
+ "@stackshift-ui/social-icons": "6.0.12"
46
54
  },
47
55
  "peerDependencies": {
48
56
  "@stackshift-ui/system": ">=6.0.11",
@@ -0,0 +1,78 @@
1
+ import { Context, createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
2
+
3
+ export interface MegaNavContextValues {
4
+ currentDropdown: string;
5
+ showDropdown: boolean;
6
+ showMobileMenu: boolean;
7
+ setShowDropdown: (state: boolean) => void;
8
+ setCurrentDropdown: (dropdown: string) => void;
9
+ setShowMobileMenu: (state: boolean) => void;
10
+ }
11
+
12
+ export const MegaNavContext: Context<MegaNavContextValues> = createContext<MegaNavContextValues>({
13
+ currentDropdown: "",
14
+ showDropdown: false,
15
+ showMobileMenu: false,
16
+ setShowDropdown: () => {},
17
+ setCurrentDropdown: () => {},
18
+ setShowMobileMenu: () => {},
19
+ });
20
+
21
+ export function MegaNavContextProvider({ children }: { children: React.ReactNode }) {
22
+ const [currentDropdown, setCurrentDropdown] = useState<string>("");
23
+ const [showDropdown, setShowDropdown] = useState(false);
24
+ const [showMobileMenu, setShowMobileMenu] = useState(false);
25
+ const closeTimeoutRef = useRef<NodeJS.Timeout | null>(null);
26
+
27
+ const handleDropdownClick = () => {
28
+ setShowDropdown(!showDropdown);
29
+ };
30
+
31
+ const handleCurrentDropdown = (dropdown: string) => {
32
+ if (closeTimeoutRef.current) {
33
+ clearTimeout(closeTimeoutRef.current);
34
+ }
35
+
36
+ if (dropdown === "") {
37
+ closeTimeoutRef.current = setTimeout(() => {
38
+ setCurrentDropdown("");
39
+ }, 200);
40
+ } else {
41
+ setCurrentDropdown(dropdown);
42
+ }
43
+ };
44
+
45
+ const handleMobileMenuClick = () => {
46
+ setShowMobileMenu(!showMobileMenu);
47
+ };
48
+
49
+ useEffect(() => {
50
+ return () => {
51
+ if (closeTimeoutRef.current) {
52
+ clearTimeout(closeTimeoutRef.current);
53
+ }
54
+ };
55
+ }, []);
56
+
57
+ const values = useMemo(
58
+ () => ({
59
+ currentDropdown,
60
+ showDropdown,
61
+ showMobileMenu,
62
+ setShowDropdown: handleDropdownClick,
63
+ setCurrentDropdown: handleCurrentDropdown,
64
+ setShowMobileMenu: handleMobileMenuClick,
65
+ }),
66
+ [currentDropdown, showDropdown, showMobileMenu],
67
+ );
68
+
69
+ return <MegaNavContext.Provider value={values}>{children}</MegaNavContext.Provider>;
70
+ }
71
+
72
+ export function useMegaNavContext() {
73
+ const context = useContext(MegaNavContext);
74
+ if (context === undefined) {
75
+ throw new Error("useMegaNavContext must be used within a MegaNavContextProvider");
76
+ }
77
+ return context;
78
+ }
@@ -0,0 +1,130 @@
1
+ import { Link } from "@stackshift-ui/link";
2
+ import { ConditionalLinkTypes, Logo } from "../types";
3
+
4
+ export const logoLink = (logo: Logo) => {
5
+ if (logo?.internalLink && logo?.type === "linkInternal") {
6
+ if (logo?.internalLink?.toLowerCase()?.includes("home")) {
7
+ return "/";
8
+ }
9
+ return `/${logo.internalLink}`;
10
+ } else if (logo?.externalLink && logo?.type === "linkExternal") {
11
+ return logo?.externalLink ?? "/";
12
+ } else {
13
+ return "/";
14
+ }
15
+ };
16
+
17
+ export const ConditionalLink = ({
18
+ className,
19
+ ariaLabel,
20
+ style = {},
21
+ children,
22
+ link,
23
+ target,
24
+ }: ConditionalLinkTypes) => {
25
+ const defaultStyle =
26
+ "inline-block py-2 px-6 rounded-l-xl rounded-t-xl bg-primary hover:bg-primary-foreground text-gray-50 font-bold leading-loose outline-none transition duration-200";
27
+
28
+ if (!link?.internalLink && !link?.externalLink) {
29
+ return (
30
+ <a
31
+ className={className ?? defaultStyle}
32
+ aria-label={ariaLabel}
33
+ //style={style}
34
+ target={target}
35
+ href="/page-not-found">
36
+ {children}
37
+ </a>
38
+ );
39
+ } else if (
40
+ link?.type === "linkInternal" &&
41
+ // link?.internalLink?.toLowerCase()?.includes("home")
42
+ link?.internalLink?.toLowerCase() === "home"
43
+ ) {
44
+ return (
45
+ <Link
46
+ href={link?.referenceType === "projects" ? "/projects" : "/"}
47
+ aria-label={ariaLabel}
48
+ className={className ?? defaultStyle}
49
+ //style={style}
50
+ target={target}>
51
+ {children}
52
+ </Link>
53
+ );
54
+ } else if (link?.type === "linkInternal") {
55
+ let hrefPath = "";
56
+
57
+ switch (link?.referenceType) {
58
+ case "projects":
59
+ hrefPath = `/projects/${link?.internalLink}`;
60
+ break;
61
+ case "commercial":
62
+ hrefPath = `/projects/commercial/${link?.internalLink}`;
63
+ break;
64
+ case "residential":
65
+ hrefPath = `/projects/residential/${link?.internalLink}`;
66
+ break;
67
+ case "landscape":
68
+ hrefPath = `/projects/landscape/${link?.internalLink}`;
69
+ break;
70
+ case "public":
71
+ hrefPath = `/projects/public/${link?.internalLink}`;
72
+ break;
73
+ case "teaching":
74
+ hrefPath = `/projects/teaching/${link?.internalLink}`;
75
+ break;
76
+ case "designInMotion":
77
+ hrefPath = `/projects/future-projects/${link?.internalLink}`;
78
+ break;
79
+ case "renovation":
80
+ hrefPath = `/projects/residential/renovation/${link?.internalLink}`;
81
+ break;
82
+ case "newConstruction":
83
+ hrefPath = `/projects/residential/new-construction/${link?.internalLink}`;
84
+ break;
85
+ case "ourTeam":
86
+ hrefPath = `/our-team/${link?.internalLink}`;
87
+ break;
88
+ case "recognition":
89
+ hrefPath = `/recognition/${link?.internalLink}`;
90
+ break;
91
+
92
+ default:
93
+ hrefPath = `/${link?.internalLink}`;
94
+ }
95
+
96
+ return (
97
+ <Link
98
+ href={hrefPath}
99
+ aria-label={ariaLabel}
100
+ className={className ?? defaultStyle}
101
+ //style={style}
102
+ target={target}>
103
+ {children}
104
+ </Link>
105
+ );
106
+ } else if (link?.type === "linkExternal") {
107
+ return (
108
+ <a
109
+ aria-label={ariaLabel}
110
+ className={className ?? defaultStyle}
111
+ //style={style}
112
+ href={link?.externalLink ?? ""}
113
+ target={target}
114
+ rel={link?.linkTarget === "_blank" ? "noopener noreferrer" : undefined}>
115
+ {children}
116
+ </a>
117
+ );
118
+ } else {
119
+ return (
120
+ <Link
121
+ href="/"
122
+ aria-label={ariaLabel}
123
+ className={className ?? defaultStyle}
124
+ //style={style}
125
+ target={target}>
126
+ {children}
127
+ </Link>
128
+ );
129
+ }
130
+ };
package/src/helper.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { Logo } from "./types";
2
+
3
+ export function logoLink(logo?: Logo): string {
4
+ if (!logo) return "/";
5
+ return logo.linkExternal || "/";
6
+ }
7
+
8
+ export function getImageProperty(image?: any) {
9
+ if (!image) return { width: 0, height: 0 };
10
+ return {
11
+ width: image.width || 0,
12
+ height: image.height || 0,
13
+ };
14
+ }
package/src/index.ts CHANGED
@@ -7,3 +7,6 @@ export * from "./navigation_b";
7
7
  export * from "./navigation_c";
8
8
  export * from "./navigation_d";
9
9
  // export * from "./navigation_e";
10
+ export * from "./navigation_f";
11
+ export * from "./navigation_g";
12
+ export * from "./navigation_h";
@@ -1,11 +1,22 @@
1
1
  import { lazy } from "react";
2
- import { LabeledRoute, LabeledRouteWithKey, Logo, SectionsProps } from "./types";
2
+ import {
3
+ LabeledRoute,
4
+ LabeledRouteWithKey,
5
+ Logo,
6
+ Logos,
7
+ MegaMenu,
8
+ SectionsProps,
9
+ SocialLink,
10
+ } from "./types";
3
11
 
4
12
  const Variants = {
5
13
  variant_a: lazy(() => import("./navigation_a")),
6
14
  variant_b: lazy(() => import("./navigation_b")),
7
15
  variant_c: lazy(() => import("./navigation_c")),
8
16
  variant_d: lazy(() => import("./navigation_d")),
17
+ variant_f: lazy(() => import("./navigation_f")),
18
+ variant_g: lazy(() => import("./navigation_g")),
19
+ variant_h: lazy(() => import("./navigation_h")),
9
20
  };
10
21
 
11
22
  export interface ResponsiveNavLinksProps {
@@ -19,10 +30,18 @@ export interface ResponsiveNavLinksProps {
19
30
  export interface NavigationProps {
20
31
  template?: any;
21
32
  logo?: Logo;
33
+ smallLogo?: Logo;
34
+ logos?: Logos[];
22
35
  links?: LabeledRouteWithKey[];
23
36
  primaryButton?: LabeledRoute;
24
37
  secondaryButton?: LabeledRoute;
25
38
  banner?: any;
39
+ multipleLinks?: any;
40
+ title?: string;
41
+ socialMedia?: SocialLink[];
42
+ dropdownMenu?: LabeledRouteWithKey[];
43
+ iconLinks?: LabeledRouteWithKey[];
44
+ megaMenu?: MegaMenu[];
26
45
  }
27
46
 
28
47
  const displayName = "Navigation";
@@ -33,10 +52,19 @@ export const Navigation: React.FC<SectionsProps> = ({ data }) => {
33
52
 
34
53
  const props = {
35
54
  logo: data?.variants?.logo ?? undefined,
55
+ smallLogo: data?.variants?.smallLogo ?? undefined,
36
56
  links: data?.variants?.routes ?? undefined,
37
57
  primaryButton: data?.variants?.primaryButton ?? undefined,
38
58
  secondaryButton: data?.variants?.secondaryButton ?? undefined,
39
59
  banner: data?.variants?.banner ?? undefined,
60
+ multipleLinks: data?.variants?.multipleLinks ?? undefined,
61
+ title: data?.variants?.title ?? undefined,
62
+ dropdownMenu: data?.variants?.dropdownMenu ?? undefined,
63
+ logos: data?.variants?.logos ?? undefined,
64
+ socialMedia: data?.variants?.socialMedia ?? undefined,
65
+ socialLinks: data?.variants?.socialLinks ?? undefined,
66
+ iconLinks: data?.variants?.iconLinks ?? undefined,
67
+ megaMenu: data?.variants?.megaMenu ?? undefined,
40
68
  };
41
69
 
42
70
  return Variant ? <Variant {...props} /> : null;