From 078ee08b62fbd2f260e3209b205d957107a1f42a Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Tue, 21 Sep 2021 20:05:26 +0200 Subject: chore: separated out physics panel as component --- components/tweaks.tsx | 134 ++------------------------------------------------ 1 file changed, 3 insertions(+), 131 deletions(-) (limited to 'components/tweaks.tsx') diff --git a/components/tweaks.tsx b/components/tweaks.tsx index b19ff75..d6f5ba1 100644 --- a/components/tweaks.tsx +++ b/components/tweaks.tsx @@ -3,12 +3,8 @@ import { RepeatClockIcon, ChevronDownIcon, SettingsIcon, - InfoOutlineIcon, RepeatIcon, ArrowRightIcon, - AddIcon, - DeleteIcon, - CheckCircleIcon, } from '@chakra-ui/icons' import { Accordion, @@ -27,10 +23,6 @@ import { MenuOptionGroup, MenuItemOption, Select, - Slider, - SliderFilledTrack, - SliderThumb, - SliderTrack, StackDivider, Switch, Text, @@ -38,14 +30,10 @@ import { VStack, Heading, Collapse, - Grid, Portal, - SlideFade, - Input, } from '@chakra-ui/react' -import { CUIAutoComplete } from 'chakra-ui-autocomplete' -import React, { useState, useContext, useEffect, useCallback } from 'react' +import React, { useContext, useCallback } from 'react' import Scrollbars from 'react-custom-scrollbars-2' import { initialPhysics, @@ -65,6 +53,7 @@ import { usePersistantState } from '../util/persistant-state' import { SliderWithInfo } from './SliderWithInfo' import { EnableSection } from './EnableSection' import { InfoTooltip } from './InfoTooltip' +import { PhysicsPanel } from './PhysicsPanel' export interface TweakProps { physics: typeof initialPhysics @@ -106,11 +95,6 @@ export const Tweaks = (props: TweakProps) => { const { highlightColor, setHighlightColor } = useContext(ThemeContext) const setVisualsCallback = useCallback((val) => setVisuals(val), []) - const setPhysicsCallback = useCallback((val: number, phys: string, scale: number) => { - setPhysics((curr: typeof initialPhysics) => { - return { ...curr, [phys]: val / scale } - }) - }, []) return !showTweaks ? ( { Physics - {/* setPhysics({ ...physics, enabled: !physics.enabled })} - isChecked={physics.enabled} - /> */} - } - align="stretch" - paddingLeft={7} - color="gray.800" - > - setPhysics({ ...physics, gravityOn: !physics.gravityOn })} - > - - Also in local - { - setPhysics((curr: typeof initialPhysics) => { - return { ...curr, gravityLocal: !curr.gravityLocal } - }) - }} - isChecked={physics.gravityLocal} - > - - setPhysicsCallback(v, 'gravity', 10)} - /> - - setPhysicsCallback(v, 'charge', -1 / 100)} - label="Repulsive Force" - /> - setPhysics({ ...physics, collision: !physics.collision })} - > - setPhysicsCallback(v, 'collisionStrength', 1 / 5)} - label="Collision Radius" - infoText="Easy with this one, high values can lead to a real jiggly mess" - /> - - setPhysicsCallback(v, 'linkStrength', 5)} - label="Link Force" - /> - setPhysicsCallback(v, 'linkIts', 1)} - min={0} - max={6} - step={1} - infoText="How many links down the line the physics of a single node affects (Slow)" - /> - setPhysicsCallback(v, 'velocityDecay', 10)} - /> - - - - - - Advanced - - - - } - align="stretch" - paddingLeft={3} - color="gray.800" - > - setPhysicsCallback(v, 'alphaDecay', 50)} - /> - setPhysics({ ...physics, centering: !physics.centering })} - infoText="Keeps the nodes in the center of the viewport. If disabled you can drag the nodes anywhere you want." - > - setPhysicsCallback(v, 'centeringStrength', 1)} - /> - - - - - - + -- cgit v1.2.3