diff --git a/src/components/badge/index.tsx b/src/components/badge/index.tsx index ef218a5ef7..90c4b359df 100644 --- a/src/components/badge/index.tsx +++ b/src/components/badge/index.tsx @@ -2,7 +2,7 @@ import React from "react"; import s from "./style.module.css"; import { BadgeProps } from "./types"; -function classNames(...classes) { +function classNames(...classes: string[]) { return classes.filter(Boolean).join(" "); } @@ -10,7 +10,7 @@ export default function Badge({ type, path, children }: BadgeProps) { return ( <> {path && ( - +
{children}
diff --git a/src/components/product-heading/index.tsx b/src/components/product-heading/index.tsx index af73249d38..b0d6ed2bbf 100644 --- a/src/components/product-heading/index.tsx +++ b/src/components/product-heading/index.tsx @@ -1,6 +1,9 @@ import Icon from '@cypress-design/react-icon' import Badge from "@site/src/components/badge" import s from './style.module.css' +import {useDoc} from '@docusaurus/theme-common/internal'; +import E2EOnlyBadge from "@site/src/components/e2e-only-badge"; +import ComponentOnlyBadge from "@site/src/components/component-only-badge"; import React from 'react'; @@ -8,12 +11,14 @@ import React from 'react'; interface ProductHeadingProps { product: 'app' | 'cloud' | 'accessibility' | 'ui-coverage' plan?: 'team' | 'business' | 'enterprise' + badge?: React.ReactNode } // Build the Button component with the specified props -const ProductHeading: React.FC = ({ +const DocProductHeading: React.FC = ({ product, // The product to display plan, // The plan to display for Cloud product + badge, // The badge to display }) => { const productName = product === 'ui-coverage' ? 'UI Coverage' : product === 'accessibility' ? 'Cypress Accessibility' : product === 'cloud' ? 'Cypress Cloud' : 'Cypress App' const iconName = product === 'ui-coverage' ? 'technology-ui-coverage' : product === 'accessibility' ? 'cypress-accessibility-outline' : 'technology-cypress' @@ -26,7 +31,7 @@ const ProductHeading: React.FC = ({ } return ( -
+
= ({ {productName} - = ({ > { product !== 'app' && {badgeContent}} - + {badge}
) } -export default ProductHeading \ No newline at end of file +const ProductHeading: React.FC> = (props) => { + const { frontMatter } = useDoc(); + const e2eSpecific = (frontMatter as any).e2eSpecific; + const componentSpecific = (frontMatter as any).componentSpecific; + const testTypePill = (e2eSpecific && ) || (componentSpecific && ); + return ; +}; + +export default ProductHeading; +export { ProductHeading, DocProductHeading }; \ No newline at end of file diff --git a/src/components/product-heading/style.module.css b/src/components/product-heading/style.module.css index b58aca146d..ad75d8b051 100644 --- a/src/components/product-heading/style.module.css +++ b/src/components/product-heading/style.module.css @@ -16,4 +16,10 @@ .productHeadingText { font-size: 1.2rem; margin-right: 0.5rem; +} + +.productHeadingBadge { + margin-left: auto; + display: flex; + align-items: center; } \ No newline at end of file diff --git a/src/theme/DocItem/Content/index.tsx b/src/theme/DocItem/Content/index.tsx index 3274f2f456..620edde5e6 100644 --- a/src/theme/DocItem/Content/index.tsx +++ b/src/theme/DocItem/Content/index.tsx @@ -28,10 +28,7 @@ function useSyntheticTitle() { } return metadata.title; } -export default function DocItemContent({children}) { - -const { frontMatter: {e2eSpecific, componentSpecific} } = useDoc(); -const testTypePill = e2eSpecific && || componentSpecific && +export default function DocItemContent({children}: {children: React.ReactNode}) { const syntheticTitle = useSyntheticTitle(); return ( @@ -41,7 +38,6 @@ return (
{syntheticTitle} - {testTypePill}