|
|
@ -1,10 +1,6 @@ |
|
|
|
import { Spinner } from '../ReactIcons/Spinner.tsx'; |
|
|
|
|
|
|
|
import { useEffect, useState } from 'react'; |
|
|
|
|
|
|
|
import { cn } from '../../lib/classname.ts'; |
|
|
|
import { cn } from '../../lib/classname.ts'; |
|
|
|
import { getUser } from '../../lib/jwt.ts'; |
|
|
|
|
|
|
|
import { roadmapProgress, totalRoadmapNodes } from '../../stores/roadmap.ts'; |
|
|
|
import { roadmapProgress, totalRoadmapNodes } from '../../stores/roadmap.ts'; |
|
|
|
import { useStore } from '@nanostores/react'; |
|
|
|
import { useStore } from '@nanostores/react'; |
|
|
|
import {HelpCircle} from "lucide-react"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type ProgressNudgeProps = { |
|
|
|
type ProgressNudgeProps = { |
|
|
|
resourceType: 'roadmap' | 'best-practice'; |
|
|
|
resourceType: 'roadmap' | 'best-practice'; |
|
|
@ -12,36 +8,22 @@ type ProgressNudgeProps = { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export function ProgressNudge(props: ProgressNudgeProps) { |
|
|
|
export function ProgressNudge(props: ProgressNudgeProps) { |
|
|
|
const { resourceId, resourceType } = props; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const $totalRoadmapNodes = useStore(totalRoadmapNodes); |
|
|
|
const $totalRoadmapNodes = useStore(totalRoadmapNodes); |
|
|
|
const $roadmapProgress = useStore(roadmapProgress); |
|
|
|
const $roadmapProgress = useStore(roadmapProgress); |
|
|
|
|
|
|
|
|
|
|
|
const done = $roadmapProgress?.done?.length || 0; |
|
|
|
const done = $roadmapProgress?.done?.length || 0; |
|
|
|
|
|
|
|
|
|
|
|
const [isLoading, setIsLoading] = useState(true); |
|
|
|
|
|
|
|
const { id: userId } = getUser() || {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const hasProgress = done > 0; |
|
|
|
const hasProgress = done > 0; |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
setIsLoading(false); |
|
|
|
|
|
|
|
}, 500); |
|
|
|
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$totalRoadmapNodes) { |
|
|
|
if (!$totalRoadmapNodes) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div |
|
|
|
<div |
|
|
|
className={cn( |
|
|
|
className={ |
|
|
|
'fixed hidden sm:block -bottom-full left-1/2 z-30 -translate-x-1/2 transform overflow-hidden rounded-full bg-stone-900 px-4 py-2 text-center text-white shadow-2xl transition-all ', |
|
|
|
'fixed bottom-5 left-1/2 z-30 hidden -translate-x-1/2 transform animate-fade-slide-up overflow-hidden rounded-full bg-stone-900 px-4 py-2 text-center text-white shadow-2xl transition-all duration-300 sm:block' |
|
|
|
{ |
|
|
|
} |
|
|
|
'bottom-5 opacity-100': !isLoading, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
<span |
|
|
|
<span |
|
|
|
className={cn('block', { |
|
|
|
className={cn('block', { |
|
|
|