diff --git a/src/assets/tutorial/01.svg b/src/assets/tutorial/01.svg new file mode 100644 index 0000000..af012b6 --- /dev/null +++ b/src/assets/tutorial/01.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/assets/tutorial/02.svg b/src/assets/tutorial/02.svg new file mode 100644 index 0000000..590699f --- /dev/null +++ b/src/assets/tutorial/02.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/assets/tutorial/03.svg b/src/assets/tutorial/03.svg new file mode 100644 index 0000000..b10fb2e --- /dev/null +++ b/src/assets/tutorial/03.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/assets/tutorial/04.svg b/src/assets/tutorial/04.svg new file mode 100644 index 0000000..7d80141 --- /dev/null +++ b/src/assets/tutorial/04.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/assets/tutorial/05.svg b/src/assets/tutorial/05.svg new file mode 100644 index 0000000..32610c1 --- /dev/null +++ b/src/assets/tutorial/05.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/components/BlockContainer.jsx b/src/components/BlockContainer.jsx index 6c83333..786e123 100644 --- a/src/components/BlockContainer.jsx +++ b/src/components/BlockContainer.jsx @@ -1,31 +1,45 @@ import { useState, useEffect } from "react"; - import useStore from "../store"; - import InputBlock from "./common/InputBlock"; import MethodBlock from "./common/MethodBlock"; - import { fetchBlocks } from "../services/blocks"; - import { + Content, + Tab, + TabList, BlockList, InputBlockList, MethodBlockList, } from "../style/BlockContainerStyle"; -import { Header, Section, Content } from "../style/CommonStyle"; +import { Header, Section } from "../style/CommonStyle"; const BlockContainer = () => { const { handleBlockDragStart, handleBlockDragOver, handleDeleteBlock } = useStore(); const [inputBlocks, setInputBlocks] = useState([]); const [methodBlocks, setMethodBlocks] = useState([]); + const [activeTab, setActiveTab] = useState("All"); + const [actions, setActions] = useState(["All"]); useEffect(() => { const renderBlocks = async () => { try { const blocks = await fetchBlocks(); + setInputBlocks(blocks.inputBlocks); setMethodBlocks(blocks.methodBlocks); + + const allActions = new Set(["All"]); + + const updateAction = (allBlocks) => { + allBlocks.forEach((block) => + block.actions.forEach((action) => allActions.add(action)), + ); + }; + + [blocks.inputBlocks, blocks.methodBlocks].forEach(updateAction); + + setActions([...allActions]); } catch (error) { console.error("Fetch Error"); } @@ -33,15 +47,46 @@ const BlockContainer = () => { renderBlocks(); }, []); + const filterBlocksByAction = (blocks, action) => { + return blocks.filter((block) => block.actions.includes(action)); + }; + + const filterBlocks = (action) => { + if (action === "All") { + return { inputBlocks, methodBlocks }; + } + + return { + inputBlocks: filterBlocksByAction(inputBlocks, action), + methodBlocks: filterBlocksByAction(methodBlocks, action), + }; + }; + + const { + inputBlocks: filteredInputBlocks, + methodBlocks: filteredMethodBlocks, + } = filterBlocks(activeTab); + return (

Block Container

+ + {actions.map((action) => ( + setActiveTab(action)} + > + {action} + + ))} + - {inputBlocks.map((inputBlock) => ( + {filteredInputBlocks.map((inputBlock) => ( { ))} - {methodBlocks.map((methodBlock) => ( + {filteredMethodBlocks.map((methodBlock) => ( { + const [currentIndex, setCurrentIndex] = useState(0); + + const handleNextButton = () => { + if (currentIndex < tutorials.length - 1) { + setCurrentIndex(currentIndex + 1); + } else { + onClose(); + } + }; + + const handlePreviousButton = () => { + if (currentIndex > 0) { + setCurrentIndex(currentIndex - 1); + } + }; + + const currentTutorial = tutorials[currentIndex]; + + return ( + + +
+

{title}

+
+ + + {`Tutorial + + + {currentTutorial.content.split(".").join(".\n")} + + +