File tree Expand file tree Collapse file tree 7 files changed +556
-17
lines changed
Expand file tree Collapse file tree 7 files changed +556
-17
lines changed Original file line number Diff line number Diff line change 3333 "rdf-namespaces" : " ^1.9.2" ,
3434 "react" : " ^17.0.2" ,
3535 "react-dom" : " ^17.0.2" ,
36+ "react-markdown" : " ^6.0.2" ,
3637 "react-modal" : " ^3.14.3" ,
3738 "react-scripts" : " 4.0.3" ,
39+ "rehype-katex" : " ^5.0.0" ,
40+ "remark-math" : " ^4.0.0" ,
3841 "source-map-explorer" : " ^2.5.2" ,
3942 "styled-components" : " ^5.3.0" ,
4043 "swr" : " ^0.5.6" ,
Original file line number Diff line number Diff line change 1+ /*
2+ * based on the following example
3+ * https://github.com/rexxars/react-markdown/issues/10#issuecomment-347763068
4+ */
5+
6+ import React from 'react'
7+ import 'katex/dist/katex.min.css'
8+ import ReactMarkdown from 'react-markdown'
9+ import remarkMath from 'remark-math'
10+ import styled from 'styled-components'
11+ import rehypeKatex from 'rehype-katex'
12+
13+ const Styler = styled . div `
14+ img {
15+ max-width: 100%;
16+ }
17+ `
18+
19+ export default function Math ( { children } : { children : string } ) {
20+ const props = {
21+ children,
22+ remarkPlugins : [ remarkMath ] ,
23+ rehypePlugins : [ rehypeKatex ] ,
24+ }
25+ return (
26+ < Styler >
27+ < ReactMarkdown { ...props } />
28+ </ Styler >
29+ )
30+ }
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import { GraphNode } from '../hooks/graph'
3+ import Math from './Math'
4+
5+ interface Props {
6+ node : GraphNode
7+ onSelectNode : ( uri : string ) => void
8+ }
9+
10+ const Statement = ( { node, onSelectNode } : Props ) => {
11+ const dependencies : GraphNode [ ] = Object . values ( node . dependsOn )
12+ return (
13+ < div
14+ style = { {
15+ position : 'fixed' ,
16+ width : '100%' ,
17+ top : '0' ,
18+ bottom : 0 ,
19+ pointerEvents : 'none' ,
20+ overflowY : 'auto' ,
21+ overflowX : 'hidden' ,
22+ } }
23+ >
24+ < div className = "columns mr-1 mt-6" >
25+ < div className = "column is-one-quarter is-offset-three-quarters" >
26+ < div
27+ className = "card"
28+ style = { { pointerEvents : 'all' , overflowX : 'auto' , width : '100%' } }
29+ >
30+ < header className = "card-header" >
31+ < p className = "card-header-title" > { node . label } </ p >
32+ </ header >
33+ < section className = "card-content" >
34+ < Math > { node . description } </ Math >
35+ </ section >
36+ < header className = "card-header" >
37+ < p className = "card-header-title" >
38+ dependencies: { dependencies . length }
39+ </ p >
40+ </ header >
41+ < section className = "card-content" >
42+ < ul className = "buttons are-small" >
43+ { dependencies . map ( dependency => (
44+ < li
45+ onClick = { ( ) => onSelectNode ( dependency . uri ) }
46+ key = { dependency . uri }
47+ className = "button is-link is-inverted"
48+ >
49+ { dependency . label }
50+ </ li >
51+ ) ) }
52+ </ ul >
53+ </ section >
54+ </ div >
55+ </ div >
56+ </ div >
57+ </ div >
58+ )
59+ }
60+
61+ export default Statement
Original file line number Diff line number Diff line change @@ -120,15 +120,15 @@ const Visualization: React.FC<Props> = ({
120120 select ( canvasEl . current ) . call (
121121 drag < HTMLCanvasElement , unknown > ( )
122122 . clickDistance ( 2 )
123- . on ( 'start' , console . log )
123+ // .on('start', console.log)
124124 . on ( 'drag' , e => {
125125 onTransform ( [
126126 [ 1 , 0 , e . dx ] ,
127127 [ 0 , 1 , e . dy ] ,
128128 [ 0 , 0 , 1 ] ,
129129 ] )
130- } )
131- . on ( 'end' , console . log ) ,
130+ } ) ,
131+ // .on('end', console.log),
132132 )
133133
134134 select ( canvasEl . current ) . call (
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { SessionContext } from '../contexts/session'
88import { Grid } from '../helpers/draw'
99import { prune as pruneGraph } from '../algorithms'
1010import numeric from 'numeric'
11+ import Statement from './Statement'
1112// import useSimulation from '../hooks/simulation'
1213
1314const transform = ( matrix : number [ ] [ ] , vector : Vector ) : Vector => {
@@ -222,14 +223,23 @@ const VisualizationContainer: React.FC = props => {
222223 const grid = transformGrid ( matrix , basicGrid )
223224
224225 return (
225- < Visualization
226- graph = { transformedLayout }
227- grid = { grid }
228- onTransform = { handleTransform }
229- onHover = { handleHover }
230- onSelectNode = { handleSelect }
231- { ...props }
232- />
226+ < >
227+ < Visualization
228+ graph = { transformedLayout }
229+ grid = { grid }
230+ onTransform = { handleTransform }
231+ onHover = { handleHover }
232+ onSelectNode = { handleSelect }
233+ { ...props }
234+ />
235+
236+ { selectedNode && (
237+ < Statement
238+ node = { graph [ selectedNode ] }
239+ onSelectNode = { uri => setSelectedNode ( uri ) }
240+ />
241+ ) }
242+ </ >
233243 )
234244}
235245
Original file line number Diff line number Diff line change 33@import ' ~bulma/sass/utilities/_all' ;
44@import ' ~bulma/sass/elements/button.sass' ;
55@import ' ~bulma/sass/grid/columns.sass' ;
6+ @import ' ~bulma/sass/components/card.sass' ;
67
78// You can use Bulma variables from here on
89
1112@import ' ~bulma/sass/layout/hero' ;
1213
1314// You can use derived variables from here on
15+
16+ html {
17+ overflow-y : hidden ;
18+ }
You can’t perform that action at this time.
0 commit comments