From 85b665b343d63096a3e62c210931040a44b07a1b Mon Sep 17 00:00:00 2001
From: "Thomas F. K. Jorna" <hello@tefkah.com>
Date: Sun, 17 Oct 2021 01:04:13 +0200
Subject: feat(algos): properly working communities

---
 components/Tweaks/GraphColorSelect.tsx | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

(limited to 'components/Tweaks/GraphColorSelect.tsx')

diff --git a/components/Tweaks/GraphColorSelect.tsx b/components/Tweaks/GraphColorSelect.tsx
index b52dde2..60fd8cf 100644
--- a/components/Tweaks/GraphColorSelect.tsx
+++ b/components/Tweaks/GraphColorSelect.tsx
@@ -11,9 +11,10 @@ import {
   Text,
 } from '@chakra-ui/react'
 import { ChevronDownIcon } from '@chakra-ui/icons'
+import { initialColoring } from '../config'
 
 export interface GraphColorSelectProps {
-  coloring: string
+  coloring: typeof initialColoring
   setColoring: any
 }
 
@@ -31,12 +32,14 @@ export const GraphColorSelect = (props: GraphColorSelectProps) => {
           color="black"
           rightIcon={<ChevronDownIcon />}
         >
-          {coloring === 'degree' ? 'Links' : 'Communities'}
+          {coloring.method === 'degree' ? 'Links' : 'Communities'}
         </MenuButton>
         <Portal>
           <MenuList minW={10} zIndex="popover" bgColor="gray.200">
             <MenuItem
-              onClick={() => setColoring('degree')}
+              onClick={() =>
+                setColoring((curr: typeof initialColoring) => ({ ...curr, method: 'degree' }))
+              }
               justifyContent="space-between"
               alignItems="center"
               display="flex"
@@ -44,7 +47,9 @@ export const GraphColorSelect = (props: GraphColorSelectProps) => {
               Number of links
             </MenuItem>
             <MenuItem
-              onClick={() => setColoring('community')}
+              onClick={() =>
+                setColoring((curr: typeof initialColoring) => ({ ...curr, method: 'community' }))
+              }
               justifyContent="space-between"
               alignItems="center"
               display="flex"
-- 
cgit v1.2.3

