import Value from 'Components/Value' import React, { useContext } from 'react' import emoji from 'react-easy-emoji' import { animated, config, useSpring } from 'react-spring' import useDisplayOnIntersecting from 'Components/utils/useDisplayOnIntersecting' import { ThemeColorsContext } from 'Components/utils/colors' const ANIMATION_SPRING = config.gentle let ChartItemBar = ({ styles, color, numberToPlot, unit }) => (
{numberToPlot}
) let BranchIcône = ({ icône }) => (
{emoji(icône)}
) type BarChartBranchProps = { value: number title: React.ReactNode icon?: string maximum: number description?: string unit?: string } export default function BarChartBranch({ value, title, icon, maximum, description, unit }: BarChartBranchProps) { const [intersectionRef, brancheInViewport] = useDisplayOnIntersecting({ threshold: 0.5 }) const { color } = useContext(ThemeColorsContext) const numberToPlot = brancheInViewport ? value : 0 const styles = useSpring({ config: ANIMATION_SPRING, to: { flex: numberToPlot / maximum, opacity: numberToPlot ? 1 : 0 } }) as { flex: number; opacity: number } // TODO: problème avec les types de react-spring ? return ( {icon && }

{title}
{description && {description}}

) }