Skip to content

Commit 28dbe86

Browse files
committed
Refactor editing a definition/statement + edit and save all at once
1 parent 2f42285 commit 28dbe86

File tree

10 files changed

+362
-351
lines changed

10 files changed

+362
-351
lines changed

src/components/Layout.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import About from './About'
66
import ControlPanel from '../features/control/ControlPanel'
77
import Search from '../features/search/Search'
88
import Info from '../features/info/Info'
9+
import Statement from '../features/math/statement/Statement'
10+
import InfoContainer from '../features/math/InfoContainer'
911

1012
const PositionedAbout = styled(About)`
1113
position: fixed;
@@ -37,6 +39,12 @@ const TopNav = styled.nav`
3739
padding: 1rem;
3840
`
3941

42+
const PositionedStatement = () => (
43+
<InfoContainer>
44+
<Statement />
45+
</InfoContainer>
46+
)
47+
4048
const Layout: React.FC = () => {
4149
return (
4250
<>
@@ -58,6 +66,8 @@ const Layout: React.FC = () => {
5866

5967
<PositionedInfo />
6068

69+
<PositionedStatement />
70+
6171
<FullSizeVisualization />
6272
</>
6373
)

src/features/math/Statement.tsx

Lines changed: 0 additions & 248 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react'
2+
import Math from '../Math'
3+
import { GraphNode } from '../types'
4+
5+
export const NodeDescription = ({ node }: { node: GraphNode }) => (
6+
<Math>{node.description.en}</Math>
7+
)
8+
9+
export const NodeDescriptionEdit = ({
10+
value,
11+
onChange,
12+
}: {
13+
value: string
14+
onChange: (value: string) => void
15+
}) => {
16+
return (
17+
<>
18+
<span className="has-text-grey is-size-7">
19+
You can use{' '}
20+
<a href="https://www.markdownguide.org/basic-syntax/">Markdown</a> and{' '}
21+
<a href="http://asciimath.org/">AsciiMath</a> (use $inline math$ and
22+
$$multiline math$$).
23+
</span>
24+
<textarea
25+
className="textarea"
26+
placeholder="description"
27+
value={value}
28+
onChange={e => onChange(e.target.value)}
29+
/>
30+
<Math>{value}</Math>
31+
</>
32+
)
33+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react'
2+
3+
interface EditProps {
4+
value: string
5+
onChange: (label: string) => void
6+
}
7+
8+
export const NodeLabelEdit = ({ value, onChange }: EditProps) => {
9+
return (
10+
<input
11+
className="input is-small"
12+
type="text"
13+
placeholder="label"
14+
value={value}
15+
onChange={e => onChange(e.target.value)}
16+
size={10}
17+
/>
18+
)
19+
}
20+
21+
export const NodeLabel = ({ uri, label }: { uri: string; label: string }) => (
22+
<a href={uri}>{label}</a>
23+
)

0 commit comments

Comments
 (0)