Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 78 additions & 12 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
InfoOutlined,
BookOutlined,
CaretDownFilled,
MenuOutlined
} from "@ant-design/icons";
import ToggleDarkMode from "./ToggleDarkMode";

Expand All @@ -35,6 +36,55 @@ function Navbar({ scrollToFooter }: NavbarProps) {
config: { duration: 1000 },
});

const mobileMenu = (
<Menu>
<Menu.Item key="home">
<Link to="/">
Template Playground
</Link>
</Menu.Item>
<Menu.Item key="explore" onClick={scrollToFooter}>
Explore
</Menu.Item>
<Menu.Item key="about">
<a
href="https://github.com/accordproject/template-playground/blob/main/README.md"
target="_blank"
rel="noopener noreferrer"
>
<QuestionOutlined /> About
</a>
</Menu.Item>
<Menu.Item key="community">
<a
href="https://discord.com/invite/Zm99SKhhtA"
target="_blank"
rel="noopener noreferrer"
>
<UserOutlined /> Community
</a>
</Menu.Item>
<Menu.Item key="issues">
<a
href="https://github.com/accordproject/template-playground/issues"
target="_blank"
rel="noopener noreferrer"
>
<InfoOutlined /> Issues
</a>
</Menu.Item>
<Menu.Item key="documentation">
<a
href="https://github.com/accordproject/template-engine/blob/main/README.md"
target="_blank"
rel="noopener noreferrer"
>
<BookOutlined /> Documentation
</a>
</Menu.Item>
</Menu>
);

const helpMenu = (
<Menu>
<Menu.ItemGroup key="info" title="Info">
Expand Down Expand Up @@ -101,8 +151,8 @@ function Navbar({ scrollToFooter }: NavbarProps) {
lineHeight: "65px",
display: "flex",
alignItems: "center",
paddingLeft: screens.md ? 40 : 10,
paddingRight: screens.md ? 40 : 10,
paddingLeft: screens.lg ? 40 : screens.md ? 10 : 10,
paddingRight: screens.lg ? 40 : screens.md ? 10 : 10,
}}
>
<div
Expand All @@ -122,15 +172,15 @@ function Navbar({ scrollToFooter }: NavbarProps) {
alt="Template Playground"
preview={false}
style={{
paddingRight: screens.md ? "24px" : "10px",
paddingRight: screens.md ? "8px" : "2px",
height: "26px",
maxWidth: screens.md ? "184.17px" : "36.67px",
}}
/>
<span style={{ color: "white" }}>Template Playground</span>
<span style={{ color: "white", display: screens.lg ? "block" : "none" }}>Template Playground</span>
</Link>
</div>
{screens.md && (
{screens.md ? (
<>
<div
style={{
Expand Down Expand Up @@ -170,27 +220,43 @@ function Navbar({ scrollToFooter }: NavbarProps) {
</Dropdown>
</div>
</>
) : (
<div style={{ marginLeft: "5px" }}>
<Dropdown overlay={mobileMenu} trigger={["click"]}>
<Button
style={{
background: "transparent",
border: "none",
color: "white",
height: "65px",
display: "flex",
alignItems: "center",
}}
>
<MenuOutlined style={{ fontSize: "20px" }} />
</Button>
</Dropdown>
</div>
)}
<div
style={{
display: "flex",
marginLeft: "auto",
alignItems: "center",
height: "65px",
gap: screens.md ? "20px" : "10px",
marginRight: screens.md ? 0 : "5px"
}}
>
<div>
<div style={{ marginLeft: screens.md ? 0 : "auto" }}>
<ToggleDarkMode />
</div>
{!isLearnPage && (
<div
style={{
marginLeft: screens.md ? "20px" : "0",
height: "65px",
display: "flex",
justifyContent: "center",
paddingLeft: "15px",
borderRadius: "5px",
alignItems: "center",
backgroundColor:
hovered === "join" ? "rgba(255, 255, 255, 0.1)" : "transparent",
Expand All @@ -208,7 +274,6 @@ function Navbar({ scrollToFooter }: NavbarProps) {
color: "#050c40",
border: "none",
borderRadius: "5px",
marginRight: "15px",
cursor: "pointer",
}}
>
Expand All @@ -228,7 +293,8 @@ function Navbar({ scrollToFooter }: NavbarProps) {
borderLeft: screens.md
? "1.5px solid rgba(255, 255, 255, 0.1)"
: "none",
paddingLeft: screens.md ? "20px" : "0",
paddingLeft: screens.md ? 16 : 5,
paddingRight: screens.md ? 16 : 5,
backgroundColor:
hovered === "github" ? "rgba(255, 255, 255, 0.1)" : "transparent",
cursor: "pointer",
Expand All @@ -249,7 +315,7 @@ function Navbar({ scrollToFooter }: NavbarProps) {
marginRight: screens.md ? "5px" : "0",
}}
/>
{screens.md && <span>Github</span>}
<span style={{ display: screens.md ? "inline" : "none" }}>Github</span>
</a>
</div>
</div>
Expand Down
8 changes: 7 additions & 1 deletion src/components/useUndoRedo.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { useState } from 'react';
import { useState,useEffect } from 'react';
function useUndoRedo<T>(initialValue: T, onChange?: (value: T) => void) {
const [past, setPast] = useState<T[]>([]);
const [present, setPresent] = useState<T>(initialValue);
const [future, setFuture] = useState<T[]>([]);

useEffect(() => {
setPresent(initialValue);
setPast([]);
setFuture([]);
}, [initialValue]);

const setValue = (newValue: T) => {
setPast((prevPast) => [...prevPast, present]);
setPresent(newValue);
Expand Down