Skip to content

Commit

Permalink
[Mermaid diagrams] Enable configurable automatic numbering (#1829)
Browse files Browse the repository at this point in the history
* feat: enable automatic numbering for mermaid diagrams

* chore: add changeset
  • Loading branch information
timonrey authored Sep 19, 2023
1 parent 5ed7d98 commit d7f40a9
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-apricots-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-docs/ui-kit': minor
---

Enable configurable automatic numbering for mermaid sequence diagrams.
2 changes: 1 addition & 1 deletion packages/ui-kit/src/components/mermaid-client-side.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const config = {
mirrorActors: false,
useMaxWidth: true,
rightAngles: false,
showSequenceNumbers: true,
showSequenceNumbers: false,
diagramMarginX: 5, // prevent border clipping
diagramMarginY: 5, // prevent border clippings
bottomMarginAdj: 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ title: Mermaid Diagrams

# A Sequence Diagram

## With automatic numbering

```mermaid
sequenceDiagram
autonumber
participant CFP
participant HCP API
participant Extension Server
Note over HCP API: Formerly known as CTP
CFP->>+HCP API: Add this to the Cart
HCP API->>+HCP API: Do but don't persist yet
HCP API->>+Extension Server: New cart would be this. Okay?
Extension Server-->>-HCP API: OK, but change this before returning!
HCP API-->>-CFP: Cool, here's your new Cart
alt For comparison without extension
CFP->>+HCP API: A change that has not extension configured
HCP API-->>-CFP: I #9829; you, here's your new resource
end
```

## Without automatic numbering

```mermaid
sequenceDiagram
participant CFP
Expand Down
43 changes: 37 additions & 6 deletions websites/documentation/src/content/writing/images.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,36 @@ sequenceDiagram
end
```

If you want to show the sequence number attached to each arrow in a sequence diagram, you need to add the `autonumber` variable.

````md title="you write:" secondaryTheme
```mermaid
sequenceDiagram
autonumber
Alice->>John: Hello John, how are you?
loop Healthcheck
John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts!
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!
```
````

```mermaid
sequenceDiagram
autonumber
Alice->>John: Hello John, how are you?
loop Healthcheck
John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts!
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!
```

# Videos

It's possible to embed a video in a page by using `Video` component.
Expand All @@ -77,10 +107,11 @@ The component accepts the following properties:
poster="https://customer-ytbpo1yna9xohg5m.cloudflarestream.com/e1aa2e24614b242afdd4afb36a0c2f75/thumbnails/thumbnail.jpg?time=6s"
></Video>

```md title="you write:" secondaryTheme
<Video
url="https://customer-ytbpo1yna9xohg5m.cloudflarestream.com/e1aa2e24614b242afdd4afb36a0c2f75/manifest/video.m3u8"
poster="https://customer-ytbpo1yna9xohg5m.cloudflarestream.com/e1aa2e24614b242afdd4afb36a0c2f75/thumbnails/thumbnail.jpg?time=6s"
/>
```
```md title="you write:" secondaryTheme
<Video
url="https://customer-ytbpo1yna9xohg5m.cloudflarestream.com/e1aa2e24614b242afdd4afb36a0c2f75/manifest/video.m3u8"
poster="https://customer-ytbpo1yna9xohg5m.cloudflarestream.com/e1aa2e24614b242afdd4afb36a0c2f75/thumbnails/thumbnail.jpg?time=6s"
/>
```

</SideBySide>

0 comments on commit d7f40a9

Please sign in to comment.