|
| 1 | +import Link from "next/link"; |
| 2 | +import { MDXRemote } from "next-mdx-remote/rsc"; |
| 3 | +import rehypeRaw from "rehype-raw"; |
| 4 | +import remarkGfm from "remark-gfm"; |
| 5 | +import { CheckCircleIcon, ClockIcon } from "@heroicons/react/24/outline"; |
| 6 | +import SkillLevelIcon from "~~/app/_components/SkillLevelIcon"; |
| 7 | +import { roadmap } from "~~/app/learn-solidity/_components/data"; |
| 8 | +import type { CurriculumGroup as Group, RoadmapSection as SectionData } from "~~/app/learn-solidity/_components/data"; |
| 9 | +import type { ChallengeId } from "~~/services/database/config/types"; |
| 10 | +import { Challenges } from "~~/services/database/repositories/challenges"; |
| 11 | +import { CHALLENGE_METADATA } from "~~/utils/challenges"; |
| 12 | +import type { SkillLevel } from "~~/utils/challenges"; |
| 13 | + |
| 14 | +export const CurriculumSection = ({ challenges }: { challenges: Challenges }) => { |
| 15 | + const challengeById = Object.fromEntries(challenges.map(c => [c.id, c])); |
| 16 | + |
| 17 | + return ( |
| 18 | + <section id="curriculum" className="container mx-auto px-6 py-16"> |
| 19 | + <div className="text-center mb-12"> |
| 20 | + <h2 className="text-3xl md:text-4xl font-bold mb-4">Your Solidity Tutorial Roadmap</h2> |
| 21 | + <p className="text-base-content/80 max-w-3xl mx-auto"> |
| 22 | + Follow our structured learning path from your first smart contract to advanced Web3 concepts. |
| 23 | + </p> |
| 24 | + </div> |
| 25 | + |
| 26 | + {(["fundamentals", "advanced"] as Group[]).map((group: Group) => { |
| 27 | + const groupLabel = group === "fundamentals" ? "🧱 Solidity Fundamentals" : "⚡ Advanced Solidity Concepts"; |
| 28 | + const groupDesc = |
| 29 | + group === "fundamentals" |
| 30 | + ? "Master the core concepts of Ethereum development and smart contract basics." |
| 31 | + : "Build complex DeFi protocols and advanced smart contract systems"; |
| 32 | + |
| 33 | + return ( |
| 34 | + <div key={group} className="mb-12 rounded-2xl p-4 md:p-6 bg-accent mx-auto lg:max-w-5xl xl:max-w-6xl"> |
| 35 | + <div className="text-center mb-5"> |
| 36 | + <h3 className="text-2xl md:text-3xl font-bold text-[#026262]">{groupLabel}</h3> |
| 37 | + <p className="text-[#026262]">{groupDesc}</p> |
| 38 | + </div> |
| 39 | + |
| 40 | + <div className="space-y-5"> |
| 41 | + {roadmap |
| 42 | + .filter((s: SectionData) => s.group === group) |
| 43 | + .map((section: SectionData) => { |
| 44 | + return ( |
| 45 | + <div key={section.title} className="card bg-base-100 shadow-md overflow-hidden"> |
| 46 | + <div className="card-body p-5"> |
| 47 | + <div className="flex items-start"> |
| 48 | + <div> |
| 49 | + <h4 className="card-title text-xl mb-1">{section.title}</h4> |
| 50 | + <p className="text-sm text-base-content/80">{section.description}</p> |
| 51 | + </div> |
| 52 | + </div> |
| 53 | + |
| 54 | + <div className="grid md:grid-cols-2 gap-5 mt-4 lg:max-w-none"> |
| 55 | + <div> |
| 56 | + <h5 className="font-semibold mb-2 text-primary">🎯 Challenges</h5> |
| 57 | + <ul className="space-y-2"> |
| 58 | + {section.challengeIds.map((id: ChallengeId) => { |
| 59 | + const ch = challengeById[id]; |
| 60 | + if (!ch) return null; |
| 61 | + |
| 62 | + const meta = CHALLENGE_METADATA[id]; |
| 63 | + const desc = meta?.description || ch.description; |
| 64 | + |
| 65 | + return ( |
| 66 | + <li key={id}> |
| 67 | + <Link |
| 68 | + href={`/challenge/${ch.id}`} |
| 69 | + className="block p-3 rounded-lg bg-base-200 hover:bg-base-300 transition-colors" |
| 70 | + > |
| 71 | + <div className="flex items-center gap-3"> |
| 72 | + <div className="min-w-0"> |
| 73 | + <div className="font-medium">{ch.challengeName}</div> |
| 74 | + <div className="text-xs text-base-content/70 leading-snug">{desc}</div> |
| 75 | + </div> |
| 76 | + </div> |
| 77 | + </Link> |
| 78 | + </li> |
| 79 | + ); |
| 80 | + })} |
| 81 | + </ul> |
| 82 | + </div> |
| 83 | + <div> |
| 84 | + <h5 className="font-semibold mb-2 text-primary">📚 Recommended Resources</h5> |
| 85 | + <ul className="space-y-1 list-disc pl-5 marker:text-base-content/50"> |
| 86 | + {(() => { |
| 87 | + const guideLinks = section.challengeIds.flatMap( |
| 88 | + id => CHALLENGE_METADATA[id]?.guides ?? [], |
| 89 | + ); |
| 90 | + const helpfulLinks = section.challengeIds |
| 91 | + .flatMap(id => CHALLENGE_METADATA[id]?.helpfulLinks ?? []) |
| 92 | + .filter( |
| 93 | + l => !l.url || (!l.url.startsWith("/guides") && !l.url.includes("/challenge/")), |
| 94 | + ) |
| 95 | + .map(l => ({ title: l.text, url: l.url ?? "#" })); |
| 96 | + const combined = [...guideLinks, ...helpfulLinks]; |
| 97 | + const uniqueByUrl = Array.from( |
| 98 | + new Map(combined.map(item => [item.url, item])).values(), |
| 99 | + ); |
| 100 | + return uniqueByUrl.map(item => ( |
| 101 | + <li key={item.url} className="pl-1 text-sm text-primary"> |
| 102 | + <Link href={item.url} className="hover:underline"> |
| 103 | + {item.title} |
| 104 | + </Link> |
| 105 | + </li> |
| 106 | + )); |
| 107 | + })()} |
| 108 | + </ul> |
| 109 | + </div> |
| 110 | + </div> |
| 111 | + |
| 112 | + <div className="mt-4 rounded-lg p-3 md:p-4 bg-base-200"> |
| 113 | + <div className="flex flex-col lg:flex-row gap-6 items-stretch"> |
| 114 | + <div className="lg:basis-[60%] p-2"> |
| 115 | + <h6 className="text-base font-semibold text-primary mb-2">Skills you'll gain</h6> |
| 116 | + <ul className="space-y-2"> |
| 117 | + {section.challengeIds |
| 118 | + .flatMap(id => CHALLENGE_METADATA[id]?.skills ?? []) |
| 119 | + .map(s => ( |
| 120 | + <li key={s} className="flex items-center gap-2 text-sm"> |
| 121 | + <CheckCircleIcon className="w-5 h-5 text-primary self-start shrink-0" /> |
| 122 | + <span className="inline"> |
| 123 | + <MDXRemote |
| 124 | + source={s} |
| 125 | + options={{ |
| 126 | + mdxOptions: { |
| 127 | + rehypePlugins: [rehypeRaw], |
| 128 | + remarkPlugins: [remarkGfm], |
| 129 | + format: "md", |
| 130 | + }, |
| 131 | + }} |
| 132 | + components={{ |
| 133 | + p: (props: any) => <p className="m-0 inline">{props.children}</p>, |
| 134 | + }} |
| 135 | + /> |
| 136 | + </span> |
| 137 | + </li> |
| 138 | + ))} |
| 139 | + </ul> |
| 140 | + </div> |
| 141 | + <div className="lg:basis-[40%] grid grid-cols-1 md:grid-cols-2 gap-4 min-w-fit items-center text-sm"> |
| 142 | + <div className="flex items-center gap-3 text-sm"> |
| 143 | + <SkillLevelIcon |
| 144 | + level={CHALLENGE_METADATA[section.challengeIds[0]]?.skillLevel as SkillLevel} |
| 145 | + className="w-6 h-6 text-primary" |
| 146 | + /> |
| 147 | + <div> |
| 148 | + <div className="font-medium">Skill level</div> |
| 149 | + <div className="text-base-content/70"> |
| 150 | + {CHALLENGE_METADATA[section.challengeIds[0]]?.skillLevel || "Beginner"} |
| 151 | + </div> |
| 152 | + </div> |
| 153 | + </div> |
| 154 | + <div className="flex items-center gap-3 text-sm"> |
| 155 | + <ClockIcon className="w-6 h-6 text-primary" /> |
| 156 | + <div> |
| 157 | + <div className="font-medium">Time to complete</div> |
| 158 | + <div className="text-base-content/70"> |
| 159 | + {CHALLENGE_METADATA[section.challengeIds[0]]?.timeToComplete || ""} |
| 160 | + </div> |
| 161 | + </div> |
| 162 | + </div> |
| 163 | + </div> |
| 164 | + </div> |
| 165 | + </div> |
| 166 | + </div> |
| 167 | + </div> |
| 168 | + ); |
| 169 | + })} |
| 170 | + </div> |
| 171 | + </div> |
| 172 | + ); |
| 173 | + })} |
| 174 | + </section> |
| 175 | + ); |
| 176 | +}; |
0 commit comments