import React, { useRef } from 'react'; import { Transition } from 'react-transition-group'; import { usePrefersReducedMotion } from '@leafygreen-ui/a11y'; import { cx } from '@leafygreen-ui/emotion'; import { Theme } from '@leafygreen-ui/lib'; import { palette } from '@leafygreen-ui/palette'; import { CheckProps } from '../Checkbox/Checkbox.types'; import { checkAnimationDuration } from '../constants'; import { checkIconStyles, checkIconTransitionStyles, disableAnimation, rippleBaseStyles, rippleCheckedStyles, rippleClassName, rippleThemeStyles, wrapperBaseStyle, wrapperCheckedBaseStyle, wrapperCheckedDisabledStyle, wrapperCheckedThemeStyle, wrapperDisabledStyle, wrapperThemeStyle, } from './Check.style'; import SvgCheck from './SvgCheck'; import SvgIndeterminate from './SvgIndeterminate'; const checkIconColor: Record> = { [Theme.Light]: { default: palette.white, disabled: palette.gray.light3, }, [Theme.Dark]: { default: palette.black, disabled: palette.gray.dark1, }, }; /** * @internal * @returns JSX.Element */ export function Check({ theme, isChecked, indeterminate, disabled, animate, selector, }: CheckProps) { const prefersReducedMotion = usePrefersReducedMotion(); const CheckSVG = indeterminate ? SvgIndeterminate : SvgCheck; const showCheckIcon = indeterminate || isChecked; const shouldAnimate = animate && !indeterminate && !prefersReducedMotion; const transitionRef = useRef(null); return ( <>
{state => ( )}
); }