diff --git a/src/components/BoxLoop.tsx b/src/components/BoxLoop.tsx index 54ebe83..82c50e0 100644 --- a/src/components/BoxLoop.tsx +++ b/src/components/BoxLoop.tsx @@ -1,12 +1,11 @@ import React, {FunctionComponent, useState} from "react"; import Chance from "chance"; -import {classNames, getColor, range} from "@/utils/helpers"; -import {create} from "domain"; +import {getColor, range} from "@/utils/helpers"; import BoxGraphic from "@/components/BoxGraphic"; import Xarrow from "react-xarrows"; interface BoxLoopProps { - + count: number; } /** @@ -35,35 +34,33 @@ function createLoop(loopRange: [number, number], count: number): { start: number return {start, loop, list}; } -const BoxLoop: FunctionComponent = ({}: BoxLoopProps) => { - const count = 5; +const BoxLoop: FunctionComponent = ({count}: BoxLoopProps) => { const [{loop, start, list}] = useState(createLoop([1, 100], count)!); - return
- {list.map((i, index) => { - const [sourceKey, destinationKey] = [`x-${i}`, `x-${loop[i]}`]; - let anchor = ["top", "bottom"]; - if (index % 2 == 0) anchor.reverse() + return
+ {list.map((v, index) => { + const [sourceKey, destinationKey] = [`x-${v}`, `x-${loop[v]}`]; const isLast = index == count - 1; return ( -
+
{loop[i]}
+ className="text flex items-center justify-center w-full h-full text-[150%] absolute pt-[30%] cursor-pointer">{loop[v]}
- {i} + {v} - {loop[i] ? - : null} + zIndex={50 + v} divContainerProps={{className: "arrow"}}/> : null}
); diff --git a/src/components/BoxTable.tsx b/src/components/BoxTable.tsx index 311df5a..198c826 100644 --- a/src/components/BoxTable.tsx +++ b/src/components/BoxTable.tsx @@ -1,4 +1,4 @@ -import {classNames, range} from "@/utils/helpers"; +import {classNames, getColor, range} from "@/utils/helpers"; import BoxGraphic from "@/components/BoxGraphic"; import Xarrow from "react-xarrows"; @@ -6,25 +6,7 @@ import Chance from "chance"; import {useMemo, useState} from "react"; const chance = new Chance(); -const colors = [ - "#EF4444", - "#F97316", - "#F59E0B", - "#EAB308", - "#84CC16", - "#22C55E", - "#10B981", - "#14B8A6", - "#06B6D4", - "#0EA5E9", - "#3B82F6", - "#6366F1", - "#8B5CF6", - "#A855F7", - "#D946EF", - "#EC4899", - "#F43F5E", -] + const smartShuffle = (n: number[]): number[] => { let shuffled: number[] | null = null; @@ -91,11 +73,6 @@ const BoxTable = () => { setEnabledLines((prev) => ({...prev, ...loop})) } - const getColor = (seed: any) => { - const chance = Chance(seed); - return chance.pickone(colors); - } - const columns = Math.ceil(Math.sqrt(boxes.length)); return (
diff --git a/src/pages/index.tsx b/src/pages/index.tsx index ce7fbcf..86e6e97 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -72,7 +72,7 @@ const Home: NextPage = () => { the boxes have an interesting structure to their existence.

- +

No matter what number of configuration of boxes is given, a loop, a sequence of numbers that