From 0a99a5074654dc235c52808f07a18f3fe95ad47b Mon Sep 17 00:00:00 2001 From: Nikolaj Frey Date: Sun, 2 Jul 2023 00:49:01 +1000 Subject: [PATCH] feat: main Added click away logic to commander --- remix/app/components/Commander/Commander.tsx | 214 ++++++++++--------- remix/package.json | 1 + remix/pnpm-lock.yaml | 13 ++ 3 files changed, 125 insertions(+), 103 deletions(-) diff --git a/remix/app/components/Commander/Commander.tsx b/remix/app/components/Commander/Commander.tsx index e81ca4b..23d0e2e 100644 --- a/remix/app/components/Commander/Commander.tsx +++ b/remix/app/components/Commander/Commander.tsx @@ -3,6 +3,7 @@ import { Center, Box, Flex, Input } from '@chakra-ui/react' import { useThingtime } from '../Thingtime/useThingtime' import { Thingtime } from '../Thingtime/Thingtime' import { sanitise } from '~/functions/path' +import ClickAwayListener from 'react-click-away-listener' export const Commander = props => { const { thingtime, setThingtime, getThingtime, thingtimeRef } = useThingtime() @@ -175,7 +176,12 @@ export const Commander = props => { const fn = `() => { return ${escapedCommandValue} }` const evalFn = eval(fn) const realVal = evalFn() + const prevVal = getThingtime(commandPath) setThingtime(commandPath, realVal) + if (!prevVal) { + setContextPath(commandPath) + setShowContext(true, 'commandIsAction check') + } } catch (err) { console.log('setThingtime errored in Commander', err) } @@ -277,123 +283,125 @@ export const Commander = props => { }, []) return ( - + - {renderedSuggestions.map((suggestion, i) => { - return ( - selectSuggestion(suggestion)} - > - {suggestion} - - ) - })} + + {renderedSuggestions.map((suggestion, i) => { + return ( + selectSuggestion(suggestion)} + > + {suggestion} + + ) + })} + + + + - - - - -
- - -
-
+ sx={{ + '@keyframes rainbow-conical': { + '100%': { + transform: 'rotate(-360deg)' + } + }, + animation: 'rainbow-conical 1s linear infinite' + }} + > + + + + ) } diff --git a/remix/package.json b/remix/package.json index 4613270..9a1b4de 100644 --- a/remix/package.json +++ b/remix/package.json @@ -15,6 +15,7 @@ "isbot": "latest", "lodash-es": "^4.17.21", "react": "^18.2.0", + "react-click-away-listener": "^2.2.3", "react-dom": "^18.2.0", "uuid": "^9.0.0" }, diff --git a/remix/pnpm-lock.yaml b/remix/pnpm-lock.yaml index be18f3f..bd3d494 100644 --- a/remix/pnpm-lock.yaml +++ b/remix/pnpm-lock.yaml @@ -32,6 +32,9 @@ dependencies: react: specifier: ^18.2.0 version: 18.2.0 + react-click-away-listener: + specifier: ^2.2.3 + version: 2.2.3(react-dom@18.2.0)(react@18.2.0) react-dom: specifier: ^18.2.0 version: 18.2.0(react@18.2.0) @@ -7644,6 +7647,16 @@ packages: iconv-lite: 0.4.24 unpipe: 1.0.0 + /react-click-away-listener@2.2.3(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-p63JRQtK9d085+QHUJ2Pje22P/N4tEaXsS2x7tbbptriQqZ9o8xEk7G1JrxwND5YmEVc/VO4fC3+cSBsqqgLUQ==} + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 + dependencies: + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + dev: false + /react-clientside-effect@1.2.6(react@18.2.0): resolution: {integrity: sha512-XGGGRQAKY+q25Lz9a/4EPqom7WRjz3z9R2k4jhVKA/puQFH/5Nt27vFZYql4m4NVNdUvX8PS3O7r/Zzm7cjUlg==} peerDependencies: