site-github-card
dedevs-ui/site-github-cardFreeComponent
Site github-card component
See it running
Open the demo on dedevs-ui
ui.dedevs.com/components/site-github-cardInstall it
npx shadcn@latest add https://ui.dedevs.com/r/site-github-card.jsonSource
1"use client";23import { useState } from "react";4import Head from "next/head";5import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";6import { Card } from "@/components/ui/card";7import { Input } from "@/components/ui/input";8import { Button } from "@/components/ui/button";9import { Icon } from "@iconify/react";1011interface GitHubUser {12 login: string;13 name: string;14 bio: string;15 avatar_url: string;16 followers: number;17 following: number;18 public_repos: number;19 html_url: string;20 email?: string;21 twitter_username?: string;22 blog?: string;23}2425interface ContributionDay {26 date: string;27 level: number;28 count: number;29}3031export default function GitHubCard() {32 const [username, setUsername] = useState("");33 const [userData, setUserData] = useState<GitHubUser | null>(null);34 const [loading, setLoading] = useState(false);35 const [error, setError] = useState<string | null>(null);3637 // Generate realistic contribution data with proper GitHub-like structure38 const generateContributions = (): ContributionDay[] => {39 const contributions: ContributionDay[] = [];40 const today = new Date();41 const startDate = new Date(42 today.getFullYear() - 1,43 today.getMonth(),44 today.getDate(),45 );4647 // Start from the Sunday of the week containing startDate48 const startSunday = new Date(startDate);49 startSunday.setDate(startDate.getDate() - startDate.getDay());5051 for (let i = 0; i < 371; i++) {52 // ~53 weeks * 7 days53 const date = new Date(startSunday);54 date.setDate(startSunday.getDate() + i);5556 const dayOfWeek = date.getDay();57 const isWeekend = dayOfWeek === 0 || dayOfWeek === 6;58 const baseIntensity = isWeekend ? 0.2 : 0.6;59 const randomFactor = Math.random();60 const intensity = baseIntensity * randomFactor;6162 let level = 0;63 let count = 0;64 if (intensity > 0.7) {65 level = 4;66 count = Math.floor(Math.random() * 10) + 10;67 } else if (intensity > 0.5) {68 level = 3;69 count = Math.floor(Math.random() * 8) + 5;70 } else if (intensity > 0.3) {71 level = 2;72 count = Math.floor(Math.random() * 5) + 2;73 } else if (intensity > 0.1) {74 level = 1;75// … truncated
Files it writes
More from dedevs-ui
All 30 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-branchai-branch | dedevs-ui | Components | Free | no deps | |
| ai-conversationai-conversation | dedevs-ui | Components | Free | no deps | |
| ai-inputai-input | dedevs-ui | Components | Free | no deps | |
| ai-messageai-message | dedevs-ui | Components | Free | no deps | |
| ai-reasoningai-reasoning | dedevs-ui | Components | Free | no deps | |
| ai-responseai-response | dedevs-ui | Components | Free | no deps | |
| ai-serverai-server | dedevs-ui | Components | Free | no deps | |
| ai-simpleai-simple | dedevs-ui | Components | Free | no deps |
