Skip to content

Commit

Permalink
Merge pull request #302 from EaveLuo/hotfix-eave/darkmode
Browse files Browse the repository at this point in the history
fix: refreshing the page in dark mode causes github-stat dark mode to fail.
  • Loading branch information
kuizuo authored Jun 25, 2024
2 parents 9e8fe44 + 4216466 commit 8590f42
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/components/landing/FeaturesSection/Github.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import GitHubCalendar from 'react-github-calendar'

import { useColorMode } from '@docusaurus/theme-common'
import { Icon } from '@iconify/react'
import ThemedImage from '@theme/ThemedImage'

interface GithubProps {
className?: string
Expand All @@ -11,9 +12,9 @@ interface GithubProps {
export default function Github({ className }: GithubProps) {
const { isDarkTheme } = useColorMode()

const githubStatsUrl = (type: 'overview' | 'languages') =>
const githubStatsUrl = (type: 'overview' | 'languages', isDark: boolean) =>
`https://raw.githubusercontent.com/kuizuo/github-stats/master/generated/${type}.svg#gh-${
isDarkTheme ? 'dark' : 'light'
isDark ? 'dark' : 'light'
}-mode-only`

return (
Expand All @@ -24,8 +25,20 @@ export default function Github({ className }: GithubProps) {
</h2>
<div className="relative flex w-full flex-col items-center justify-center overflow-hidden bg-background">
<div className="github-stats mb-4 flex w-full flex-col justify-between gap-4 overflow-x-auto px-0 sm:flex-row">
<img src={githubStatsUrl('overview')} alt="GitHub Overview Stats" />
<img src={githubStatsUrl('languages')} alt="GitHub Languages Stats" />
<ThemedImage
alt="GitHub Overview Stats"
sources={{
light: githubStatsUrl('overview', false),
dark: githubStatsUrl('overview', true),
}}
/>
<ThemedImage
alt="GitHub Languages Stats"
sources={{
light: githubStatsUrl('languages', false),
dark: githubStatsUrl('languages', true),
}}
/>
</div>
<GitHubCalendar username="kuizuo" blockSize={11} colorScheme={isDarkTheme ? 'dark' : 'light'} />
</div>
Expand Down

0 comments on commit 8590f42

Please sign in to comment.