summaryrefslogtreecommitdiff
path: root/components/Tweaks/GraphColorSelect.tsx
blob: b52dde2ca160e55bd380a7a84d799510a307d48b (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
import React, { useContext } from 'react'
import {
  Box,
  Button,
  Flex,
  Menu,
  MenuButton,
  MenuItem,
  MenuList,
  Portal,
  Text,
} from '@chakra-ui/react'
import { ChevronDownIcon } from '@chakra-ui/icons'

export interface GraphColorSelectProps {
  coloring: string
  setColoring: any
}

export const GraphColorSelect = (props: GraphColorSelectProps) => {
  type Theme = { [key: string]: string }
  const { coloring, setColoring } = props
  return (
    <Flex alignItems="center" justifyContent="space-between" pl={7} pr={2}>
      <Text>Graph coloring</Text>
      <Menu isLazy placement="right">
        <MenuButton
          as={Button}
          size="sm"
          colorScheme=""
          color="black"
          rightIcon={<ChevronDownIcon />}
        >
          {coloring === 'degree' ? 'Links' : 'Communities'}
        </MenuButton>
        <Portal>
          <MenuList minW={10} zIndex="popover" bgColor="gray.200">
            <MenuItem
              onClick={() => setColoring('degree')}
              justifyContent="space-between"
              alignItems="center"
              display="flex"
            >
              Number of links
            </MenuItem>
            <MenuItem
              onClick={() => setColoring('community')}
              justifyContent="space-between"
              alignItems="center"
              display="flex"
            >
              Communities
            </MenuItem>
          </MenuList>
        </Portal>
      </Menu>
    </Flex>
  )
}