-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathFunctionButtons.tsx
67 lines (63 loc) · 1.76 KB
/
FunctionButtons.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import * as React from 'react';
import styled from 'styled-components';
import { FUNCS } from '../lib/graphtoy/constants';
import Button from './Button';
import FunctionDescription from './FunctionDescription';
import GuiWindow from './GuiWindow';
import Tooltip from './Tooltip';
const Wrapper = styled.div`
display: grid;
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
grid-gap: 5px;
min-width: 250px;
`;
const Container = styled.div`
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
align-items: flex-start;
align-content: flex-start;
row-gap: 12px;
column-gap: 12px;
`;
interface Props {}
const FunctionButtons: React.FC<Props> = () => {
const inject = (value: string) => {
document.execCommand('insertText', false, value);
};
return (
<GuiWindow>
<Container>
{FUNCS.map((funcs, idx1) => (
<Wrapper key={`${idx1}`}>
{Object.entries(funcs).map(
([key, { description, text, params }]) => (
<Tooltip
content={
<FunctionDescription
name={key}
description={description}
text={text}
params={params}
/>
}
direction="right"
key={key}
>
<Button
style={{ minWidth: '100%', height: '30px', margin: 0 }}
name={key}
onClick={() => inject(text)}
>
{key}
</Button>
</Tooltip>
),
)}
</Wrapper>
))}
</Container>
</GuiWindow>
);
};
export default FunctionButtons;