|
|
@ -6,21 +6,10 @@ import { reduceMotion } from '../initial_state';
|
|
|
|
|
|
|
|
|
|
|
|
import { ShortNumber } from './short_number';
|
|
|
|
import { ShortNumber } from './short_number';
|
|
|
|
|
|
|
|
|
|
|
|
const obfuscatedCount = (count: number) => {
|
|
|
|
|
|
|
|
if (count < 0) {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
} else if (count <= 1) {
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return '1+';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
interface Props {
|
|
|
|
value: number;
|
|
|
|
value: number;
|
|
|
|
obfuscate?: boolean;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export const AnimatedNumber: React.FC<Props> = ({ value, obfuscate }) => {
|
|
|
|
export const AnimatedNumber: React.FC<Props> = ({ value }) => {
|
|
|
|
const [previousValue, setPreviousValue] = useState(value);
|
|
|
|
const [previousValue, setPreviousValue] = useState(value);
|
|
|
|
const [direction, setDirection] = useState<1 | -1>(1);
|
|
|
|
const [direction, setDirection] = useState<1 | -1>(1);
|
|
|
|
|
|
|
|
|
|
|
@ -36,11 +25,7 @@ export const AnimatedNumber: React.FC<Props> = ({ value, obfuscate }) => {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (reduceMotion) {
|
|
|
|
if (reduceMotion) {
|
|
|
|
return obfuscate ? (
|
|
|
|
return <ShortNumber value={value} />;
|
|
|
|
<>{obfuscatedCount(value)}</>
|
|
|
|
|
|
|
|
) : (
|
|
|
|
|
|
|
|
<ShortNumber value={value} />
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const styles = [
|
|
|
|
const styles = [
|
|
|
@ -67,11 +52,7 @@ export const AnimatedNumber: React.FC<Props> = ({ value, obfuscate }) => {
|
|
|
|
transform: `translateY(${style.y * 100}%)`,
|
|
|
|
transform: `translateY(${style.y * 100}%)`,
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{obfuscate ? (
|
|
|
|
|
|
|
|
obfuscatedCount(data as number)
|
|
|
|
|
|
|
|
) : (
|
|
|
|
|
|
|
|
<ShortNumber value={data as number} />
|
|
|
|
<ShortNumber value={data as number} />
|
|
|
|
)}
|
|
|
|
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|