diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-07-29 06:23:14 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-07-29 06:23:14 +0200 |
commit | 220a63994898fd65503fee2cd7ffc97d2583a2a5 (patch) | |
tree | 30b02f484847cef38e7a6a5c31dc4865758b0464 | |
parent | e0c6d0ec5091536734288ab06ad4587b43387d2f (diff) |
handled all node color cases
-rw-r--r-- | components/tweaks.tsx | 7 | ||||
-rw-r--r-- | pages/index.tsx | 36 |
2 files changed, 19 insertions, 24 deletions
diff --git a/components/tweaks.tsx b/components/tweaks.tsx index 709cbf5..bd607b7 100644 --- a/components/tweaks.tsx +++ b/components/tweaks.tsx @@ -372,6 +372,9 @@ export const Tweaks = (props: TweakProps) => { type="checkbox" defaultValue={visuals.nodeColorScheme} onChange={(colors) => { + if (!colors.length) { + return + } setVisuals({ ...visuals, nodeColorScheme: colors }) console.log(visuals.nodeColorScheme) }} @@ -383,6 +386,10 @@ export const Tweaks = (props: TweakProps) => { (c) => c === color, )} value={color} + isDisabled={ + visuals.nodeColorScheme.length === 1 && + visuals.nodeColorScheme[0] === color + } > <Box justifyContent="space-between" diff --git a/pages/index.tsx b/pages/index.tsx index bb801a4..5a9c825 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -532,9 +532,18 @@ export const Graph = function (props: GraphProps) { return highlightColors[visuals.linkColorScheme][visuals.linkHighlight](opacity) } - const getLinkBaseColor = (link: OrgRoamLinkObject) => { - if (!visuals.linkColorScheme) { + const getNodeColor = (node: OrgRoamNodeObject) => { + // I'm so sorry + const needsHighlighting = highlightedNodes[node.id!] || previouslyHighlightedNodes[node.id!] + // if we are matching the node color and don't have a highlight color + // or we don't have our own scheme and we're not being highlighted + if (!needsHighlighting) { + return theme.colors[getNodeColorById(node.id)][500] + } + if (!visuals.nodeHighlight) { + return theme.colors[getNodeColorById(node.id)][500] } + return highlightColors[getNodeColorById(node.id)][visuals.nodeHighlight](opacity) } const graphCommonProps: ComponentPropsWithoutRef<typeof TForceGraph2D> = { graphData: scopedGraphData, @@ -543,28 +552,7 @@ export const Graph = function (props: GraphProps) { backgroundColor: theme.colors.gray[visuals.backgroundColor], nodeLabel: (node) => (node as OrgRoamNode).title, nodeColor: (node) => { - if (!physics.colorful) { - return previouslyHighlightedNodes[node.id!] || highlightedNodes[node.id!] - ? interHighlight(opacity) - : interGray(opacity) - } - if (node.id === emacsNodeId) { - return theme.colors[visuals.emacsNodeColor][500] - } - - // otherwise links with parents get shown as having one note - const linklen = linksByNodeId[node.id!]?.length ?? 0 - const parentCiteNeighbors = linklen - ? linksByNodeId[node.id!]?.filter((link) => link.type === 'parent' || link.type === 'cite') - .length - : 0 - const neighbors = filter.parents ? linklen : linklen - parentCiteNeighbors! - - return theme.colors[ - visuals.nodeColorScheme[ - numbereWithinRange(neighbors, 0, visuals.nodeColorScheme.length - 1) - ] - ][500] + return getNodeColor(node) }, nodeRelSize: physics.nodeRel, nodeVal: (node) => { |