mirror of
https://github.com/hazemKrimi/personal-website.git
synced 2026-05-01 18:00:26 +00:00
Update card styles
This commit is contained in:
+32
-10
@@ -1,17 +1,19 @@
|
|||||||
import { FC, useContext } from 'react';
|
import { FC, useContext } from 'react';
|
||||||
import { DarkModeContext } from '../components/DarkMode';
|
import { DarkModeContext } from '../components/DarkMode';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import Image from 'next/image';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
image?: string;
|
||||||
tags?: string[];
|
tags?: string[];
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StyledCard = styled.div<{ dark: boolean }>`
|
const StyledCard = styled.div<{ dark: boolean }>`
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 1rem;
|
padding: 1rem 0rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: grid;
|
display: grid;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -20,7 +22,7 @@ const StyledCard = styled.div<{ dark: boolean }>`
|
|||||||
transition: box-shadow 250ms ease-in-out, color 0ms ease-in-out;
|
transition: box-shadow 250ms ease-in-out, color 0ms ease-in-out;
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
padding: 0.5rem;
|
padding: 0.5rem 0rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
@@ -29,6 +31,25 @@ const StyledCard = styled.div<{ dark: boolean }>`
|
|||||||
box-shadow: ${({ dark }) => !dark && '5px 2px 26px 6px rgba(21, 115, 202, 0.30)'};
|
box-shadow: ${({ dark }) => !dark && '5px 2px 26px 6px rgba(21, 115, 202, 0.30)'};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
|
display: grid;
|
||||||
|
row-gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3,
|
||||||
|
p,
|
||||||
|
.tags-wrapper {
|
||||||
|
padding: 0rem 1rem;
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
padding: 0rem 0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 1.3rem;
|
||||||
|
}
|
||||||
|
|
||||||
.tags-wrapper {
|
.tags-wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@@ -36,26 +57,27 @@ const StyledCard = styled.div<{ dark: boolean }>`
|
|||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
h3 {
|
|
||||||
font-size: 1.3rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
span {
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Card: FC<Props> = ({ title, description, tags, onClick }) => {
|
const Card: FC<Props> = ({ title, description, image, tags, onClick }) => {
|
||||||
const { dark } = useContext(DarkModeContext);
|
const { dark } = useContext(DarkModeContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledCard dark={dark} onClick={onClick}>
|
<StyledCard dark={dark} onClick={onClick}>
|
||||||
<div>
|
<div>
|
||||||
<h3>{title}</h3>
|
<h3>{title}</h3>
|
||||||
|
{image && (
|
||||||
|
<Image src={image} className='image' width='auto' height='auto' layout='responsive' />
|
||||||
|
)}
|
||||||
<p>{description}</p>
|
<p>{description}</p>
|
||||||
<div className='tags-wrapper'>
|
{tags && (
|
||||||
{tags && tags.map((tag, index) => <span key={index}>#{tag} </span>)}
|
<div className='tags-wrapper'>
|
||||||
</div>
|
{tags && tags.map((tag, index) => <span key={index}>#{tag} </span>)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</StyledCard>
|
</StyledCard>
|
||||||
);
|
);
|
||||||
|
|||||||
+10
-6
@@ -106,9 +106,11 @@ const Index: FC<Props> = ({ blogPosts, portfolioProjects }) => {
|
|||||||
<div className='portfolio'>
|
<div className='portfolio'>
|
||||||
<div className='projects-wrapper'>
|
<div className='projects-wrapper'>
|
||||||
{portfolioProjects.length !== 0 ? (
|
{portfolioProjects.length !== 0 ? (
|
||||||
portfolioProjects.map(({ slug, ...rest }) => (
|
portfolioProjects
|
||||||
<Card {...rest} key={slug} onClick={() => router.push(`/portfolio/${slug}`)} />
|
.slice(0, 3)
|
||||||
))
|
.map(({ slug, ...rest }) => (
|
||||||
|
<Card {...rest} key={slug} onClick={() => router.push(`/portfolio/${slug}`)} />
|
||||||
|
))
|
||||||
) : (
|
) : (
|
||||||
<h4>Nothing for now</h4>
|
<h4>Nothing for now</h4>
|
||||||
)}
|
)}
|
||||||
@@ -121,9 +123,11 @@ const Index: FC<Props> = ({ blogPosts, portfolioProjects }) => {
|
|||||||
<div className='blog'>
|
<div className='blog'>
|
||||||
<div className='articles-wrapper'>
|
<div className='articles-wrapper'>
|
||||||
{blogPosts.length !== 0 ? (
|
{blogPosts.length !== 0 ? (
|
||||||
blogPosts.map(({ slug, ...rest }) => (
|
blogPosts
|
||||||
<Card {...rest} key={slug} onClick={() => router.push(`/blog/${slug}`)} />
|
.slice(0, 3)
|
||||||
))
|
.map(({ slug, ...rest }) => (
|
||||||
|
<Card {...rest} key={slug} onClick={() => router.push(`/blog/${slug}`)} />
|
||||||
|
))
|
||||||
) : (
|
) : (
|
||||||
<h4>Nothing for now</h4>
|
<h4>Nothing for now</h4>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user