diff --git a/src/App.tsx b/src/App.tsx index a21e4af..e3d4299 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,15 +1,16 @@ import { useEffect, useState } from "react"; import { Container, - Header, Grid, Segment, Accordion, AccordionTitleProps, } from "semantic-ui-react"; +import Navbar from "./Navbar"; import AgreementData from "./AgreementData"; import AgreementHtml from "./AgreementHtml"; +import "./App.css"; import Errors from "./Errors"; import TemplateMarkdown from "./TemplateMarkdown"; import TemplateModel from "./TemplateModel"; @@ -18,13 +19,32 @@ import SampleDropdown from "./SampleDropdown"; const App = () => { const init = useAppStore((state) => state.init); - const [activeIndex, setActiveIndex] = useState(-1); + const [activeIndex, setActiveIndex] = useState([]); - const handleAccordionClick = (titleProps: AccordionTitleProps) => { + const scrollToExplore = () => { + const exploreContent = document.getElementById("explore"); + if (exploreContent) { + exploreContent.scrollIntoView({ behavior: "smooth" }); + } + }; + + const handleAccordionClick = ( + _event: React.MouseEvent, + titleProps: AccordionTitleProps + ) => { const { index } = titleProps; if (typeof index === "number") { - const newIndex = activeIndex === index ? -1 : index; - setActiveIndex(newIndex); + const currentIndex = activeIndex.indexOf(index); + let newIndexes: number[]; + if (currentIndex === -1) { + newIndexes = [...activeIndex, index]; + } else { + newIndexes = [ + ...activeIndex.slice(0, currentIndex), + ...activeIndex.slice(currentIndex + 1), + ]; + } + setActiveIndex(newIndexes); } }; @@ -36,63 +56,66 @@ const App = () => { { key: "templateMark", label: "TemplateMark", - content: { content: , key: "templateMark" }, + content: , }, { key: "model", label: "Concerto Model", - content: { content: , key: "model" }, + content: , }, { key: "data", label: "Preview Data", - content: { content: , key: "data" }, + content: , }, ]; return ( - -
- Template Playground{" "} - (BETA) -
-
- - - - - - - - - - - - - - {panels.map((panel, index) => ( -
- - {panel.label} - - - {panel.content.content} - -
- ))} -
-
- - - -
-
-
+ + + + + + + + + + + + + + + + {panels.map((panel, index) => ( +
+ + {panel.label} + + + {panel.content} + +
+ ))} +
+
+ + + +
+
+
+
); }; diff --git a/src/SampleDropdown.tsx b/src/SampleDropdown.tsx index 9176d6e..551ab4b 100644 --- a/src/SampleDropdown.tsx +++ b/src/SampleDropdown.tsx @@ -1,6 +1,5 @@ import { useState } from "react"; -import { Dropdown, DropdownProps } from "semantic-ui-react"; - +import { Dropdown, DropdownProps, Loader } from "semantic-ui-react"; import useAppStore from "./store"; function SampleDropdown() { @@ -12,36 +11,40 @@ function SampleDropdown() { const items = samples.map((s) => ({ text: s.NAME, value: s.NAME, + key: s.NAME, })); - const handleMenuClick = async (data: DropdownProps) => { + const handleDropdownChange = async ( + _event: React.SyntheticEvent, + data: DropdownProps + ) => { const { value } = data; - setLoading(true); - try { - if (typeof value === "string") { + if (typeof value === "string") { + setLoading(true); + try { await loadSample(value); alert(`Loaded ${value} sample`); - } else { - throw new Error("Invalid sample value"); + } catch (error) { + alert("Failed to load sample"); + } finally { + setLoading(false); } - } catch (error) { - alert("Failed to load sample"); - } finally { - setLoading(false); } }; return ( - +
+ + {loading && } +
); }