You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.0 KiB
47 lines
1.0 KiB
import { CaretDownOutlined, CaretUpOutlined } from '@ant-design/icons';
|
|
import classNames from 'classnames';
|
|
import React from 'react';
|
|
import useStyles from './index.style';
|
|
|
|
export type TrendProps = {
|
|
colorful?: boolean;
|
|
flag: 'up' | 'down';
|
|
style?: React.CSSProperties;
|
|
reverseColor?: boolean;
|
|
className?: string;
|
|
children?: React.ReactNode;
|
|
};
|
|
|
|
const Trend: React.FC<TrendProps> = ({
|
|
colorful = true,
|
|
reverseColor = false,
|
|
flag,
|
|
children,
|
|
className,
|
|
...rest
|
|
}) => {
|
|
const { styles } = useStyles();
|
|
const classString = classNames(
|
|
styles.trendItem,
|
|
{
|
|
[styles.trendItemGrey]: !colorful,
|
|
[styles.reverseColor]: reverseColor && colorful,
|
|
},
|
|
className,
|
|
);
|
|
return (
|
|
<div
|
|
{...rest}
|
|
className={classString}
|
|
title={typeof children === 'string' ? children : ''}
|
|
>
|
|
<span>{children}</span>
|
|
{flag && (
|
|
<span className={styles[flag]}>
|
|
{flag === 'up' ? <CaretUpOutlined /> : <CaretDownOutlined />}
|
|
</span>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
export default Trend;
|
|
|