/** * Copyright 2022 Design Barn Inc. */ import { Controls, IPlayerProps, Player } from '@lottiefiles/react-lottie-player'; import * as React from 'react'; // eslint-disable-next-line import/no-unassigned-import import './lottieplayer.scss'; import { DotLottiePlayer, Controls as DLControls } from '@lottiefiles/dotlottie-react-player'; // import '@dotlottie/player-component'; interface ILottiePlayerProps extends IPlayerProps { bgColor?: string; isPreview: boolean; isSimple?: boolean; setBackground?: (value: string) => void; src: string | Record; } interface IGenericPlayerProps extends IPlayerProps { bgColor: string; isDotLottie: boolean; setBackground?: (value: string) => void; src: string; } const PreviewPlayer: React.FC = ({ isDotLottie, bgColor, src, ...props }) => { if (isDotLottie) { return ( ); } return ( ); }; const LargePlayer: React.FC = ({ isDotLottie, bgColor, src, ...props }) => { if (isDotLottie) { return ( ); } return ( ); }; const SimplePlayer: React.FC = ({ isDotLottie, bgColor, setBackground, src, ...props }) => { if (isDotLottie) { return ( => { setBackground?.(color); }} {...props} > ); } return ( => { setBackground?.(color); }} {...props} > ); }; const checkDotLottie = (url: string) => { if (url.endsWith('.lottie')) return true; const basename = url.substring((url.lastIndexOf('/') as number) + 1, url.indexOf('?')); const extension = basename.split('.').pop(); return extension === 'lottie'; }; export const LottiePlayer: React.FC = ({ bgColor = '#fff', isPreview, isSimple = false, isLarge = false, setBackground, src, ...props }) => { const isDotLottie = checkDotLottie(src); if (isPreview) { return ; } else if (isSimple) { return ( ); } else if (isLarge) { return ; } };