2022-07-07 15:45:29 +02:00
|
|
|
import React from "react";
|
|
|
|
import {FlexRow, Svg} from "../../utils/containers";
|
2022-07-08 11:55:15 +02:00
|
|
|
import {Body, Medium} from "../../utils/fonts";
|
|
|
|
import metricIco from '../../assets/metric_ico.svg';
|
|
|
|
import coinsIco from '../../assets/coins_ico.svg';
|
|
|
|
import baselineIco from '../../assets/baseline_ico.svg';
|
|
|
|
import clockIco from '../../assets/clock_ico.svg';
|
|
|
|
import cupIco from '../../assets/cup_ico.svg';
|
|
|
|
import styled from "styled-components";
|
2022-07-08 12:22:52 +02:00
|
|
|
import textIco from '../../assets/text_ico.svg';
|
|
|
|
import tabularIco from '../../assets/tabular_ico.svg';
|
|
|
|
import imageIco from '../../assets/image_ico.svg';
|
2022-07-08 11:55:15 +02:00
|
|
|
|
|
|
|
const HoverLabel = styled(Body)`
|
|
|
|
position: absolute;
|
|
|
|
top: -32px;
|
2022-07-08 14:09:33 +02:00
|
|
|
left: ${({type}) => (type === 'text' || type === 'image' || type === 'tabular') ? '-32px' : 0};
|
|
|
|
width: 100px;
|
2022-07-08 11:55:15 +02:00
|
|
|
display: none;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
border-radius: 6px;
|
|
|
|
padding: 4px 12px;
|
|
|
|
background-color: ${({theme}) => theme.colors.green};
|
|
|
|
color: ${({theme}) => theme.colors.white};
|
|
|
|
`;
|
|
|
|
|
|
|
|
const renderHoverLabel = (type) => {
|
2022-07-08 12:22:52 +02:00
|
|
|
const hoverLabel = (label) =>
|
2022-07-08 14:09:33 +02:00
|
|
|
<HoverLabel className='HoverLabel' type={type}>
|
2022-07-08 12:22:52 +02:00
|
|
|
{label}
|
|
|
|
</HoverLabel>;
|
|
|
|
|
2022-07-08 11:55:15 +02:00
|
|
|
switch (type) {
|
|
|
|
case 'metric':
|
2022-07-08 12:22:52 +02:00
|
|
|
return hoverLabel('metric');
|
2022-07-08 11:55:15 +02:00
|
|
|
case 'prize':
|
2022-07-08 12:22:52 +02:00
|
|
|
return hoverLabel('prize');
|
2022-07-08 11:55:15 +02:00
|
|
|
case 'baseline':
|
2022-07-08 12:22:52 +02:00
|
|
|
return hoverLabel('baseline');
|
2022-07-12 13:37:28 +02:00
|
|
|
case 'deadline':
|
|
|
|
return hoverLabel('deadline');
|
2022-07-08 11:55:15 +02:00
|
|
|
case 'bestScore':
|
2022-07-08 12:22:52 +02:00
|
|
|
return hoverLabel('best score');
|
|
|
|
case 'text':
|
|
|
|
return hoverLabel('text data');
|
|
|
|
case 'image':
|
|
|
|
return hoverLabel('image data');
|
|
|
|
case 'tabular':
|
|
|
|
return hoverLabel('tabular data');
|
2022-07-12 13:37:28 +02:00
|
|
|
default:
|
|
|
|
return '';
|
2022-07-08 11:55:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const renderIco = (type) => {
|
|
|
|
switch (type) {
|
|
|
|
case 'metric':
|
|
|
|
return metricIco;
|
|
|
|
case 'prize':
|
|
|
|
return coinsIco;
|
|
|
|
case 'baseline':
|
|
|
|
return baselineIco;
|
2022-07-12 13:37:28 +02:00
|
|
|
case 'deadline':
|
2022-07-08 11:55:15 +02:00
|
|
|
return clockIco;
|
|
|
|
case 'bestScore':
|
|
|
|
return cupIco;
|
2022-07-08 12:22:52 +02:00
|
|
|
case 'text':
|
|
|
|
return textIco;
|
|
|
|
case 'image':
|
|
|
|
return imageIco;
|
|
|
|
case 'tabular':
|
|
|
|
return tabularIco;
|
2022-07-12 13:37:28 +02:00
|
|
|
default:
|
|
|
|
return '';
|
2022-07-08 11:55:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const IconLabelStyle = styled(FlexRow)`
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
.HoverLabel {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2022-07-07 15:45:29 +02:00
|
|
|
|
|
|
|
const IconLabel = (props) => {
|
|
|
|
return (
|
2022-07-08 11:55:15 +02:00
|
|
|
<IconLabelStyle gap={props.gap}>
|
2022-07-08 11:03:21 +02:00
|
|
|
<Svg width={props.size} height={props.size}
|
2022-07-08 11:55:15 +02:00
|
|
|
src={renderIco(props.type)}/>
|
2022-07-08 12:22:52 +02:00
|
|
|
{props.children ?
|
|
|
|
<Medium as='p'>
|
|
|
|
{props.children}
|
|
|
|
</Medium> : ''}
|
2022-07-08 11:55:15 +02:00
|
|
|
{renderHoverLabel(props.type)}
|
|
|
|
</IconLabelStyle>
|
2022-07-07 15:45:29 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default IconLabel;
|