From 03c85f29c8c2d0ba78e40cbed22ee841007c69cb Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Fri, 6 Dec 2024 11:59:11 +0500 Subject: [PATCH] Make the question on the roadmap top sticky --- .../CustomRoadmap/FlowRoadmapRenderer.tsx | 6 ++- src/components/RoadmapTitleQuestion.tsx | 43 ++++++++++++++++--- src/pages/[roadmapId]/index.astro | 1 + 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/components/CustomRoadmap/FlowRoadmapRenderer.tsx b/src/components/CustomRoadmap/FlowRoadmapRenderer.tsx index f64bf7cad..61df6d708 100644 --- a/src/components/CustomRoadmap/FlowRoadmapRenderer.tsx +++ b/src/components/CustomRoadmap/FlowRoadmapRenderer.tsx @@ -17,7 +17,9 @@ import { totalRoadmapNodes } from '../../stores/roadmap.ts'; type FlowRoadmapRendererProps = { isEmbed?: boolean; - roadmap: RoadmapDocument; + roadmap: RoadmapDocument & { + canManage?: boolean + }; }; export function FlowRoadmapRenderer(props: FlowRoadmapRendererProps) { @@ -159,7 +161,7 @@ export function FlowRoadmapRenderer(props: FlowRoadmapRendererProps) { {hideRenderer && ( )} diff --git a/src/components/RoadmapTitleQuestion.tsx b/src/components/RoadmapTitleQuestion.tsx index fc14bb0e2..82096a0f0 100644 --- a/src/components/RoadmapTitleQuestion.tsx +++ b/src/components/RoadmapTitleQuestion.tsx @@ -8,24 +8,43 @@ import { import { useRef, useState } from 'react'; import { useOutsideClick } from '../hooks/use-outside-click'; import { markdownToHtml } from '../lib/markdown'; +import { cn } from '../lib/classname'; +import { useScrollPosition } from '../hooks/use-scroll-position'; type RoadmapTitleQuestionProps = { question: string; answer: string; + roadmapId?: string; }; export function RoadmapTitleQuestion(props: RoadmapTitleQuestionProps) { - const { question, answer } = props; + const { question, answer, roadmapId } = props; const [isAnswerVisible, setIsAnswerVisible] = useState(false); const ref = useRef(null); + const h2Ref = useRef(null); useOutsideClick(ref, () => { setIsAnswerVisible(false); }); + const { y: scrollY } = useScrollPosition(); + return ( -
+