@hashicorp/react-components 0.0.0-nightly.e8ac55b → 0.0.0-nightly.eb4c59d

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 (32) hide show
  1. package/package.json +8 -5
  2. package/src/components/marketo-form/partials/fields/htmltext-field/style.module.css +16 -4
  3. package/src/components/marketo-form/utils.ts +4 -0
  4. package/src/components/nav-panel/components/link-list/index.tsx +88 -0
  5. package/src/components/nav-panel/components/link-list/style.module.css +57 -0
  6. package/src/components/nav-panel/components/panel/column/index.tsx +24 -0
  7. package/src/components/nav-panel/components/panel/column/style.module.css +24 -0
  8. package/src/components/nav-panel/components/panel/index.tsx +4 -0
  9. package/src/components/nav-panel/components/panel/root/index.tsx +20 -0
  10. package/src/components/nav-panel/components/panel/root/style.module.css +30 -0
  11. package/src/components/nav-panel/components/promo/index.tsx +86 -0
  12. package/src/components/nav-panel/components/promo/style.module.css +114 -0
  13. package/src/components/nav-panel/index.tsx +6 -0
  14. package/src/components/nav-panel/product-panel/index.tsx +160 -0
  15. package/src/components/nav-panel/product-panel/style.module.css +315 -0
  16. package/src/components/nav-panel/standard-panel/index.tsx +44 -0
  17. package/src/components/nav-panel/standard-panel/style.module.css +11 -0
  18. package/src/components/next-steps/index.tsx +4 -10
  19. package/src/components/subnav/index.tsx +6 -6
  20. package/src/components/subnav/partials/CtaLinks/index.tsx +1 -1
  21. package/src/components/subnav/partials/DropdownTrigger/index.tsx +1 -1
  22. package/src/components/subnav/partials/MenuItemsDefault/index.tsx +1 -1
  23. package/src/components/subnav/partials/MenuItemsOverflow/index.tsx +2 -2
  24. package/src/components/subnav/partials/TitleLink/index.tsx +9 -9
  25. package/src/components/subnav/partials/TitleLink/mktg-logos/all-community-product-logos_on-dark.ts +7 -7
  26. package/src/components/subnav/partials/TitleLink/mktg-logos/all-community-product-logos_on-light.ts +7 -7
  27. package/src/components/subnav/partials/TitleLink/mktg-logos/all-primary-logos_on-dark.ts +10 -10
  28. package/src/components/subnav/partials/TitleLink/mktg-logos/all-primary-logos_on-light.ts +10 -10
  29. package/src/lib/parse-url/index.test.ts +30 -0
  30. package/src/lib/parse-url/index.ts +32 -0
  31. package/src/lib/track-nav-click-event/index.ts +22 -0
  32. package/src/lib/v/index.ts +11 -0
@@ -0,0 +1,32 @@
1
+ export function parseUrl(url: string | undefined): {
2
+ linkType: 'inbound' | 'outbound'
3
+ href: string
4
+ } {
5
+ if (!url) {
6
+ throw new Error('url is required')
7
+ }
8
+
9
+ if (isRelative(url) || isAnchor(url)) {
10
+ return { linkType: 'inbound', href: url }
11
+ }
12
+
13
+ if (isInternal(url)) {
14
+ try {
15
+ const { pathname, search } = new URL(url)
16
+ const href = pathname + search
17
+ return { linkType: 'inbound', href }
18
+ } catch (error) {
19
+ throw new Error(`Invalid href: ${url}`)
20
+ }
21
+ }
22
+
23
+ return { linkType: 'outbound', href: url }
24
+ }
25
+
26
+ const isRelative = (url) => url.startsWith('/')
27
+ const isAnchor = (url) => url.startsWith('#')
28
+
29
+ export const isInternal = (url) => {
30
+ const hostname = new URL(url).hostname
31
+ return hostname === 'hashicorp.com'
32
+ }
@@ -0,0 +1,22 @@
1
+ import va from '@vercel/analytics'
2
+
3
+ /**
4
+ * Pushes a 'Nav link click' custom event to Vercel Analytics.
5
+ * A wrapper around the Vercel Analytics track method.
6
+ *
7
+ * @param {string} name - The name of the nav link
8
+ * @param {string} href - The href for the nav link
9
+ * @param {string} [section] - The name of the section of the nav. Top-level links do not have a section.
10
+ */
11
+
12
+ export const trackNavClickEvent = (
13
+ name: string,
14
+ href: string,
15
+ section: string
16
+ ) => {
17
+ va.track('Nav link click', {
18
+ name,
19
+ href,
20
+ section,
21
+ })
22
+ }
@@ -0,0 +1,11 @@
1
+ import { vercelStegaSplit } from '@vercel/stega'
2
+
3
+ /**
4
+ * Takes in a Vercel Visual Editing string and returns the string without
5
+ * hidden data.
6
+ */
7
+ export function v<VercelVEString extends string>(
8
+ s: VercelVEString
9
+ ): VercelVEString {
10
+ return vercelStegaSplit(s).cleaned as VercelVEString
11
+ }