Diagram Guidelines
We use custom React components rendering SVG elements for complex state diagrams. This ensures diagrams are accessible, responsive, and easy to translate or update without needing external design tools.
Example output
Implementation Details
Diagrams should be placed in src/components/diagrams and imported into MDX files.
Create a new diagram
To create a new diagram, you can copy one of the existing files at src/components/diagrams into a new .js file. You can also copy the contents into an LLM such as Gemini and ask it to follow the same principles of design to create the new diagram, providing it with this information as a guideline.
The LLM can create an HTML version of the diagram for faster iteration. You can copy the contents into a .html file and open it in a browser to preview the output.
Import the diagram into an MDX file
To add the diagram, use the following syntax:
import DepositLifeCycleDiagram from '@site/src/components/diagrams/DepositLifeCycleDiagram'; //this can be placed at the top of the file, or just before the declaration
<DepositLifeCycleDiagram />
1. File structure
Create your component in src/components/diagrams/<DiagramName>.js.
2. Design system colors
Use the following color palette to ensure consistency across lifecycle diagrams:
| State Type | Fill Color | Stroke Color | Text Color |
|---|---|---|---|
| Start Node | #9fc5e8 (Blue) | #3d85c6 | Black |
| Active State | #6aa84f (Green) | #38761d | White (Bold) |
| Closed Header | #5000be (Purple) | #5000be | White (Bold) |
| Closed Body | #fffebb (Yellow) | #5000be | Black |
| Lines/Arrows | N/A | #000000 | Black |
3. Geometry & routing
- Technique: Use SVG
<path>elements with Quadratic Bezier curves (Q). - Directionality: Avoid straight lines crossing over nodes. Use curvature (
curvatureprop in our helper) to arc lines around obstacles. - Overlaps: When lines must cross, ensure one arcs significantly higher or lower (Z-axis visual separation) or change the routing side.
- Labels: Labels should be rendered on top of lines with a semi-transparent white background (
opacity="0.95") to ensure readability.
4. Component template
Use the CurvedArrow and BiDirectionalArrow helper components defined in the diagram files to handle the math for bezier curves automatically.