Skip to content

Commit

Permalink
feat: react-zoom-pan-pinch
Browse files Browse the repository at this point in the history
  • Loading branch information
wkylin committed Oct 7, 2023
1 parent a46db20 commit 9a520d7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,15 @@
"react-scroll-to-bottom": "^4.2.0",
"react-sticky": "^6.0.3",
"react-sticky-ts": "^1.0.7",
"react-zoom-pan-pinch": "^3.1.0",
"remark-gfm": "^3.0.1",
"remove-markdown": "^0.5.0",
"sanitize.css": "^13.0.0",
"screenfull": "^6.0.2",
"sse": "github:mpetazzoni/sse.js",
"styled-components": "^6.0.7",
"three": "^0.156.1",
"typescript": "^5.2.2",
"typescript": "^5.2.0",
"use-deep-compare-effect": "^1.8.1",
"use-react-router-breadcrumbs": "^4.0.1",
"user-agents": "^1.0.1444",
Expand Down
6 changes: 5 additions & 1 deletion src/components/stateful/mermaidHooks/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ const MermaidHooks = ({ chart }) => {
useEffect(() => {
mermaid.contentLoaded()
}, [])
return <div className="mermaid">{chart}</div>
return (
<div className="mermaid" style={{ minHeight: 0, background: '#fff' }}>
{chart}
</div>
)
}

export default MermaidHooks
19 changes: 17 additions & 2 deletions src/pages/mermaid/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react'
import { Space, Button } from 'antd'
import MermaidHooks from '@stateful/mermaidHooks'
import FixTabPanel from '@stateless/FixTabPanel'
import MarkmapHooks from '@stateful/markmap'
import { TransformWrapper, TransformComponent } from 'react-zoom-pan-pinch'

const gitChart = `gitGraph
commit
Expand Down Expand Up @@ -48,9 +50,22 @@ const Mermaid = () => (
<FixTabPanel>
<h2>Meraid: http://https://mermaid.js.org/</h2>

<h3>演示1:Git Diagram </h3>
<MermaidHooks chart={gitChart} />
<h3 style={{ marginBottom: 30 }}>演示1:Git Diagram </h3>

<TransformWrapper centerOnInit centerZoomedOut>
{({ zoomIn, zoomOut, resetTransform }) => (
<React.Fragment>
<Space>
<Button onClick={() => zoomIn()}>放大</Button>
<Button onClick={() => zoomOut()}>缩小</Button>
<Button onClick={() => resetTransform()}>还原</Button>
</Space>
<TransformComponent>
<MermaidHooks chart={gitChart} />
</TransformComponent>
</React.Fragment>
)}
</TransformWrapper>
<h3> 演示2: Markmap</h3>
<section>
<MarkmapHooks markmap={initMarkup} />
Expand Down

1 comment on commit 9a520d7

@vercel
Copy link

@vercel vercel bot commented on 9a520d7 Oct 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

pro-react-admin – ./

pro-react-admin-wkylin.vercel.app
pro-react-admin-git-main-wkylin.vercel.app
pro-react-admin.vercel.app

Please sign in to comment.