From e8a3611dfb036174bfba0abb9b5e012ed77b42ce Mon Sep 17 00:00:00 2001 From: seccodesmith Date: Mon, 26 May 2025 18:09:09 +0200 Subject: [PATCH] feat: refactor BlogCard, ProjectCard, and ProjectModal components to use new type definitions and improve structure --- src/components/BlogCard.tsx | 16 +- src/components/ProjectCard.tsx | 27 +-- src/components/ProjectModal.tsx | 288 +++++++++++++++++--------------- src/data/blogPostsData.ts | 2 +- src/data/projectsData.ts | 2 +- src/pages/Projects.tsx | 7 +- src/untils/BlogPostProps.ts | 15 ++ src/untils/ProjectProps.ts | 39 +++++ 8 files changed, 214 insertions(+), 182 deletions(-) create mode 100644 src/untils/BlogPostProps.ts create mode 100644 src/untils/ProjectProps.ts diff --git a/src/components/BlogCard.tsx b/src/components/BlogCard.tsx index c15c786..198d36e 100644 --- a/src/components/BlogCard.tsx +++ b/src/components/BlogCard.tsx @@ -1,21 +1,7 @@ import { Link } from 'react-router-dom'; import styles from '@styles/BlogCard.module.scss'; -export interface BlogPostProps { - id: string; - slug: string; - title: string; - excerpt: string; - image: string; - category: string; - date: string; - author: string; - commentCount: number; - readTime: string; - featured?: boolean; - tags: string[]; - content: string; -} +import type {BlogPostProps} from '../untils/BlogPostProps'; interface BlogCardProps { post: BlogPostProps; diff --git a/src/components/ProjectCard.tsx b/src/components/ProjectCard.tsx index 01a5a48..25b582c 100644 --- a/src/components/ProjectCard.tsx +++ b/src/components/ProjectCard.tsx @@ -1,32 +1,7 @@ import React, { useEffect, useState } from 'react' import style from '@styles/Project.module.scss' - -export interface ProjectTech { - name: string; - icon: string; -} - -export interface ProjectProps { - id: string; - title: string; - description: string; - image: string; - category: Category[]; - featured?: boolean; - technologies: ProjectTech[]; - links: { - github?: string; - demo?: string; - }; -} - -export interface Category { - [key: string]: string; - fullName: string; - shortName: string; - icon: string; -} +import type {ProjectTech, Category, ProjectProps } from '../untils/ProjectProps' interface ProjectCardProps { project: ProjectProps; diff --git a/src/components/ProjectModal.tsx b/src/components/ProjectModal.tsx index 6cc4f03..52dd64f 100644 --- a/src/components/ProjectModal.tsx +++ b/src/components/ProjectModal.tsx @@ -1,154 +1,166 @@ -import type { ProjectProps } from './ProjectCard'; +import type { ProjectProps } from '../untils/ProjectProps'; import style from '@styles/Project.module.scss' interface ProjectModalProps { - project: ProjectProps | null; + project: ProjectProps | null; } export const ProjectModal: React.FC = ({ project }) => { - if (!project) return null; - - return ( -