gonito-frontend/src/components/elements/MiniChallenge.js

89 lines
2.8 KiB
JavaScript
Raw Normal View History

2022-07-07 15:45:29 +02:00
import React from "react";
import {Container, FlexColumn, FlexRow, Grid} from "../../utils/containers";
2022-07-07 15:45:29 +02:00
import {Body, H3} from "../../utils/fonts";
import styled from "styled-components";
import IconLabel from "./IconLabel";
import {Link} from "react-router-dom";
2022-07-15 12:49:10 +02:00
import {CHALLENGE_PAGE, MINI_DESCRIPTION_RENDER} from "../../utils/globals";
2022-07-15 10:30:43 +02:00
import theme from "../../utils/theme";
2022-07-07 15:45:29 +02:00
const ChallengeStyle = styled(FlexColumn)`
padding: 12px;
border: 1px solid ${({theme}) => theme.colors.dark05};
cursor: pointer;
2022-07-08 09:36:10 +02:00
transition: transform 0.3s ease-in-out;
position: relative;
max-width: 420px;
2022-07-07 15:45:29 +02:00
* {
cursor: pointer;
}
&:hover {
2022-07-08 09:36:10 +02:00
transform: scale(1.05);
2022-07-07 15:45:29 +02:00
}
2022-07-14 09:34:56 +02:00
article {
width: 100%;
2022-07-14 09:34:56 +02:00
align-items: flex-start;
p {
width: 80%;
}
}
@media (min-width: ${({theme}) => theme.overMobile}) {
width: 360px;
padding: 20px;
justify-content: flex-start;
}
2022-07-07 15:45:29 +02:00
`;
const IconsGrid = styled(Grid)`
width: 100%;
grid-gap: 14px;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
@media (min-width: 500px) {
grid-template-columns: 1fr 1fr 1fr;
}
`;
const MiniChallenge = (props) => {
return (
2022-07-14 09:34:56 +02:00
<ChallengeStyle as={Link} to={`${CHALLENGE_PAGE}/${props.name}`}>
<FlexColumn as='article'>
<FlexRow margin='0 0 14px 0' gap='12px' width='100%' alignmentX='space-between'>
<H3 as='h3' width='85%'>
{props.title}
</H3>
{props.type ? <IconLabel type={props.type} size='30px'/> : 'xxx'}
</FlexRow>
2022-07-15 10:30:43 +02:00
<Container margin='0 0 14px 0' width='85%' height='1px' backgroundColor={theme.colors.dark05}/>
2022-07-14 09:34:56 +02:00
<Body as='p' margin='0 0 14px 0'>
2022-07-15 12:49:10 +02:00
{props.description ? MINI_DESCRIPTION_RENDER(props.description) : 'xxx'}
2022-07-14 09:34:56 +02:00
</Body>
<IconsGrid>
<IconLabel size='24px' gap='8px' type='metric'>
{props.metric ? props.metric : 'xxx'}
</IconLabel>
<IconLabel size='24px' gap='8px' type='bestScore'>
{props.bestScore ? props.bestScore : 'xxx'}
</IconLabel>
<IconLabel size='24px' gap='8px' type='deadline'>
{props.deadline ? props.deadline.slice(0, 10) : 'xxx'}
</IconLabel>
<IconLabel size='24px' gap='8px' type='baseline'>
{props.baseline ? props.baseline : 'xxx'}
</IconLabel>
{props.prize ? <IconLabel size='24px' gap='8px' type='prize'>
{props.prize}
</IconLabel> : ''}
</IconsGrid>
</FlexColumn>
2022-07-07 15:45:29 +02:00
</ChallengeStyle>
);
}
export default MiniChallenge;