diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-07-29 18:25:08 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-07-29 18:25:08 +0200 |
commit | e61f1e124f052e2317385b48f0b474175f685378 (patch) | |
tree | a62b3d26ba740a4e036ca809a3e125c0e594043e | |
parent | 22f6ecfc21b3899a832e1c24b8c40f41f09e9d25 (diff) |
emacsnode for mlord
-rw-r--r-- | components/config.ts | 1 | ||||
-rw-r--r-- | components/tweaks.tsx | 51 | ||||
-rw-r--r-- | org-roam-ui.el | 6 | ||||
-rw-r--r-- | pages/index.tsx | 7 |
4 files changed, 60 insertions, 5 deletions
diff --git a/components/config.ts b/components/config.ts index 9c49068..d538941 100644 --- a/components/config.ts +++ b/components/config.ts @@ -89,6 +89,7 @@ export const initialVisuals = { nodeHighlight: '', linkHighlight: '', backgroundColor: 'white', + emacsNodeColor: '', } export const initialBehavior = { diff --git a/components/tweaks.tsx b/components/tweaks.tsx index a30ce4c..e9ab582 100644 --- a/components/tweaks.tsx +++ b/components/tweaks.tsx @@ -679,6 +679,57 @@ export const Tweaks = (props: TweakProps) => { </MenuList> </Menu> </Flex> + <Flex alignItems="center" justifyContent="space-between"> + <Text>Emacs Node</Text> + <Menu isLazy> + <MenuButton + as={Button} + colorScheme="" + color="black" + rightIcon={<ChevronDownIcon />} + > + { + <Box + bgColor={visuals.emacsNodeColor + '.500'} + borderRadius="sm" + height={6} + width={6} + ></Box> + } + </MenuButton> + <MenuList bgColor="gray.200" width={50}> + <MenuItem + key={'none'} + onClick={() => setVisuals({ ...visuals, emacsNodeColor: '' })} + justifyContent="space-between" + alignItems="center" + display="flex" + > + <Text>No change</Text> + <Box borderRadius="sm" height={6} width={6}></Box> + </MenuItem> + {colorList.map((color) => ( + <MenuItem + key={color} + onClick={() => + setVisuals({ ...visuals, emacsNodeColor: color }) + } + justifyContent="space-between" + alignItems="center" + display="flex" + > + <Text>{color[0]!.toUpperCase() + color!.slice(1)}</Text> + <Box + bgColor={color + '.500'} + borderRadius="sm" + height={6} + width={6} + ></Box> + </MenuItem> + ))} + </MenuList> + </Menu> + </Flex> </Box> </VStack> </AccordionPanel> diff --git a/org-roam-ui.el b/org-roam-ui.el index 183902f..8f7cc56 100644 --- a/org-roam-ui.el +++ b/org-roam-ui.el @@ -268,13 +268,13 @@ The padding around the nodes in the viewport." (defun orui-toggle-following () "Set whether ORUI should follow your every move in emacs. Default yes." (interactive) - (if (member #'org-roam-ui--update-current-node (default-value 'post-command-hook)) + (if (member 'org-roam-ui--update-current-node (default-value 'post-command-hook)) (progn (remove-hook 'post-command-hook #'org-roam-ui--update-current-node) - (message "Org-Roam-UI will now leave you alone.") + (message "Org-Roam-UI will now leave you alone.")) (add-hook 'post-command-hook #'org-roam-ui--update-current-node) (message "Org-Roam-UI will now follow you around.")) - )) + ) (defun orui-toggle-local-zoom () "Toggles whether org-roam-ui should go to the local view of a given node or zoom to it. diff --git a/pages/index.tsx b/pages/index.tsx index d32ebc4..96d3ba8 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -417,6 +417,7 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) { opacity > 0.5 ? fadeOut() : setOpacity(0) } }, [hoverNode]) + const theme = useTheme() const themeContext = useContext<ThemeContextProps>(ThemeContext) @@ -507,10 +508,12 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) { } const getNodeColor = (node: OrgRoamNode) => { - // 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 (visuals.emacsNodeColor && node.id === emacsNodeId) { + return theme.colors[visuals.emacsNodeColor][500] + } if (!needsHighlighting) { return theme.colors[getNodeColorById(node.id)][500] } @@ -643,7 +646,7 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) { onBackgroundClick: () => { setHoverNode(null) if (scope.nodeIds.length === 0) { - return + return } setScope((currentScope) => ({ ...currentScope, |