Skip to content

Commit

Permalink
Show anatomy and docs (#1757)
Browse files Browse the repository at this point in the history
Wat is nieuw:

- we halen aliases, anatomie afbeelding en anatomie legenda op uit de
candidate repo en tonen ze

Aanpak:

- los component voor anatomie (met <ComponentAnatomy
name={NAAM_VAN_HET_COMPONENT} /> tonen we die dan zodat de logica en
locatie van het ophalen lekker op 1 plek kan staan en we mapnamen later
nog kunnen wijzigen, of per estafettestatus anders kunnen doen)
- los component voor aliases (same-ish)
- de h1's in de Markdowns negeren we en tonen we niet, yay `omitH1`
- SVGs importeren we op de pagina van het component, zodat we
Docusaurus' loader voor SVGs kunnen gebruiken ipv eigen magic
- we halen de informatie op uit de `candidate` repo

Known issues (will fix als de aanpak verder ok is):

- [x] ~het `React.lazy()` truucje werkte niet precies hetzelfde als het
binnen te halen component SVG is (Docusaurus kan een SVG die lokaal
staat wel inlinen, dus lijkt erop dat deze specifieke manier van ophalen
niet goed samenwerkt met die magie)~
- [x] ~de link naar candidate is nu ff lokaal, daarom failt de build bij
Vercel, lokaal kun je evt een lokale `nl-design-system/candidate` pnpm
adden zodat de link werkt~

---------

Signed-off-by: Hidde de Vries <[email protected]>
  • Loading branch information
hidde authored Dec 6, 2024
1 parent 159e278 commit 00a7bb7
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 6 deletions.
9 changes: 9 additions & 0 deletions docs/componenten/code-block/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ keywords:
{/* @license CC0-1.0 */}

import componentProgress from "@nl-design-system/component-progress/dist/index.json";
import CodeBlockIllustration from "@nl-design-system-candidate/code-block-docs/docs/anatomy/anatomy.svg";
import AcIntro from "@nl-design-system-unstable/documentation/componenten/ac/_ac_intro.md";
import Wcag131 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.3.1-code-block.md";
import Wcag1411 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.4.11-code.md";
import Wcag1412 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.4.12.md";
import Wcag143 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.4.3.md";
import Wcag144 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.4.4.md";
import Wcag141 from "@nl-design-system-unstable/documentation/wcag/summaries/_1.4.1-summary.md";
import { ComponentAliases } from "@site/src/components/ComponentAliases";
import { ComponentAnatomy } from "@site/src/components/ComponentAnatomy";
import { CriteriaList } from "@site/src/components/ComponentCriteriaList";
import {
DefinitionOfDone,
Expand All @@ -37,6 +40,12 @@ export const component = componentProgress.find((item) => item.number === issueN

<Introduction component={component} headingLevel={1} description={description} />

<ComponentAliases component={component} />

## Anatomie

<ComponentAnatomy component={component} illustration={CodeBlockIllustration} />

## Definition of Done

<DefinitionOfDone component={component} headingLevel={3} />
Expand Down
9 changes: 9 additions & 0 deletions docs/componenten/code/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ keywords:
{/* @license CC0-1.0 */}

import componentProgress from "@nl-design-system/component-progress/dist/index.json";
import CodeIllustration from "@nl-design-system-candidate/code-docs/docs/anatomy/anatomy.svg";
import AcIntro from "@nl-design-system-unstable/documentation/componenten/ac/_ac_intro.md";
import Wcag131 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.3.1-code.md";
import Wcag1411 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.4.11-code.md";
import Wcag1412 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.4.12.md";
import Wcag143 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.4.3.md";
import Wcag144 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.4.4.md";
import Wcag141 from "@nl-design-system-unstable/documentation/wcag/summaries/_1.4.1-summary.md";
import { ComponentAliases } from "@site/src/components/ComponentAliases";
import { ComponentAnatomy } from "@site/src/components/ComponentAnatomy";
import { CriteriaList } from "@site/src/components/ComponentCriteriaList";
import {
DefinitionOfDone,
Expand All @@ -37,8 +40,14 @@ export const component = componentProgress.find((item) => item.number === issueN

<Introduction component={component} headingLevel={1} description={description} />

<ComponentAliases component={component} />

Let op: Gebruik de component [Code Block](/code-block) als de code meerdere regels beslaat.

## Anatomie

<ComponentAnatomy component={component} illustration={CodeIllustration} />

## Definition of Done

<DefinitionOfDone component={component} headingLevel={3} />
Expand Down
9 changes: 9 additions & 0 deletions docs/componenten/color-sample/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ keywords:
{/* @license CC0-1.0 */}

import componentProgress from "@nl-design-system/component-progress/dist/index.json";
import ColorSampleIllustration from "@nl-design-system-candidate/color-sample-docs/docs/anatomy/anatomy.svg";
import AcIntro from "@nl-design-system-unstable/documentation/componenten/ac/_ac_intro.md";
import Wcag111 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.1.1-color-sample.md";
import Wcag131 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.3.1-color-sample.md";
Expand All @@ -25,6 +26,8 @@ import Wcag1412 from "@nl-design-system-unstable/documentation/componenten/ac/_w
import Wcag144 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.4.4.md";
import Wcag145 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.4.5-color-sample.md";
import Wcag143 from "@nl-design-system-unstable/documentation/wcag/summaries/_1.4.3-summary.md";
import { ComponentAliases } from "@site/src/components/ComponentAliases";
import { ComponentAnatomy } from "@site/src/components/ComponentAnatomy";
import { CriteriaList } from "@site/src/components/ComponentCriteriaList";
import {
DefinitionOfDone,
Expand All @@ -42,6 +45,12 @@ export const component = componentProgress.find((item) => item.number === issueN

<Introduction component={component} headingLevel={1} description={description} />

<ComponentAliases component={component} />

## Anatomie

<ComponentAnatomy component={component} illustration={ColorSampleIllustration} />

## Definition of Done

<DefinitionOfDone component={component} headingLevel={3} />
Expand Down
9 changes: 9 additions & 0 deletions docs/componenten/data-badge/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ keywords:
{/* @license CC0-1.0 */}

import componentProgress from "@nl-design-system/component-progress/dist/index.json";
import DataBadgeIllustration from "@nl-design-system-candidate/data-badge-docs/docs/anatomy/anatomy.svg";
import AcIntro from "@nl-design-system-unstable/documentation/componenten/ac/_ac_intro.md";
import Wcag111 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.1.1-data-badge.md";
import Wcag131 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.3.1-data-badge.md";
Expand All @@ -50,6 +51,8 @@ import Wcag143 from "@nl-design-system-unstable/documentation/componenten/ac/_wc
import Wcag144 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.4.4.md";
import Wcag145 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-1.4.5.md";
import Wcag312 from "@nl-design-system-unstable/documentation/componenten/ac/_wcag-3.1.2.md";
import { ComponentAliases } from "@site/src/components/ComponentAliases";
import { ComponentAnatomy } from "@site/src/components/ComponentAnatomy";
import { CriteriaList } from "@site/src/components/ComponentCriteriaList";
import {
DefinitionOfDone,
Expand All @@ -67,6 +70,12 @@ export const component = componentProgress.find((item) => item.number === issueN

<Introduction component={component} headingLevel={1} description={description} />

<ComponentAliases component={component} />

## Anatomie

<ComponentAnatomy component={component} illustration={DataBadgeIllustration} />

## Definition of Done

<DefinitionOfDone component={component} headingLevel={3} />
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
"@docusaurus/theme-common": "3.1.0",
"@docusaurus/theme-search-algolia": "3.1.0",
"@iframe-resizer/react": "5.3.2",
"@nl-design-system-candidate/code-block-docs": "1.0.0",
"@nl-design-system-candidate/code-docs": "1.0.0",
"@nl-design-system-candidate/color-sample-docs": "1.0.0",
"@nl-design-system-candidate/data-badge-docs": "1.0.0",
"@tabler/icons-react": "3.17.0",
"@utrecht/design-tokens": "1.1.0",
"clsx": "2.1.1",
Expand Down Expand Up @@ -93,7 +97,7 @@
"@nl-design-system-unstable/documentation": "workspace:*",
"@nl-design-system-unstable/nlds-design-tokens": "workspace:*",
"@nl-design-system-unstable/voorbeeld-design-tokens": "1.0.0-alpha.151",
"@nl-design-system/component-progress": "1.0.1-alpha.80",
"@nl-design-system/component-progress": "1.0.1-alpha.82",
"@nl-design-system/eslint-config": "0.0.1",
"@persoonlijke-regelingen-assistent/components-react": "1.0.0-alpha.152",
"@playwright/test": "1.47.1",
Expand Down
42 changes: 37 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/components/ComponentAliases.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Markdown } from '@site/src/components/Markdown';
import React, { type PropsWithChildren, Suspense } from 'react';
import { toKebabCase } from '../utils';
import type { CleanComponentProgress as ComponentProgressObject } from '@nl-design-system/component-progress/dist/utils';

interface ComponentAliasesProps {
component?: ComponentProgressObject;
}

export const ComponentAliases = ({ component }: PropsWithChildren<ComponentAliasesProps>) => {
const { title } = component;
const slug = toKebabCase(title);
const Aliases = React.lazy(() =>
import(`@nl-design-system-candidate/${slug}-docs/docs/aliases.md`).catch(() => {
return { default: () => null };
}),
);

return (
<Suspense fallback={null}>
<Markdown omitH1 headingLevel={1}>
<Aliases />
</Markdown>
</Suspense>
);
};
7 changes: 7 additions & 0 deletions src/components/ComponentAnatomy.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.component-anatomy {
margin: 0;
}
.component-anatomy__illustration {
max-width: 100%;
height: auto;
}
46 changes: 46 additions & 0 deletions src/components/ComponentAnatomy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Markdown } from '@site/src/components/Markdown';
import clsx from 'clsx';
import React, { type PropsWithChildren, Suspense } from 'react';
import { toKebabCase } from '../utils';
import './ComponentAnatomy.css';
import type { CleanComponentProgress as ComponentProgressObject } from '@nl-design-system/component-progress/dist/utils';

interface IllustrationProps {
className?: string;
height?: boolean;
}

interface ComponentAnatomyProps {
component?: ComponentProgressObject;
illustration?: React.ComponentType<IllustrationProps>;
}

export const ComponentAnatomy = ({
component,
illustration: AnatomyIllustration,
}: PropsWithChildren<ComponentAnatomyProps>) => {
const { title } = component;
const slug = toKebabCase(title);
const AnatomyLegend = React.lazy(() =>
import(`@nl-design-system-candidate/${slug}-docs/docs/anatomy/anatomy.md`).catch(() => {
return { default: () => null };
}),
);

return (
<Suspense fallback={null}>
<figure className={clsx('component-anatomy')}>
{AnatomyIllustration && (
<AnatomyIllustration height={null} className={clsx('component-anatomy__illustration')} />
)}
{AnatomyIllustration && AnatomyLegend && (
<figcaption>
<Markdown omitH1 headingLevel={1}>
<AnatomyLegend />
</Markdown>
</figcaption>
)}
</figure>
</Suspense>
);
};
4 changes: 4 additions & 0 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,10 @@ pre {
display: none !important;
}

.utrecht-paragraph--lead + p {
margin-block-start: var(--utrecht-paragraph-margin-block-start);
}

/* Temporary fix for accordion spacing */
.utrecht-accordion__header {
margin: 0;
Expand Down

0 comments on commit 00a7bb7

Please sign in to comment.