From 0d7e346f45f2fa7c7483a919a63e8baaec8788a1 Mon Sep 17 00:00:00 2001 From: ljc1991 Date: Sat, 28 Oct 2023 17:02:05 +0800 Subject: [PATCH] refactor: extract job card and event card to create NonProjectCard component --- homepage/public/css/style.css | 4 +- homepage/src/components/cards/card.jsx | 108 ++---------------- .../src/components/cards/nonProjectCard.jsx | 39 +++++++ 3 files changed, 51 insertions(+), 100 deletions(-) create mode 100644 homepage/src/components/cards/nonProjectCard.jsx diff --git a/homepage/public/css/style.css b/homepage/public/css/style.css index 11128874..932a30e2 100644 --- a/homepage/public/css/style.css +++ b/homepage/public/css/style.css @@ -943,9 +943,7 @@ code { width: 10rem; border-radius: 50%; } -.avatar-event { - background-color: #f1c287; -} + @media only screen and (max-width: 991px) { .blogs-list .item { width: 50% !important; diff --git a/homepage/src/components/cards/card.jsx b/homepage/src/components/cards/card.jsx index 8e885d42..929c635d 100644 --- a/homepage/src/components/cards/card.jsx +++ b/homepage/src/components/cards/card.jsx @@ -1,101 +1,10 @@ import Image from 'next/image'; +import NonProjectCard from './nonProjectCard'; import { ParseMarkdownAndHtml } from '../parseMarkdownAndHtml'; const Card = ({ card }) => { - if (card.data.type === 'event') { - return ( -
-
-

{card.data.title}

-
-
-
- {card.data.title} -
-
- {card.data.description} - - {card.content} - -
-
-
- ); - } else if (card.data.type === 'job') { - const color = {}; - - switch (card.data.tags[0]) { - case 'civil servants': - color.avatar = '#b1bb95'; - color.background = '#8b9f6d'; - color.border = '#6f8d50'; - break; - case 'engineer': - color.avatar = '#95a2b2'; - color.background = '#5e7d93'; - color.border = '#2a6780'; - break; - case 'writer': - color.avatar = '#94a8a1'; - color.background = '#62867f'; - color.border = '#287168'; - break; - case 'legal': - color.avatar = '#d4ab8d'; - color.background = '#c2865f'; - color.border = '#b76a46'; - break; - case 'designer': - color.avatar = '#d1bb8f'; - color.background = '#be9f5f'; - color.border = '#b18b42'; - break; - case 'marketing': - color.avatar = '#c1907b'; - color.background = '#aa644f'; - color.border = '#984334'; - break; - case 'advocator': - color.avatar = '#9a91ab'; - color.background = '#6c688b'; - color.border = '#474c79'; - break; - } - - return ( -
-
-

{card.data.title}

-
-
-
- {card.data.title} -
-
- {card.data.description} - - {card.content} - -
-
-
- ); + if (card.data.type !== 'project') { + return ; } else { return (
@@ -103,15 +12,20 @@ const Card = ({ card }) => {

{card.data.title}

- {card.data.title} + {card.data.title}
- { + {/* { card.data.avatarList.map((avatar) => {
{avatar.data.title}
}) - } + } */} {card.data.description} {card.content} diff --git a/homepage/src/components/cards/nonProjectCard.jsx b/homepage/src/components/cards/nonProjectCard.jsx new file mode 100644 index 00000000..414b7f63 --- /dev/null +++ b/homepage/src/components/cards/nonProjectCard.jsx @@ -0,0 +1,39 @@ +import Image from 'next/image'; +import { ParseMarkdownAndHtml } from '../parseMarkdownAndHtml'; + +const NonProjectCard = ({ card }) => ( +
+
+

{card.data.title}

+
+
+
+ {card.data.title} +
+
+ {card.data.description} + + {card.content} + +
+
+
+); + +export default NonProjectCard;