computer-scienceangular-roadmapbackend-roadmapblockchain-roadmapdba-roadmapdeveloper-roadmapdevops-roadmapfrontend-roadmapgo-roadmaphactoberfestjava-roadmapjavascript-roadmapnodejs-roadmappython-roadmapqa-roadmapreact-roadmaproadmapstudy-planvue-roadmapweb3-roadmap
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
import type { ReactNode } from 'react'; |
|
import { cn } from '../../lib/classname.ts'; |
|
import { CheckIcon, CircleDashed, Loader, Loader2, X } from 'lucide-react'; |
|
import { Spinner } from '../ReactIcons/Spinner.tsx'; |
|
|
|
type SubmissionRequirementProps = { |
|
status: 'pending' | 'success' | 'error'; |
|
children: ReactNode; |
|
isLoading?: boolean; |
|
}; |
|
|
|
export function SubmissionRequirement(props: SubmissionRequirementProps) { |
|
const { status, isLoading = false, children } = props; |
|
|
|
return ( |
|
<div |
|
className={cn(`flex items-center rounded-lg p-2 text-sm text-gray-900`, { |
|
'bg-gray-200': status === 'pending', |
|
'bg-green-200': status === 'success', |
|
'bg-red-200': status === 'error', |
|
})} |
|
> |
|
{!isLoading && ( |
|
<> |
|
{status === 'pending' ? ( |
|
<CircleDashed className="h-4 w-4 flex-shrink-0 text-gray-400" /> |
|
) : status === 'success' ? ( |
|
<CheckIcon className="h-4 w-4 flex-shrink-0 text-green-800" /> |
|
) : ( |
|
<X className="h-4 w-4 flex-shrink-0 text-yellow-800" /> |
|
)} |
|
</> |
|
)} |
|
|
|
{isLoading && ( |
|
<Loader2 |
|
className={'h-4 w-4 animate-spin text-gray-400'} |
|
strokeWidth={3} |
|
/> |
|
)} |
|
<span className="ml-2">{children}</span> |
|
</div> |
|
); |
|
}
|
|
|