-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Prettify mermaid diagram rendering #27366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: production
Are you sure you want to change the base?
Conversation
Document microfrontend architecture using router workers and service bindings, including routing logic, path rewriting, asset handling, preloading, and deployment workflows.
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
|
Preview URL: https://c071c67c.preview.developers.cloudflare.com |
|
@cloudflare/pcx-content-engineering thoughts? would love to land this |
colbywhite
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the state of our mermaid integration (custom fork, client-side focused), this is likely the most straightforward way to get the custom theme in there. Ideally, Cloudflare's theme(s) would be represented via something like style-dictionary to avoid the hardcoding. Let's merge it for now. I've got comments that may or may not need to be easy to address.
| @@ -1,3 +1,75 @@ | |||
| /* Hide unprocessed diagrams to prevent flash of unstyled content */ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sidenote: I don't think this comment is 100% accurate. Instead of a quick shift from the raw diagram text to the svg, this opts for a quick shift from nothing to the svg. Both strategies still flash and result in CLS. This seems like a purposeful decision and thus a bit orthogonal to this PR, but the comment implies that this is preventing any flash.
| attributeFilter: ["data-theme"], | ||
| }); | ||
|
|
||
| render(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason this is needed at the root level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to be a general "How to do mermaid" doc? The accTitle and accDesc recommendation likely makes more sense in the style guide, although I'm not sure where. We might need to create a good spot for it. The rest might be better served in the contributing page in some shape or form.
This loose md file might get lost.
This PR enhances mermaid diagram rendering with:
Examples
Before:
After:
Notes
Why some values are hardcoded: The styling logic currently lives in TypeScript (src/scripts/mermaid.ts) since mermaid's theme configuration requires JavaScript initialization. Hex codes and specific style values are hardcoded for:
This seemed like the simplest starting point. If there's a better approach to make these values more maintainable (e.g., extracting to a config file or reading more from CSS custom properties), I'm open to refactoring.
Files changed