@hashicorp/react-components 0.0.0-canary.3a0af3d → 0.0.0-canary.43d0406

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 (34) hide show
  1. package/package.json +8 -5
  2. package/src/components/consent-manager/README.md +1 -1
  3. package/src/components/consent-manager/loader/README.md +1 -1
  4. package/src/components/marketo-form/partials/fields/htmltext-field/style.module.css +16 -4
  5. package/src/components/marketo-form/utils.ts +4 -0
  6. package/src/components/nav-panel/components/link-list/index.tsx +88 -0
  7. package/src/components/nav-panel/components/link-list/style.module.css +57 -0
  8. package/src/components/nav-panel/components/panel/column/index.tsx +24 -0
  9. package/src/components/nav-panel/components/panel/column/style.module.css +24 -0
  10. package/src/components/nav-panel/components/panel/index.tsx +4 -0
  11. package/src/components/nav-panel/components/panel/root/index.tsx +20 -0
  12. package/src/components/nav-panel/components/panel/root/style.module.css +30 -0
  13. package/src/components/nav-panel/components/promo/index.tsx +86 -0
  14. package/src/components/nav-panel/components/promo/style.module.css +113 -0
  15. package/src/components/nav-panel/index.tsx +6 -0
  16. package/src/components/nav-panel/product-panel/index.tsx +170 -0
  17. package/src/components/nav-panel/product-panel/style.module.css +296 -0
  18. package/src/components/nav-panel/standard-panel/index.tsx +44 -0
  19. package/src/components/nav-panel/standard-panel/style.module.css +11 -0
  20. package/src/components/next-steps/index.tsx +4 -10
  21. package/src/components/subnav/index.tsx +6 -6
  22. package/src/components/subnav/partials/CtaLinks/index.tsx +1 -1
  23. package/src/components/subnav/partials/DropdownTrigger/index.tsx +1 -1
  24. package/src/components/subnav/partials/MenuItemsDefault/index.tsx +1 -1
  25. package/src/components/subnav/partials/MenuItemsOverflow/index.tsx +2 -2
  26. package/src/components/subnav/partials/TitleLink/index.tsx +9 -9
  27. package/src/components/subnav/partials/TitleLink/mktg-logos/all-community-product-logos_on-dark.ts +7 -7
  28. package/src/components/subnav/partials/TitleLink/mktg-logos/all-community-product-logos_on-light.ts +7 -7
  29. package/src/components/subnav/partials/TitleLink/mktg-logos/all-primary-logos_on-dark.ts +10 -10
  30. package/src/components/subnav/partials/TitleLink/mktg-logos/all-primary-logos_on-light.ts +10 -10
  31. package/src/lib/parse-url/index.test.ts +30 -0
  32. package/src/lib/parse-url/index.ts +32 -0
  33. package/src/lib/track-nav-click-event/index.ts +22 -0
  34. package/src/lib/v/index.ts +11 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashicorp/react-components",
3
- "version": "0.0.0-canary.3a0af3d",
3
+ "version": "0.0.0-canary.43d0406",
4
4
  "main": "src/index.ts",
5
5
  "scripts": {
6
6
  "lint": "next-hashicorp lint",
@@ -8,20 +8,23 @@
8
8
  "test:watch": "vitest watch"
9
9
  },
10
10
  "dependencies": {
11
- "@hashicorp/flight-icons": "^2.15.0",
11
+ "@hashicorp/flight-icons": "^3.5.0",
12
12
  "@hashicorp/platform-product-meta": "^0.1.1",
13
13
  "@hashicorp/platform-util": "^0.2.0",
14
14
  "@hashicorp/react-design-system-components": "*",
15
- "@radix-ui/react-visually-hidden": "^1.0.3",
15
+ "@hashicorp/web-mktg-logos": "*",
16
+ "@radix-ui/react-navigation-menu": "^1.2.0",
17
+ "@radix-ui/react-visually-hidden": "^1.1.0",
18
+ "@vercel/analytics": "^1.3.1",
16
19
  "@vercel/fetch": "^7.0.0",
17
- "@web/mktg-logos": "*",
20
+ "@vercel/stega": "^0.1.2",
18
21
  "classnames": "^2.3.2",
19
22
  "js-cookie": "^3.0.5",
20
23
  "moize": "^6.1.3",
21
24
  "react-hook-form": "^7.43.5"
22
25
  },
