#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
---
property | type | description |
---|---|---|
navigation | string | Navigation location, values: "design" , "components" , "code" |
title | string | Page title and navigation text. |
figmaLink | string | optional Link to the Figma file for the component |
isPublic | string | optional default: false makes the page publicly available |
order | number | optional For custom ordering of pages on the same hierarchical level in navigation |
slug | string | optional For nice and SEO friendly URLs |
tab | string | optional For tabbed pages (pages with the same title) tabs |
terms | string[] | 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:
property | type | description |
---|---|---|
modifiedDate | string | ISO date of the last content change hash |
sourcePath | string | Relative path to the current .mdx file. |
#PropTable
Displays the contents of docgen in an interactive table. Here is the table of <PropTable />
itself.
Name | Type | Default | Description |
---|---|---|---|
component * | DocumentedFunctionComponent | - | |
context | FunctionComponent<Record<string, unknown> & { children: ReactNode }> | - | Frame wrapper element usally used for context |
controls | Record<string, ControlSpec> | - | Override control defaults NoteYou 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
|
frameStyles | CSSProperties | - | Additional styles for the wrapping size-container. Useful for additional margin/paddings around the children. |
maxResizeWidth | number | - | Maximum resize container width in pixels |
noBreakpoints | boolean | - | Hide breakpoint toggles |
noFrame | boolean | - | Hide frame (top part) and controls column |
noTheme | boolean | - | 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 Object If an
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
|
// __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 "@tools/documentation-support";
import { Checkbox } from "../checkbox.tsx";
// Two way syncing prop values
<PropTable
docs={meta.docs.Checkbox}
staticProps={(setProp) => ({
onChange: (event) => {
setProp("checked", event.target.checked);
},
})}
>
<Checkbox />
</PropTable>
#ResponsiveFrame
An iframe that renders components. For style isolation in both directions, all component examples are rendered inside frames.
Name | Type | Default | Description |
---|---|---|---|
children * | ReactNode | - | Subject being rendered in frame |
context | FunctionComponent<Record<string, unknown> & { children: ReactNode }> | - | Frame wrapper element usally used for context |
frameStyles | CSSProperties | - | Additional styles for the wrapping size-container. Useful for additional margin/paddings around the children. |
maxResizeWidth | number | - | Maximum resize container width in pixels |
noBreakpoints | boolean | - | Hide breakpoint toggles |
noTheme | boolean | - | 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
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 |
import { ResponsiveFrame } from "@tools/documentation-support";
import { Button } from "../button.tsx";
<ResponsiveFrame>
<Button />
</ResponsiveFrame>
#ComponentFrame
The same as ResponsiveFrame, but without all the borders and stuff around.
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 "@tools/documentation-support";
import { Button } from "../button.tsx";
<ComponentFrame>
<Button />
</ComponentFrame>
#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:
- "../exampleComponent.tsx"
---
import { PropTable, ResponsiveFrame } from "@tools/documentation-support";
import { ExampleComponent } from "../exampleComponent.tsx";
## Example Code Documentation
Some lead text
### Props
<PropTable
docs={meta.docs.ExampleComponent}
controls={{
children: "Some editable text",
}}
>
<ExampleComponent />
</PropTable>
### Variants
[ExapmleStateDemo](../exampleComponent.demo.tsx)
### Advanced variants
<ResponsiveFrame>
<ExampleComponent variant="big" />
</ResponsiveFrame>
#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'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

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

#Info Panel
Use the InfoPanel
component to guide the user's attention to the displayed information.
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>;