import { Text, Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, Box, Flex, StackDivider, Switch, VStack, } from '@chakra-ui/react' import React, { useCallback } from 'react' import { initialPhysics } from '../config' import { EnableSection } from './EnableSection' import { SliderWithInfo } from './SliderWithInfo' export interface PhysicsPanelProps { physics: typeof initialPhysics setPhysics: any } export const PhysicsPanel = (props: PhysicsPanelProps) => { const { physics, setPhysics } = props const setPhysicsCallback = useCallback((val: number, phys: string, scale: number) => { setPhysics((curr: typeof initialPhysics) => { return { ...curr, [phys]: val / scale } }) }, []) return ( } 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" /> setPhysicsCallback(v, 'linkStrength', 5)} label="Link Force" /> setPhysicsCallback(v, 'alphaDecay', 50)} /> Advanced } align="stretch" paddingLeft={3} color="gray.800" > 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, '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)} /> 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)} /> ) }