From 938a8e121667ab8bb0e495af6b35d9cb1affdaa7 Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Wed, 28 Jul 2021 21:45:53 +0200 Subject: added the ability to change the main highlight color --- components/config.ts | 24 +++++++++ components/tweaks.tsx | 142 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 131 insertions(+), 35 deletions(-) (limited to 'components') diff --git a/components/config.ts b/components/config.ts index d6c2296..753f2db 100644 --- a/components/config.ts +++ b/components/config.ts @@ -64,3 +64,27 @@ export const initialFilter = { links: [], date: [], } + +export const initialVisuals = { + particles: false, + particlesNumber: 0, + particlesWidth: 4, + linkOpacity: 0.7, + linkWidth: 1, + nodeRel: 4, + nodeOpacity: 0.9, + nodeResolution: 8, + labels: 2, + labelScale: 1.5, + highlight: true, + highlightNodeSize: 2, + highlightLinkSize: 2, + highlightAnim: false, + animationSpeed: 250, + algorithms: algorithms, + algorithmOptions: options, + algorithmName: 'CubicOut', + linkColorScheme: 'plain', + nodeColorScheme: 'colorful', + highlightColor: 'purple', +} diff --git a/components/tweaks.tsx b/components/tweaks.tsx index f9c58a1..15fadcf 100644 --- a/components/tweaks.tsx +++ b/components/tweaks.tsx @@ -32,9 +32,11 @@ import { Heading, Collapse, } from '@chakra-ui/react' -import React, { useState } from 'react' +import React, { useState, useContext } from 'react' import Scrollbars from 'react-custom-scrollbars-2' -import { initialPhysics, initialFilter } from './config' +import { initialPhysics, initialFilter, initialVisuals } from './config' + +import { ThemeContext } from '../pages/themecontext' export interface TweakProps { physics: typeof initialPhysics @@ -43,11 +45,15 @@ export interface TweakProps { setThreeDim: (newValue: boolean) => void filter: typeof initialFilter setFilter: any + visuals: typeof initialVisuals + setVisuals: any } export const Tweaks = (props: TweakProps) => { - const { physics, setPhysics, threeDim, setThreeDim, filter, setFilter } = props + const { physics, setPhysics, threeDim, setThreeDim, filter, setFilter, visuals, setVisuals } = + props const [showTweaks, setShowTweaks] = useState(true) + const { highlightColor, setHighlightColor } = useContext(ThemeContext) return ( <> @@ -67,24 +73,19 @@ export const Tweaks = (props: TweakProps) => { - @@ -94,14 +95,12 @@ export const Tweaks = (props: TweakProps) => { aria-label="Reset Defaults" icon={} onClick={() => setPhysics(initialPhysics)} - colorScheme="purple" variant="none" size="sm" /> } aria-label="Close Tweak Panel" variant="ghost" @@ -120,7 +119,7 @@ export const Tweaks = (props: TweakProps) => { ...style, borderRadius: 10, }} - bg="purple.500" + bg={highlightColor + '.500'} /> )} > @@ -142,7 +141,6 @@ export const Tweaks = (props: TweakProps) => { Orphans { setFilter({ ...filter, orphans: !filter.orphans }) }} @@ -152,7 +150,6 @@ export const Tweaks = (props: TweakProps) => { Link nodes with parent file { setFilter({ ...filter, parents: !filter.parents }) }} @@ -172,7 +169,6 @@ export const Tweaks = (props: TweakProps) => { id="physicsOn" onChange={() => setPhysics({ ...physics, enabled: !physics.enabled })} isChecked={physics.enabled} - colorScheme="purple" /> @@ -270,7 +266,7 @@ export const Tweaks = (props: TweakProps) => { label="Centering Strength" value={physics.centeringStrength} max={2} - step={0.1} + step={0.01} onChange={(v) => setPhysics({ ...physics, centeringStrength: v })} /> @@ -296,13 +292,95 @@ export const Tweaks = (props: TweakProps) => { paddingLeft={7} color="gray.800" > - setPhysics({ ...physics, colorful: !physics.colorful })} - value={physics.colorful} - > - Child - + + + + + Visual + + + } + align="stretch" + paddingLeft={7} + color="gray.800" + > + + + Node Color Scheme + + }> + {visuals.nodeColorScheme === 'colorful' ? 'Colorful' : 'Plain'} + + + setPhysics({ ...physics, labels: 1 })}> + Colorful + + setPhysics({ ...physics, labels: 2 })}> + Plain + + + + + + Link Color Scheme + + }> + {visuals.linkColorScheme === 'colorful' ? 'Colorful' : 'Plain'} + + + setPhysics({ ...physics, labels: 1 })}> + Colorful + + setPhysics({ ...physics, labels: 2 })}> + Plain + + + + + + Highlight color + + }> + {highlightColor[0]!.toUpperCase() + highlightColor!.slice(1)} + + + {[ + 'red', + 'orange', + 'yellow', + 'green', + 'cyan', + 'blue', + 'pink', + 'purple', + ].map((color) => ( + setHighlightColor(color)} + justifyContent="space-between" + alignItems="center" + display="flex" + > + {color[0]!.toUpperCase() + color!.slice(1)} + + + ))} + + + + + + + + { const { onChange, label, infoText } = rest + const { highlightColor } = useContext(ThemeContext) return ( {label} {infoText && } - + - + @@ -558,7 +630,7 @@ export const EnableSection = (props: EnableSectionProps) => { {label} {infoText && } - + -- cgit v1.2.3