23
26
  "devDependencies": {
24
- "@hashicorp/platform-cli": "^2.6.0",
27
+ "@hashicorp/platform-cli": "^2.8.0",
25
28
  "@hashicorp/platform-types": "^0.4.0",
26
29
  "@testing-library/jest-dom": "^6.4.2",
27
30
  "@vitejs/plugin-react": "^4.2.1",
@@ -44,7 +44,7 @@ Expect the new change to look like the following:
44
44
 
45
45
  import Document, { Html, Head, Main, NextScript } from 'next/document'
46
46
  import HashiHead from '@hashicorp/react-head'
47
- + import { SegmentPreloadScript } from '@hashicorp/react-consent-manager/scripts/segment'
47
+ + import { SegmentPreloadScript } from '@web/react-components/src/components/consent-manager/scripts/segment'
48
48
  // other imports
49
49
 
50
50
  export default class MyDocument extends Document {
@@ -9,7 +9,7 @@ The loader also ships with a couple **presets**, which load in standard sets of
9
9
  Code block below shows basic usage:
10
10
 
11
11
  ```js
12
- import createConsentManager from '@hashicorp/react-consent-manager/loader'
12
+ import createConsentManager from '@web/react-components/src/components/consent-manager/loader'
13
13
 
14
14
  const { ConsentManager, openConsentManager } = createConsentManager({
15
15
  preset: 'oss',
@@ -1,6 +1,18 @@
1
1
  .htmltext {
2
- composes: g-type-body-small from global;
3
- color: var(--wpl-neutral-500);
4
- margin-top: var(--wpl-spacing-02);
5
- margin-bottom: var(--wpl-spacing-05);
2
+ composes: g-type-body-small from global;
3
+ margin-top: var(--hdsplus-spacing-04);
4
+ margin-bottom: var(--hdsplus-spacing-07);
5
+ color: var(--token-color-foreground-faint);
6
+
7
+ & a {
8
+ color: var(--token-color-foreground-action);
9
+ text-decoration: underline;
10
+
11
+ &:focus-visible {
12
+ text-decoration: none;
13
+ border-radius: 2px;
14
+ outline: 2px solid var(--token-color-focus-action-internal);
15
+ outline-offset: 1px;
16
+ }
17
+ }
6
18
  }
@@ -426,6 +426,10 @@ export const resolverErrors = (
426
426
  * @returns MarketoFormField[] with columnSplit property set
427
427
  */
428
428
  export function setFieldsColumnSplit(fieldsArr: MarketoFormField[]) {
429
+ if (!fieldsArr) {
430
+ return []
431
+ }
432
+
429
433
  return fieldsArr.map((f) => {
430
434
  const columnSplit = getFieldColumnSplit(fieldsArr, f)
431
435
  return { ...f, columnSplit }
@@ -0,0 +1,88 @@
1
+ import Link from 'next/link'
2
+ import { parseUrl } from '../../../../lib/parse-url'
3
+ import { v } from '../../../../lib/v'
4
+ import FlightIcon from '@hashicorp/react-design-system-components/src/components/flight-icon'
5
+ import * as NavigationMenu from '@radix-ui/react-navigation-menu'
6
+ import s from './style.module.css'
7
+
8
+ export interface LinkListProps {
9
+ links: {
10
+ title: string
11
+ url: string
12
+ icon?: string
13
+ description?: string
14
+ iconGradient?: string
15
+ }[]
16
+ linkClickHandler?: (title: string, url: string) => void
17
+ }
18
+
19
+ const GRADIENT_VALUE_MAP = new Map([
20
+ [
21
+ 'ILM',
22
+ {
23
+ iconGradient: 'var(--icon-gradient-infrastructure-lifecycle-management)',
24
+ },
25
+ ],
26
+ [
27
+ 'SLM',
28
+ {
29
+ iconGradient: 'var(--icon-gradient-security-lifecycle-management)',
30
+ },
31
+ ],
32
+ [
33
+ 'Cloud',
34
+ {
35
+ iconGradient: 'var(--icon-gradient-infrastructure-cloud)',
36
+ },
37
+ ],
38
+ ])
39
+
40
+ export default function LinkList({ links, linkClickHandler }: LinkListProps) {
41
+ return (
42
+ <ul className={s.linkList}>
43
+ {links.map((link) => {
44
+ let style
45
+ link.iconGradient
46
+ ? (style = {
47
+ '--iconGradient': GRADIENT_VALUE_MAP.get(v(link.iconGradient))
48
+ ?.iconGradient,
49
+ } as React.CSSProperties)
50
+ : (style = null)
51
+ return (
52
+ <li key={link.title}>
53
+ <NavigationMenu.Link asChild>
54
+ <Link
55
+ className={s.link}
56
+ href={parseUrl(link.url).href}
57
+ onClickCapture={() => {
58
+ linkClickHandler && linkClickHandler(link.title, link.url)
59
+ }}
60
+ >
61
+ {link.iconGradient && link.icon ? (
62
+ <div className={s.iconBackground} style={style}>
63
+ <FlightIcon name={v(link.icon)} />
64
+ </div>
65
+ ) : (
66
+ link.icon && (
67
+ <FlightIcon
68
+ name={v(link.icon)}
69
+ color="var(--token-color-foreground-faint)"
70
+ />
71
+ )
72
+ )}
73
+ <div>
74
+ <div className={link.iconGradient && s.boldTitle}>
75
+ {link.title}
76
+ </div>
77
+ {link.description && (
78
+ <div className={s.description}>{link.description}</div>
79
+ )}
80
+ </div>
81
+ </Link>
82
+ </NavigationMenu.Link>
83
+ </li>
84
+ )
85
+ })}
86
+ </ul>
87
+ )
88
+ }
@@ -0,0 +1,57 @@
1
+ .linkList {
2
+ display: flex;
3
+ list-style: none;
4
+ flex-direction: column;
5
+ gap: var(--hdsplus-spacing-03);
6
+ margin: 0;
7
+ padding: 0;
8
+ }
9
+
10
+ .link {
11
+ color: var(--token-color-foreground-primary);
12
+ display: flex;
13
+ gap: var(--hdsplus-spacing-04);
14
+ padding: var(--hdsplus-spacing-03) var(--hdsplus-spacing-04);
15
+ min-width: 190px;
16
+ align-items: center;
17
+
18
+ &:hover {
19
+ background-color: var(--token-color-surface-interactive-hover);
20
+ border-radius: var(--hdsplus-spacing-01);
21
+ }
22
+
23
+ &:has(.iconBackground) {
24
+ align-items: flex-start;
25
+ }
26
+
27
+ @media (--large) {
28
+ max-width: 416px;
29
+ }
30
+
31
+ &:focus {
32
+ outline: 2px solid var(--token-color-focus-action-internal);
33
+ outline-style: auto;
34
+ }
35
+ }
36
+
37
+ .description {
38
+ font-size: var(--hdsplus-typography-body-200-font-size);
39
+ font-weight: var(--token-typography-font-weight-regular);
40
+ margin-top: var(--hdsplus-spacing-02);
41
+ }
42
+
43
+ .iconBackground {
44
+ background: var(--iconGradient);
45
+ height: var(--hdsplus-spacing-08);
46
+ width: var(--hdsplus-spacing-08);
47
+ display: flex;
48
+ align-items: center;
49
+ justify-content: center;
50
+ border-radius: 3px;
51
+ flex: none;
52
+ margin-top: 3px;
53
+ }
54
+
55
+ .boldTitle {
56
+ font-weight: var(--font-weight-semi-bold);
57
+ }
@@ -0,0 +1,24 @@
1
+ import classNames from 'classnames'
2
+ import s from './style.module.css'
3
+
4
+ export interface NavColumnProps {
5
+ className?: string
6
+ children: React.ReactNode
7
+ hasSidePanel?: boolean
8
+ }
9
+
10
+ export default function Column({
11
+ className,
12
+ children,
13
+ hasSidePanel,
14
+ }: NavColumnProps) {
15
+ return (
16
+ <div
17
+ className={classNames(s.column, className, {
18
+ [s.hasSide]: hasSidePanel,
19
+ })}
20
+ >
21
+ {children}
22
+ </div>
23
+ )
24
+ }
@@ -0,0 +1,24 @@
1
+ @custom-media --dev-dot-viewport (min-width: 1230px);
2
+
3
+ .column {
4
+ position: relative;
5
+ display: flex;
6
+ flex-direction: column;
7
+ justify-content: flex-start;
8
+ min-width: 190px;
9
+ padding: 0;
10
+ margin: 0 var(--hdsplus-spacing-05);
11
+ border-radius: var(--hdsplus-spacing-03);
12
+
13
+ @media (--large) {
14
+ &:not(.hasSide) {
15
+ margin: 0;
16
+ }
17
+ }
18
+
19
+ @media (--dev-dot-viewport) {
20
+ &.hasSide {
21
+ margin: 0;
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,4 @@
1
+ import Root from './root'
2
+ import Column from './column'
3
+
4
+ export { Root, Column }
@@ -0,0 +1,20 @@
1
+ import classNames from 'classnames'
2
+ import s from './style.module.css'
3
+
4
+ interface RootProps {
5
+ className?: string
6
+ children: React.ReactNode
7
+ hasSidePanel?: boolean
8
+ }
9
+
10
+ export default function Root({ className, children, hasSidePanel }: RootProps) {
11
+ return (
12
+ <div
13
+ className={classNames(s.root, className, {
14
+ [s.hasSide]: hasSidePanel,
15
+ })}
16
+ >
17
+ {children}
18
+ </div>
19
+ )
20
+ }
@@ -0,0 +1,30 @@
1
+ @custom-media --dev-dot-viewport (min-width: 1230px);
2
+
3
+ .root {
4
+ width: 100%;
5
+ display: flex;
6
+ flex-direction: column;
7
+ justify-content: space-between;
8
+ /* stylelint-disable-next-line unit-no-unknown */
9
+ min-height: calc(100dvh - var(--hdsplus-spacing-12));
10
+
11
+ @media (--large) {
12
+ &:not(.hasSide) {
13
+ justify-content: flex-start;
14
+ height: 100%;
15
+ min-height: fit-content;
16
+ padding: var(--hdsplus-spacing-05) var(--hdsplus-spacing-04);
17
+ gap: var(--hdsplus-spacing-04);
18
+ }
19
+ }
20
+
21
+ @media (--dev-dot-viewport) {
22
+ &.hasSide {
23
+ justify-content: flex-start;
24
+ height: 100%;
25
+ min-height: fit-content;
26
+ padding: var(--hdsplus-spacing-05) var(--hdsplus-spacing-04);
27
+ gap: var(--hdsplus-spacing-04);
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,86 @@
1
+ import { useCallback } from 'react'
2
+ import classNames from 'classnames'
3
+ import { v } from '../../../../lib/v'
4
+ import Link from 'next/link'
5
+ import { parseUrl } from '../../../../lib/parse-url'
6
+ import { trackNavClickEvent } from '../../../../lib/track-nav-click-event'
7
+ import FlightIcon from '@hashicorp/react-design-system-components/src/components/flight-icon'
8
+ import * as NavigationMenu from '@radix-ui/react-navigation-menu'
9
+ import s from './style.module.css'
10
+
11
+ export interface PromoProps {
12
+ title: string
13
+ description: string
14
+ linkUrl: string
15
+ linkTitle: string
16
+ slug?: string
17
+ icon?: string
18
+ theme: string
19
+ hasSidePanel?: boolean
20
+ }
21
+
22
+ export default function Promo({
23
+ title,
24
+ description,
25
+ linkUrl,
26
+ linkTitle,
27
+ slug,
28
+ icon,
29
+ theme,
30
+ hasSidePanel,
31
+ }: PromoProps) {
32
+ const handleClick = useCallback((title, linkUrl, linkTitle, slug) => {
33
+ if (window && window.analytics) {
34
+ window.analytics.track('Nav Promo', {
35
+ url: linkUrl,
36
+ title: title,
37
+ callout: linkTitle,
38
+ })
39
+
40
+ trackNavClickEvent(title, linkUrl, slug)
41
+ }
42
+ }, [])
43
+
44
+ return (
45
+ <div
46
+ className={classNames(s.promo, {
47
+ [s.hasSide]: hasSidePanel,
48
+ [s.noSide]: !hasSidePanel,
49
+ })}
50
+ >
51
+ {icon && (
52
+ <div
53
+ className={classNames(s.icon, {
54
+ [s.hashidays]: v(theme) === 'hashidays',
55
+ [s.hashiconf]: v(theme) === 'hashiconf',
56
+ })}
57
+ >
58
+ <FlightIcon name={v(icon)} />
59
+ </div>
60
+ )}
61
+ <div className={s.rightContent}>
62
+ <div>
63
+ <div
64
+ className={classNames(s.title, {
65
+ [s.hashidays]: v(theme) === 'hashidays',
66
+ [s.hashiconf]: v(theme) === 'hashiconf',
67
+ })}
68
+ >
69
+ {title}
70
+ </div>
71
+ <div className={s.description}>{description}</div>
72
+ </div>
73
+ <NavigationMenu.Link asChild>
74
+ <Link
75
+ href={parseUrl(linkUrl).href}
76
+ className={s.link}
77
+ onClickCapture={() => handleClick(title, linkUrl, linkTitle, slug)}
78
+ >
79
+ {linkTitle}
80
+ <FlightIcon name="external-link" />
81
+ </Link>
82
+ </NavigationMenu.Link>
83
+ </div>
84
+ </div>
85
+ )
86
+ }
@@ -0,0 +1,113 @@
1
+ @custom-media --dev-dot-viewport (min-width: 1230px);
2
+
3
+ .promo {
4
+ display: flex;
5
+ border-radius: var(--hdsplus-spacing-01);
6
+ border: 1px solid var(--token-color-border-faint);
7
+ background-color: var(--token-color-surface-faint);
8
+ padding: var(--hdsplus-spacing-05) var(--hdsplus-spacing-08)
9
+ var(--hdsplus-spacing-06) var(--hdsplus-spacing-08);
10
+ flex-direction: row;
11
+ gap: var(--hdsplus-spacing-04);
12
+ margin: var(--hdsplus-spacing-05);
13
+
14
+ @media (--large) {
15
+ &.noSide {
16
+ margin: 0;
17
+ width: min-content;
18
+ min-width: 100%;
19
+ }
20
+ }
21
+
22
+ @media (--dev-dot-viewport) {
23
+ &.hasSide {
24
+ margin: 0;
25
+ width: min-content;
26
+ min-width: 100%;
27
+ }
28
+ }
29
+ }
30
+
31
+ .rightContent {
32
+ display: flex;
33
+ flex-wrap: wrap;
34
+ gap: var(--hdsplus-spacing-03);
35
+ width: 100%;
36
+ justify-content: space-between;
37
+ }
38
+
39
+ .title {
40
+ font-weight: var(--font-weight-semi-bold);
41
+ }
42
+
43
+ .description {
44
+ font-size: var(--hdsplus-typography-body-200-font-size);
45
+ font-weight: var(--token-typography-font-weight-regular);
46
+ margin-top: var(--hdsplus-spacing-01);
47
+ }
48
+
49
+ .icon {
50
+ display: none;
51
+
52
+ @media (--large) {
53
+ @nest .noSide & {
54
+ display: block;
55
+ margin-top: 3px;
56
+ }
57
+ }
58
+
59
+ @media (--dev-dot-viewport) {
60
+ @nest .hasSide & {
61
+ display: block;
62
+ margin-top: 3px;
63
+ }
64
+ }
65
+ }
66
+
67
+ .link {
68
+ color: var(--token-color-foreground-strong);
69
+ display: flex;
70
+ flex-direction: row;
71
+ align-items: center;
72
+ gap: var(--hdsplus-spacing-02);
73
+
74
+ &:hover {
75
+ text-decoration: underline;
76
+ }
77
+
78
+ &:focus {
79
+ outline: 2px solid var(--token-color-focus-action-internal);
80
+ outline-style: auto;
81
+ }
82
+ }
83
+
84
+ .hashidays {
85
+ background: linear-gradient(
86
+ 90deg,
87
+ #7b54b6 0%,
88
+ #4c69d8 74.77%,
89
+ #60d0dc 115.93%
90
+ );
91
+ -webkit-background-clip: text;
92
+ -webkit-text-fill-color: transparent;
93
+ max-width: fit-content;
94
+
95
+ & svg {
96
+ color: #7956b9;
97
+ }
98
+ }
99
+
100
+ .hashiconf {
101
+ background: linear-gradient(
102
+ to right,
103
+ var(--token-color-terraform-foreground),
104
+ var(--token-color-vagrant-foreground)
105
+ );
106
+ -webkit-background-clip: text;
107
+ -webkit-text-fill-color: transparent;
108
+ max-width: fit-content;
109
+
110
+ & svg {
111
+ color: var(--token-color-terraform-foreground);
112
+ }
113
+ }
@@ -0,0 +1,6 @@
1
+ import ProductPanel, { type NavProductProps } from './product-panel'
2
+ import StandardPanel, { type NavItem } from './standard-panel'
3
+ import { PromoProps } from './components/promo'
4
+
5
+ export { ProductPanel, StandardPanel }
6
+ export type { NavProductProps, PromoProps, NavItem }