Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: learning pathway build implementation && intro tour guide #96

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
19ee755
cursor inconsistency in editor fixed (#95)
nitro56565 Aug 5, 2024
cc5dfe6
update(ui): secondary theme color (#93)
Vinyl-Davyl Aug 6, 2024
0c5e033
chore(doc): doc updated with recent project feature (#92)
Vinyl-Davyl Aug 6, 2024
77a9b88
update: development
Vinyl-Davyl Aug 9, 2024
044aadb
update: development
Vinyl-Davyl Aug 12, 2024
5339875
update: development
Vinyl-Davyl Aug 12, 2024
b4b26ea
update: development
Vinyl-Davyl Aug 12, 2024
66efc30
update: development
Vinyl-Davyl Aug 12, 2024
b407722
update: development
Vinyl-Davyl Aug 19, 2024
c712d9c
update: development
Vinyl-Davyl Aug 19, 2024
d653999
update development
Vinyl-Davyl Aug 20, 2024
dded3a1
update: development
Vinyl-Davyl Aug 22, 2024
3df01c4
update: development
Vinyl-Davyl Aug 22, 2024
19a5f41
update: development
Vinyl-Davyl Aug 22, 2024
61b47ab
update: development
Vinyl-Davyl Aug 22, 2024
d5d7602
update: development
Vinyl-Davyl Aug 22, 2024
71e3328
update: development
Vinyl-Davyl Aug 23, 2024
c11f4ef
update: development
Vinyl-Davyl Aug 23, 2024
029971d
update: development
Vinyl-Davyl Aug 23, 2024
92e1d1b
update: development
Vinyl-Davyl Aug 23, 2024
4aeb497
chore: updated contents
Vinyl-Davyl Aug 23, 2024
2ddf0e7
update: development
Vinyl-Davyl Aug 26, 2024
4beca0d
update: development
Vinyl-Davyl Aug 26, 2024
3aa4d4b
update: development
Vinyl-Davyl Aug 28, 2024
c2b14e8
update: development
Vinyl-Davyl Aug 30, 2024
23a3696
update: development
Vinyl-Davyl Aug 30, 2024
2e3f24b
Merge branch 'main' into vinyl/feat/intro-tooltip
Vinyl-Davyl Aug 30, 2024
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
19,498 changes: 13,772 additions & 5,726 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,27 @@
"@accordproject/template-engine": "^2.3.5",
"@ant-design/icons": "^5.3.7",
"@monaco-editor/react": "^4.6.0",
"@types/styled-components": "^5.1.34",
"antd": "^5.7.2",
"core-js": "^3.37.1",
"immer": "^10.0.2",
"highlight.js": "^11.10.0",
"immer": "^10.1.1",
"lz-string": "^1.5.0",
"monaco-editor": "^0.50.0",
"node-stdlib-browser": "^1.2.0",
"normalize.css": "^8.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-dropdown": "^1.11.0",
"react-markdown": "^9.0.1",
"react-router-dom": "^6.24.1",
"react-shepherd": "^6.1.1",
"react-spring": "^9.7.4",
"regenerator-runtime": "^0.13.11",
"rehype-highlight": "^7.0.0",
"rehype-raw": "^7.0.0",
"shepherd.js": "^13.0.3",
"styled-components": "^6.1.12",
"ts-debounce": "^4.0.0",
"zustand": "^4.3.9"
},
Expand Down
1 change: 1 addition & 0 deletions public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* /index.html 200
Binary file added public/assets/content/template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/content/template_logic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/content/template_model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/content/template_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

131 changes: 84 additions & 47 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { useEffect, useState } from "react";
import { App as AntdApp, Layout, Row, Col, Collapse, theme, Grid } from "antd";
import { Routes, Route, useSearchParams } from "react-router-dom";
import Navbar from "./components/Navbar";
import Footer from "./components/Footer";
import tour from "./components/Tour";
import AgreementData from "./editors/editorsContainer/AgreementData";
import LearnNow from "./pages/LearnNow";
import AgreementHtml from "./AgreementHtml";
import Errors from "./utils/helpers/Errors";
import TemplateMarkdown from "./editors/editorsContainer/TemplateMarkdown";
import TemplateModel from "./editors/editorsContainer/TemplateModel";
import useAppStore from "./store/store";
import SampleDropdown from "./components/SampleDropdown";
import FullScreenModal from "./components/FullScreenModal";
import { useSearchParams } from "react-router-dom";
import UseShare from "./components/UseShare";
import LearnContent from "./components/Content";

const { Content } = Layout;
const { useBreakpoint } = Grid;
Expand Down Expand Up @@ -50,6 +53,15 @@ const App = () => {
initializeApp();
}, [init, loadFromLink, searchParams]);

useEffect(() => {
const showTour = searchParams.get("showTour") === "true";

if (showTour || !localStorage.getItem("hasVisited")) {
tour.start();
localStorage.setItem("hasVisited", "true");
}
}, [searchParams]);

const screens = useBreakpoint();

const panels = [
Expand All @@ -75,60 +87,85 @@ const App = () => {
<Layout style={{ minHeight: "100vh" }}>
<Navbar scrollToExplore={scrollToExplore} />
<Content>
<div
style={{
padding: 24,
paddingBottom: 150,
minHeight: 360,
background: colorBgContainer,
}}
>
<Row id="explore">
<Col xs={24} sm={8}>
<Row
<Routes>
<Route
path="/"
element={
<div
style={{
marginLeft: "25px",
display: "flex",
flexDirection: "row",
gap: "10px",
padding: 24,
paddingBottom: 150,
minHeight: 360,
background: colorBgContainer,
}}
>
<SampleDropdown setLoading={setLoading} />
<UseShare />
</Row>
</Col>
<Col span={18}>
<Errors />
</Col>
</Row>
<div
style={{
padding: 24,
minHeight: 360,
background: colorBgContainer,
}}
>
<Row gutter={24}>
<Col xs={24} sm={16} style={{ paddingBottom: "20px" }}>
<Collapse
defaultActiveKey={activePanel}
onChange={onChange}
items={panels}
/>
</Col>
<Col xs={24} sm={8}>
<Row id="explore">
<Col xs={24} sm={8}>
<Row
style={{
marginLeft: "25px",
display: "flex",
flexDirection: "row",
gap: "10px",
}}
>
<SampleDropdown setLoading={setLoading} />
<UseShare />
</Row>
</Col>
<Col span={18}>
<Errors />
</Col>
</Row>
<div
style={{
marginBottom: "10px",
padding: 24,
minHeight: 360,
background: colorBgContainer,
}}
>
<FullScreenModal />
<Row gutter={24}>
<Col xs={24} sm={16} style={{ paddingBottom: "20px" }}>
<Collapse
defaultActiveKey={activePanel}
onChange={onChange}
items={panels}
/>
</Col>
<Col xs={24} sm={8}>
<div
style={{
marginBottom: "10px",
}}
>
<FullScreenModal />
</div>
<AgreementHtml loading={loading} />
</Col>
</Row>
</div>
<AgreementHtml loading={loading} />
</Col>
</Row>
</div>
</div>
</div>
}
/>

<Route path="/learn" element={<LearnNow />}>
{/* ❕ learning-module routes */}
<Route path="intro" element={<LearnContent file="intro.md" />} />
<Route
path="module1"
element={<LearnContent file="module1.md" />}
/>
<Route
path="module2"
element={<LearnContent file="module2.md" />}
/>

<Route
path="module3"
element={<LearnContent file="module3.md" />}
/>
</Route>
</Routes>
</Content>
<Footer />
{!screens.md && (
Expand Down
123 changes: 123 additions & 0 deletions src/components/Content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import React, { useEffect, useState } from "react";
import ReactMarkdown from "react-markdown";
import rehypeRaw from "rehype-raw";
import rehypeHighlight from "rehype-highlight";
import { useNavigate } from "react-router-dom";
import {
ContentContainer,
NavigationButtons,
NavigationButton,
} from "../styles/components/Content";
import {
LoadingOutlined,
LeftOutlined,
RightOutlined,
} from "@ant-design/icons";
import { Spin } from "antd";
import fetchContent from "../utils/fetchContent";
import { steps } from "../constants/learningSteps/steps";

// markdown syntax highlighting theme
import "highlight.js/styles/github.css";

interface LearnContentProps {
file: string;
}

const LearnContent: React.FC<LearnContentProps> = ({ file }) => {
const [content, setContent] = useState<string | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const navigate = useNavigate();

useEffect(() => {
const loadContent = async () => {
try {
setLoading(true);
const content = await fetchContent(file);
setContent(content);
setError(null);
} catch (err: any) {
setError("Failed to load content");
} finally {
setLoading(false);
}
};

loadContent();
}, [file]);

const currentIndex = steps.findIndex((step) =>
step.link.includes(file.split(".")[0])
);

const handlePrevious = () => {
if (currentIndex > 0) {
navigate(steps[currentIndex - 1].link);
}
};

const handleNext = () => {
if (currentIndex < steps.length - 1) {
navigate(steps[currentIndex + 1].link);
}
};

if (loading) {
return (
<div
style={{
flex: 1,
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
>
<Spin
indicator={
<LoadingOutlined style={{ fontSize: 42, color: "#19c6c7" }} spin />
}
/>
</div>
);
}

if (error) {
return <div>Error: {error}</div>;
}

return (
<ContentContainer>
{content && (
<ReactMarkdown
rehypePlugins={[rehypeRaw, rehypeHighlight]}
components={{
img: ({ node, ...props }) => (
<div className="image-container">
<img {...props} alt={props.alt || ""} />
</div>
),
}}
>
{content}
</ReactMarkdown>
)}
<NavigationButtons>
<NavigationButton
onClick={handlePrevious}
disabled={currentIndex === 0}
>
<LeftOutlined /> Previous
</NavigationButton>
<NavigationButton
onClick={handleNext}
disabled={currentIndex === steps.length - 1}
>
Next <RightOutlined />
</NavigationButton>
</NavigationButtons>
</ContentContainer>
);
};

export default LearnContent;
2 changes: 1 addition & 1 deletion src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ const CustomFooter: React.FC = () => {
</Link>
<Link href="https://discord.com/invite/Zm99SKhhtA" target="_blank">
<Button
shape="round"
size="large"
style={{
padding: "5px 30px",
backgroundColor: "#19c6c7",
borderRadius: "5px",
color: "#050c40",
textAlign: "center",
border: "none",
Expand Down
2 changes: 1 addition & 1 deletion src/components/FullScreenModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const FullScreenModal: React.FC = () => {
const [open, setOpen] = useState(false);

return (
<div style={{ textAlign: "right" }}>
<div style={{ textAlign: "right" }} className="preview-element">
<FullscreenOutlined
style={{ fontSize: "24px", cursor: "pointer", marginRight: "10px" }}
onClick={() => setOpen(true)}
Expand Down
Loading
Loading