-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* client mermaid * lil loader * make it work
- Loading branch information
1 parent
d0d14b6
commit 6666d36
Showing
10 changed files
with
330 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,7 +109,7 @@ flowchart TD | |
Events(Events Service) | ||
App(Web Service) | ||
na %% Invisible helper node | ||
na | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { useEffect, useRef, useState } from 'react' | ||
import mermaid from 'mermaid' | ||
|
||
export default function Mermaid({ children }: { children: string }): JSX.Element { | ||
const [loading, setLoading] = useState(true) | ||
const mermaidRef = useRef<HTMLDivElement>(null) | ||
useEffect(() => { | ||
mermaid.initialize({ startOnLoad: false }) | ||
if (mermaidRef.current && !mermaidRef.current.hasAttribute('data-rendered')) { | ||
mermaid.run({ | ||
nodes: [mermaidRef.current], | ||
postRenderCallback: () => { | ||
setLoading(false) | ||
mermaidRef.current?.setAttribute('data-rendered', 'true') | ||
}, | ||
}) | ||
} | ||
}, []) | ||
return ( | ||
<div className="relative"> | ||
{loading && ( | ||
<div className="bg-accent dark:bg-accent-dark flex items-center justify-center size-full rounded-md animate-pulse absolute inset-0" /> | ||
)} | ||
<div ref={mermaidRef} className={loading ? 'invisible' : ''}> | ||
{children} | ||
</div> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.