@hashicorp/react-components 1.2.1 → 1.2.2

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 (31) hide show
  1. package/.test/setup-vitest.js +4 -0
  2. package/global.d.ts +1 -1
  3. package/package.json +1 -1
  4. package/postcss.config.js +4 -0
  5. package/src/components/nav-panel/components/flight-icon/index.tsx +4 -0
  6. package/src/components/nav-panel/components/flight-icon/style.module.css +4 -0
  7. package/src/components/nav-panel/components/link/index.tsx +36 -2
  8. package/src/components/nav-panel/components/link/style.module.css +5 -0
  9. package/src/components/nav-panel/components/link-list/index.tsx +5 -0
  10. package/src/components/nav-panel/components/link-list/style.module.css +4 -0
  11. package/src/components/nav-panel/components/panel/column/index.tsx +4 -0
  12. package/src/components/nav-panel/components/panel/column/style.module.css +4 -0
  13. package/src/components/nav-panel/components/panel/index.tsx +4 -0
  14. package/src/components/nav-panel/components/panel/root/index.tsx +4 -0
  15. package/src/components/nav-panel/components/panel/root/style.module.css +4 -0
  16. package/src/components/nav-panel/components/promo/index.tsx +4 -0
  17. package/src/components/nav-panel/components/promo/style.module.css +4 -0
  18. package/src/components/nav-panel/components/text/index.tsx +4 -0
  19. package/src/components/nav-panel/index.tsx +4 -0
  20. package/src/components/nav-panel/product-panel/index.tsx +4 -0
  21. package/src/components/nav-panel/product-panel/style.module.css +4 -0
  22. package/src/components/nav-panel/standard-panel/index.tsx +4 -0
  23. package/src/components/nav-panel/standard-panel/style.module.css +4 -0
  24. package/src/lib/get-localized-link-props/index.test.ts +4 -0
  25. package/src/lib/get-localized-link-props/index.ts +4 -0
  26. package/src/lib/parse-url/index.test.ts +4 -0
  27. package/src/lib/parse-url/index.ts +4 -0
  28. package/src/lib/send-posthog-event/index.ts +4 -0
  29. package/src/lib/supported-locales/index.ts +4 -0
  30. package/src/lib/track-nav-click-event/index.ts +4 -0
  31. package/src/lib/v/index.ts +4 -0
