diff --git a/remix/app/components/Layout/Main.tsx b/remix/app/components/Layout/Main.tsx
index b5eeed7..e7deeac 100644
--- a/remix/app/components/Layout/Main.tsx
+++ b/remix/app/components/Layout/Main.tsx
@@ -1,9 +1,18 @@
import { Flex } from '@chakra-ui/react'
import { Nav } from '../Nav/Nav'
+import { ProfileDrawer } from '../Nav/ProfileDrawer'
export const Main = props => {
return (
-
+
+ {/* */}
{props.children}
diff --git a/remix/app/components/Nav/Nav.tsx b/remix/app/components/Nav/Nav.tsx
index e2f71b7..6256aa1 100644
--- a/remix/app/components/Nav/Nav.tsx
+++ b/remix/app/components/Nav/Nav.tsx
@@ -1,8 +1,15 @@
import React from 'react'
import { Flex } from '@chakra-ui/react'
import { RainbowSkeleton } from '../Skeleton/RainbowSkeleton'
+import { ProfileDrawer } from './ProfileDrawer'
export const Nav = props => {
+ const [profileDrawerOpen, setProfileDrawerOpen] = React.useState(false)
+
+ const toggleProfileDrawer = React.useCallback(() => {
+ setProfileDrawerOpen(!profileDrawerOpen)
+ }, [profileDrawerOpen])
+
return (
<>
{
top={0}
left={0}
right={0}
- py={4}
- px={4}
+ py={6}
+ px={6}
+ bg='white'
+ zIndex={999}
+ boxShadow={'0px 0px 10px rgba(0,0,0,0.1)'}
>
+
{/*
*/}
+ {/* */}
>
)
}
diff --git a/remix/app/components/Nav/ProfileDrawer.tsx b/remix/app/components/Nav/ProfileDrawer.tsx
new file mode 100644
index 0000000..b48a5fa
--- /dev/null
+++ b/remix/app/components/Nav/ProfileDrawer.tsx
@@ -0,0 +1,27 @@
+import React from 'react'
+import { Drawer, DrawerBody, DrawerContent, Flex } from '@chakra-ui/react'
+
+export const ProfileDrawer = props => {
+ const navItems = ['settings']
+
+ const onClose = React.useCallback(() => {
+ // nothing
+ }, [])
+
+ return (
+
+
+
+ {navItems.map((item, idx) => {
+ return {item}
+ })}
+
+
+
+ )
+}
diff --git a/remix/app/components/Safety/Safe.tsx b/remix/app/components/Safety/Safe.tsx
new file mode 100644
index 0000000..600908a
--- /dev/null
+++ b/remix/app/components/Safety/Safe.tsx
@@ -0,0 +1,7 @@
+import { safe } from '~/functions/safe'
+
+export const Safe = props => {
+ // do not render more than the limit of things to prevent infinite loops
+
+ return safe(props)
+}
diff --git a/remix/app/components/Skeleton/RainbowSkeleton.tsx b/remix/app/components/Skeleton/RainbowSkeleton.tsx
index 2d19ca7..f2ab80f 100644
--- a/remix/app/components/Skeleton/RainbowSkeleton.tsx
+++ b/remix/app/components/Skeleton/RainbowSkeleton.tsx
@@ -2,46 +2,46 @@ import React from 'react'
import { Flex } from '@chakra-ui/react'
export const RainbowSkeleton = props => {
-
- const [rainbowColours] = React.useState(["#f34a4a", "#ffbc48", "#58ca70", "#47b5e6", "#a555e8"])
+ const [rainbowColours] = React.useState([
+ '#f34a4a',
+ '#ffbc48',
+ '#58ca70',
+ '#47b5e6',
+ '#a555e8'
+ ])
const keyframes = React.useMemo(() => {
let keyframes = {}
rainbowColours.forEach((colour, idx) => {
- keyframes[Math.round(idx * 100 / rainbowColours.length) + "%"] = { backgroundColor: colour }
+ keyframes[Math.round((idx * 100) / rainbowColours.length) + '%'] = {
+ backgroundColor: colour
+ }
})
- keyframes["100%"] = { backgroundColor: rainbowColours[0] }
+ keyframes['100%'] = { backgroundColor: rainbowColours[0] }
return keyframes
}, [rainbowColours])
if (props?.loaded) {
return props?.children
}
-
+
return (
-
-
+ >
)
}
diff --git a/remix/app/components/Thingtime/Thingtime.tsx b/remix/app/components/Thingtime/Thingtime.tsx
index 921abd8..1076aa3 100644
--- a/remix/app/components/Thingtime/Thingtime.tsx
+++ b/remix/app/components/Thingtime/Thingtime.tsx
@@ -1,12 +1,16 @@
import React from 'react'
import { Box, Flex } from '@chakra-ui/react'
-import { safe } from '~/functions/safe'
+import { Safe } from '../Safety/Safe'
export const Thingtime = props => {
- // const cuid = React.useMemo(() => {
+ // const uuid = React.useMemo(() => {
// return Math.random().toString(36).substring(7)
// }, [])
- const cuid = React.useRef(Math.random().toString(36).substring(7))
+ const uuid = React.useRef(Math.random().toString(36).substring(7))
+
+ const depth = React.useMemo(() => {
+ return props?.depth || 1
+ }, [props?.depth])
const thing = React.useMemo(() => {
return props.thing
@@ -28,13 +32,6 @@ export const Thingtime = props => {
}
}, [thing, validKeyTypes])
- React.useEffect(() => {
- if (window?.thingtime?.things) {
- window.thingtime.things.count =
- (window?.thingtime?.things?.count || 1) + 1
- }
- }, [])
-
const type = React.useMemo(() => {
return typeof thing
}, [thing])
@@ -84,15 +81,11 @@ export const Thingtime = props => {
})
}
- console.log('nik ret 1', thing)
-
recurse(thing, '')
} catch (err) {
// console.error('Error in Thingtime.tsx creating flattenedKeys', err)
}
- console.log('nik ret 2', ret)
-
return ret
}, [thing])
@@ -105,37 +98,42 @@ export const Thingtime = props => {
const template1Modes = ['view', 'edit']
if (template1Modes?.includes(mode)) {
- console.log('nik keys', keys)
if (keys?.length) {
value = (
-
- {keysToUse?.length &&
- keysToUse.map((key, idx) => {
- if (!key?.human) {
- key = {
- human: key,
- key: key
+
+
+ {keysToUse?.length &&
+ keysToUse.map((key, idx) => {
+ if (!key?.human) {
+ key = {
+ human: key,
+ key: key
+ }
}
- }
- const nextThing = thing[key?.key]
+ const nextThing = thing[key?.key]
- return (
-
- )
- })}
-
+ return (
+
+ )
+ })}
+
+
)
} else {
editableValue = (
@@ -161,39 +159,45 @@ export const Thingtime = props => {
const [showContextMenu, setShowContextMenu] = React.useState(false)
const path = React.useMemo(() => {
- return {props?.path?.human}
+ return (
+
+ {props?.path?.human}
+
+ )
}, [props?.path])
const handleMouseEvent = React.useCallback(
e => {
const target = e?.target
- // extract cuid from className
- console.log('nik eh', target?.className, cuid)
+ // extract uuid from className
const className = target?.className
- if (className?.includes(cuid?.current)) {
+ if (className?.includes(uuid?.current)) {
setShowContextMenu(e?.type === 'mouseenter')
}
},
- [cuid]
+ [uuid]
)
- console.log('nik cuid', cuid)
-
- return safe(
-
- {/* {cuid?.current} */}
- {path}
- {showContextMenu && contextMenu}
- {editableValue}
- {value}
-
+ return (
+
+
+ {/* {uuid?.current} */}
+ {path}
+ {showContextMenu && contextMenu}
+ {editableValue}
+ {value}
+
+
)
}
diff --git a/remix/app/components/Thingtime/ThingtimeDemo.tsx b/remix/app/components/Thingtime/ThingtimeDemo.tsx
index 12e9843..34ea768 100644
--- a/remix/app/components/Thingtime/ThingtimeDemo.tsx
+++ b/remix/app/components/Thingtime/ThingtimeDemo.tsx
@@ -28,7 +28,7 @@ export const ThingtimeDemo = props => {
// return null
return (
-
+
)
diff --git a/remix/app/functions/safe.tsx b/remix/app/functions/safe.tsx
index 4d5dbf6..34125bb 100644
--- a/remix/app/functions/safe.tsx
+++ b/remix/app/functions/safe.tsx
@@ -1,16 +1,56 @@
-export const safe = response => {
+export const safe = props => {
// do not render more than the limit of things to prevent infinite loops
+ const thingtime = getThingtime()
+
+ const uuid = props?.uuid
+
try {
if (
- typeof window?.thingtime?.things?.count === 'number' &&
- window?.thingtime?.things?.count > window?.thingtime?.things?.limit
+ typeof thingtime?.things?.count === 'number' &&
+ thingtime?.things?.count >= thingtime?.things?.limit
) {
- console.error('Maximum things reached')
+ console.error(
+ '[codex] Maximum things reached',
+ thingtime?.things?.count,
+ thingtime?.things?.limit
+ )
return null
}
} catch (err) {
- // console.error('Error in Thingtime.tsx checking maximum things', err)
+ console.error('[codex] Error in Thingtime.tsx checking maximum things', err)
}
- return response
+ try {
+ if (!thingtime?.things?.db?.[uuid]) {
+ thingtime.things.db[uuid] = {
+ count: 1
+ }
+ thingtime.things.count++
+ }
+ } catch {
+ // empty
+ }
+
+ try {
+ if (props?.depth >= thingtime?.things?.maxDepth) {
+ console.error(
+ '[codex] Reached max depth',
+ props?.depth,
+ thingtime?.things?.maxDepth
+ )
+ return null
+ }
+ } catch {
+ // nothing
+ }
+
+ return props?.children
+}
+
+export const getThingtime = () => {
+ try {
+ return window?.thingtime || globalThis?.thingtime
+ } catch {
+ return globalThis?.thingtime
+ }
}
diff --git a/remix/app/root.tsx b/remix/app/root.tsx
index 6a12ada..3c998fb 100644
--- a/remix/app/root.tsx
+++ b/remix/app/root.tsx
@@ -48,16 +48,26 @@ export default function App () {
)
}
-
// limiter
-try {
- window.thingtime = {
- tmp: {},
- things: {
- limit: 999,
- count: 0,
+
+const setThingtime = glob => {
+ try {
+ glob.thingtime = {
+ tmp: {},
+ things: {
+ db: {},
+ limit: 9999,
+ maxDepth: 10,
+ count: 0
+ }
}
+ } catch (err) {
+ // will error on server
}
-} catch (err) {
- // will error on server
-}
\ No newline at end of file
+}
+
+try {
+ setThingtime(window)
+} catch {
+ setThingtime(globalThis)
+}
diff --git a/remix/app/routes/index.tsx b/remix/app/routes/index.tsx
index 0ddb304..49d9657 100644
--- a/remix/app/routes/index.tsx
+++ b/remix/app/routes/index.tsx
@@ -1,12 +1,19 @@
import { Flex } from '@chakra-ui/react'
+import { ProfileDrawer } from '~/components/Nav/ProfileDrawer'
import { Splash } from '~/components/Splash/Splash'
import { ThingtimeDemo } from '~/components/Thingtime/ThingtimeDemo'
export default function Index () {
return (
-
+
+
)
}