@hashicorp/react-components 0.0.0-nightly.a1d968e → 0.0.0-nightly.a80dc5e
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 +1 -1
- package/src/components/card/index.test.tsx +1 -1
- package/src/components/card/newsroom-card/index.test.tsx +1 -1
- package/src/components/card/primitives.tsx +12 -12
- package/src/components/card/resource-card/index.test.tsx +1 -1
- package/src/components/card/unified-card/index.spec.tsx +40 -0
- package/src/components/subnav/index.tsx +5 -1
package/package.json
CHANGED
|
@@ -56,7 +56,7 @@ describe('<Card />', () => {
|
|
|
56
56
|
const metaElement = screen.getByTestId('wpl-card-meta')
|
|
57
57
|
|
|
58
58
|
cardMeta.forEach((item) => {
|
|
59
|
-
expect(metaElement).
|
|
59
|
+
expect(metaElement).toHaveTextContent(item)
|
|
60
60
|
})
|
|
61
61
|
expect(metaElement).toContainElement(screen.getByText('|'))
|
|
62
62
|
})
|
|
@@ -26,7 +26,7 @@ describe('<NewsroomCard />', () => {
|
|
|
26
26
|
const metaElement = screen.getByTestId('wpl-card-meta')
|
|
27
27
|
|
|
28
28
|
expectedMeta.forEach((item) => {
|
|
29
|
-
expect(metaElement).
|
|
29
|
+
expect(metaElement).toHaveTextContent(item)
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
expect(metaElement).toContainElement(screen.queryByText('|'))
|
|
@@ -101,23 +101,23 @@ function LogoThumbnail({ src, alt }: ThumbnailProps) {
|
|
|
101
101
|
|
|
102
102
|
function Meta({ items }: MetaProps) {
|
|
103
103
|
return (
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
<div className={s.meta} data-testid="wpl-card-meta">
|
|
105
|
+
<TextPlus.Label>
|
|
106
|
+
{items.map((item, stableIdx) => {
|
|
107
|
+
const isLastItem = stableIdx === items.length - 1
|
|
108
|
+
return (
|
|
109
|
+
<>
|
|
110
110
|
{item}
|
|
111
|
-
{
|
|
111
|
+
{!isLastItem ? (
|
|
112
112
|
<span className={s.metaSeparator} aria-hidden={true}>
|
|
113
113
|
|
|
|
114
114
|
</span>
|
|
115
115
|
) : null}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
</
|
|
116
|
+
</>
|
|
117
|
+
)
|
|
118
|
+
})}
|
|
119
|
+
</TextPlus.Label>
|
|
120
|
+
</div>
|
|
121
121
|
)
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -26,7 +26,7 @@ describe('<ResourceCard />', () => {
|
|
|
26
26
|
const metaElement = screen.getByTestId('wpl-card-meta')
|
|
27
27
|
|
|
28
28
|
expectedMeta.forEach((item) => {
|
|
29
|
-
expect(metaElement).
|
|
29
|
+
expect(metaElement).toHaveTextContent(item)
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
expect(metaElement).toContainElement(screen.getByText('|'))
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) HashiCorp, Inc.
|
|
3
|
+
* SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { render, screen } from '@testing-library/react'
|
|
7
|
+
import { UnifiedCard, UnifiedCardProps } from '.'
|
|
8
|
+
|
|
9
|
+
const defaultProps: UnifiedCardProps = {
|
|
10
|
+
link: 'https://hashicorp.com',
|
|
11
|
+
heading: 'Example heading',
|
|
12
|
+
thumbnail: {
|
|
13
|
+
src: 'https://www.datocms-assets.com/19447/1648680074-screenshot-2022-03-31-at-00-40-47.png',
|
|
14
|
+
alt: 'HashiConf Europe 2022 Recap',
|
|
15
|
+
},
|
|
16
|
+
} as const
|
|
17
|
+
|
|
18
|
+
describe(`<UnifiedCard />`, () => {
|
|
19
|
+
it('should render the provided meta with a separator if n > 1', () => {
|
|
20
|
+
const expectedMeta = ['Category', 'Hello']
|
|
21
|
+
render(<UnifiedCard {...defaultProps} meta={expectedMeta} />)
|
|
22
|
+
|
|
23
|
+
const metaElement = screen.getByTestId('wpl-card-meta')
|
|
24
|
+
|
|
25
|
+
expectedMeta.forEach((item) => {
|
|
26
|
+
expect(metaElement).toHaveTextContent(item)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
expect(metaElement).toContainElement(screen.getByText('|'))
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('it should not render a separator if n === 1', () => {
|
|
33
|
+
render(<UnifiedCard {...defaultProps} meta={['Category']} />)
|
|
34
|
+
const metaElement = screen.getByTestId('wpl-card-meta')
|
|
35
|
+
|
|
36
|
+
expect(metaElement).toContainElement(screen.getByText('Category'))
|
|
37
|
+
|
|
38
|
+
expect(metaElement).not.toContainElement(screen.queryByText('|'))
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -164,6 +164,10 @@ function Subnav({ className, theme = 'light', ...restProps }: SubnavProps) {
|
|
|
164
164
|
setActivePanel(panel)
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
const ariaLabel = restProps?.titleLink?.text
|
|
168
|
+
? `${restProps.titleLink.text} pages`
|
|
169
|
+
: 'Subnav pages'
|
|
170
|
+
|
|
167
171
|
return (
|
|
168
172
|
<>
|
|
169
173
|
{/**
|
|
@@ -179,7 +183,7 @@ function Subnav({ className, theme = 'light', ...restProps }: SubnavProps) {
|
|
|
179
183
|
[s.hasOverflow]: hasOverflow,
|
|
180
184
|
'hdsplus-dark-mode': theme === 'dark',
|
|
181
185
|
})}
|
|
182
|
-
aria-label={
|
|
186
|
+
aria-label={ariaLabel}
|
|
183
187
|
onValueChange={activatePanel}
|
|
184
188
|
value={activePanel}
|
|
185
189
|
delayDuration={0}
|