import { forwardRef, useImperativeHandle, useRef, memo } from 'react' import { useClassNames } from '../../_lib/useClassNames' import './index.css' export type LoadingSpinnerProps = { readonly size?: number readonly padding?: number readonly transparent?: boolean readonly className?: string } const LoadingSpinner = forwardRef( function LoadingSpinnerInner( { size = 48, padding = 16, transparent = false, ...props }, ref, ) { const classNames = useClassNames( 'charcoal-loading-spinner', props.className, ) return (
) }, ) export default memo(LoadingSpinner) type Props = { once?: boolean } export interface LoadingSpinnerIconHandler { restart(): void } export const LoadingSpinnerIcon = forwardRef( function LoadingSpinnerIcon({ once = false }, ref) { const iconRef = useRef(null) useImperativeHandle(ref, () => ({ restart: () => { if (!iconRef.current) { return } iconRef.current.dataset.resetAnimation = 'true' // Force reflow hack! void iconRef.current.offsetWidth delete iconRef.current.dataset.resetAnimation }, })) return (
) }, )