#Markdown

Most of the GitHub flavoured markdown features are enabled, in addition there is syntax highlighting for code samples and images are supported. For a full list, there is the markdown features page.

#Linking design system pages

Use a simplified markdown syntax to link to pages, in order to prevent dead links. Just specify the top-navigation category and child category if present and the page title in the link syntax
[Icons](Components) or [Radio Button Form Field](Develop/Form).

#Handling spaces in titles

Due to limitations of the mdx parser, we need to replace spaces with + in the href part: [Help Text](Components/Input+Field).

#Linking a tab

Linking directly into tabs is possible by specifying the tab in the link description
[Button/Code](Components)

#Custom link text

Using a pipe to separate the page title, results in custom link text
[Custom link text|Button/Code](Components)

#Front matter

A a front matter part configuration part is required for every documentation page. This is a yaml object within a tripple-dash boundary.

---
isPublic: false
navigation: Develop
title: Example Code Documentation
tab: Code
terms:
  - Searchterm
---
propertytypedescription
navigationstringNavigation location, values: "design", "components", "code"
titlestringPage title and navigation text.
figmaLinkstringoptional Link to the Figma file for the component
isPublicstringoptional default: false makes the page publicly available
ordernumberoptional For custom ordering of pages on the same hierarchical level in navigation
slugstringoptional For nice and SEO friendly URLs
tabstringoptional For tabbed pages (pages with the same title) tabs
termsstring[]optional For SEO tags, just words not occuring in context but should match in search

#The global meta object

Parsed front matter including some enriched data:

propertytypedescription
modifiedDatestringISO date of the last content change hash
sourcePathstringRelative path to the current .mdx file.

#PropTable

Displays the contents of docgen in an interactive table. Here is the table of <PropTable /> itself.

NameTypeDefaultDescription
component *DocumentedFunctionComponent
-
contextFunctionComponent<Record<string, unknown> & { children: ReactNode }>
-

Frame wrapper element usally used for context

controlsRecord<string, ControlSpec>
-

Override control defaults

Note

You only need this, if you need to OVERRIDE some initial values or if you're not happy whith the guess. Simple stuff like string, booleans and numbers are generally guessed fine.

Examples

{
 // Passing a boolean, generates a checkbox
 // Using the passed value as initial state
 checked: false,

 // Passing a string, generrates a text field
 // Using the passed value as initial state
 // Useful to override `ReactNode` and similar
 children: "Some text content",

 // Number works similar to string
 count: 20,

 // Array `number[]` and `string[]` are supported
 // Generate a select dropdown, the first value
 // is selected. If the prop is optional, an empty
 // first option is added automatically
 lineHeight: ["12", "18", "24"],

 // Null disables an automatically generated control
 checkbox: null,

 // Complex overrides
 // Useful for complex types
 // initialValue is optional. If present the
 // `text` part (string) of the options is expected
 icon: {
   initialValue: "filled hearts",
   options: [
     { text: "cart", value: <CartIcon /> },
     { text: "minus", value: <MinusIcon /> },
     { text: "filled heart", value: <HeartFilledIcon /> },
     { text: "plus", value: <PlusIcon /> },
     { text: "calendar", value: <CalendarIcon /> },
   ]
 },
}
frameStylesCSSProperties
-

Additional styles for the wrapping size-container. Useful for additional margin/paddings around the children.

maxResizeWidthnumber
-

Maximum resize container width in pixels

noBreakpointsboolean
-

Hide breakpoint toggles

noFrameboolean
-

Hide frame (top part) and controls column

noThemeboolean
-

Hide theme toggles

onFrameResize(width: number, height: number) => void
-

On resize callback when the frame gets resized. Resizes may ocure from surrounding context and from frame contend changes thourg re-renders or styles

staticProps(setProp: (name: string, value: unknown) => void, currentProps: Record<string, unknown>, child: ReactElement, frameWindow: Window) => Record<string, unknown> | Record<string, unknown>
-

Enforcing prop values for frame childs, before render. This overrides everything. In case there is a prop listed in controls and staticProps simuntanously controls.propName is set to null , which hides and disables the control.

Object

