import React, { useEffect, useRef, useState } from "react"; import { JsonProvider } from "~/hooks/useJson"; import { JsonColumnViewProvider, useJsonColumnViewAPI, } from "~/hooks/useJsonColumnView"; import { JsonDocProvider } from "~/hooks/useJsonDoc"; import { JsonPreview } from "../JsonPreview"; import { PreviewValue } from "../Preview/PreviewValue"; import { ExtraLargeTitle } from "../Primitives/ExtraLargeTitle"; import { SmallSubtitle } from "../Primitives/SmallSubtitle"; import { PropertiesValue } from "../Properties/PropertiesValue"; import { HomeSection } from "./HomeSection"; const json = { id: "a1c33bd1-0528-4de3-a745-44d95e7ac3d8", title: "JSON Hero is a tool for JSON", thumbnail: "https://media.giphy.com/media/13CoXDiaCcCoyk/giphy-downsized.gif", createdAt: "2022-02-01T02:25:41-05:00", tint: "#EAB308", webpages: "https://www.theonion.com/", youtube: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", json: "bourne", }; const infoBoxData = [ { title: "Images", highlight: "$.thumbnail", }, { title: "Dates", highlight: "$.createdAt", }, { title: "Colors", highlight: "$.tint", }, { title: "URLs", highlight: "$.webpages", }, { title: "Videos", highlight: "$.youtube", }, ]; const autoplayDuration = 3000; export function HomeInfoBoxSection() { return ( ); } function HomeInfoBoxSectionContent() { const [index, setIndex] = useState(0); const api = useJsonColumnViewAPI(); const interval = useRef(null); useEffect(() => { const selectedPath = infoBoxData[index].highlight; api.goToNodeId(selectedPath, "home"); }, [index]); const resetInterval = () => { if (interval.current != null) { clearInterval(interval.current); } interval.current = setInterval(() => { setIndex((i) => (i = (i + 1) % infoBoxData.length)); }, autoplayDuration); }; useEffect(() => { resetInterval(); return () => { if (interval.current == null) return; clearInterval(interval.current); }; }, []); return (
{infoBoxData[index].title} are more than just strings We figure out what your strings are made of, so you don't have to.
    {infoBoxData.map((value, i) => { return (
  • { resetInterval(); setIndex(i); }} className={`flex flex-grow justify-center px-4 py-2 cursor-pointer border-b-2 ${ index === i ? "text-white border-lime-500" : "border-slate-600" }`} > {value.title}
  • ); })}
); } function SampleJSONPreview({ children, initialSelection, }: { children: React.ReactNode; initialSelection: string; }) { return ( {children} ); }