import * as React from 'react' import { chakra, forwardRef, HTMLChakraProps, ThemingProps, omitThemingProps, useColorModeValue, useMultiStyleConfig, SystemStyleObject, } from '@chakra-ui/react' import { cx } from '@chakra-ui/utils' import { useNProgress } from '@tanem/react-nprogress' interface NProgressOptions { /** * Set to true to start the progress animation. */ isAnimating: boolean } export interface NProgressProps extends NProgressOptions, HTMLChakraProps<'div'>, ThemingProps<'SuiNProgress'> {} /** * Show feedback when switching pages and content is loading in the background. * * @see Docs https://saas-ui.dev/docs/components/feedback/nprogress */ export const NProgress = forwardRef((props, ref) => { const styles = useMultiStyleConfig('SuiNProgress', props) const { colorScheme: c } = props const { children, isAnimating, ...containerProps } = omitThemingProps(props) const { animationDuration, isFinished, progress } = useNProgress({ isAnimating, }) const barStyles: SystemStyleObject = { width: '100%', height: '2px', bg: useColorModeValue(`${c}.500`, `${c}.300`), ...styles.bar, } return ( ) }) NProgress.displayName = 'NProgress'