diff --git a/packages/docs/content/components/hero.md b/packages/docs/content/components/hero.md index 730f526..e03fd8e 100644 --- a/packages/docs/content/components/hero.md +++ b/packages/docs/content/components/hero.md @@ -14,18 +14,19 @@ The Hoverkraft theme ships a `HoverkraftHero` component that encapsulates the br ## Props -| Prop | Type | Required | Default | Description | -| ------------------ | -------------------------- | -------- | ------------ | --------------------------------------------------- | -| `title` | `ReactNode` | ✅ | - | Main heading text | -| `description` | `ReactNode` | ❌ | - | Subheading text | -| `eyebrow` | `string` | ❌ | - | Small text above title | -| `brandedText` | `ReactNode` | ❌ | - | Deprecated: use `HoverkraftBrandHighlight` in title | -| `supportingVisual` | `ReactNode` | ❌ | - | Image or graphic to display | -| `actions` | `HoverkraftAction[]` | ❌ | - | Call-to-action buttons | -| `align` | `'left' \| 'center'` | ❌ | `'left'` | Text alignment and grid alignment | -| `tone` | `'midnight' \| 'daylight'` | ❌ | `'midnight'` | Color scheme (dark or light background) | -| `id` | `string` | ❌ | - | Optional DOM ID for deep-linking | -| `className` | `string` | ❌ | - | Extend styling with additional classes | +| Prop | Type | Required | Default | Description | +| --------------------- | -------------------------- | -------- | ------------ | --------------------------------------------------- | +| `title` | `ReactNode` | ✅ | - | Main heading text | +| `description` | `ReactNode` | ❌ | - | Subheading text | +| `eyebrow` | `string` | ❌ | - | Small text above title | +| `brandedText` | `ReactNode` | ❌ | - | Deprecated: use `HoverkraftBrandHighlight` in title | +| `supportingVisual` | `string` | ❌ | - | Path to the supporting image (e.g., `img/hero.png`) | +| `supportingVisualAlt` | `string` | ❌ | `""` | Alt text describing the supporting image | +| `actions` | `HoverkraftAction[]` | ❌ | - | Call-to-action buttons | +| `align` | `'left' \| 'center'` | ❌ | `'left'` | Text alignment and grid alignment | +| `tone` | `'midnight' \| 'daylight'` | ❌ | `'midnight'` | Color scheme (dark or light background) | +| `id` | `string` | ❌ | - | Optional DOM ID for deep-linking | +| `className` | `string` | ❌ | - | Extend styling with additional classes | ### Action Object Structure @@ -75,25 +76,7 @@ const actions = [ }, ]; -const supportingVisual = ( - -); +const supportingVisual = "img/home.png"; render( ); @@ -121,25 +105,7 @@ const actions = [ { label: "Configuration", to: "/docs/configuration", variant: "secondary" }, ]; -const supportingVisual = ( - -); +const supportingVisual = "img/home.png"; render( ); diff --git a/packages/docs/content/examples.md b/packages/docs/content/examples.md index 4c0044f..d9fd474 100644 --- a/packages/docs/content/examples.md +++ b/packages/docs/content/examples.md @@ -33,7 +33,8 @@ export default function Home() { } description="Your gateway to open-source innovation." - supportingVisual={Platform} + supportingVisual="/static/img/home.png" + supportingVisualAlt="Screenshot of the Hoverkraft platform" actions={[ { label: "Explore Projects", to: "/docs/intro", variant: "primary" }, { @@ -77,7 +78,6 @@ export default function Home() { /> - {/* Projects Grid */}
@@ -316,7 +316,8 @@ You can use multiple hero sections with different tones: description="Highlight another key feature" tone="daylight" align="left" - supportingVisual={Feature} + supportingVisual="img/home.png" + supportingVisualAlt="Illustration of the highlighted feature" /> ``` diff --git a/packages/docs/src/pages/index.tsx b/packages/docs/src/pages/index.tsx index 002bc7e..efaf2a0 100644 --- a/packages/docs/src/pages/index.tsx +++ b/packages/docs/src/pages/index.tsx @@ -95,12 +95,12 @@ export default function Home(): JSX.Element { - Hoverkraft Theme for{" "} - Docusaurus + Hoverkraft Theme for Docusaurus } description="Craft documentation that feels premium out-of-the-box. Opinionated visual language meets pragmatic components that let your content shine." actions={heroActions} + supportingVisual="/img/home.png" tone="midnight" align="center" /> diff --git a/packages/docs/static/.nojekyll b/packages/docs/static/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/packages/docs/static/img/home.png b/packages/docs/static/img/home.png new file mode 100644 index 0000000..861bd9c Binary files /dev/null and b/packages/docs/static/img/home.png differ diff --git a/packages/theme/package.json b/packages/theme/package.json index 15ba6af..5dbc9e2 100644 --- a/packages/theme/package.json +++ b/packages/theme/package.json @@ -77,7 +77,8 @@ "testEnvironment": "jsdom", "moduleNameMapper": { "\\.(css|less|scss|sass)$": "identity-obj-proxy", - "^@docusaurus/Link$": "/src/test-utils/docusaurusLinkMock.tsx" + "^@docusaurus/Link$": "/src/test-utils/docusaurusLinkMock.tsx", + "^@docusaurus/useBaseUrl$": "/src/test-utils/docusaurusUseBaseUrlMock.ts" }, "testMatch": [ "**/__tests__/**/*.[jt]s?(x)", diff --git a/packages/theme/src/test-utils/docusaurusUseBaseUrlMock.ts b/packages/theme/src/test-utils/docusaurusUseBaseUrlMock.ts new file mode 100644 index 0000000..9508aea --- /dev/null +++ b/packages/theme/src/test-utils/docusaurusUseBaseUrlMock.ts @@ -0,0 +1,13 @@ +type UseBaseUrlOptions = { + forcePrependBaseUrl?: boolean; + absolute?: boolean; +}; + +export default function useBaseUrl(targetUrl?: string, _options?: UseBaseUrlOptions): string { + void _options; + if (typeof targetUrl !== "string") { + return ""; + } + + return targetUrl; +} diff --git a/packages/theme/src/theme/__tests__/HoverkraftHero.test.tsx b/packages/theme/src/theme/__tests__/HoverkraftHero.test.tsx new file mode 100644 index 0000000..622969d --- /dev/null +++ b/packages/theme/src/theme/__tests__/HoverkraftHero.test.tsx @@ -0,0 +1,28 @@ +import React from "react"; +import { renderToStaticMarkup } from "react-dom/server"; + +import { HoverkraftHero } from "../hoverscape/HoverkraftHero"; + +describe("HoverkraftHero", () => { + it("renders supporting image when a path is provided", () => { + const markup = renderToStaticMarkup( + + ); + + expect(markup).toContain("img"); + expect(markup).toContain('src="/img/example.png"'); + expect(markup).toContain('alt="Dashboard screenshot"'); + }); + + it("omits supporting image when the path is empty", () => { + const markup = renderToStaticMarkup( + + ); + + expect(markup).not.toContain(" 0; const highlightContent = brandedText !== null && brandedText !== undefined ? ( {brandedText} @@ -73,7 +77,19 @@ export function HoverkraftHero({
)} - {hasSupportingVisual &&
{supportingVisual}
} + {hasSupportingVisual && ( +
+
+ {supportingVisualAlt +
+
+ )}
);