@@ -1 +1,5 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import '@testing-library/jest-dom'
package/global.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) HashiCorp, Inc.
2
+ * Copyright IBM Corp. 2022, 2026
3
3
  * SPDX-License-Identifier: MPL-2.0
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashicorp/react-components",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "main": "src/index.ts",
5
5
  "scripts": {
6
6
  "lint": "npm run lint:js",
package/postcss.config.js CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  // Next.js allows for plugins to be specified as an array of arrays, but this
2
6
  // isn't supported by Vitest, so use a helper function to convert the array of
3
7
  // arrays to an object.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import svgSprite from '@hashicorp/flight-icons/svg-sprite/svg-sprite.svg'
2
6
  import classNames from 'classnames'
3
7
  import { useId, type SVGProps } from 'react'
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  .flight-icon {
2
6
  display: inline-block;
3
7
  }
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import Image from 'next/image'
2
6
  import Link from 'next/link'
3
7
  import classNames from 'classnames'
@@ -17,6 +21,7 @@ interface NavLinkProps {
17
21
  icon?: string
18
22
  description?: string
19
23
  iconGradient?: string
24
+ isDevPortal?: boolean
20
25
  linkClickHandler?: (title: string, url: string) => void
21
26
  locale?: string
22
27
  className?: string
@@ -56,6 +61,13 @@ const GRADIENT_VALUE_MAP = new Map([
56
61
  ],
57
62
  ['ILM Solid', { iconBackground: '#7948FF' }],
58
63
  ['SLM Solid', { iconBackground: '#FF6423' }],
64
+ [
65
+ 'Learn',
66
+ {
67
+ iconBackground: 'var(--mds-color-foreground-high-contrast)',
68
+ iconBorder: 'var(--mds-color-border-primary)',
69
+ },
70
+ ],
59
71
  ])
60
72
 
61
73
  export default function NavLink({
@@ -67,12 +79,16 @@ export default function NavLink({
67
79
  linkClickHandler,
68
80
  locale,
69
81
  className,
82
+ isDevPortal = false,
70
83
  }: NavLinkProps) {
71
84
  const style = iconGradient
72
85
  ? {
73
86
  ['--iconBackground' as string]: GRADIENT_VALUE_MAP.get(
74
87
  vercelSplit(iconGradient),
75
88
  )?.iconBackground,
89
+ ['--iconBorder' as string]: GRADIENT_VALUE_MAP.get(
90
+ vercelSplit(iconGradient),
91
+ )?.iconBorder,
76
92
  }
77
93
  : undefined
78
94
 
@@ -86,8 +102,16 @@ export default function NavLink({
86
102
  }}
87
103
  >
88
104
  {iconGradient && icon ? (
89
- <div className={s.iconBackground} style={style} data-theme="dark">
90
- <IconSwitcher icon={icon} iconGradient={iconGradient} />
105
+ <div
106
+ className={s.iconBackground}
107
+ style={style}
108
+ data-theme={!isDevPortal && 'dark'}
109
+ >
110
+ <IconSwitcher
111
+ icon={icon}
112
+ iconGradient={iconGradient}
113
+ isDevPortal={isDevPortal}
114
+ />
91
115
  </div>
92
116
  ) : (
93
117
  icon && (
@@ -111,10 +135,20 @@ export default function NavLink({
111
135
  const IconSwitcher = ({
112
136
  icon,
113
137
  iconGradient,
138
+ isDevPortal = false,
114
139
  }: {
115
140
  icon: string
116
141
  iconGradient: string
142
+ isDevPortal?: boolean
117
143
  }) => {
144
+ if (isDevPortal) {
145
+ return (
146
+ <FlightIcon
147
+ name={vercelSplit(icon)}
148
+ color={'var(--mds-color-foreground-faint)'}
149
+ />
150
+ )
151
+ }
118
152
  switch (icon) {
119
153
  case 'shield-alert':
120
154
  return <Image src={ShieldAlertFill} alt="shield alert icon" />
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  .linkList {
2
6
  display: flex;
3
7
  list-style: none;
@@ -52,6 +56,7 @@
52
56
  border-radius: 3px;
53
57
  flex: none;
54
58
  margin-top: 3px;
59
+ border: 1px solid var(--iconBorder);
55
60
  }
56
61
 
57
62
  .boldTitle {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import NavLink from '../link'
2
6
  import s from './style.module.css'
3
7
 
@@ -9,6 +13,7 @@ export interface LinkListProps {
9
13
  icon?: string
10
14
  description?: string
11
15
  iconGradient?: string
16
+ isDevPortal?: boolean
12
17
  }[]
13
18
  linkClickHandler?: (title: string, url: string) => void
14
19
  }
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  .linkList {
2
6
  display: flex;
3
7
  list-style: none;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import classNames from 'classnames'
2
6
  import s from './style.module.css'
3
7
 
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  @custom-media --dev-dot-viewport (min-width: 924px);
2
6
 
3
7
  .column {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import Root from './root'
2
6
  import Column from './column'
3
7
 
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import classNames from 'classnames'
2
6
  import s from './style.module.css'
3
7
 
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  @custom-media --dev-dot-viewport (min-width: 924px);
2
6
 
3
7
  .root {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import { useCallback } from 'react'
2
6
  import classNames from 'classnames'
3
7
  import { vercelSplit } from '../../../../lib/v'
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  @custom-media --dev-dot-viewport (min-width: 924px);
2
6
 
3
7
  .promo {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import classNames from 'classnames'
2
6
  import { type ReactNode, type HTMLAttributes } from 'react'
3
7
 
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import ProductPanel, { type NavProductProps } from './product-panel'
2
6
  import StandardPanel, { type NavItem } from './standard-panel'
3
7
  import { PromoProps } from './components/promo'
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import classNames from 'classnames'
2
6
  import Link from 'next/link'
3
7
  import * as NavPanel from '../components/panel'
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  @custom-media --dev-dot-viewport (min-width: 924px);
2
6
 
3
7
  .productPanel {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import { trackNavClickEvent } from '../../../lib/track-nav-click-event'
2
6
  import * as NavPanel from '../components/panel'
3
7
  import LinkList, { type LinkListProps } from '../components/link-list'
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  .columns {
2
6
  display: flex;
3
7
  gap: var(--mds-spacing-03);
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import { getLocalizedLinkProps } from '.'
2
6
 
3
7
  describe('getLocalizedLinkProps', () => {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import { parseUrl } from '../parse-url'
2
6
  import { allSupportedLocales } from '../supported-locales'
3
7
 
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import { parseUrl, hasHashiCorpDestination } from '.'
2
6
 
3
7
  describe('parseUrl', () => {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  export const hashicorpDestinations: string[] = [
2
6
  'app.terraform.io',
3
7
  'boundaryproject.io',
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import posthog from 'posthog-js'
2
6
 
3
7
  /**
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  export const allSupportedLocales = [
2
6
  'en',
3
7
  'de',
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import sendPosthogEvent from '../send-posthog-event'
2
6
 
3
7
  /**
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2026
3
+ */
4
+
1
5
  import { vercelStegaSplit } from '@vercel/stega'
2
6
 
3
7
  /**