1
1
import Icon from '@cypress-design/react-icon'
2
2
import Badge from "@site/src/components/badge"
3
3
import s from './style.module.css'
4
+ import { useDoc } from '@docusaurus/theme-common/internal' ;
5
+ import E2EOnlyBadge from "@site/src/components/e2e-only-badge" ;
6
+ import ComponentOnlyBadge from "@site/src/components/component-only-badge" ;
4
7
5
8
import React from 'react' ;
6
9
7
10
// Define the types for the props
8
11
interface ProductHeadingProps {
9
12
product : 'app' | 'cloud' | 'accessibility' | 'ui-coverage'
10
13
plan ?: 'team' | 'business' | 'enterprise'
14
+ badge ?: React . ReactNode
11
15
}
12
16
13
17
// Build the Button component with the specified props
14
- const ProductHeading : React . FC < ProductHeadingProps > = ( {
18
+ const DocProductHeading : React . FC < ProductHeadingProps > = ( {
15
19
product, // The product to display
16
20
plan, // The plan to display for Cloud product
21
+ badge, // The badge to display
17
22
} ) => {
18
23
const productName = product === 'ui-coverage' ? 'UI Coverage' : product === 'accessibility' ? 'Cypress Accessibility' : product === 'cloud' ? 'Cypress Cloud' : 'Cypress App'
19
24
const iconName = product === 'ui-coverage' ? 'technology-ui-coverage' : product === 'accessibility' ? 'cypress-accessibility-outline' : 'technology-cypress'
@@ -26,15 +31,14 @@ const ProductHeading: React.FC<ProductHeadingProps> = ({
26
31
}
27
32
28
33
return (
29
- < div className = { s . productHeading } >
34
+ < div className = { s . productHeading } style = { { display : 'flex' , alignItems : 'center' , gap : '0.5rem' } } >
30
35
< Icon
31
36
name = { iconName }
32
37
className = { s . productHeadingIcon }
33
38
/>
34
39
< span className = { s . productHeadingText } >
35
40
{ productName }
36
41
</ span >
37
-
38
42
< a
39
43
href = { `https://www.cypress.io/${ linkPath } ?utm_source=docs&utm_medium=product-heading-${ product } &utm_content=${ badgeContent } ` }
40
44
target = "_blank"
@@ -43,9 +47,18 @@ const ProductHeading: React.FC<ProductHeadingProps> = ({
43
47
>
44
48
{ product !== 'app' && < Badge type = "success" > { badgeContent } </ Badge > }
45
49
</ a >
46
-
50
+ < span className = { s . productHeadingBadge } > { badge } </ span >
47
51
</ div >
48
52
)
49
53
}
50
54
51
- export default ProductHeading
55
+ const ProductHeading : React . FC < Omit < ProductHeadingProps , 'badge' > > = ( props ) => {
56
+ const { frontMatter } = useDoc ( ) ;
57
+ const e2eSpecific = ( frontMatter as any ) . e2eSpecific ;
58
+ const componentSpecific = ( frontMatter as any ) . componentSpecific ;
59
+ const testTypePill = ( e2eSpecific && < E2EOnlyBadge /> ) || ( componentSpecific && < ComponentOnlyBadge /> ) ;
60
+ return < DocProductHeading { ...props } badge = { testTypePill } /> ;
61
+ } ;
62
+
63
+ export default ProductHeading ;
64
+ export { ProductHeading , DocProductHeading } ;
0 commit comments