@hashicorp/react-components 0.0.0-canary.57d393c
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/.eslintrc.js +4 -0
- package/.stylelintrc.js +3 -0
- package/.test/setup-vitest.js +1 -0
- package/README.md +3 -0
- package/global.d.ts +6 -0
- package/package.json +31 -0
- package/postcss.config.js +21 -0
- package/src/components/actions/index.tsx +107 -0
- package/src/components/actions/style.module.css +28 -0
- package/src/components/actions/types.ts +73 -0
- package/src/components/call-to-action/index.tsx +205 -0
- package/src/components/call-to-action/styles/variant-centered.module.css +93 -0
- package/src/components/call-to-action/styles/variant-compact-grid.module.css +88 -0
- package/src/components/call-to-action/styles/variant-compact.module.css +91 -0
- package/src/components/call-to-action/styles/variant-links.module.css +85 -0
- package/src/components/card/README.md +11 -0
- package/src/components/card/card.tsx +45 -0
- package/src/components/card/index.test.tsx +69 -0
- package/src/components/card/index.tsx +14 -0
- package/src/components/card/newsroom-card/index.test.tsx +39 -0
- package/src/components/card/newsroom-card/index.tsx +37 -0
- package/src/components/card/newsroom-card/style.module.css +12 -0
- package/src/components/card/partner-card/index.test.tsx +57 -0
- package/src/components/card/partner-card/index.tsx +69 -0
- package/src/components/card/partner-card/style.module.css +24 -0
- package/src/components/card/person-card/index.test.tsx +71 -0
- package/src/components/card/person-card/index.tsx +93 -0
- package/src/components/card/person-card/style.module.css +33 -0
- package/src/components/card/primitives.tsx +176 -0
- package/src/components/card/promo-card/index.tsx +51 -0
- package/src/components/card/resource-card/index.test.tsx +48 -0
- package/src/components/card/resource-card/index.tsx +37 -0
- package/src/components/card/style.module.css +145 -0
- package/src/components/card/types.ts +66 -0
- package/src/components/card/unified-card/index.tsx +64 -0
- package/src/components/consent-manager/README.md +73 -0
- package/src/components/consent-manager/components/banner/banner.module.css +23 -0
- package/src/components/consent-manager/components/banner/banner.test.tsx +31 -0
- package/src/components/consent-manager/components/banner/banner.tsx +73 -0
- package/src/components/consent-manager/components/dialog/dialog.module.css +145 -0
- package/src/components/consent-manager/components/dialog/dialog.test.tsx +194 -0
- package/src/components/consent-manager/components/dialog/dialog.tsx +339 -0
- package/src/components/consent-manager/img/icn_close.tsx +19 -0
- package/src/components/consent-manager/index.test.tsx +334 -0
- package/src/components/consent-manager/index.tsx +186 -0
- package/src/components/consent-manager/loader/README.md +29 -0
- package/src/components/consent-manager/loader/categories.ts +22 -0
- package/src/components/consent-manager/loader/index.tsx +94 -0
- package/src/components/consent-manager/loader/presets/enterprise.ts +12 -0
- package/src/components/consent-manager/loader/presets/oss.ts +10 -0
- package/src/components/consent-manager/loader/services.ts +45 -0
- package/src/components/consent-manager/scripts/custom.tsx +59 -0
- package/src/components/consent-manager/scripts/segment.tsx +87 -0
- package/src/components/consent-manager/style.module.css +9 -0
- package/src/components/consent-manager/types.ts +55 -0
- package/src/components/consent-manager/util/cookies.test.ts +75 -0
- package/src/components/consent-manager/util/cookies.ts +70 -0
- package/src/components/consent-manager/util/integrations.test.ts +115 -0
- package/src/components/consent-manager/util/integrations.ts +110 -0
- package/src/components/intro/index.tsx +82 -0
- package/src/components/intro/style.module.css +67 -0
- package/src/components/intro/types.ts +44 -0
- package/src/components/marketo-form/CHANGELOG.md +122 -0
- package/src/components/marketo-form/README.md +1 -0
- package/src/components/marketo-form/contexts/FormMetadata.ts +11 -0
- package/src/components/marketo-form/docs.mdx +197 -0
- package/src/components/marketo-form/fixtures/index.ts +185 -0
- package/src/components/marketo-form/form/index.tsx +369 -0
- package/src/components/marketo-form/index.test.tsx +320 -0
- package/src/components/marketo-form/index.ts +11 -0
- package/src/components/marketo-form/package.original.json +30 -0
- package/src/components/marketo-form/partials/error-message/index.tsx +12 -0
- package/src/components/marketo-form/partials/error-message/style.module.css +13 -0
- package/src/components/marketo-form/partials/field/index.tsx +90 -0
- package/src/components/marketo-form/partials/field-wrapper/index.tsx +26 -0
- package/src/components/marketo-form/partials/fields/checkbox-field/index.tsx +32 -0
- package/src/components/marketo-form/partials/fields/email-field/index.tsx +35 -0
- package/src/components/marketo-form/partials/fields/form-page-url-field/index.tsx +21 -0
- package/src/components/marketo-form/partials/fields/hidden-field/index.tsx +37 -0
- package/src/components/marketo-form/partials/fields/htmltext-field/index.tsx +21 -0
- package/src/components/marketo-form/partials/fields/htmltext-field/style.module.css +6 -0
- package/src/components/marketo-form/partials/fields/name-field/index.tsx +19 -0
- package/src/components/marketo-form/partials/fields/name-field/style.module.css +13 -0
- package/src/components/marketo-form/partials/fields/radio-buttons-field/index.tsx +48 -0
- package/src/components/marketo-form/partials/fields/select-field/index.tsx +39 -0
- package/src/components/marketo-form/partials/fields/select-field/style.module.css +5 -0
- package/src/components/marketo-form/partials/fields/telephone-field/index.tsx +30 -0
- package/src/components/marketo-form/partials/fields/text-field/index.tsx +30 -0
- package/src/components/marketo-form/partials/fields/textarea-field/index.tsx +29 -0
- package/src/components/marketo-form/partials/label/index.tsx +24 -0
- package/src/components/marketo-form/partials/label/style.module.css +12 -0
- package/src/components/marketo-form/partials/visibility-rule/index.tsx +84 -0
- package/src/components/marketo-form/props.js +66 -0
- package/src/components/marketo-form/server/api-routes.ts +109 -0
- package/src/components/marketo-form/server/client.ts +98 -0
- package/src/components/marketo-form/server/index.ts +8 -0
- package/src/components/marketo-form/types.ts +268 -0
- package/src/components/marketo-form/utils.test.tsx +103 -0
- package/src/components/marketo-form/utils.ts +445 -0
- package/src/components/next-steps/index.tsx +143 -0
- package/src/components/next-steps/style.module.css +270 -0
- package/src/components/next-steps/types.ts +63 -0
- package/src/components/product-badge/index.test.tsx +11 -0
- package/src/components/product-badge/index.tsx +42 -0
- package/src/components/product-badge/style.module.css +76 -0
- package/src/components/products-used/index.tsx +84 -0
- package/src/components/products-used/style.module.css +87 -0
- package/src/components/products-used/types.ts +31 -0
- package/src/components/related-content/index.test.tsx +74 -0
- package/src/components/related-content/index.tsx +56 -0
- package/src/components/related-content/style.module.css +89 -0
- package/src/components/related-content/types.ts +21 -0
- package/src/components/subnav/helpers/areBasePathsMatching.ts +13 -0
- package/src/components/subnav/helpers/traverse/index.ts +42 -0
- package/src/components/subnav/helpers/useHeightRef.ts +42 -0
- package/src/components/subnav/helpers/useNavRef.ts +30 -0
- package/src/components/subnav/helpers/useOverflowRef.ts +85 -0
- package/src/components/subnav/helpers/useStuckRef.ts +51 -0
- package/src/components/subnav/index.tsx +199 -0
- package/src/components/subnav/partials/CtaLinks/github-stars-link/formatStarCount/index.test.ts +26 -0
- package/src/components/subnav/partials/CtaLinks/github-stars-link/formatStarCount/index.ts +22 -0
- package/src/components/subnav/partials/CtaLinks/github-stars-link/index.tsx +87 -0
- package/src/components/subnav/partials/CtaLinks/github-stars-link/parseGithubUrl/index.test.ts +29 -0
- package/src/components/subnav/partials/CtaLinks/github-stars-link/parseGithubUrl/index.ts +32 -0
- package/src/components/subnav/partials/CtaLinks/github-stars-link/style.module.css +85 -0
- package/src/components/subnav/partials/CtaLinks/icons/github-logo.js +20 -0
- package/src/components/subnav/partials/CtaLinks/icons/github.svg.js +7 -0
- package/src/components/subnav/partials/CtaLinks/icons/star.js +20 -0
- package/src/components/subnav/partials/CtaLinks/index.tsx +131 -0
- package/src/components/subnav/partials/CtaLinks/style.module.css +45 -0
- package/src/components/subnav/partials/DropdownTrigger/index.tsx +35 -0
- package/src/components/subnav/partials/DropdownTrigger/style.module.css +36 -0
- package/src/components/subnav/partials/MenuItemsDefault/index.tsx +151 -0
- package/src/components/subnav/partials/MenuItemsDefault/style.module.css +91 -0
- package/src/components/subnav/partials/MenuItemsOverflow/index.tsx +139 -0
- package/src/components/subnav/partials/MenuItemsOverflow/style.module.css +82 -0
- package/src/components/subnav/partials/TitleLink/index.tsx +113 -0
- package/src/components/subnav/partials/TitleLink/mktg-logos/all-community-product-logos_on-dark.ts +9 -0
- package/src/components/subnav/partials/TitleLink/mktg-logos/all-community-product-logos_on-light.ts +9 -0
- package/src/components/subnav/partials/TitleLink/mktg-logos/all-primary-logos_on-dark.ts +23 -0
- package/src/components/subnav/partials/TitleLink/mktg-logos/all-primary-logos_on-light.ts +23 -0
- package/src/components/subnav/partials/TitleLink/style.module.css +43 -0
- package/src/components/subnav/partials/nav-item-text/index.tsx +37 -0
- package/src/components/subnav/partials/nav-item-text/style.module.css +15 -0
- package/src/components/subnav/style.module.css +68 -0
- package/src/components/subnav/subnav-consts.ts +1 -0
- package/src/components/subnav/theme.module.css +50 -0
- package/tsconfig.json +14 -0
- package/vitest.config.mts +12 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.nextSteps {
|
|
7
|
+
--padding-y: var(--wpl-spacing-10);
|
|
8
|
+
|
|
9
|
+
position: relative;
|
|
10
|
+
padding-top: var(--padding-y);
|
|
11
|
+
padding-bottom: var(--padding-y);
|
|
12
|
+
|
|
13
|
+
@media (--medium-up) {
|
|
14
|
+
--padding-y: var(--wpl-spacing-13);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.container {
|
|
19
|
+
composes: g-grid-container from global;
|
|
20
|
+
composes: g-grid from global;
|
|
21
|
+
row-gap: var(--wpl-spacing-06);
|
|
22
|
+
align-items: flex-start;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.content {
|
|
26
|
+
grid-column: 1 / -1;
|
|
27
|
+
|
|
28
|
+
@media (--large) {
|
|
29
|
+
grid-column: 1 / 5;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.heading {
|
|
34
|
+
--color: var(--black);
|
|
35
|
+
|
|
36
|
+
composes: g-type-display-2 from global;
|
|
37
|
+
margin: 0;
|
|
38
|
+
color: var(--color);
|
|
39
|
+
|
|
40
|
+
@nest .dark & {
|
|
41
|
+
--color: var(--white);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.description {
|
|
46
|
+
--color: var(--gray-3);
|
|
47
|
+
|
|
48
|
+
composes: g-type-body-large from global;
|
|
49
|
+
margin: var(--wpl-spacing-05) 0 0;
|
|
50
|
+
color: var(--color);
|
|
51
|
+
|
|
52
|
+
@nest .dark & {
|
|
53
|
+
--color: var(--gray-5);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.actions {
|
|
58
|
+
margin-top: var(--wpl-spacing-06);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.stepsWrapper {
|
|
62
|
+
--grid-gap: var(--wpl-spacing-05);
|
|
63
|
+
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
gap: var(--wpl-spacing-05);
|
|
67
|
+
grid-column: 1 / -1;
|
|
68
|
+
|
|
69
|
+
@media (--large) {
|
|
70
|
+
--grid-gap: var(--wpl-spacing-06);
|
|
71
|
+
|
|
72
|
+
grid-column: 6 / -1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.stepsList {
|
|
77
|
+
--grid-template-columns: 1;
|
|
78
|
+
|
|
79
|
+
display: grid;
|
|
80
|
+
grid-template-columns: repeat(var(--grid-template-columns), 1fr);
|
|
81
|
+
gap: var(--grid-gap);
|
|
82
|
+
list-style: none;
|
|
83
|
+
padding: 0;
|
|
84
|
+
margin: 0;
|
|
85
|
+
|
|
86
|
+
@media (--medium-up) {
|
|
87
|
+
--grid-template-columns: 2;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.stepsListItem {
|
|
92
|
+
display: flex;
|
|
93
|
+
width: 100%;
|
|
94
|
+
|
|
95
|
+
&.stepsListItemFeature {
|
|
96
|
+
@media (--medium-up) {
|
|
97
|
+
grid-column: span 2;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.tile {
|
|
103
|
+
--background-color: transparent;
|
|
104
|
+
--color: var(--wpl-neutral-0);
|
|
105
|
+
--transition-duration: 250ms;
|
|
106
|
+
--transition-timing-function: ease-in-out;
|
|
107
|
+
--border-radius: 8px;
|
|
108
|
+
--scrim-background: transparent;
|
|
109
|
+
|
|
110
|
+
position: relative;
|
|
111
|
+
display: flex;
|
|
112
|
+
width: 100%;
|
|
113
|
+
min-height: 208px;
|
|
114
|
+
flex-direction: column;
|
|
115
|
+
padding: var(--wpl-spacing-06);
|
|
116
|
+
background-color: var(--background-color);
|
|
117
|
+
color: var(--color);
|
|
118
|
+
border-radius: var(--border-radius);
|
|
119
|
+
transition-duration: var(--transition-duration);
|
|
120
|
+
transition-timing-function: var(--transition-timing-function);
|
|
121
|
+
transition-property: background-color;
|
|
122
|
+
|
|
123
|
+
&.primary {
|
|
124
|
+
--background-color: var(--brand-secondary);
|
|
125
|
+
--color: var(--wpl-neutral-900);
|
|
126
|
+
--scrim-background: black;
|
|
127
|
+
|
|
128
|
+
&:hover {
|
|
129
|
+
--background-color: var(--brand-secondary);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@nest .hashicorp & {
|
|
133
|
+
--background-color: var(--wpl-blue-500);
|
|
134
|
+
--color: var(--wpl-neutral-0);
|
|
135
|
+
--scrim-background: transparent;
|
|
136
|
+
|
|
137
|
+
&:hover {
|
|
138
|
+
--background-color: var(--wpl-blue-600);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@nest .dark & {
|
|
143
|
+
--background-color: var(--wpl-neutral-700);
|
|
144
|
+
--color: var(--wpl-neutral-0);
|
|
145
|
+
|
|
146
|
+
&:hover {
|
|
147
|
+
--background-color: var(--wpl-neutral-600);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
&:not(.primary) {
|
|
153
|
+
--color: var(--wpl-neutral-900);
|
|
154
|
+
--background-color: var(--wpl-neutral-50);
|
|
155
|
+
|
|
156
|
+
&:hover {
|
|
157
|
+
--background-color: var(--wpl-neutral-100);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@nest .dark & {
|
|
161
|
+
--background-color: var(--wpl-neutral-700);
|
|
162
|
+
--color: var(--white);
|
|
163
|
+
|
|
164
|
+
&:hover {
|
|
165
|
+
--background-color: var(--wpl-neutral-600);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.tileInner {
|
|
172
|
+
position: relative;
|
|
173
|
+
display: flex;
|
|
174
|
+
flex-direction: column;
|
|
175
|
+
flex-grow: 1;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.tileScrim {
|
|
179
|
+
position: absolute;
|
|
180
|
+
inset: 0;
|
|
181
|
+
background: var(--scrim-background);
|
|
182
|
+
border-radius: var(--border-radius);
|
|
183
|
+
opacity: 0;
|
|
184
|
+
transition-duration: var(--transition-duration);
|
|
185
|
+
transition-timing-function: var(--transition-timing-function);
|
|
186
|
+
transition-property: opacity;
|
|
187
|
+
|
|
188
|
+
@nest .tile &:hover {
|
|
189
|
+
opacity: 0.05;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.tileHeading {
|
|
194
|
+
margin: 0;
|
|
195
|
+
color: inherit;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.tileHeadingText {
|
|
199
|
+
composes: g-type-display-4 from global;
|
|
200
|
+
vertical-align: middle;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.tileBadge {
|
|
204
|
+
display: inline-flex;
|
|
205
|
+
margin: 0 0 0 var(--wpl-spacing-02);
|
|
206
|
+
vertical-align: middle;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.tileDescription {
|
|
210
|
+
--color: var(--wpl-neutral-900);
|
|
211
|
+
|
|
212
|
+
composes: g-type-display-6 from global;
|
|
213
|
+
margin: 8px 0 0;
|
|
214
|
+
color: var(--color);
|
|
215
|
+
|
|
216
|
+
@nest .hashicorp .primary & {
|
|
217
|
+
--color: var(--wpl-neutral-0);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@nest .primary & {
|
|
221
|
+
--color: var(--brand-text-on-primary);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@nest .primary & {
|
|
225
|
+
--color: var(--brand-text-on-primary);
|
|
226
|
+
--color: var(--wpl-neutral-900);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
@nest .dark & {
|
|
230
|
+
--color: var(--wpl-neutral-0);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.tileCta {
|
|
235
|
+
margin-top: auto;
|
|
236
|
+
padding-top: var(--wpl-spacing-05);
|
|
237
|
+
display: inline-flex;
|
|
238
|
+
align-items: center;
|
|
239
|
+
gap: 8px;
|
|
240
|
+
color: inherit;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.tileCtaLabel {
|
|
244
|
+
font-size: 0.875rem;
|
|
245
|
+
line-height: 1.143;
|
|
246
|
+
font-weight: var(--token-typography-font-weight-medium);
|
|
247
|
+
font-family: var(--token-typography-font-stack-text);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.tileCtaIcon {
|
|
251
|
+
flex-shrink: 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.cta {
|
|
255
|
+
grid-column: 1/ -1;
|
|
256
|
+
display: flex;
|
|
257
|
+
flex-wrap: wrap;
|
|
258
|
+
column-gap: var(--wpl-spacing-03);
|
|
259
|
+
row-gap: var(--wpl-spacing-01);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.ctaCopy {
|
|
263
|
+
margin: 0;
|
|
264
|
+
composes: g-type-body-strong from global;
|
|
265
|
+
font-size: 16px;
|
|
266
|
+
|
|
267
|
+
@nest .dark & {
|
|
268
|
+
color: var(--wpl-neutral-0);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Products } from '@hashicorp/platform-product-meta'
|
|
7
|
+
import type { ActionsProps } from '@hashicorp/react-actions/types'
|
|
8
|
+
|
|
9
|
+
export interface StepProps {
|
|
10
|
+
/**
|
|
11
|
+
* The heading for the step.
|
|
12
|
+
*/
|
|
13
|
+
heading: string
|
|
14
|
+
/**
|
|
15
|
+
* Optional badge for the step.
|
|
16
|
+
*/
|
|
17
|
+
badge?: string
|
|
18
|
+
/**
|
|
19
|
+
* Optional description for the step.
|
|
20
|
+
*/
|
|
21
|
+
description?: string
|
|
22
|
+
/**
|
|
23
|
+
* The call to action for the step.
|
|
24
|
+
*/
|
|
25
|
+
cta: {
|
|
26
|
+
title: string
|
|
27
|
+
url: string
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface NextStepsProps {
|
|
32
|
+
/**
|
|
33
|
+
* Render NextSteps on light or dark background.
|
|
34
|
+
*/
|
|
35
|
+
appearance?: 'light' | 'dark'
|
|
36
|
+
/**
|
|
37
|
+
* Optional theme which controls the primary step color.
|
|
38
|
+
*/
|
|
39
|
+
theme?: Products
|
|
40
|
+
/**
|
|
41
|
+
* The heading for the section.
|
|
42
|
+
*/
|
|
43
|
+
heading: string
|
|
44
|
+
/**
|
|
45
|
+
* The description for the section.
|
|
46
|
+
*/
|
|
47
|
+
description: string
|
|
48
|
+
/**
|
|
49
|
+
* The list of steps to display as tiles.
|
|
50
|
+
*/
|
|
51
|
+
steps:
|
|
52
|
+
| [StepProps]
|
|
53
|
+
| [StepProps, StepProps]
|
|
54
|
+
| [StepProps, StepProps, StepProps]
|
|
55
|
+
/**
|
|
56
|
+
* Optional CTA displayed below the tiles.
|
|
57
|
+
*/
|
|
58
|
+
cta?: {
|
|
59
|
+
copy: string
|
|
60
|
+
href: string
|
|
61
|
+
ctaText: string
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
import ProductBadge from '.'
|
|
3
|
+
|
|
4
|
+
describe('<ProductBadge />', () => {
|
|
5
|
+
it('should render the name of the product', () => {
|
|
6
|
+
const productName = 'waypoint'
|
|
7
|
+
render(<ProductBadge productName={productName} />)
|
|
8
|
+
const productBadgeEl = screen.getByText(productName)
|
|
9
|
+
expect(productBadgeEl).toBeInTheDocument()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Products } from '@hashicorp/platform-product-meta'
|
|
7
|
+
import Badge from '@hashicorp/react-design-system-components/src/components/badge'
|
|
8
|
+
import { IconDot16 } from '@hashicorp/flight-icons/svg-react/dot-16'
|
|
9
|
+
import s from './style.module.css'
|
|
10
|
+
|
|
11
|
+
export interface ProductBadgeProps {
|
|
12
|
+
productName: Products
|
|
13
|
+
hasDot?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const ProductBadge = ({ productName, hasDot }: ProductBadgeProps) => {
|
|
17
|
+
const finalProductName = productName.replace('hashicorp', 'HashiCorp')
|
|
18
|
+
|
|
19
|
+
const productBrand =
|
|
20
|
+
finalProductName === 'HashiCorp cloud platform' ? 'hashicorp' : productName
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Badge
|
|
24
|
+
className={s.badge}
|
|
25
|
+
text={finalProductName}
|
|
26
|
+
icon={
|
|
27
|
+
hasDot ? (
|
|
28
|
+
<IconDot16
|
|
29
|
+
width="100%"
|
|
30
|
+
height="100%"
|
|
31
|
+
style={{
|
|
32
|
+
display: 'block',
|
|
33
|
+
color: `var(--token-color-${productBrand}-brand)`,
|
|
34
|
+
}}
|
|
35
|
+
/>
|
|
36
|
+
) : undefined
|
|
37
|
+
}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default ProductBadge
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.root {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
height: 24px;
|
|
10
|
+
padding: 1.5px 12px 2.5px 12px;
|
|
11
|
+
border-radius: 24px;
|
|
12
|
+
width: max-content;
|
|
13
|
+
background-color: var(--brand);
|
|
14
|
+
color: var(--brand-text-on-primary);
|
|
15
|
+
|
|
16
|
+
&.hasDot {
|
|
17
|
+
gap: 5px;
|
|
18
|
+
|
|
19
|
+
&::before {
|
|
20
|
+
--size: 7px;
|
|
21
|
+
|
|
22
|
+
content: '';
|
|
23
|
+
width: var(--size);
|
|
24
|
+
height: var(--size);
|
|
25
|
+
background-color: var(--brand);
|
|
26
|
+
border-radius: 50%;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.light {
|
|
31
|
+
&.secondary,
|
|
32
|
+
&.hasDot {
|
|
33
|
+
background-color: hsla(225, 2%, 63%, 0.13);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&.dark {
|
|
38
|
+
background-color: var(--wpl-neutral-0);
|
|
39
|
+
|
|
40
|
+
&.secondary,
|
|
41
|
+
&.hasDot {
|
|
42
|
+
background-color: hsla(0, 0%, 100%, 0.18);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.text {
|
|
48
|
+
display: inline-block;
|
|
49
|
+
position: relative;
|
|
50
|
+
font-family: var(--font-body);
|
|
51
|
+
font-weight: var(--font-weight-bold);
|
|
52
|
+
font-size: 14px;
|
|
53
|
+
letter-spacing: 0.0125em;
|
|
54
|
+
text-transform: capitalize;
|
|
55
|
+
margin: 0;
|
|
56
|
+
|
|
57
|
+
&.light {
|
|
58
|
+
&.secondary,
|
|
59
|
+
&.hasDot {
|
|
60
|
+
color: var(--wpl-neutral-500);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&.dark {
|
|
65
|
+
color: var(--wpl-neutral-500);
|
|
66
|
+
|
|
67
|
+
&.secondary,
|
|
68
|
+
&.hasDot {
|
|
69
|
+
color: var(--wpl-neutral-300);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.badge {
|
|
75
|
+
text-transform: capitalize;
|
|
76
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ProductsUsedProps } from './types'
|
|
7
|
+
import { IconBoundaryColor16 } from '@hashicorp/flight-icons/svg-react/boundary-color-16'
|
|
8
|
+
import { IconConsulColor16 } from '@hashicorp/flight-icons/svg-react/consul-color-16'
|
|
9
|
+
import { IconNomadColor16 } from '@hashicorp/flight-icons/svg-react/nomad-color-16'
|
|
10
|
+
import { IconPackerColor16 } from '@hashicorp/flight-icons/svg-react/packer-color-16'
|
|
11
|
+
import { IconTerraformColor16 } from '@hashicorp/flight-icons/svg-react/terraform-color-16'
|
|
12
|
+
import { IconVaultColor16 } from '@hashicorp/flight-icons/svg-react/vault-color-16'
|
|
13
|
+
import { IconVagrantColor16 } from '@hashicorp/flight-icons/svg-react/vagrant-color-16'
|
|
14
|
+
import { IconWaypointColor16 } from '@hashicorp/flight-icons/svg-react/waypoint-color-16'
|
|
15
|
+
import classNames from 'classnames'
|
|
16
|
+
import s from './style.module.css'
|
|
17
|
+
|
|
18
|
+
const ProductIconMap = {
|
|
19
|
+
boundary: <IconBoundaryColor16 />,
|
|
20
|
+
consul: <IconConsulColor16 />,
|
|
21
|
+
nomad: <IconNomadColor16 />,
|
|
22
|
+
packer: <IconPackerColor16 />,
|
|
23
|
+
terraform: <IconTerraformColor16 />,
|
|
24
|
+
vault: <IconVaultColor16 />,
|
|
25
|
+
vagrant: <IconVagrantColor16 />,
|
|
26
|
+
waypoint: <IconWaypointColor16 />,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const ProductsUsed = ({
|
|
30
|
+
appearance = 'light',
|
|
31
|
+
products,
|
|
32
|
+
}: ProductsUsedProps) => {
|
|
33
|
+
const eyebrowText = 'Products used'
|
|
34
|
+
|
|
35
|
+
// Products with links have different spacing between each other (8px) than
|
|
36
|
+
// products without links (16px). This spacing is set on the `ul` using the `gap` property.
|
|
37
|
+
// This logic determines whether or not products have links so as to conditionally change
|
|
38
|
+
// the spacing.
|
|
39
|
+
const productsHaveLinks = products[0]?.hasOwnProperty('href')
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div className={classNames([s.root, s[appearance]])} data-testid="root">
|
|
43
|
+
<p className={classNames([s.eyebrow, s[appearance]])}>{eyebrowText}</p>
|
|
44
|
+
<ul
|
|
45
|
+
className={classNames([s.productList], {
|
|
46
|
+
[s.isSmallerGap]: productsHaveLinks,
|
|
47
|
+
})}
|
|
48
|
+
>
|
|
49
|
+
{products.map((product, index) => {
|
|
50
|
+
return (
|
|
51
|
+
<li
|
|
52
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
53
|
+
key={index}
|
|
54
|
+
>
|
|
55
|
+
<ConditionalLink
|
|
56
|
+
className={classNames([s.product, s[appearance]])}
|
|
57
|
+
href={product.href}
|
|
58
|
+
>
|
|
59
|
+
<span className={s.productIcon}>
|
|
60
|
+
{ProductIconMap[product.name]}
|
|
61
|
+
</span>
|
|
62
|
+
<span className={classNames([s.productName, s[appearance]])}>
|
|
63
|
+
{product.name}
|
|
64
|
+
</span>
|
|
65
|
+
</ConditionalLink>
|
|
66
|
+
</li>
|
|
67
|
+
)
|
|
68
|
+
})}
|
|
69
|
+
</ul>
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const ConditionalLink = ({ href, children, className }) => {
|
|
75
|
+
return href ? (
|
|
76
|
+
<a href={href} className={className} data-testid={'anchorEl'}>
|
|
77
|
+
{children}
|
|
78
|
+
</a>
|
|
79
|
+
) : (
|
|
80
|
+
<div className={className}>{children}</div>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default ProductsUsed
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.root {
|
|
7
|
+
position: relative;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.eyebrow {
|
|
11
|
+
composes: g-type-label-strong from global;
|
|
12
|
+
margin: 0 0 var(--hdsplus-spacing-05) 0;
|
|
13
|
+
color: var(--token-color-foreground-faint);
|
|
14
|
+
|
|
15
|
+
&.dark {
|
|
16
|
+
color: var(--wpl-neutral-400);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.productList {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
flex-wrap: wrap;
|
|
24
|
+
padding: 0;
|
|
25
|
+
list-style-type: none;
|
|
26
|
+
row-gap: var(--hdsplus-spacing-03);
|
|
27
|
+
column-gap: var(--hdsplus-spacing-05);
|
|
28
|
+
|
|
29
|
+
&.isSmallerGap {
|
|
30
|
+
column-gap: var(--hdsplus-spacing-03);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.product {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
|
|
38
|
+
&[href] {
|
|
39
|
+
min-height: 40px;
|
|
40
|
+
padding: var(--hdsplus-spacing-03) var(--hdsplus-spacing-04);
|
|
41
|
+
border-radius: calc(var(--hdsplus-spacing-03) / 2);
|
|
42
|
+
border: 1px solid var(--token-color-border-primary);
|
|
43
|
+
transition: background-color 0.2s, border 0.2s;
|
|
44
|
+
|
|
45
|
+
&:hover {
|
|
46
|
+
background-color: var(--token-color-border-primary);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&:focus {
|
|
50
|
+
outline: transparent;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&:focus-visible {
|
|
54
|
+
outline: 2px solid var(--token-color-surface-interactive-active);
|
|
55
|
+
outline-offset: 2px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&.dark {
|
|
59
|
+
border-color: var(--token-color-border-strong);
|
|
60
|
+
|
|
61
|
+
&:hover {
|
|
62
|
+
background-color: var(--token-color-border-strong);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&:focus-visible {
|
|
66
|
+
outline: 2px solid var(--token-color-border-strong);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.productIcon {
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
margin-right: 6px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.productName {
|
|
79
|
+
composes: hds-typography-body-100 hds-font-weight-medium from global;
|
|
80
|
+
font-size: 14px;
|
|
81
|
+
text-transform: capitalize;
|
|
82
|
+
color: var(--token-color-foreground-primary);
|
|
83
|
+
|
|
84
|
+
&.dark {
|
|
85
|
+
color: var(--wpl-neutral-0);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Products } from '@hashicorp/platform-product-meta'
|
|
7
|
+
|
|
8
|
+
export interface ProductsUsedProps {
|
|
9
|
+
/**
|
|
10
|
+
* Display actions on light or dark background.
|
|
11
|
+
*/
|
|
12
|
+
appearance?: 'light' | 'dark'
|
|
13
|
+
/**
|
|
14
|
+
* Array of products or products with links. Only supports one or the other, not a mix of the two.
|
|
15
|
+
*/
|
|
16
|
+
products: Array<Product> | Array<ProductLink>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Product {
|
|
20
|
+
/**
|
|
21
|
+
* Renders a product name
|
|
22
|
+
*/
|
|
23
|
+
name: Exclude<Products, 'hashicorp'>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface ProductLink extends Product {
|
|
27
|
+
/**
|
|
28
|
+
* Where the anchor element links to when clicked.
|
|
29
|
+
*/
|
|
30
|
+
href: string
|
|
31
|
+
}
|