@hashicorp/react-components 0.0.0-nightly.b46420c → 0.0.0-nightly.c2272e8
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/package.json +3 -3
- package/src/components/nav-panel/components/panel/column/index.tsx +4 -2
- package/src/components/nav-panel/components/panel/root/index.tsx +4 -2
- package/src/components/nav-panel/components/panel/root/style.module.css +1 -0
- package/src/components/nav-panel/product-panel/index.tsx +88 -24
- package/src/components/nav-panel/product-panel/style.module.css +119 -2
- package/src/lib/parse-url/index.ts +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashicorp/react-components",
|
|
3
|
-
"version": "0.0.0-nightly.
|
|
3
|
+
"version": "0.0.0-nightly.c2272e8",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "next-hashicorp lint",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"test:watch": "vitest watch"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@hashicorp/flight-icons": "^
|
|
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": "*",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"react-hook-form": "^7.43.5"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@hashicorp/platform-cli": "^2.
|
|
27
|
+
"@hashicorp/platform-cli": "^2.8.0",
|
|
28
28
|
"@hashicorp/platform-types": "^0.4.0",
|
|
29
29
|
"@testing-library/jest-dom": "^6.4.2",
|
|
30
30
|
"@vitejs/plugin-react": "^4.2.1",
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import classNames from 'classnames'
|
|
1
2
|
import s from './style.module.css'
|
|
2
3
|
|
|
3
4
|
export interface NavColumnProps {
|
|
5
|
+
className?: string
|
|
4
6
|
children: React.ReactNode
|
|
5
7
|
}
|
|
6
8
|
|
|
7
|
-
export default function Column({ children }: NavColumnProps) {
|
|
8
|
-
return <div className={s.column}>{children}</div>
|
|
9
|
+
export default function Column({ className, children }: NavColumnProps) {
|
|
10
|
+
return <div className={classNames(s.column, className)}>{children}</div>
|
|
9
11
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import classNames from 'classnames'
|
|
1
2
|
import s from './style.module.css'
|
|
2
3
|
|
|
3
4
|
interface RootProps {
|
|
5
|
+
className?: string
|
|
4
6
|
children: React.ReactNode
|
|
5
7
|
}
|
|
6
8
|
|
|
7
|
-
export default function Root({ children }: RootProps) {
|
|
8
|
-
return <div className={s.root}>{children}</div>
|
|
9
|
+
export default function Root({ className, children }: RootProps) {
|
|
10
|
+
return <div className={classNames(s.root, className)}>{children}</div>
|
|
9
11
|
}
|
|
@@ -18,37 +18,96 @@ const PRODUCT_LOGO_MAP = new Map([
|
|
|
18
18
|
['Nomad', 'nomad-fill-color'],
|
|
19
19
|
['Waypoint', 'waypoint-fill-color'],
|
|
20
20
|
['Vagrant', 'vagrant-fill-color'],
|
|
21
|
+
['HCP Vault Secrets', 'vault-secrets'],
|
|
22
|
+
['HCP Vault Radar', 'vault-radar'],
|
|
21
23
|
])
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
const PRODUCT_LOGO_EXCEPTION_CLASSNAMES = {
|
|
26
|
+
'HCP Vault Secrets': 'hcpVaultSecrets',
|
|
27
|
+
'HCP Vault Radar': 'hcpVaultRadar',
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ProductsPanelProps {
|
|
24
31
|
productCategories: any
|
|
25
32
|
promo?: PromoProps
|
|
33
|
+
sidePanel?: {
|
|
34
|
+
label: string
|
|
35
|
+
navItems: {
|
|
36
|
+
icon: string
|
|
37
|
+
title: string
|
|
38
|
+
description: string
|
|
39
|
+
url: string
|
|
40
|
+
}[]
|
|
41
|
+
}
|
|
26
42
|
}
|
|
27
43
|
|
|
28
|
-
const ProductPanel = ({
|
|
44
|
+
const ProductPanel = ({
|
|
45
|
+
productCategories,
|
|
46
|
+
promo,
|
|
47
|
+
sidePanel,
|
|
48
|
+
}: ProductsPanelProps) => {
|
|
29
49
|
return (
|
|
30
|
-
<NavPanel.Root>
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
{productCategories
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
<NavPanel.Root className={s.productPanel}>
|
|
51
|
+
<div className={s.mainPanel}>
|
|
52
|
+
<NavPanel.Column>
|
|
53
|
+
<ul className={s.productCategories}>
|
|
54
|
+
{productCategories.map(({ title, products }) => {
|
|
55
|
+
return (
|
|
56
|
+
<li key={title} className={s.productCategory}>
|
|
57
|
+
<TextPlus.Body className={s.eyebrow}>{title}</TextPlus.Body>
|
|
58
|
+
<ul className={s.productList}>
|
|
59
|
+
{products.map((product) => {
|
|
60
|
+
return (
|
|
61
|
+
<li key={product.url}>
|
|
62
|
+
<NavProduct {...product} />
|
|
63
|
+
</li>
|
|
64
|
+
)
|
|
65
|
+
})}
|
|
66
|
+
</ul>
|
|
67
|
+
</li>
|
|
68
|
+
)
|
|
69
|
+
})}
|
|
70
|
+
</ul>
|
|
71
|
+
</NavPanel.Column>
|
|
72
|
+
{promo ? <Promo {...promo} /> : null}
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
{sidePanel ? (
|
|
76
|
+
<NavPanel.Column className={s.sidePanel}>
|
|
77
|
+
<TextPlus.Body size="200" weight="semibold">
|
|
78
|
+
{sidePanel.label}
|
|
79
|
+
</TextPlus.Body>
|
|
80
|
+
|
|
81
|
+
{/* ! TODO Replace the below list with the <LinkList /> component,
|
|
82
|
+
That component will require a refactor to support greater customization
|
|
83
|
+
Ticket:
|
|
84
|
+
https://app.asana.com/0/1206176289707208/1208162145034615/f
|
|
85
|
+
*/}
|
|
86
|
+
<ul className={s.sidePanelItems}>
|
|
87
|
+
{sidePanel.navItems.map(({ icon, title, description, url }) => {
|
|
88
|
+
return (
|
|
89
|
+
<li key={title}>
|
|
90
|
+
<Link href={parseUrl(url).href} className={s.sidePanelItem}>
|
|
91
|
+
<div className={s.iconBackground}>
|
|
92
|
+
<FlightIcon
|
|
93
|
+
size={16}
|
|
94
|
+
name={icon}
|
|
95
|
+
color="var(--token-color-foreground-faint)"
|
|
96
|
+
/>
|
|
97
|
+
</div>
|
|
98
|
+
<div className={s.sidePanelItemContent}>
|
|
99
|
+
<TextPlus.Body size="200" weight="semibold" tag="span">
|
|
100
|
+
{title}
|
|
101
|
+
</TextPlus.Body>
|
|
102
|
+
<span className={s.sidePanelItemDesc}>{description}</span>
|
|
103
|
+
</div>
|
|
104
|
+
</Link>
|
|
105
|
+
</li>
|
|
106
|
+
)
|
|
107
|
+
})}
|
|
108
|
+
</ul>
|
|
109
|
+
</NavPanel.Column>
|
|
110
|
+
) : null}
|
|
52
111
|
</NavPanel.Root>
|
|
53
112
|
)
|
|
54
113
|
}
|
|
@@ -73,6 +132,11 @@ function NavProduct({ url, product, description }: NavProductProps) {
|
|
|
73
132
|
<div className={s.productLogo}>
|
|
74
133
|
<FlightIcon
|
|
75
134
|
name={PRODUCT_LOGO_MAP.get(product) ?? 'hashicorp-fill-color'}
|
|
135
|
+
className={
|
|
136
|
+
PRODUCT_LOGO_EXCEPTION_CLASSNAMES[product]
|
|
137
|
+
? s[PRODUCT_LOGO_EXCEPTION_CLASSNAMES[product]]
|
|
138
|
+
: undefined
|
|
139
|
+
}
|
|
76
140
|
/>
|
|
77
141
|
</div>
|
|
78
142
|
<div className={s.productTextContent}>
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
.productPanel {
|
|
2
|
+
height: 100%;
|
|
3
|
+
|
|
4
|
+
@media (--large) {
|
|
5
|
+
display: grid;
|
|
6
|
+
grid-template-rows: 1fr;
|
|
7
|
+
grid-template-columns: max-content max-content;
|
|
8
|
+
padding: 0;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
1
12
|
.productCategories {
|
|
2
13
|
list-style: none;
|
|
3
14
|
padding: 0;
|
|
@@ -27,7 +38,8 @@
|
|
|
27
38
|
font-weight: var(--font-weight-semi-bold);
|
|
28
39
|
|
|
29
40
|
@media (--large) {
|
|
30
|
-
padding: 0
|
|
41
|
+
padding-bottom: 0;
|
|
42
|
+
padding-left: var(--hdsplus-spacing-06);
|
|
31
43
|
}
|
|
32
44
|
}
|
|
33
45
|
|
|
@@ -39,6 +51,8 @@
|
|
|
39
51
|
padding: 0;
|
|
40
52
|
|
|
41
53
|
@media (--large) {
|
|
54
|
+
padding: var(--hdsplus-spacing-06) var(--hdsplus-spacing-05)
|
|
55
|
+
var(--hdsplus-spacing-04);
|
|
42
56
|
grid-auto-flow: row;
|
|
43
57
|
grid-template-columns: repeat(2, 300px);
|
|
44
58
|
grid-template-rows: repeat(2, max-content);
|
|
@@ -54,7 +68,7 @@
|
|
|
54
68
|
gap: var(--hdsplus-spacing-05);
|
|
55
69
|
|
|
56
70
|
@media (--large) {
|
|
57
|
-
padding: var(--hdsplus-spacing-05);
|
|
71
|
+
padding: var(--hdsplus-spacing-03) var(--hdsplus-spacing-05);
|
|
58
72
|
margin-bottom: 0;
|
|
59
73
|
|
|
60
74
|
&:hover {
|
|
@@ -98,3 +112,106 @@
|
|
|
98
112
|
outline-style: auto;
|
|
99
113
|
}
|
|
100
114
|
}
|
|
115
|
+
|
|
116
|
+
.mainPanel {
|
|
117
|
+
height: 100%;
|
|
118
|
+
display: flex;
|
|
119
|
+
justify-content: space-between;
|
|
120
|
+
flex-direction: column;
|
|
121
|
+
|
|
122
|
+
@media (--large) {
|
|
123
|
+
padding: var(--hdsplus-spacing-07) 0 var(--hdsplus-spacing-05)
|
|
124
|
+
var(--hdsplus-spacing-04);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.sidePanel {
|
|
129
|
+
height: 100%;
|
|
130
|
+
background: var(--token-color-surface-faint);
|
|
131
|
+
display: flex;
|
|
132
|
+
flex-direction: column;
|
|
133
|
+
gap: var(--hdsplus-spacing-05);
|
|
134
|
+
margin: 0;
|
|
135
|
+
padding: var(--hdsplus-spacing-07) var(--hdsplus-spacing-04)
|
|
136
|
+
var(--hdsplus-spacing-09) var(--hdsplus-spacing-07);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.sidePanelItems {
|
|
140
|
+
list-style: none;
|
|
141
|
+
margin: 0;
|
|
142
|
+
padding: 0;
|
|
143
|
+
display: grid;
|
|
144
|
+
grid-template-columns: 1fr;
|
|
145
|
+
gap: var(--hdsplus-spacing-07);
|
|
146
|
+
|
|
147
|
+
@media (--large) {
|
|
148
|
+
gap: var(--hdsplus-spacing-05);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* Lifted from .productWrapper */
|
|
153
|
+
.sidePanelItem {
|
|
154
|
+
display: flex;
|
|
155
|
+
margin-bottom: var(--hdsplus-spacing-05);
|
|
156
|
+
gap: var(--hdsplus-spacing-05);
|
|
157
|
+
|
|
158
|
+
@media (--large) {
|
|
159
|
+
padding: var(--hdsplus-spacing-03) var(--hdsplus-spacing-05);
|
|
160
|
+
margin-bottom: 0;
|
|
161
|
+
|
|
162
|
+
&:hover {
|
|
163
|
+
background-color: var(--token-color-surface-interactive-hover);
|
|
164
|
+
border-radius: var(--hdsplus-spacing-01);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/* Lifted from:
|
|
170
|
+
packages/react-components/src/components/nav-panel/components/link-list/style.module.css */
|
|
171
|
+
.iconBackground {
|
|
172
|
+
background: var(--token-color-foreground-high-contrast);
|
|
173
|
+
height: var(--hdsplus-spacing-08);
|
|
174
|
+
width: var(--hdsplus-spacing-08);
|
|
175
|
+
display: flex;
|
|
176
|
+
align-items: center;
|
|
177
|
+
justify-content: center;
|
|
178
|
+
border-radius: 3px;
|
|
179
|
+
flex: none;
|
|
180
|
+
margin-top: 3px;
|
|
181
|
+
border: 1px solid var(--token-color-border-primary);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* Lifted from .productTextContent */
|
|
185
|
+
.sidePanelItemContent {
|
|
186
|
+
display: flex;
|
|
187
|
+
flex-direction: column;
|
|
188
|
+
color: var(--token-color-foreground-strong);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.sidePanelItemDesc {
|
|
192
|
+
font-weight: 400;
|
|
193
|
+
font-size: 13px;
|
|
194
|
+
line-height: 18px;
|
|
195
|
+
color: var(--token-color-foreground-primary);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* Branding exception classnames */
|
|
199
|
+
|
|
200
|
+
/* Styles for HCP Vault mimic the spec for `product-square` icons,
|
|
201
|
+
while allowing the symbol inside the icon border to change color
|
|
202
|
+
based on the site's theme
|
|
203
|
+
*/
|
|
204
|
+
.hcpVaultSecrets,
|
|
205
|
+
.hcpVaultRadar {
|
|
206
|
+
padding: var(--hdsplus-spacing-01);
|
|
207
|
+
border: 2px solid var(--token-color-vault-brand);
|
|
208
|
+
border-radius: 3px;
|
|
209
|
+
|
|
210
|
+
& use {
|
|
211
|
+
fill: var(--token-color-foreground-strong);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
& path {
|
|
215
|
+
fill: inherit;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -26,5 +26,7 @@ export function parseUrl(url: string | undefined): {
|
|
|
26
26
|
const isRelative = (url) => url.startsWith('/')
|
|
27
27
|
const isAnchor = (url) => url.startsWith('#')
|
|
28
28
|
|
|
29
|
-
export const isInternal = (url) =>
|
|
30
|
-
new URL(url).hostname
|
|
29
|
+
export const isInternal = (url) => {
|
|
30
|
+
const hostname = new URL(url).hostname
|
|
31
|
+
return hostname === 'hashicorp.com'
|
|
32
|
+
}
|