Files
web2.0-frontend/src/components/ContactCard.tsx
T
2022-02-16 14:57:26 +02:00

86 lines
1.5 KiB
TypeScript

import React from "react";
import Image from "next/image";
import styled from "styled-components";
import colors from "@theme/colors";
const Card = styled.article`
display: flex;
justify-content: space-between;
flex: 1 0 50%;
padding: 0.5rem;
color: ${colors.darkBlue};
`;
const Row = styled.div`
display: flex;
flex-flow: row nowrap;
`;
const ImageContainer = styled.div`
position: relative;
height: 125px;
width: 125px;
flex-shrink: 0;
img {
padding: 0.5rem !important;
border-radius: 15%;
}
`;
const Info = styled.div`
display: flex;
flex-direction: column;
align-items: flex-start;
margin-left: -20px;
min-width: 150px;
padding: 2rem;
color: ${colors.darkBlue};
& > p {
font-size: 1.0rem;
margin: 0;
}
& > h3 {
font-size: 1.2rem;
font-weight: 500;
}
`;
interface ContactCardProps {
name: string;
phone: string;
email: string;
image: string;
role_fi: string;
role_en: string;
}
const ContactCard: React.FC<ContactCardProps> = ({
name, phone, email, image, role_fi, role_en,
}) => (
<Card>
<Row>
{image ? (
<ImageContainer>
<Image
src={image}
alt={name}
layout="fill"
objectFit="scale-down"
/>
</ImageContainer>
) : null}
<Info>
<h3>{name}</h3>
<p>{role_fi || role_en}</p>
{phone ? <p>{phone}</p> : null}
{email ? <p>{email}</p> : null}
</Info>
</Row>
</Card>
);
export default ContactCard;