From 95e4cef2e4df0a8382b3b83f3c012f4aba3bb73d Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Thu, 18 Aug 2022 15:44:03 +0400 Subject: [PATCH] Refactor featured roadmap item --- components/home/featured-roadmaps-list.tsx | 32 ++++++++++++++++++ pages/index.tsx | 38 +++++----------------- 2 files changed, 41 insertions(+), 29 deletions(-) create mode 100644 components/home/featured-roadmaps-list.tsx diff --git a/components/home/featured-roadmaps-list.tsx b/components/home/featured-roadmaps-list.tsx new file mode 100644 index 000000000..6d7c69d24 --- /dev/null +++ b/components/home/featured-roadmaps-list.tsx @@ -0,0 +1,32 @@ +import { RoadmapType } from '../../lib/roadmap'; +import { Box, SimpleGrid, Tag } from '@chakra-ui/react'; +import { HomeRoadmapItem } from '../roadmap/home-roadmap-item'; + +type FeaturedRoadmapsListProps = { + roadmaps: RoadmapType[]; + title: string; + +}; + +export function FeaturedRoadmapsList(props: FeaturedRoadmapsListProps) { + const { roadmaps, title } = props; + + return ( + <> + {title} + + {roadmaps.map((roadmap: RoadmapType, counter: number) => ( + + ))} + + + ); +} diff --git a/pages/index.tsx b/pages/index.tsx index 8212ed0f1..8a7443a2a 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -12,6 +12,7 @@ import { getAllGuides, GuideType } from '../lib/guide'; import { getAllVideos, VideoType } from '../lib/video'; import Helmet from '../components/helmet'; import { PageWrapper } from '../components/page-wrapper'; +import { FeaturedRoadmapsList } from '../components/home/featured-roadmaps-list'; type HomeProps = { roadmaps: RoadmapType[]; @@ -46,36 +47,15 @@ export default function Home(props: HomeProps) { - Role Based Roadmaps - - {roadmaps.filter(roadmap => roadmap.type === 'role').map((roadmap: RoadmapType, counter: number) => ( - - ))} - - - Tool Based Skill Trees + roadmap.type === 'role')} + title={'Role Based Roadmaps' } + /> - - {roadmaps.filter(roadmap => roadmap.type === 'tool').map((roadmap: RoadmapType, counter: number) => ( - - ))} - + roadmap.type === 'tool')} + title={'Tool Based Skill Trees' } + />