summaryrefslogtreecommitdiff
path: root/components/Tweaks/BehaviorPanel.tsx
blob: 8edb986a3e9adabb66cc8d104b6f7b1789e074a7 (about) (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import { ChevronDownIcon } from '@chakra-ui/icons'
import {
  Button,
  Flex,
  Menu,
  MenuButton,
  MenuItem,
  MenuList,
  Portal,
  StackDivider,
  VStack,
  Text,
} from '@chakra-ui/react'
import React from 'react'
import { initialBehavior, initialMouse } from '../config'
import { InfoTooltip } from './InfoTooltip'
import { SliderWithInfo } from './SliderWithInfo'

export interface BehaviorPanelProps {
  behavior: typeof initialBehavior
  setBehavior: any
  mouse: typeof initialMouse
  setMouse: any
}
export const BehaviorPanel = (props: BehaviorPanelProps) => {
  const { behavior, setBehavior, mouse, setMouse } = props
  return (
    <VStack
      spacing={2}
      justifyContent="flex-start"
      divider={<StackDivider borderColor="gray.500" />}
      align="stretch"
      paddingLeft={7}
      color="gray.800"
    >
      <Flex alignItems="center" justifyContent="space-between">
        <Flex>
          <Text>Expand Node</Text>
          <InfoTooltip infoText="View only the node and its direct neighbors" />
        </Flex>
        <Menu isLazy placement="right">
          <MenuButton as={Button} rightIcon={<ChevronDownIcon />} colorScheme="" color="black">
            <Text>
              {mouse.local ? mouse.local[0]!.toUpperCase() + mouse.local!.slice(1) : 'Never'}
            </Text>
          </MenuButton>
          <Portal>
            {' '}
            <MenuList zIndex="popover" bgColor="gray.200">
              <MenuItem onClick={() => setMouse({ ...mouse, local: '' })}>Never</MenuItem>
              <MenuItem onClick={() => setMouse({ ...mouse, local: 'click' })}>Click</MenuItem>
              <MenuItem onClick={() => setMouse({ ...mouse, local: 'double' })}>
                Double Click
              </MenuItem>
              <MenuItem onClick={() => setMouse({ ...mouse, local: 'right' })}>
                Right Click
              </MenuItem>
            </MenuList>
          </Portal>
        </Menu>
      </Flex>
      <Flex alignItems="center" justifyContent="space-between">
        <Text>Open in Emacs</Text>
        <Menu isLazy placement="right">
          <MenuButton as={Button} rightIcon={<ChevronDownIcon />} colorScheme="" color="black">
            <Text>
              {mouse.follow ? mouse.follow[0]!.toUpperCase() + mouse.follow!.slice(1) : 'Never'}
            </Text>
          </MenuButton>
          <Portal>
            {' '}
            <MenuList bgColor="gray.200" zIndex="popover">
              <MenuItem onClick={() => setMouse({ ...mouse, follow: '' })}>Never</MenuItem>
              <MenuItem onClick={() => setMouse({ ...mouse, follow: 'click' })}>Click</MenuItem>
              <MenuItem onClick={() => setMouse({ ...mouse, follow: 'double' })}>
                Double Click
              </MenuItem>
              <MenuItem onClick={() => setMouse({ ...mouse, follow: 'right' })}>
                Right Click
              </MenuItem>
            </MenuList>
          </Portal>
        </Menu>
      </Flex>
      <Flex alignItems="center" justifyContent="space-between">
        <Text>Follow Emacs by...</Text>
        <Menu isLazy placement="right">
          <MenuButton as={Button} rightIcon={<ChevronDownIcon />} colorScheme="" color="black">
            <Text>{behavior.follow[0].toUpperCase() + behavior.follow.slice(1)}</Text>
          </MenuButton>
          <Portal>
            {' '}
            <MenuList bgColor="gray.200" zIndex="popover">
              <MenuItem onClick={() => setBehavior({ ...behavior, follow: 'color' })}>
                Just coloring the currently opened node
              </MenuItem>
              <MenuItem onClick={() => setBehavior({ ...behavior, follow: 'local' })}>
                Opening the local graph
              </MenuItem>
              <MenuItem onClick={() => setBehavior({ ...behavior, follow: 'zoom' })}>
                Zooming to the current node
              </MenuItem>
            </MenuList>
          </Portal>
        </Menu>
      </Flex>
      <Flex alignItems="center" justifyContent="space-between">
        <Flex>
          <Text>Local graph</Text>
          <InfoTooltip infoText="When in local mode and clicking a new node, should I add that node's local graph or open the new one?" />
        </Flex>
        <Menu isLazy placement="right">
          <MenuButton as={Button} rightIcon={<ChevronDownIcon />} colorScheme="" color="black">
            <Text>{behavior.localSame === 'add' ? 'Add' : 'Replace'}</Text>
          </MenuButton>
          <Portal>
            {' '}
            <MenuList bgColor="gray.200" zIndex="popover">
              <MenuItem onClick={() => setBehavior({ ...behavior, localSame: 'replace' })}>
                Open that nodes graph
              </MenuItem>
              <MenuItem onClick={() => setBehavior({ ...behavior, localSame: 'add' })}>
                Add node to local graph
              </MenuItem>
            </MenuList>
          </Portal>
        </Menu>
      </Flex>
      <SliderWithInfo
        label="Zoom speed"
        value={behavior.zoomSpeed}
        min={0}
        max={4000}
        step={100}
        onChange={(value) => setBehavior({ ...behavior, zoomSpeed: value })}
      />
      <SliderWithInfo
        label="Zoom padding"
        value={behavior.zoomPadding}
        min={0}
        max={400}
        step={1}
        onChange={(value) => setBehavior({ ...behavior, zoomPadding: value })}
        infoText="How much to zoom out to accomodate all nodes when changing the view."
      />
    </VStack>
  )
}