| 
9 | 9 | import Image from 'next/image'  | 
10 | 10 | import Link from 'next/link'  | 
11 | 11 | import { useParams } from 'next/navigation'  | 
 | 12 | +import { useTheme } from 'next-themes'  | 
12 | 13 | import React, { useState, useEffect, useRef } from 'react'  | 
13 | 14 | import { handleAppError, ErrorDisplay } from 'app/global-error'  | 
14 | 15 | import { GET_USER_DATA } from 'server/queries/userQueries'  | 
@@ -139,37 +140,59 @@ const UserDetailsPage: React.FC = () => {  | 
139 | 140 |     { icon: faCodeMerge, value: user?.contributionsCount || 0, unit: 'Contribution' },  | 
140 | 141 |   ]  | 
141 | 142 | 
 
  | 
142 |  | -  const Heatmap = () => (  | 
143 |  | -    <div className="flex flex-col gap-4">  | 
144 |  | -      <div className="overflow-hidden rounded-lg bg-white shadow-xl dark:bg-gray-800">  | 
145 |  | -        <div className="relative">  | 
146 |  | -          <canvas ref={canvasRef} style={{ display: 'none' }} aria-hidden="true"></canvas>  | 
147 |  | -          {imageLink ? (  | 
148 |  | -            <div className="h-40 bg-[#10151c]">  | 
149 |  | -              <Image  | 
150 |  | -                width={100}  | 
151 |  | -                height={100}  | 
152 |  | -                src={imageLink || '/placeholder.svg'}  | 
153 |  | -                className="h-full w-full object-cover object-[54%_60%]"  | 
154 |  | -                alt="Contribution Heatmap"  | 
155 |  | -              />  | 
156 |  | -            </div>  | 
157 |  | -          ) : (  | 
158 |  | -            <div className="relative h-40 items-center justify-center bg-[#10151c]">  | 
159 |  | -              <Image  | 
160 |  | -                height={100}  | 
161 |  | -                width={100}  | 
162 |  | -                src="/img/heatmapBackground.png"  | 
163 |  | -                className="heatmap-background-loader h-full w-full border-none object-cover object-[54%_60%]"  | 
164 |  | -                alt="Heatmap Background"  | 
165 |  | -              />  | 
166 |  | -              <div className="heatmap-loader"></div>  | 
167 |  | -            </div>  | 
168 |  | -          )}  | 
 | 143 | +  const Heatmap = () => {  | 
 | 144 | +    const canvasRef = useRef<HTMLCanvasElement | null>(null)  | 
 | 145 | +    const { resolvedTheme } = useTheme()  | 
 | 146 | +    const isDarkMode = (resolvedTheme ?? 'light') === 'dark'  | 
 | 147 | + | 
 | 148 | +    useEffect(() => {  | 
 | 149 | +      if (canvasRef.current && data?.years?.length) {  | 
 | 150 | +        drawContributions(canvasRef.current, {  | 
 | 151 | +          data,  | 
 | 152 | +          username,  | 
 | 153 | +          themeName: isDarkMode ? 'dark' : 'light',  | 
 | 154 | +        })  | 
 | 155 | +        const imageURL = canvasRef.current.toDataURL()  | 
 | 156 | +        setImageLink(imageURL)  | 
 | 157 | +      }  | 
 | 158 | +    }, [isDarkMode])  | 
 | 159 | + | 
 | 160 | +    return (  | 
 | 161 | +      <div className="flex flex-col gap-4">  | 
 | 162 | +        <div className="overflow-hidden rounded-lg bg-white dark:bg-gray-800">  | 
 | 163 | +          <div className="relative">  | 
 | 164 | +            <canvas ref={canvasRef} style={{ display: 'none' }} aria-hidden="true"></canvas>  | 
 | 165 | +            {imageLink ? (  | 
 | 166 | +              <div className="h-40">  | 
 | 167 | +                <Image  | 
 | 168 | +                  width={100}  | 
 | 169 | +                  height={100}  | 
 | 170 | +                  src={imageLink}  | 
 | 171 | +                  className="h-full w-full object-cover object-[54%_60%]"  | 
 | 172 | +                  alt="Contribution Heatmap"  | 
 | 173 | +                />  | 
 | 174 | +              </div>  | 
 | 175 | +            ) : (  | 
 | 176 | +              <div className="relative h-40 items-center justify-center">  | 
 | 177 | +                <Image  | 
 | 178 | +                  height={100}  | 
 | 179 | +                  width={100}  | 
 | 180 | +                  src={  | 
 | 181 | +                    isDarkMode  | 
 | 182 | +                      ? '/img/heatmap-background-dark.png'  | 
 | 183 | +                      : '/img/heatmap-background-light.png'  | 
 | 184 | +                  }  | 
 | 185 | +                  className="heatmap-background-loader h-full w-full border-none object-cover object-[54%_60%]"  | 
 | 186 | +                  alt="Heatmap Background"  | 
 | 187 | +                />  | 
 | 188 | +                <div className="heatmap-loader"></div>  | 
 | 189 | +              </div>  | 
 | 190 | +            )}  | 
 | 191 | +          </div>  | 
169 | 192 |         </div>  | 
170 | 193 |       </div>  | 
171 |  | -    </div>  | 
172 |  | -  )  | 
 | 194 | +    )  | 
 | 195 | +  }  | 
173 | 196 | 
 
  | 
174 | 197 |   const UserSummary = () => (  | 
175 | 198 |     <div className="mt-4 flex items-center">  | 
 | 
0 commit comments