From 0895967f20ef33bc0f32c99bac0a93761915b87f Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Sat, 16 Oct 2021 23:54:48 +0200 Subject: feat(algos): ability to select coloring --- components/Tweaks/GraphColorSelect.tsx | 59 ++++++++++++++++++++++++++++++++++ components/Tweaks/ThemeSelect.tsx | 8 ++++- components/Tweaks/VisualsPanel.tsx | 14 +++++++- components/Tweaks/index.tsx | 8 +++++ 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 components/Tweaks/GraphColorSelect.tsx (limited to 'components') diff --git a/components/Tweaks/GraphColorSelect.tsx b/components/Tweaks/GraphColorSelect.tsx new file mode 100644 index 0000000..b52dde2 --- /dev/null +++ b/components/Tweaks/GraphColorSelect.tsx @@ -0,0 +1,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 ( + + Graph coloring + + } + > + {coloring === 'degree' ? 'Links' : 'Communities'} + + + + setColoring('degree')} + justifyContent="space-between" + alignItems="center" + display="flex" + > + Number of links + + setColoring('community')} + justifyContent="space-between" + alignItems="center" + display="flex" + > + Communities + + + + + + ) +} diff --git a/components/Tweaks/ThemeSelect.tsx b/components/Tweaks/ThemeSelect.tsx index 6a6b5d8..d5a7f54 100644 --- a/components/Tweaks/ThemeSelect.tsx +++ b/components/Tweaks/ThemeSelect.tsx @@ -22,7 +22,13 @@ export const ThemeSelect = () => { Theme - }> + } + > {emacsTheme[0]} diff --git a/components/Tweaks/VisualsPanel.tsx b/components/Tweaks/VisualsPanel.tsx index d3c8415..015acfc 100644 --- a/components/Tweaks/VisualsPanel.tsx +++ b/components/Tweaks/VisualsPanel.tsx @@ -24,6 +24,7 @@ import { LabelsPanel } from './LabelsPanel' import { CitationsPanel } from './CitationsPanel' import { ColorMenu } from './ColorMenu' import { ThemeSelect } from './ThemeSelect' +import { GraphColorSelect } from './GraphColorSelect' export interface VisualsPanelProps { visuals: typeof initialVisuals @@ -31,14 +32,25 @@ export interface VisualsPanelProps { highlightColor: string setHighlightColor: any threeDim: boolean + coloring: string + setColoring: any } export const VisualsPanel = (props: VisualsPanelProps) => { - const { visuals, setVisuals, highlightColor, setHighlightColor, threeDim } = props + const { + coloring, + setColoring, + visuals, + setVisuals, + highlightColor, + setHighlightColor, + threeDim, + } = props const setVisualsCallback = useCallback((val) => setVisuals(val), []) return ( + diff --git a/components/Tweaks/index.tsx b/components/Tweaks/index.tsx index afd0ea7..078ee99 100644 --- a/components/Tweaks/index.tsx +++ b/components/Tweaks/index.tsx @@ -48,6 +48,8 @@ export interface TweakProps { tags: string[] tagColors: TagColors setTagColors: any + coloring: string + setColoring: any } export const Tweaks = (props: TweakProps) => { @@ -67,6 +69,8 @@ export const Tweaks = (props: TweakProps) => { tags, tagColors, setTagColors, + coloring, + setColoring, } = props const [showTweaks, setShowTweaks] = usePersistantState('showTweaks', false) @@ -194,6 +198,10 @@ export const Tweaks = (props: TweakProps) => { highlightColor={highlightColor} setHighlightColor={setHighlightColor} threeDim={threeDim} + {...{ + coloring, + setColoring, + }} /> -- cgit v1.2.3