From aad5a87db23023a3302b228c5c566a0f36cf4f74 Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Wed, 13 Jan 2021 23:13:07 +0100 Subject: [PATCH] Add card component --- components/Card.tsx | 63 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 components/Card.tsx diff --git a/components/Card.tsx b/components/Card.tsx new file mode 100644 index 0000000..709c17f --- /dev/null +++ b/components/Card.tsx @@ -0,0 +1,63 @@ +import { FC, useContext } from 'react'; +import { DarkModeContext } from '../components/DarkMode'; +import styled from 'styled-components'; + +interface Props { + title: string; + description: string; + tags?: string[]; +} + +const StyledCard = styled.div<{ dark: boolean }>` + cursor: pointer; + padding: 1rem; + width: 100%; + display: grid; + align-items: center; + background: ${({ dark, theme }) => (dark ? '#2f2f2f' : theme.colors.dark.text)}; + box-shadow: ${({ dark }) => !dark && `6px 2px 15px 0px rgba(0, 0, 0, 0.15)`}; + transition: box-shadow 250ms ease-in-out, color 0ms ease-in-out; + + @media (max-width: 768px) { + padding: 0.5rem; + } + + &:hover { + background: #3889d4; + color: ${({ theme }) => theme.colors.dark.text}; + box-shadow: ${({ dark }) => !dark && '5px 2px 26px 6px rgba(21, 115, 202, 0.30)'}; + } + + .tags-wrapper { + display: flex; + flex-direction: row; + align-content: center; + flex-wrap: wrap; + } + + h3 { + font-size: 1.3rem; + } + + span { + font-size: 0.7rem; + } +`; + +const Card: FC = ({ title, description, tags }) => { + const { dark } = useContext(DarkModeContext); + + return ( + +
+

{title}

+

{description}

+
+ {tags && tags.map((tag, index) => #{tag} )} +
+
+
+ ); +}; + +export default Card;