2021-10-26 21:23:08 -07:00
|
|
|
import React from 'react';
|
2022-01-27 10:33:12 -08:00
|
|
|
import { Image, Typography, Button } from 'antd';
|
2021-10-26 21:23:08 -07:00
|
|
|
import styled from 'styled-components';
|
|
|
|
import { ANTD_GRAY } from '../entity/shared/constants';
|
|
|
|
import { formatNumber } from './formatNumber';
|
|
|
|
|
2022-01-27 10:33:12 -08:00
|
|
|
const Container = styled(Button)`
|
|
|
|
margin-right: 12px;
|
|
|
|
margin-left: 12px;
|
2021-10-26 21:23:08 -07:00
|
|
|
margin-bottom: 12px;
|
|
|
|
width: 160px;
|
|
|
|
height: 140px;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
border-radius: 4px;
|
|
|
|
align-items: center;
|
|
|
|
flex-direction: column;
|
|
|
|
border: 1px solid ${ANTD_GRAY[4]};
|
|
|
|
box-shadow: ${(props) => props.theme.styles['box-shadow']};
|
|
|
|
&&:hover {
|
|
|
|
box-shadow: ${(props) => props.theme.styles['box-shadow-hover']};
|
|
|
|
}
|
2022-02-22 20:32:33 -08:00
|
|
|
white-space: unset;
|
2021-10-26 21:23:08 -07:00
|
|
|
`;
|
|
|
|
|
|
|
|
const PlatformLogo = styled(Image)`
|
|
|
|
max-height: 32px;
|
|
|
|
width: auto;
|
|
|
|
object-fit: contain;
|
|
|
|
background-color: transparent;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const CountText = styled(Typography.Text)`
|
|
|
|
font-size: 18px;
|
|
|
|
color: ${ANTD_GRAY[8]};
|
|
|
|
`;
|
|
|
|
|
|
|
|
const LogoContainer = styled.div``;
|
|
|
|
|
|
|
|
const TitleContainer = styled.div``;
|
|
|
|
|
2022-02-22 20:32:33 -08:00
|
|
|
const Title = styled(Typography.Title)`
|
|
|
|
word-break: break-word;
|
|
|
|
`;
|
2021-10-26 21:23:08 -07:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
logoUrl?: string;
|
|
|
|
logoComponent?: React.ReactNode;
|
|
|
|
name: string;
|
|
|
|
count?: number;
|
2022-01-27 10:33:12 -08:00
|
|
|
onClick?: () => void;
|
2021-10-26 21:23:08 -07:00
|
|
|
};
|
|
|
|
|
2022-01-27 10:33:12 -08:00
|
|
|
export const LogoCountCard = ({ logoUrl, logoComponent, name, count, onClick }: Props) => {
|
2021-10-26 21:23:08 -07:00
|
|
|
return (
|
2022-01-27 10:33:12 -08:00
|
|
|
<Container type="link" onClick={onClick}>
|
2021-10-26 21:23:08 -07:00
|
|
|
<LogoContainer>
|
|
|
|
{(logoUrl && <PlatformLogo preview={false} src={logoUrl} alt={name} />) || logoComponent}
|
|
|
|
</LogoContainer>
|
|
|
|
<TitleContainer>
|
2022-02-22 20:32:33 -08:00
|
|
|
<Title
|
|
|
|
ellipsis={{
|
|
|
|
rows: 4,
|
|
|
|
}}
|
|
|
|
level={5}
|
|
|
|
>
|
|
|
|
{name}
|
|
|
|
</Title>
|
2021-10-26 21:23:08 -07:00
|
|
|
</TitleContainer>
|
2022-05-30 00:26:07 -04:00
|
|
|
{count !== undefined && <CountText>{formatNumber(count)}</CountText>}
|
2021-10-26 21:23:08 -07:00
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
};
|