From 2b6432ebf6657fc6956505aa34fed0dc284a5f1d Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Thu, 9 Dec 2021 16:39:09 +0100 Subject: [PATCH] Marking progress on roadmap --- .../md-renderer/mdx-components/heading.tsx | 12 ++-- components/roadmap/content-drawer.tsx | 67 +++++++++++++++++-- pages/[roadmap]/interactive.tsx | 17 +++-- pages/_app.tsx | 5 ++ 4 files changed, 82 insertions(+), 19 deletions(-) diff --git a/components/md-renderer/mdx-components/heading.tsx b/components/md-renderer/mdx-components/heading.tsx index 1bda10f03..ea94a5e40 100644 --- a/components/md-renderer/mdx-components/heading.tsx +++ b/components/md-renderer/mdx-components/heading.tsx @@ -70,12 +70,12 @@ const H6 = styled(H1).attrs({ as: 'h6' })` `; const Headings = { - h1: linkify(H1), - h2: linkify(H2), - h3: linkify(H3), - h4: linkify(H4), - h5: linkify(H5), - h6: linkify(H6) + h1: H1, + h2: H2, + h3: H3, + h4: H4, + h5: H5, + h6: H6 }; export default Headings; diff --git a/components/roadmap/content-drawer.tsx b/components/roadmap/content-drawer.tsx index 9d179809d..42b5b6c65 100644 --- a/components/roadmap/content-drawer.tsx +++ b/components/roadmap/content-drawer.tsx @@ -1,7 +1,8 @@ -import { Box, CloseButton } from '@chakra-ui/react'; +import { Box, Button, Flex, Text } from '@chakra-ui/react'; import { RemoveScroll } from 'react-remove-scroll'; import { RoadmapType } from '../../lib/roadmap'; import RoadmapGroup from '../../pages/[roadmap]/[group]'; +import { CheckIcon, CloseIcon, RepeatIcon } from '@chakra-ui/icons'; type ContentDrawerProps = { roadmap: RoadmapType; @@ -15,6 +16,8 @@ export function ContentDrawer(props: ContentDrawerProps) { return null; } + const isDone = localStorage.getItem(groupId) === 'done'; + return ( - + > + {!isDone && ( + + )} + {isDone && ( + + )} + + diff --git a/pages/[roadmap]/interactive.tsx b/pages/[roadmap]/interactive.tsx index 140c38b0c..c54a91b1e 100644 --- a/pages/[roadmap]/interactive.tsx +++ b/pages/[roadmap]/interactive.tsx @@ -12,6 +12,7 @@ import { RoadmapPageHeader } from '../../components/roadmap/roadmap-page-header' import { ContentDrawer } from '../../components/roadmap/content-drawer'; import { RoadmapError } from '../../components/roadmap/roadmap-error'; import { RoadmapLoader } from '../../components/roadmap/roadmap-loader'; +import { removeSortingInfo } from '../../lib/renderer/utils'; type RoadmapProps = { roadmap: RoadmapType; @@ -19,10 +20,6 @@ type RoadmapProps = { export function InteractiveRoadmapRenderer(props: RoadmapProps) { const { roadmap } = props; - if (!roadmap.jsonUrl) { - return null; - } - const { loading: isLoading, error: hasErrorLoading, get } = useFetch(); const roadmapRef = useRef(null); @@ -33,6 +30,10 @@ export function InteractiveRoadmapRenderer(props: RoadmapProps) { const [hasErrorRendering, setHasErrorRendering] = useState(false); useEffect(() => { + if (!roadmap.jsonUrl) { + return; + } + get(roadmap.jsonUrl) .then((roadmapJson) => { setRoadmapJson(roadmapJson); @@ -65,7 +66,7 @@ export function InteractiveRoadmapRenderer(props: RoadmapProps) { // e.g. 100-internet:how-does-the-internet-work // will be translated to `internet:how-does-the-internet-work` - setGroupId(groupId.replace(/^\d+-/, '')); + setGroupId(removeSortingInfo(groupId)); } window.addEventListener('keydown', keydownListener); @@ -104,8 +105,12 @@ export function InteractiveRoadmapRenderer(props: RoadmapProps) { }); }, [roadmapJson]); + if (!roadmap.jsonUrl) { + return null; + } + if (hasErrorLoading || hasErrorRendering) { - return + return ; } return ( diff --git a/pages/_app.tsx b/pages/_app.tsx index fcd7ac9c8..245a60b87 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -43,6 +43,11 @@ const GlobalStyles = css` &:hover > [fill="rgb(153,153,153)"] { fill: #646464; } &:hover > [fill="rgb(255,255,255)"] { fill: #d7d7d7; } } + + svg .done { + & rect { fill: #cbcbcb; } + & text { text-decoration: line-through; } + } `;