From c584c73a6bf4b804a4c5d6cfdcb50b3ed308e5e3 Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Sun, 12 Sep 2021 21:49:46 +0200 Subject: feat: #70 label text wrapping --- components/config.ts | 2 + components/tweaks.tsx | 767 +++++++++++++++++++++++++++++--------------------- 2 files changed, 447 insertions(+), 322 deletions(-) (limited to 'components') diff --git a/components/config.ts b/components/config.ts index 0c23528..dce9b7d 100644 --- a/components/config.ts +++ b/components/config.ts @@ -61,6 +61,8 @@ export const initialVisuals = { labelScale: 1.5, labelFontSize: 13, labelLength: 40, + labelWordWrap: 25, + labelLineSpace: 1, highlight: true, highlightNodeSize: 2, highlightLinkSize: 2, diff --git a/components/tweaks.tsx b/components/tweaks.tsx index d0605cd..e03cea5 100644 --- a/components/tweaks.tsx +++ b/components/tweaks.tsx @@ -733,351 +733,474 @@ export const Tweaks = (props: TweakProps) => { - - } - align="stretch" - paddingLeft={7} - color="gray.800" - > - setVisuals({ ...visuals, nodeRel: value })} - /> - setVisuals({ ...visuals, nodeSizeLinks: value })} - /> - {threeDim && ( - <> - setVisuals({ ...visuals, nodeOpacity: value })} - /> - setVisuals({ ...visuals, nodeResolution: value })} - /> - - )} - setVisuals({ ...visuals, linkWidth: value })} - /> - {threeDim && ( - setVisuals({ ...visuals, linkOpacity: value })} - /> - )} - setVisuals({ ...visuals, citeDashes: !visuals.citeDashes })} - > - setVisuals({ ...visuals, citeDashLength: value * 10 })} - /> - setVisuals({ ...visuals, citeGapLength: value * 5 })} - /> - - - - - setVisuals({ ...visuals, refDashes: !visuals.refDashes })} - > - setVisuals({ ...visuals, refDashLength: value * 10 })} - /> - setVisuals({ ...visuals, refGapLength: value * 5 })} - /> - - - - - - - Labels - - } - > - {!visuals.labels - ? 'Never' - : visuals.labels < 2 - ? 'On Highlight' - : 'Always'} - - - {' '} - - setVisuals({ ...visuals, labels: 0 })}> - Never - - setVisuals({ ...visuals, labels: 1 })}> - On Highlight - - setVisuals({ ...visuals, labels: 2 })}> - Always - - setVisuals({ ...visuals, labels: 3 })}> - Always (even in 3D) - - - - - - 0} animateOpacity> + + + + Nodes & Links + + + + } + divider={} align="stretch" - paddingLeft={2} color="gray.800" > - setVisuals({ ...visuals, labelFontSize: value })} - /> - setVisuals({ ...visuals, labelLength: value })} - /> - - - - + + setVisuals({ ...visuals, nodeRel: value })} + /> + setVisuals({ ...visuals, nodeSizeLinks: value })} + /> + {threeDim && ( + <> + setVisuals({ ...visuals, nodeOpacity: value })} + /> + + setVisuals({ ...visuals, nodeResolution: value }) + } + /> + + )} + setVisuals({ ...visuals, linkWidth: value })} + /> + {threeDim && ( { - console.log(visuals.labelBackgroundOpacity) - setVisuals({ ...visuals, labelBackgroundOpacity: value }) - }} + label="Link opacity" + min={0} + max={1} + value={visuals.linkOpacity} + onChange={(value) => setVisuals({ ...visuals, linkOpacity: value })} + /> + )} + setVisuals({ ...visuals, arrows: !visuals.arrows })} + > + + setVisuals({ ...visuals, arrowsLength: 10 * value }) + } + /> + setVisuals({ ...visuals, arrowsPos: value })} + /> + - - - 1} animateOpacity> - + + + setVisuals({ ...visuals, particles: !visuals.particles }) + } + > - setVisuals({ ...visuals, labelScale: value / 5 }) + setVisuals({ ...visuals, particlesNumber: value }) } /> - - + + setVisuals({ ...visuals, particlesWidth: value }) + } + /> + + - - - setVisuals({ ...visuals, arrows: !visuals.arrows })} - > - setVisuals({ ...visuals, arrowsLength: 10 * value })} - /> - setVisuals({ ...visuals, arrowsPos: value })} - /> - - - setVisuals({ ...visuals, particles: !visuals.particles })} - > - setVisuals({ ...visuals, particlesNumber: value })} - /> - setVisuals({ ...visuals, particlesWidth: value })} - /> - - setVisuals({ ...visuals, highlight: !visuals.highlight })} - value={visuals.highlight} - > - + + {/* } + divider={} align="stretch" - paddingLeft={0} - > - setVisuals({ ...visuals, highlightLinkSize: value })} - /> - setVisuals({ ...visuals, highlightNodeSize: value })} - /> - setVisuals({ ...visuals, highlightFade: value })} - /> - {/* + paddingLeft={7} + color="gray.800" + > */} + + + + Labels + + + + + } + align="stretch" + color="gray.800" + > + + + Show labels + + } + > + {!visuals.labels + ? 'Never' + : visuals.labels < 2 + ? 'On Highlight' + : 'Always'} + + + {' '} + + setVisuals({ ...visuals, labels: 0 })}> + Never + + setVisuals({ ...visuals, labels: 1 })}> + On Highlight + + setVisuals({ ...visuals, labels: 2 })}> + Always + + setVisuals({ ...visuals, labels: 3 })}> + Always (even in 3D) + + + + + + } + align="stretch" + paddingLeft={2} + color="gray.800" + > + setVisuals({ ...visuals, labelFontSize: value })} + /> + setVisuals({ ...visuals, labelLength: value })} + /> + setVisuals({ ...visuals, labelWordWrap: value })} + /> + + setVisuals({ ...visuals, labelLineSpace: value }) + } + /> + + + + + { + console.log(visuals.labelBackgroundOpacity) + setVisuals({ ...visuals, labelBackgroundOpacity: value }) + }} + min={0} + max={1} + step={0.01} + /> + + + 1} animateOpacity> + + + setVisuals({ ...visuals, labelScale: value / 5 }) + } + /> + + + + + + + + + + + Highlighting + + + + + } + align="stretch" + color="gray.800" + > + + + setVisuals({ ...visuals, highlight: !visuals.highlight }) + } + value={visuals.highlight} + > + } + align="stretch" + paddingLeft={0} + > + + setVisuals({ ...visuals, highlightLinkSize: value }) + } + /> + + setVisuals({ ...visuals, highlightNodeSize: value }) + } + /> + + setVisuals({ ...visuals, highlightFade: value }) + } + /> + {/* Highlight node color Highlight link color */} - { - setVisuals({ ...visuals, highlightAnim: !visuals.highlightAnim }) - }} - value={visuals.highlightAnim} + { + setVisuals({ ...visuals, highlightAnim: !visuals.highlightAnim }) + }} + value={visuals.highlightAnim} + > + setVisuals({ ...visuals, animationSpeed: v })} + value={visuals.animationSpeed} + infoText="Slower speed has a chance of being buggy" + min={50} + max={1000} + step={10} + /> + + + + + + + + + + + + Citations + + + + + } + align="stretch" + color="gray.800" > - setVisuals({ ...visuals, animationSpeed: v })} - value={visuals.animationSpeed} - infoText="Slower speed has a chance of being buggy" - min={50} - max={1000} - step={10} - /> - - - - - + + + setVisuals({ ...visuals, citeDashes: !visuals.citeDashes }) + } + > + + setVisuals({ ...visuals, citeDashLength: value * 10 }) + } + /> + + setVisuals({ ...visuals, citeGapLength: value * 5 }) + } + /> + + + + + + setVisuals({ ...visuals, refDashes: !visuals.refDashes }) + } + > + + setVisuals({ ...visuals, refDashLength: value * 10 }) + } + /> + + setVisuals({ ...visuals, refGapLength: value * 5 }) + } + /> + + + + + + + + + -- cgit v1.2.3