2022-07-07 15:45:29 +02:00
|
|
|
import React from "react";
|
2022-07-12 13:37:28 +02:00
|
|
|
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";
|
2022-07-15 13:45:51 +02:00
|
|
|
import IconLabel from "../elements/IconLabel";
|
2022-07-12 16:12:18 +02:00
|
|
|
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-27 15:08:38 +02:00
|
|
|
import PropsTypes from "prop-types";
|
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;
|
2022-07-12 16:12:18 +02:00
|
|
|
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-12 16:12:18 +02:00
|
|
|
|
2022-07-14 09:34:56 +02:00
|
|
|
article {
|
2022-07-12 16:12:18 +02:00
|
|
|
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-12 16:12:18 +02:00
|
|
|
}
|
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>
|
2022-07-18 11:19:23 +02:00
|
|
|
<IconLabel size='24px' gap='8px' type='deadline' time={props.deadline}>
|
2022-07-14 09:34:56 +02:00
|
|
|
{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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-07-27 15:08:38 +02:00
|
|
|
MiniChallenge.propTypes = {
|
|
|
|
name: PropsTypes.string,
|
|
|
|
title: PropsTypes.string,
|
|
|
|
type: PropsTypes.string,
|
|
|
|
description: PropsTypes.string,
|
|
|
|
metric: PropsTypes.string,
|
|
|
|
bestScore: PropsTypes.string,
|
|
|
|
deadline: PropsTypes.string,
|
|
|
|
baseline: PropsTypes.string,
|
|
|
|
prize: PropsTypes.string
|
|
|
|
};
|
|
|
|
|
|
|
|
MiniChallenge.defaultProps = {
|
|
|
|
name: 'xxx',
|
|
|
|
title: 'xxx',
|
|
|
|
type: 'xxx',
|
|
|
|
description: 'xxx',
|
|
|
|
metric: 'xxx',
|
|
|
|
bestScore: 'xxx',
|
|
|
|
deadline: 'xxx',
|
|
|
|
baseline: 'xxx',
|
|
|
|
prize: 'xxx'
|
|
|
|
}
|
|
|
|
|
2022-07-07 15:45:29 +02:00
|
|
|
export default MiniChallenge;
|