If an object is passed, it's used as merge into the current props. Unset individual props, with { propName: undefined }

<PropTable staticProps={{ name: "checkbox1" }}>
 <Checkbox />
</PropTable>

Callback

Called once for each child. The returned object is used to extend the current child props. The returned object is merged into the current props. Unset individal props, with { propName: undefined } . Useful for two way sync.

<PropTable
 staticProps={(setProp) => ({
   onChange: (event) => setProp("checked", event.target.checked),
 })}
>
 <Checkbox />
</PropTable>
// __docs__/button.mdx
import { PropTable } from "@tools/documentation-support";

<PropTable component={Button} />;

#Default value

Default values are not automatically guessed, but can be set in JSDOC by using the @defaultValue keyword.

Make sure the type of the value is correct and is wrapped in code ticks.`

export interface IAlertProps extends ComponentPropsWithRef<"div"> {
  /**
   * The variant of the alert
   * @defaultValue `"warning"`
   * */
  variant: AlertVariant;
}

#Hiding props

The easiest way is to not specify any JSDOC comment and use regular comments. In some case this is not possible, e.g. when extending. In this case the @ignore keyword may be used

export interface IIconButton extends ComponentPropsWithRef<"div"> {
  // this won't show up in PropTable
  internalStuff: boolean;

  /**
   * No children expeced
   * @ignore
   * */
  children?: null;
}

#Two way sync controls

In cases like form controls, sometimes a two way sync is desired, between the controls in the prop table and the control itself. This can be easily achieved by passing a function to staticProps, this gives access to the setProp(propName: string, value: unknown) dispatch method for the PropTableContext (internally used to store current props).

import { PropTable } from &quot;@tools/documentation-support&quot;;
import { Checkbox } from &quot;../checkbox.tsx&quot;;

// Two way syncing prop values

&lt;PropTable
  docs={meta.docs.Checkbox}
  staticProps={(setProp) =&gt; ({
    onChange: (event) =&gt; {
      setProp(&quot;checked&quot;, event.target.checked);
    },
  })}
&gt;
  &lt;Checkbox /&gt;
&lt;/PropTable&gt;

#ResponsiveFrame

An iframe that renders components. For style isolation in both directions, all component examples are rendered inside frames.

NameTypeDefaultDescription
children *ReactNode
-

Subject being rendered in frame

contextFunctionComponent<Record<string, unknown> & { children: ReactNode }>
-

Frame wrapper element usally used for context

frameStylesCSSProperties
-

Additional styles for the wrapping size-container. Useful for additional margin/paddings around the children.

maxResizeWidthnumber
-

Maximum resize container width in pixels

noBreakpointsboolean
-

Hide breakpoint toggles

noThemeboolean
-

Hide theme toggles

onFrameResize(width: number, height: number) => void
-

On resize callback when the frame gets resized. Resizes may ocure from surrounding context and from frame contend changes thourg re-renders or styles

staticProps(currentProps: Record<string, unknown>, child: ReactElement, frameWindow: Window) => Record<string, unknown> | Record<string, unknown>
-

Force props for frame childs, before render.

Object Merged into the current props. Unset individual props, with { propName: undefined }

<ComponentFrame staticProps={{ name: "checkbox1" }}>
 <Checkbox />
</ComponentFrame>

Callback Called once for each child. The returned object is used to extend the current child props. The returned object is merged into the current props. Unset individual props, with { propName: undefined }

import { ResponsiveFrame } from &quot;@tools/documentation-support&quot;;
import { Button } from &quot;../button.tsx&quot;;

&lt;ResponsiveFrame&gt;
  &lt;Button /&gt;
&lt;/ResponsiveFrame&gt;

#ComponentFrame

The same as ResponsiveFrame, but without all the borders and stuff around.

ERROR
Typedoc PropTable did not find any documented props - make sure there is JSDOC for all props of the interface and the interface is being exported.
import { ComponentFrame } from &quot;@tools/documentation-support&quot;;
import { Button } from &quot;../button.tsx&quot;;

&lt;ComponentFrame&gt;
  &lt;Button /&gt;
&lt;/ComponentFrame&gt;

#Demos in mdx

Demos from the demo-studio integrate with the link syntax. This is useful to present alternative variants of the component. This generates a ResponsiveFrame and a code block. Under the hood, a custom webpack loader is used to achieve this.

### Dense Inline Button

The Button uses _minimal width_ on every screen size.

[DenseInlineButtonDemo](../button.demo.tsx)

#Seting frame props for demos

Setting ResponsiveFrame props for demos when rendered in documentation, with the setPresentationOptions() method

import { setPresentationOptions } from "@tools/documentation-support/demo";

export const DummyDemo = () => <div>hello demo</div>;

setPresentationOptions([DummyDemo], {
  noBreakpoints: true,
});

#Markdown Page Template

Note: By using the Package Generator this get's generated automatically for your component.

---
navigation: Develop
title: Example Code Documentation
docgen:
  - &quot;../exampleComponent.tsx&quot;
---

import { PropTable, ResponsiveFrame } from &quot;@tools/documentation-support&quot;;
import { ExampleComponent } from &quot;../exampleComponent.tsx&quot;;

## Example Code Documentation

Some lead text

### Props

&lt;PropTable
  docs={meta.docs.ExampleComponent}
  controls={{
    children: &quot;Some editable text&quot;,
  }}
&gt;
  &lt;ExampleComponent /&gt;
&lt;/PropTable&gt;

### Variants

[ExapmleStateDemo](../exampleComponent.demo.tsx)

### Advanced variants

&lt;ResponsiveFrame&gt;
  &lt;ExampleComponent variant=&quot;big&quot; /&gt;
&lt;/ResponsiveFrame&gt;

#Images

Images can be integrated by saving them in the directory applications/design-system/public/design/static/documentation.

To integrate them in your documentation, there is a special component you should use:

import { Image } from "@tools/documentation-support";

<Image
  src="/designsystem/static/documentation/ownership-overview.png"
  width="500"
  height="425"
  alt="overview of the monorepo structure"
/>;

It is very important to define width and height props - and the values for width/height must be half of the actual image size. So, if your image has the dimensions 900x500 pixels, then the props for width/height will be 450x250. This is needed for retina screens where the device-pixel-ratio is bigger than 1 - the image will be integrated in full resolution but only rendered half the size.

💡 All images will be uploaded to Akamai NetStorage and we use Image Manager to optimize them in Production!

#Dos And Don'ts

Use the DosAndDonts component to display dos and don'ts examples.

You can increase the block width by using the fullWidth property. Additionally the direction property can be used to display the items either vertically or horizontally.

import {
  DoOrDont,
  DoOrDontDescription,
  DosAndDonts,
  Image,
} from "@tools/documentation-support";

<DosAndDonts>
  <DoOrDont>
    <DoOrDontDescription variant="do">
      Explain why is the button disabled
    </DoOrDontDescription>
    <Image
      src="/designsystem/static/figma-graphics/button_do___do_example_do-f81ffbdff81ff81ffbdff80ff80fe007e007e007edf7e007e007e7f7e007e007.png"
      width="313"
      height="106"
      alt="Button do - Do example-do"
    />
  </DoOrDont>
  <DoOrDont>
    <DoOrDontDescription variant="dont">
      Without an explanation, the user doesn&apos;t know why they cannot use
      this feature.
    </DoOrDontDescription>
    <Image
      src="/designsystem/static/figma-graphics/button_dont___dont_example_dont-00037ffb7ffb7ffb7ffb5a5b400b400b400b7ff97ff87ff87ff00000fff8fffc.png"
      width="119"
      height="48"
      alt="Button dont - Dont example-dont"
    />
  </DoOrDont>
</DosAndDonts>;

Do

Explain why is the button disabled

Button do - Do example-do

Don't

Without an explanation, the user doesn't know why they cannot use this feature.

Button dont - Dont example-dont

#Info Panel

Use the InfoPanel component to guide the user's attention to the displayed information.

Some important information
ERROR
Typedoc PropTable did not find any documented props - make sure there is JSDOC for all props of the interface and the interface is being exported.
import { InfoPanel } from "@tools/documentation-support";

<InfoPanel variant="warning">Some important information</InfoPanel>;