-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathGrapherComponentList.tsx
51 lines (47 loc) · 1.37 KB
/
GrapherComponentList.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import Link from 'next/link';
import * as React from 'react';
import Grapher from '../lib/graphtoy';
import { MyStore } from '../store';
import GrapherComponent from './GrapherComponent';
import { tiny_url } from '.prisma/client';
import styled from 'styled-components';
const Wrapper = styled.div`
display: grid;
grid-auto-columns: auto;
grid-template-columns: auto auto auto auto;
`;
interface Props {
grapherList: tiny_url[];
}
const GrapherComponentList: React.FC<Props> = ({ grapherList }) => {
return (
<Wrapper>
{grapherList.map((t) => {
const { id, url, value } = t;
const { formulas, variables, notes } = (value as unknown) as MyStore;
return (
<div key={id}>
<Link href={`/${url}`} passHref>
<a><h3> {url}</h3></a>
</Link>
<div>{notes}</div>
<div style={{ width: 400, height: 400 }}>
<GrapherComponent
formulas={formulas}
variables={variables}
grapher={new Grapher()}
extraInit={(grapher) => {
grapher.toggleVisualizer();
}}
/>
{formulas.map((f) => (
<div key={f.value}>{f.value}</div>
))}
</div>
</div>
);
})}
</Wrapper>
);
};
export default GrapherComponentList;