From 1a744165f6056697b4be72695c37fe3f836e1b08 Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Thu, 22 Jul 2021 17:39:15 +0200 Subject: changed EnableSlider to Section wrapper --- pages/index.tsx | 149 +++++++++++++++++++++++--------------------------------- 1 file changed, 60 insertions(+), 89 deletions(-) (limited to 'pages') diff --git a/pages/index.tsx b/pages/index.tsx index 1b7eb79..1630835 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -246,44 +246,26 @@ export const SliderWithInfo = ({ ) } -export interface EnableSliderProps extends SliderWithInfoProps { - enableValue: boolean - onEnableValueChange: () => void - enableLabel: string - enableInfoText?: string | boolean +export interface EnableSectionProps { + label: string + value: () => void + onChange: string + infoText?: string + children: React.ReactNode } -export const EnableSlider = ({ min = 0, max = 10, step = 0.1, ...rest }: EnableSliderProps) => { - const { - value, - onChange, - label, - infoText, - enableValue, - onEnableValueChange, - enableInfoText, - enableLabel, - } = rest +export const EnableSection = (props: EnableSectionProps) => { + const { value, onChange, label, infoText, children } = props return ( - {enableLabel} - {enableInfoText && } + {label} + {infoText && } - + - {enableValue && ( - - )} + {value && children} ) } @@ -338,32 +320,34 @@ export const Tweaks = function (props: TweakProps) { divider={} align="stretch" > - - setPhysics({ ...physics, gravityOn: !physics.gravityOn }) - } - label="Strength" - value={physics.gravity * 10} - onChange={(v) => setPhysics({ ...physics, gravity: v / 10 })} - /> + setPhysics({ ...physics, gravityOn: !physics.gravityOn })} + > + setPhysics({ ...physics, gravity: v / 10 })} + /> + setPhysics({ ...physics, charge: -100 * value })} label="Repulsive Force" /> - setPhysics({ ...physics, collisionStrength: value / 10 })} - label="Strength" - enableLabel="Collision" - enableInfoText="Perfomance sap, disable if slow" - enableValue={physics.collision} - onEnableValueChange={() => - setPhysics({ ...physics, collision: !physics.collision }) - } - /> + setPhysics({ ...physics, collision: !physics.collision })} + > + setPhysics({ ...physics, collisionStrength: value / 10 })} + label="Strength" + /> + setPhysics({ ...physics, linkStrength: value / 5 })} @@ -442,21 +426,23 @@ export const Tweaks = function (props: TweakProps) { value={physics.linkWidth} onChange={(value) => setPhysics({ ...physics, linkWidth: value })} /> - setPhysics({ ...physics, labels: !physics.labels })} - label="Label Appearance Scale" - value={physics.labelScale * 5} - onChange={(value) => setPhysics({ ...physics, labelScale: value / 5 })} - /> - - - setPhysics({ ...physics, labels: physics.particles ? 0 : 1 }) - } + setPhysics({ ...physics, labels: !physics.labels })} + > + setPhysics({ ...physics, labelScale: value / 5 })} + /> + + setPhysics({ ...physics, labels: physics.particles ? 0 : 1 })} + > + setPhysics({ ...physics, particleWidth: value })} /> - - setPhysics({ ...physics, nodeRel: value })} - /> - Ayyyy + + setPhysics({ ...physics, highlight: !physics.hightligth })} + value={physics.hightlight} + > + Hi + @@ -511,22 +498,6 @@ export const Tweaks = function (props: TweakProps) { - - - - Visual - - - } - align="stretch" - > - Ayyyy - - - ) -- cgit v1.2.3