github-contrib-graph
Advanced tools
| /** | ||
| * Contribution level indicating activity intensity | ||
| */ | ||
| type ContributionLevel = 'NONE' | 'FIRST_QUARTILE' | 'SECOND_QUARTILE' | 'THIRD_QUARTILE' | 'FOURTH_QUARTILE'; | ||
| /** | ||
| * A single day's contribution data | ||
| */ | ||
| interface ContributionDay { | ||
| date: string; | ||
| contributionCount: number; | ||
| contributionLevel: ContributionLevel; | ||
| weekday: number; | ||
| } | ||
| /** | ||
| * A week of contribution data | ||
| */ | ||
| interface ContributionWeek { | ||
| contributionDays: ContributionDay[]; | ||
| } | ||
| /** | ||
| * A month label in the calendar | ||
| */ | ||
| interface ContributionMonth { | ||
| name: string; | ||
| totalWeeks: number; | ||
| } | ||
| /** | ||
| * The full contribution calendar data | ||
| */ | ||
| interface ContributionCalendar { | ||
| totalContributions: number; | ||
| months: ContributionMonth[]; | ||
| weeks: ContributionWeek[]; | ||
| } | ||
| /** | ||
| * GitHub user data from API response | ||
| */ | ||
| interface GitHubUser { | ||
| avatarUrl: string; | ||
| contributionsCollection: { | ||
| contributionCalendar: ContributionCalendar; | ||
| }; | ||
| } | ||
| /** | ||
| * API response structure | ||
| */ | ||
| interface APIResponse { | ||
| user: GitHubUser | null; | ||
| error?: string; | ||
| } | ||
| /** | ||
| * Available theme presets | ||
| */ | ||
| type ThemePreset = 'default' | 'void' | 'slate' | 'midnight' | 'glacier' | 'cyber'; | ||
| /** | ||
| * Custom theme configuration | ||
| */ | ||
| interface ThemeConfig { | ||
| bgColor?: string; | ||
| textColor?: string; | ||
| cellLevel0?: string; | ||
| cellLevel1?: string; | ||
| cellLevel2?: string; | ||
| cellLevel3?: string; | ||
| cellLevel4?: string; | ||
| borderColor?: string; | ||
| fontFamily?: string; | ||
| } | ||
| /** | ||
| * Widget render options | ||
| */ | ||
| interface RenderOptions { | ||
| showHeader?: boolean; | ||
| showFooter?: boolean; | ||
| showThumbnail?: boolean; | ||
| } | ||
| /** | ||
| * Configuration for the widget | ||
| */ | ||
| interface GitHubContributionGraphConfig extends RenderOptions { | ||
| username: string; | ||
| apiEndpoint?: string; | ||
| container?: string | HTMLElement; | ||
| theme?: ThemePreset | ThemeConfig; | ||
| onDataLoaded?: (data: GitHubUser) => void; | ||
| onError?: (error: Error) => void; | ||
| } | ||
| /** | ||
| * Default API endpoint for fetching contribution data | ||
| */ | ||
| declare const DEFAULT_API_ENDPOINT = "https://githubgraph.jigyansurout.com/api/ghcg/fetch-data"; | ||
| /** | ||
| * Repository URL for the widget | ||
| */ | ||
| declare const REPO_URL = "https://github.com/iamjr15/github-contribution-graph"; | ||
| /** | ||
| * Contribution level values in order | ||
| */ | ||
| declare const CONTRIBUTION_LEVELS: ContributionLevel[]; | ||
| /** | ||
| * Day labels for the calendar rows | ||
| */ | ||
| declare const DAY_LABELS: string[]; | ||
| /** | ||
| * Theme presets with CSS variable values | ||
| */ | ||
| declare const THEME_PRESETS: Record<ThemePreset, ThemeConfig>; | ||
| /** | ||
| * Fetch contribution data for a GitHub user | ||
| * | ||
| * @param username - GitHub username | ||
| * @param apiEndpoint - Optional custom API endpoint | ||
| * @returns Promise resolving to user data | ||
| * @throws Error if user not found or network error | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const userData = await fetchContributionData('octocat'); | ||
| * console.log(userData.contributionsCollection.contributionCalendar.totalContributions); | ||
| * ``` | ||
| */ | ||
| declare function fetchContributionData(username: string, apiEndpoint?: string): Promise<GitHubUser>; | ||
| /** | ||
| * Apply a theme to an element by setting CSS custom properties | ||
| * | ||
| * @param element - The element to apply theme to | ||
| * @param theme - Theme preset name or custom config | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * applyTheme(container, 'void'); | ||
| * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' }); | ||
| * ``` | ||
| */ | ||
| declare function applyTheme(element: HTMLElement, theme: ThemePreset | ThemeConfig): void; | ||
| /** | ||
| * Generate CSS string from a theme configuration | ||
| * | ||
| * @param theme - Theme preset name or custom config | ||
| * @returns CSS custom properties string | ||
| */ | ||
| declare function getThemeCSS(theme: ThemePreset | ThemeConfig): string; | ||
| /** | ||
| * Get all available theme preset names | ||
| */ | ||
| declare function getThemePresets(): ThemePreset[]; | ||
| export { type APIResponse as A, type ContributionCalendar as C, DEFAULT_API_ENDPOINT as D, type GitHubUser as G, type RenderOptions as R, type ThemePreset as T, type ThemeConfig as a, applyTheme as b, getThemeCSS as c, THEME_PRESETS as d, type ContributionDay as e, fetchContributionData as f, getThemePresets as g, type ContributionWeek as h, type ContributionMonth as i, type GitHubContributionGraphConfig as j, type ContributionLevel as k, REPO_URL as l, CONTRIBUTION_LEVELS as m, DAY_LABELS as n }; |
| /** | ||
| * Contribution level indicating activity intensity | ||
| */ | ||
| type ContributionLevel = 'NONE' | 'FIRST_QUARTILE' | 'SECOND_QUARTILE' | 'THIRD_QUARTILE' | 'FOURTH_QUARTILE'; | ||
| /** | ||
| * A single day's contribution data | ||
| */ | ||
| interface ContributionDay { | ||
| date: string; | ||
| contributionCount: number; | ||
| contributionLevel: ContributionLevel; | ||
| weekday: number; | ||
| } | ||
| /** | ||
| * A week of contribution data | ||
| */ | ||
| interface ContributionWeek { | ||
| contributionDays: ContributionDay[]; | ||
| } | ||
| /** | ||
| * A month label in the calendar | ||
| */ | ||
| interface ContributionMonth { | ||
| name: string; | ||
| totalWeeks: number; | ||
| } | ||
| /** | ||
| * The full contribution calendar data | ||
| */ | ||
| interface ContributionCalendar { | ||
| totalContributions: number; | ||
| months: ContributionMonth[]; | ||
| weeks: ContributionWeek[]; | ||
| } | ||
| /** | ||
| * GitHub user data from API response | ||
| */ | ||
| interface GitHubUser { | ||
| avatarUrl: string; | ||
| contributionsCollection: { | ||
| contributionCalendar: ContributionCalendar; | ||
| }; | ||
| } | ||
| /** | ||
| * API response structure | ||
| */ | ||
| interface APIResponse { | ||
| user: GitHubUser | null; | ||
| error?: string; | ||
| } | ||
| /** | ||
| * Available theme presets | ||
| */ | ||
| type ThemePreset = 'default' | 'void' | 'slate' | 'midnight' | 'glacier' | 'cyber'; | ||
| /** | ||
| * Custom theme configuration | ||
| */ | ||
| interface ThemeConfig { | ||
| bgColor?: string; | ||
| textColor?: string; | ||
| cellLevel0?: string; | ||
| cellLevel1?: string; | ||
| cellLevel2?: string; | ||
| cellLevel3?: string; | ||
| cellLevel4?: string; | ||
| borderColor?: string; | ||
| fontFamily?: string; | ||
| } | ||
| /** | ||
| * Widget render options | ||
| */ | ||
| interface RenderOptions { | ||
| showHeader?: boolean; | ||
| showFooter?: boolean; | ||
| showThumbnail?: boolean; | ||
| } | ||
| /** | ||
| * Configuration for the widget | ||
| */ | ||
| interface GitHubContributionGraphConfig extends RenderOptions { | ||
| username: string; | ||
| apiEndpoint?: string; | ||
| container?: string | HTMLElement; | ||
| theme?: ThemePreset | ThemeConfig; | ||
| onDataLoaded?: (data: GitHubUser) => void; | ||
| onError?: (error: Error) => void; | ||
| } | ||
| /** | ||
| * Default API endpoint for fetching contribution data | ||
| */ | ||
| declare const DEFAULT_API_ENDPOINT = "https://githubgraph.jigyansurout.com/api/ghcg/fetch-data"; | ||
| /** | ||
| * Repository URL for the widget | ||
| */ | ||
| declare const REPO_URL = "https://github.com/iamjr15/github-contribution-graph"; | ||
| /** | ||
| * Contribution level values in order | ||
| */ | ||
| declare const CONTRIBUTION_LEVELS: ContributionLevel[]; | ||
| /** | ||
| * Day labels for the calendar rows | ||
| */ | ||
| declare const DAY_LABELS: string[]; | ||
| /** | ||
| * Theme presets with CSS variable values | ||
| */ | ||
| declare const THEME_PRESETS: Record<ThemePreset, ThemeConfig>; | ||
| /** | ||
| * Fetch contribution data for a GitHub user | ||
| * | ||
| * @param username - GitHub username | ||
| * @param apiEndpoint - Optional custom API endpoint | ||
| * @returns Promise resolving to user data | ||
| * @throws Error if user not found or network error | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const userData = await fetchContributionData('octocat'); | ||
| * console.log(userData.contributionsCollection.contributionCalendar.totalContributions); | ||
| * ``` | ||
| */ | ||
| declare function fetchContributionData(username: string, apiEndpoint?: string): Promise<GitHubUser>; | ||
| /** | ||
| * Apply a theme to an element by setting CSS custom properties | ||
| * | ||
| * @param element - The element to apply theme to | ||
| * @param theme - Theme preset name or custom config | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * applyTheme(container, 'void'); | ||
| * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' }); | ||
| * ``` | ||
| */ | ||
| declare function applyTheme(element: HTMLElement, theme: ThemePreset | ThemeConfig): void; | ||
| /** | ||
| * Generate CSS string from a theme configuration | ||
| * | ||
| * @param theme - Theme preset name or custom config | ||
| * @returns CSS custom properties string | ||
| */ | ||
| declare function getThemeCSS(theme: ThemePreset | ThemeConfig): string; | ||
| /** | ||
| * Get all available theme preset names | ||
| */ | ||
| declare function getThemePresets(): ThemePreset[]; | ||
| export { type APIResponse as A, type ContributionCalendar as C, DEFAULT_API_ENDPOINT as D, type GitHubUser as G, type RenderOptions as R, type ThemePreset as T, type ThemeConfig as a, applyTheme as b, getThemeCSS as c, THEME_PRESETS as d, type ContributionDay as e, fetchContributionData as f, getThemePresets as g, type ContributionWeek as h, type ContributionMonth as i, type GitHubContributionGraphConfig as j, type ContributionLevel as k, REPO_URL as l, CONTRIBUTION_LEVELS as m, DAY_LABELS as n }; |
@@ -1,2 +0,2 @@ | ||
| "use strict";var GitHubContributionGraph=(()=>{var u=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var N=(o,e)=>{for(var t in e)u(o,t,{get:e[t],enumerable:!0})},R=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of P(e))!M.call(o,n)&&n!==t&&u(o,n,{get:()=>e[n],enumerable:!(r=x(e,n))||r.enumerable});return o};var D=o=>R(u({},"__esModule",{value:!0}),o);var k={};N(k,{GitHubContributionWidget:()=>c,applyTheme:()=>f,autoInit:()=>g,fetchContributionData:()=>d,getThemePresets:()=>E,renderWidget:()=>p});var v="https://github-contribution-graph.netlify.app/api/ghcg/fetch-data",T="https://github.com/iamjr15/github-contribution-graph",y=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],m=["","Mon","","Wed","","Fri",""],C={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function d(o,e=v){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=await fetch(t);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function S(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),n=e.insertRow().insertCell();n.style.width="28px";for(let i=0;i<7;i++){let a=t.insertRow().insertCell();m[i]&&(a.innerHTML=`<span class="ghCalendarLabel">${m[i]}</span>`)}return{table:o,thead:e,tbody:t}}function U(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let n=o.rows[0].insertCell(),i=document.createElement("span");i.textContent=e[t].name,i.className="ghCalendarLabel",n.appendChild(i),n.colSpan=r}}}function A(o,e){for(let t of e)for(let r of t.contributionDays){let n=document.createElement("span"),i=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${i.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel}}function G(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function I(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function _(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${o} contributions in the last year`;let i=document.createElement("div");return i.innerHTML=`<a href="https://github.com/${e}">${e}</a><img src="${t}" alt="${e}'s avatar">`,r.appendChild(n),r.appendChild(i),r}function O(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let n of y){let i=document.createElement("div");i.className="ghCalendarDayCell",i.dataset.level=n,e.appendChild(i)}return e.appendChild(r),o.appendChild(e),o}function $(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=T,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","30"),t.setAttribute("height","30"),t.style.marginTop="15px",t.style.opacity="0.6",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function p(o,e,t,r={}){let{showHeader:n=!0,showFooter:i=!0,showThumbnail:l=!0}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:L,thead:w,tbody:H}=S();A(H,a.weeks),U(w,a.months);let b=G(),h=I();if(h.appendChild(L),i){let s=O();h.appendChild(s)}if(b.appendChild(h),n){let s=_(a.totalContributions,t,e.avatarUrl);o.appendChild(s)}if(o.appendChild(b),l){let s=$();o.appendChild(s)}}function f(o,e){let t=typeof e=="string"?C[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily))}function E(){return Object.keys(C)}var c=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container)}resolveContainer(e){if(typeof e=="string"){let r=document.querySelector(e);if(!r)throw new Error(`Container not found: ${e}`);return r}if(e instanceof HTMLElement)return e;let t=document.getElementById("gh");if(!t)throw new Error('No container found. Specify container in config or add element with id="gh"');return t}async render(){try{this.data=await d(this.config.username,this.config.apiEndpoint),p(this.container,this.data,this.config.username,{showHeader:this.config.showHeader,showFooter:this.config.showFooter,showThumbnail:this.config.showThumbnail}),this.config.theme&&f(this.container,this.config.theme),this.config.onDataLoaded?.(this.data)}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"))}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container)),this.render()}};function g(){let o=document.getElementById("gh");if(!o)return;let e=o.dataset.login;if(!e)return;let t=new c({username:e,container:o});t.render(),typeof window<"u"&&(window.renderGitHubWidget=()=>t.render())}typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",g):g());return D(k);})(); | ||
| "use strict";var GitHubContributionGraph=(()=>{var u=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var N=(t,e)=>{for(var o in e)u(t,o,{get:e[o],enumerable:!0})},R=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of P(e))!M.call(t,n)&&n!==o&&u(t,n,{get:()=>e[n],enumerable:!(r=x(e,n))||r.enumerable});return t};var D=t=>R(u({},"__esModule",{value:!0}),t);var $={};N($,{GitHubContributionWidget:()=>c,applyTheme:()=>h,autoInit:()=>g,fetchContributionData:()=>d,getThemePresets:()=>E,renderWidget:()=>f});var T="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",v="https://github.com/iamjr15/github-contribution-graph",y=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],m=["","Mon","","Wed","","Fri",""],C={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function d(t,e=T){if(!t||typeof t!="string")throw new Error("Username is required");let o=`${e}?login=${encodeURIComponent(t.trim())}`,r=await fetch(o);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function S(){let t=document.createElement("table");t.className="ghCalendarTable";let e=t.createTHead(),o=t.createTBody(),n=e.insertRow().insertCell();n.style.width="28px";for(let i=0;i<7;i++){let a=o.insertRow().insertCell();m[i]&&(a.innerHTML=`<span class="ghCalendarLabel">${m[i]}</span>`)}return{table:t,thead:e,tbody:o}}function U(t,e){for(let o=0;o<e.length-1;o++){let r=e[o].totalWeeks;if(r>=2){let n=t.rows[0].insertCell(),i=document.createElement("span");i.textContent=e[o].name,i.className="ghCalendarLabel",n.appendChild(i),n.colSpan=r}}}function A(t,e){for(let o of e)for(let r of o.contributionDays){let n=document.createElement("span"),i=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${i.toDateString()}`;let l=t.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel}}function G(){let t=document.createElement("div");return t.className="ghCalendarCard",t}function I(){let t=document.createElement("div");return t.className="ghCalendarCanvas",t}function _(t,e,o){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${t} contributions in the last year`;let i=document.createElement("div");return i.innerHTML=`<a href="https://github.com/${e}">${e}</a><img src="${o}" alt="${e}'s avatar">`,r.appendChild(n),r.appendChild(i),r}function F(){let t=document.createElement("div");t.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let o=document.createElement("span");o.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(o);for(let n of y){let i=document.createElement("div");i.className="ghCalendarDayCell",i.dataset.level=n,e.appendChild(i)}return e.appendChild(r),t.appendChild(e),t}function O(){let t=document.createElement("div");t.className="ghThumbNail";let e=document.createElement("a");e.href=v,e.target="_blank",e.rel="noopener noreferrer";let o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("viewBox","0 0 98 96"),o.setAttribute("width","18"),o.setAttribute("height","18"),o.style.marginTop="10px",o.style.opacity="0.5",o.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),o.appendChild(r),e.appendChild(o),t.appendChild(e),t}function f(t,e,o,r={}){let{showHeader:n=!0,showFooter:i=!0,showThumbnail:l=!0}=r;t.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:L,thead:w,tbody:H}=S();A(H,a.weeks),U(w,a.months);let b=G(),p=I();if(p.appendChild(L),i){let s=F();p.appendChild(s)}if(b.appendChild(p),n){let s=_(a.totalContributions,o,e.avatarUrl);t.appendChild(s)}if(t.appendChild(b),l){let s=O();t.appendChild(s)}}function h(t,e){let o=typeof e=="string"?C[e]:e;o&&(o.bgColor&&t.style.setProperty("--gh-bg-color",o.bgColor),o.textColor&&t.style.setProperty("--gh-text-default-color",o.textColor),o.cellLevel0&&t.style.setProperty("--gh-cell-level0-color",o.cellLevel0),o.cellLevel1&&t.style.setProperty("--gh-cell-level1-color",o.cellLevel1),o.cellLevel2&&t.style.setProperty("--gh-cell-level2-color",o.cellLevel2),o.cellLevel3&&t.style.setProperty("--gh-cell-level3-color",o.cellLevel3),o.cellLevel4&&t.style.setProperty("--gh-cell-level4-color",o.cellLevel4),o.borderColor&&t.style.setProperty("--gh-border-card-color",o.borderColor),o.fontFamily&&t.style.setProperty("--gh-font-default-family",o.fontFamily))}function E(){return Object.keys(C)}var c=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container)}resolveContainer(e){if(typeof e=="string"){let r=document.querySelector(e);if(!r)throw new Error(`Container not found: ${e}`);return r}if(e instanceof HTMLElement)return e;let o=document.getElementById("gh");if(!o)throw new Error('No container found. Specify container in config or add element with id="gh"');return o}async render(){try{this.data=await d(this.config.username,this.config.apiEndpoint),f(this.container,this.data,this.config.username,{showHeader:this.config.showHeader,showFooter:this.config.showFooter,showThumbnail:this.config.showThumbnail}),this.config.theme&&h(this.container,this.config.theme),this.config.onDataLoaded?.(this.data)}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"))}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container)),this.render()}};function g(){let t=document.getElementById("gh");if(!t)return;let e=t.dataset.login;if(!e)return;let o=t.dataset.showThumbnail!=="false",r=t.dataset.showHeader!=="false",n=t.dataset.showFooter!=="false",i=new c({username:e,container:t,showThumbnail:o,showHeader:r,showFooter:n});i.render(),typeof window<"u"&&(window.renderGitHubWidget=()=>i.render())}typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",g):g());return D($);})(); | ||
| //# sourceMappingURL=browser.global.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/vanilla/browser.ts","../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"sourcesContent":["/**\n * Browser entry point for script tag usage\n * This file is bundled as IIFE/UMD for direct browser usage\n */\n\nimport { GitHubContributionWidget } from './widget';\nimport { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport { applyTheme, getThemePresets } from '../styles/themes';\nimport type { GitHubContributionGraphConfig } from '../core/types';\n\n// Export everything for global access\nexport { GitHubContributionWidget };\nexport { fetchContributionData };\nexport { renderWidget };\nexport { applyTheme, getThemePresets };\nexport type { GitHubContributionGraphConfig };\n\n// Re-export types\nexport * from '../core/types';\n\n/**\n * Auto-initialize widget for backward compatibility\n * Looks for element with id=\"gh\" and data-login attribute\n */\nexport function autoInit(): void {\n const container = document.getElementById('gh');\n if (!container) return;\n\n const username = container.dataset.login;\n if (!username) return;\n\n const widget = new GitHubContributionWidget({\n username,\n container,\n });\n\n widget.render();\n\n // Expose for manual re-render (backward compatibility)\n if (typeof window !== 'undefined') {\n (window as Window & { renderGitHubWidget?: () => Promise<void> }).renderGitHubWidget = () =>\n widget.render();\n }\n}\n\n// Auto-init when DOM is ready (only in browser context)\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', autoInit);\n } else {\n // DOM is already ready\n autoInit();\n }\n}\n","import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://github-contribution-graph.netlify.app/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '30');\n svg.setAttribute('height', '30');\n svg.style.marginTop = '15px';\n svg.style.opacity = '0.6';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"],"mappings":"2cAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,eAAAC,EAAA,aAAAC,EAAA,0BAAAC,EAAA,oBAAAC,EAAA,iBAAAC,ICKO,IAAMC,EAAuB,oEAKvBC,EAAW,uDAKXC,EAA2C,CACtD,OACA,iBACA,kBACA,iBACA,iBACF,EAKaC,EAAa,CAAC,GAAI,MAAO,GAAI,MAAO,GAAI,MAAO,EAAE,EAKjDC,EAAkD,CAC7D,QAAS,CACP,QAA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CAKA,MAAM,SAAyB,CAC7B,OAAO,KAAK,OAAO,CACrB,CAKA,SAA6B,CAC3B,OAAO,KAAK,IACd,CAKA,SAAgB,CACd,KAAK,UAAU,UAAY,GAC3B,KAAK,KAAO,IACd,CAKA,MAAM,OAAON,EAA+D,CAC1E,YAAK,OAAS,CAAE,GAAG,KAAK,OAAQ,GAAGA,CAAO,EAEtCA,EAAO,YACT,KAAK,UAAY,KAAK,iBAAiBA,EAAO,SAAS,GAGlD,KAAK,OAAO,CACrB,CACF,EL7FO,SAASO,GAAiB,CAC/B,IAAMC,EAAY,SAAS,eAAe,IAAI,EAC9C,GAAI,CAACA,EAAW,OAEhB,IAAMC,EAAWD,EAAU,QAAQ,MACnC,GAAI,CAACC,EAAU,OAEf,IAAMC,EAAS,IAAIC,EAAyB,CAC1C,SAAAF,EACA,UAAAD,CACF,CAAC,EAEDE,EAAO,OAAO,EAGV,OAAO,OAAW,MACnB,OAAiE,mBAAqB,IACrFA,EAAO,OAAO,EAEpB,CAGI,OAAO,OAAW,KAAe,OAAO,SAAa,MACnD,SAAS,aAAe,UAC1B,SAAS,iBAAiB,mBAAoBH,CAAQ,EAGtDA,EAAS","names":["browser_exports","__export","GitHubContributionWidget","applyTheme","autoInit","fetchContributionData","getThemePresets","renderWidget","DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","DEFAULT_API_ENDPOINT","url","response","data","createTable","table","thead","tbody","firstCell","cell","DAY_LABELS","addMonths","months","i","totalWeeks","label","addWeeks","weeks","week","day","data","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","username","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","CONTRIBUTION_LEVELS","createThumbnail","thumbnail","link","REPO_URL","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","applyTheme","element","theme","config","THEME_PRESETS","getThemePresets","THEME_PRESETS","GitHubContributionWidget","config","container","el","fetchContributionData","renderWidget","applyTheme","error","autoInit","container","username","widget","GitHubContributionWidget"]} | ||
| {"version":3,"sources":["../src/vanilla/browser.ts","../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"sourcesContent":["/**\n * Browser entry point for script tag usage\n * This file is bundled as IIFE/UMD for direct browser usage\n */\n\nimport { GitHubContributionWidget } from './widget';\nimport { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport { applyTheme, getThemePresets } from '../styles/themes';\nimport type { GitHubContributionGraphConfig } from '../core/types';\n\n// Export everything for global access\nexport { GitHubContributionWidget };\nexport { fetchContributionData };\nexport { renderWidget };\nexport { applyTheme, getThemePresets };\nexport type { GitHubContributionGraphConfig };\n\n// Re-export types\nexport * from '../core/types';\n\n/**\n * Auto-initialize widget for backward compatibility\n * Looks for element with id=\"gh\" and data-login attribute\n */\nexport function autoInit(): void {\n const container = document.getElementById('gh');\n if (!container) return;\n\n const username = container.dataset.login;\n if (!username) return;\n\n // Parse data attributes for options\n const showThumbnail = container.dataset.showThumbnail !== 'false';\n const showHeader = container.dataset.showHeader !== 'false';\n const showFooter = container.dataset.showFooter !== 'false';\n\n const widget = new GitHubContributionWidget({\n username,\n container,\n showThumbnail,\n showHeader,\n showFooter,\n });\n\n widget.render();\n\n // Expose for manual re-render (backward compatibility)\n if (typeof window !== 'undefined') {\n (window as Window & { renderGitHubWidget?: () => Promise<void> }).renderGitHubWidget = () =>\n widget.render();\n }\n}\n\n// Auto-init when DOM is ready (only in browser context)\nif (typeof window !== 'undefined' && typeof document !== 'undefined') {\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', autoInit);\n } else {\n // DOM is already ready\n autoInit();\n }\n}\n","import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"],"mappings":"2cAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,eAAAC,EAAA,aAAAC,EAAA,0BAAAC,EAAA,oBAAAC,EAAA,iBAAAC,ICKO,IAAMC,EAAuB,2DAKvBC,EAAW,uDAKXC,EAA2C,CACtD,OACA,iBACA,kBACA,iBACA,iBACF,EAKaC,EAAa,CAAC,GAAI,MAAO,GAAI,MAAO,GAAI,MAAO,EAAE,EAKjDC,EAAkD,CAC7D,QAAS,CACP,QAAS,UACT,UAAW,UACX,WAAY,UACZ,WAAY,UACZ,WAAY,UACZ,WAAY,UACZ,WAAY,UACZ,YAAa,SACf,EACA,KAAM,CACJ,QAAS,UACT,UAAW,UACX,WAAY,UACZ,YAAa,SACf,EACA,MAAO,CACL,QAAS,UACT,UAAW,UACX,WAAY,UACZ,YAAa,SACf,EACA,SAAU,CACR,QAAS,UACT,UAAW,UACX,WAAY,UACZ,YAAa,SACf,EACA,QAAS,CACP,QAAS,UACT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,KAAK,OAAO,CACrB,CACF,EL7FO,SAASO,GAAiB,CAC/B,IAAMC,EAAY,SAAS,eAAe,IAAI,EAC9C,GAAI,CAACA,EAAW,OAEhB,IAAMC,EAAWD,EAAU,QAAQ,MACnC,GAAI,CAACC,EAAU,OAGf,IAAMC,EAAgBF,EAAU,QAAQ,gBAAkB,QACpDG,EAAaH,EAAU,QAAQ,aAAe,QAC9CI,EAAaJ,EAAU,QAAQ,aAAe,QAE9CK,EAAS,IAAIC,EAAyB,CAC1C,SAAAL,EACA,UAAAD,EACA,cAAAE,EACA,WAAAC,EACA,WAAAC,CACF,CAAC,EAEDC,EAAO,OAAO,EAGV,OAAO,OAAW,MACnB,OAAiE,mBAAqB,IACrFA,EAAO,OAAO,EAEpB,CAGI,OAAO,OAAW,KAAe,OAAO,SAAa,MACnD,SAAS,aAAe,UAC1B,SAAS,iBAAiB,mBAAoBN,CAAQ,EAGtDA,EAAS","names":["browser_exports","__export","GitHubContributionWidget","applyTheme","autoInit","fetchContributionData","getThemePresets","renderWidget","DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","DEFAULT_API_ENDPOINT","url","response","data","createTable","table","thead","tbody","firstCell","cell","DAY_LABELS","addMonths","months","i","totalWeeks","label","addWeeks","weeks","week","day","data","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","username","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","CONTRIBUTION_LEVELS","createThumbnail","thumbnail","link","REPO_URL","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","applyTheme","element","theme","config","THEME_PRESETS","getThemePresets","THEME_PRESETS","GitHubContributionWidget","config","container","el","fetchContributionData","renderWidget","applyTheme","error","autoInit","container","username","showThumbnail","showHeader","showFooter","widget","GitHubContributionWidget"]} |
+1
-1
@@ -1,3 +0,3 @@ | ||
| 'use strict';var u="https://github-contribution-graph.netlify.app/api/ghcg/fetch-data",m="https://github.com/iamjr15/github-contribution-graph",C=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],h=["","Mon","","Wed","","Fri",""],c={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function g(o,e=u){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=await fetch(t);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function L(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),n=e.insertRow().insertCell();n.style.width="28px";for(let i=0;i<7;i++){let a=t.insertRow().insertCell();h[i]&&(a.innerHTML=`<span class="ghCalendarLabel">${h[i]}</span>`);}return {table:o,thead:e,tbody:t}}function w(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let n=o.rows[0].insertCell(),i=document.createElement("span");i.textContent=e[t].name,i.className="ghCalendarLabel",n.appendChild(i),n.colSpan=r;}}}function H(o,e){for(let t of e)for(let r of t.contributionDays){let n=document.createElement("span"),i=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${i.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function x(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function P(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function M(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${o} contributions in the last year`;let i=document.createElement("div");return i.innerHTML=`<a href="https://github.com/${e}">${e}</a><img src="${t}" alt="${e}'s avatar">`,r.appendChild(n),r.appendChild(i),r}function N(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let n of C){let i=document.createElement("div");i.className="ghCalendarDayCell",i.dataset.level=n,e.appendChild(i);}return e.appendChild(r),o.appendChild(e),o}function R(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=m,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","30"),t.setAttribute("height","30"),t.style.marginTop="15px",t.style.opacity="0.6",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function b(o,e,t,r={}){let{showHeader:n=true,showFooter:i=true,showThumbnail:l=true}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:T,thead:E,tbody:y}=L();H(y,a.weeks),w(E,a.months);let p=x(),d=P();if(d.appendChild(T),i){let s=N();d.appendChild(s);}if(p.appendChild(d),n){let s=M(a.totalContributions,t,e.avatarUrl);o.appendChild(s);}if(o.appendChild(p),l){let s=R();o.appendChild(s);}}function S(o){return o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function v(o,e){let t=typeof e=="string"?c[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily));}function G(o){let e=typeof o=="string"?c[o]:o;if(!e)return "";let t=[];for(let[r,n]of Object.entries(e))if(n){let i=`--gh-${S(r).replace("color","-color")}`;t.push(`${i}: ${n};`);}return t.join(` | ||
| 'use strict';var u="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",m="https://github.com/iamjr15/github-contribution-graph",C=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],h=["","Mon","","Wed","","Fri",""],c={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function g(o,e=u){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=await fetch(t);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function L(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),n=e.insertRow().insertCell();n.style.width="28px";for(let i=0;i<7;i++){let a=t.insertRow().insertCell();h[i]&&(a.innerHTML=`<span class="ghCalendarLabel">${h[i]}</span>`);}return {table:o,thead:e,tbody:t}}function w(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let n=o.rows[0].insertCell(),i=document.createElement("span");i.textContent=e[t].name,i.className="ghCalendarLabel",n.appendChild(i),n.colSpan=r;}}}function H(o,e){for(let t of e)for(let r of t.contributionDays){let n=document.createElement("span"),i=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${i.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function x(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function P(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function M(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${o} contributions in the last year`;let i=document.createElement("div");return i.innerHTML=`<a href="https://github.com/${e}">${e}</a><img src="${t}" alt="${e}'s avatar">`,r.appendChild(n),r.appendChild(i),r}function N(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let n of C){let i=document.createElement("div");i.className="ghCalendarDayCell",i.dataset.level=n,e.appendChild(i);}return e.appendChild(r),o.appendChild(e),o}function R(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=m,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.style.marginTop="10px",t.style.opacity="0.5",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function b(o,e,t,r={}){let{showHeader:n=true,showFooter:i=true,showThumbnail:l=true}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:T,thead:E,tbody:y}=L();H(y,a.weeks),w(E,a.months);let p=x(),d=P();if(d.appendChild(T),i){let s=N();d.appendChild(s);}if(p.appendChild(d),n){let s=M(a.totalContributions,t,e.avatarUrl);o.appendChild(s);}if(o.appendChild(p),l){let s=R();o.appendChild(s);}}function S(o){return o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function v(o,e){let t=typeof e=="string"?c[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily));}function G(o){let e=typeof o=="string"?c[o]:o;if(!e)return "";let t=[];for(let[r,n]of Object.entries(e))if(n){let i=`--gh-${S(r).replace("color","-color")}`;t.push(`${i}: ${n};`);}return t.join(` | ||
| `)}function O(){return Object.keys(c)}var f=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container);}resolveContainer(e){if(typeof e=="string"){let r=document.querySelector(e);if(!r)throw new Error(`Container not found: ${e}`);return r}if(e instanceof HTMLElement)return e;let t=document.getElementById("gh");if(!t)throw new Error('No container found. Specify container in config or add element with id="gh"');return t}async render(){try{this.data=await g(this.config.username,this.config.apiEndpoint),b(this.container,this.data,this.config.username,{showHeader:this.config.showHeader,showFooter:this.config.showFooter,showThumbnail:this.config.showThumbnail}),this.config.theme&&v(this.container,this.config.theme),this.config.onDataLoaded?.(this.data);}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null;}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container)),this.render()}};exports.CONTRIBUTION_LEVELS=C;exports.DAY_LABELS=h;exports.DEFAULT_API_ENDPOINT=u;exports.GitHubContributionWidget=f;exports.REPO_URL=m;exports.THEME_PRESETS=c;exports.addMonths=w;exports.addWeeks=H;exports.applyTheme=v;exports.createCanvas=P;exports.createCard=x;exports.createFooter=N;exports.createHeader=M;exports.createTable=L;exports.createThumbnail=R;exports.fetchContributionData=g;exports.getThemeCSS=G;exports.getThemePresets=O;exports.renderWidget=b;//# sourceMappingURL=index.cjs.map | ||
| //# sourceMappingURL=index.cjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","response","data","createTable","table","thead","tbody","firstCell","cell","addMonths","months","i","totalWeeks","label","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","link","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionWidget","el","error"],"mappings":"aAKO,IAAMA,CAAAA,CAAuB,mEAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,EAAa,CAAC,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,MAAO,EAAE,CAAA,CAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,QAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,YAAa,SACf,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,MAAO,CACL,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,UACZ,WAAA,CAAa,SACf,CAAA,CACA,QAAA,CAAU,CACR,OAAA,CAAS,UACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,EACA,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,KAAA,CAAO,CACL,QAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CACF,ECvDA,eAAsBC,CAAAA,CACpBC,CAAAA,CACAC,CAAAA,CAAsBP,EACD,C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ACF,CACF,CAKA,MAAM,SAAyB,CAC7B,OAAO,KAAK,MAAA,EACd,CAKA,OAAA,EAA6B,CAC3B,OAAO,KAAK,IACd,CAKA,SAAgB,CACd,IAAA,CAAK,UAAU,SAAA,CAAY,EAAA,CAC3B,IAAA,CAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOT,CAAAA,CAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,EAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CAAA,CAGlD,IAAA,CAAK,MAAA,EACd,CACF","file":"index.cjs","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://github-contribution-graph.netlify.app/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '30');\n svg.setAttribute('height', '30');\n svg.style.marginTop = '15px';\n svg.style.opacity = '0.6';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"]} | ||
| {"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","response","data","createTable","table","thead","tbody","firstCell","cell","addMonths","months","i","totalWeeks","label","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","link","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionWidget","el","error"],"mappings":"aAKO,IAAMA,CAAAA,CAAuB,0DAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,EAAa,CAAC,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,MAAO,EAAE,CAAA,CAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,QAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,YAAa,SACf,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,MAAO,CACL,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,UACZ,WAAA,CAAa,SACf,CAAA,CACA,QAAA,CAAU,CACR,OAAA,CAAS,UACT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AAA,CAEG,IAAA,CAAK,OAAO,KAAA,EACdW,CAAAA,CAAW,IAAA,CAAK,SAAA,CAAW,IAAA,CAAK,MAAA,CAAO,KAAK,CAAA,CAG9C,IAAA,CAAK,OAAO,YAAA,GAAe,IAAA,CAAK,IAAI,EACtC,CAAA,MAASY,CAAAA,CAAO,CACd,IAAA,CAAK,SAAA,CAAU,UACb,kEAAA,CACF,IAAA,CAAK,OAAO,OAAA,GACVA,CAAAA,YAAiB,MAAQA,CAAAA,CAAQ,IAAI,KAAA,CAAM,eAAe,CAC5D,EACF,CACF,CAKA,MAAM,SAAyB,CAC7B,OAAO,KAAK,MAAA,EACd,CAKA,OAAA,EAA6B,CAC3B,OAAO,KAAK,IACd,CAKA,SAAgB,CACd,IAAA,CAAK,UAAU,SAAA,CAAY,EAAA,CAC3B,IAAA,CAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOT,CAAAA,CAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,EAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CAAA,CAGlD,IAAA,CAAK,MAAA,EACd,CACF","file":"index.cjs","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"]} |
+2
-2
@@ -1,3 +0,3 @@ | ||
| import { i as ContributionMonth, h as ContributionWeek, G as GitHubUser, R as RenderOptions, j as GitHubContributionGraphConfig } from './themes-C8Fy4Stl.cjs'; | ||
| export { A as APIResponse, m as CONTRIBUTION_LEVELS, C as ContributionCalendar, e as ContributionDay, k as ContributionLevel, n as DAY_LABELS, D as DEFAULT_API_ENDPOINT, l as REPO_URL, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-C8Fy4Stl.cjs'; | ||
| import { i as ContributionMonth, h as ContributionWeek, G as GitHubUser, R as RenderOptions, j as GitHubContributionGraphConfig } from './themes-DbIjuNDH.cjs'; | ||
| export { A as APIResponse, m as CONTRIBUTION_LEVELS, C as ContributionCalendar, e as ContributionDay, k as ContributionLevel, n as DAY_LABELS, D as DEFAULT_API_ENDPOINT, l as REPO_URL, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-DbIjuNDH.cjs'; | ||
@@ -4,0 +4,0 @@ /** |
+2
-2
@@ -1,3 +0,3 @@ | ||
| import { i as ContributionMonth, h as ContributionWeek, G as GitHubUser, R as RenderOptions, j as GitHubContributionGraphConfig } from './themes-C8Fy4Stl.js'; | ||
| export { A as APIResponse, m as CONTRIBUTION_LEVELS, C as ContributionCalendar, e as ContributionDay, k as ContributionLevel, n as DAY_LABELS, D as DEFAULT_API_ENDPOINT, l as REPO_URL, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-C8Fy4Stl.js'; | ||
| import { i as ContributionMonth, h as ContributionWeek, G as GitHubUser, R as RenderOptions, j as GitHubContributionGraphConfig } from './themes-DbIjuNDH.js'; | ||
| export { A as APIResponse, m as CONTRIBUTION_LEVELS, C as ContributionCalendar, e as ContributionDay, k as ContributionLevel, n as DAY_LABELS, D as DEFAULT_API_ENDPOINT, l as REPO_URL, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-DbIjuNDH.js'; | ||
@@ -4,0 +4,0 @@ /** |
+1
-1
@@ -1,3 +0,3 @@ | ||
| var u="https://github-contribution-graph.netlify.app/api/ghcg/fetch-data",m="https://github.com/iamjr15/github-contribution-graph",C=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],h=["","Mon","","Wed","","Fri",""],c={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function g(o,e=u){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=await fetch(t);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function L(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),n=e.insertRow().insertCell();n.style.width="28px";for(let i=0;i<7;i++){let a=t.insertRow().insertCell();h[i]&&(a.innerHTML=`<span class="ghCalendarLabel">${h[i]}</span>`);}return {table:o,thead:e,tbody:t}}function w(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let n=o.rows[0].insertCell(),i=document.createElement("span");i.textContent=e[t].name,i.className="ghCalendarLabel",n.appendChild(i),n.colSpan=r;}}}function H(o,e){for(let t of e)for(let r of t.contributionDays){let n=document.createElement("span"),i=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${i.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function x(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function P(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function M(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${o} contributions in the last year`;let i=document.createElement("div");return i.innerHTML=`<a href="https://github.com/${e}">${e}</a><img src="${t}" alt="${e}'s avatar">`,r.appendChild(n),r.appendChild(i),r}function N(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let n of C){let i=document.createElement("div");i.className="ghCalendarDayCell",i.dataset.level=n,e.appendChild(i);}return e.appendChild(r),o.appendChild(e),o}function R(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=m,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","30"),t.setAttribute("height","30"),t.style.marginTop="15px",t.style.opacity="0.6",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function b(o,e,t,r={}){let{showHeader:n=true,showFooter:i=true,showThumbnail:l=true}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:T,thead:E,tbody:y}=L();H(y,a.weeks),w(E,a.months);let p=x(),d=P();if(d.appendChild(T),i){let s=N();d.appendChild(s);}if(p.appendChild(d),n){let s=M(a.totalContributions,t,e.avatarUrl);o.appendChild(s);}if(o.appendChild(p),l){let s=R();o.appendChild(s);}}function S(o){return o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function v(o,e){let t=typeof e=="string"?c[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily));}function G(o){let e=typeof o=="string"?c[o]:o;if(!e)return "";let t=[];for(let[r,n]of Object.entries(e))if(n){let i=`--gh-${S(r).replace("color","-color")}`;t.push(`${i}: ${n};`);}return t.join(` | ||
| var u="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",m="https://github.com/iamjr15/github-contribution-graph",C=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],h=["","Mon","","Wed","","Fri",""],c={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function g(o,e=u){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=await fetch(t);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function L(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),n=e.insertRow().insertCell();n.style.width="28px";for(let i=0;i<7;i++){let a=t.insertRow().insertCell();h[i]&&(a.innerHTML=`<span class="ghCalendarLabel">${h[i]}</span>`);}return {table:o,thead:e,tbody:t}}function w(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let n=o.rows[0].insertCell(),i=document.createElement("span");i.textContent=e[t].name,i.className="ghCalendarLabel",n.appendChild(i),n.colSpan=r;}}}function H(o,e){for(let t of e)for(let r of t.contributionDays){let n=document.createElement("span"),i=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${i.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function x(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function P(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function M(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${o} contributions in the last year`;let i=document.createElement("div");return i.innerHTML=`<a href="https://github.com/${e}">${e}</a><img src="${t}" alt="${e}'s avatar">`,r.appendChild(n),r.appendChild(i),r}function N(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let n of C){let i=document.createElement("div");i.className="ghCalendarDayCell",i.dataset.level=n,e.appendChild(i);}return e.appendChild(r),o.appendChild(e),o}function R(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=m,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.style.marginTop="10px",t.style.opacity="0.5",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function b(o,e,t,r={}){let{showHeader:n=true,showFooter:i=true,showThumbnail:l=true}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:T,thead:E,tbody:y}=L();H(y,a.weeks),w(E,a.months);let p=x(),d=P();if(d.appendChild(T),i){let s=N();d.appendChild(s);}if(p.appendChild(d),n){let s=M(a.totalContributions,t,e.avatarUrl);o.appendChild(s);}if(o.appendChild(p),l){let s=R();o.appendChild(s);}}function S(o){return o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function v(o,e){let t=typeof e=="string"?c[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily));}function G(o){let e=typeof o=="string"?c[o]:o;if(!e)return "";let t=[];for(let[r,n]of Object.entries(e))if(n){let i=`--gh-${S(r).replace("color","-color")}`;t.push(`${i}: ${n};`);}return t.join(` | ||
| `)}function O(){return Object.keys(c)}var f=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container);}resolveContainer(e){if(typeof e=="string"){let r=document.querySelector(e);if(!r)throw new Error(`Container not found: ${e}`);return r}if(e instanceof HTMLElement)return e;let t=document.getElementById("gh");if(!t)throw new Error('No container found. Specify container in config or add element with id="gh"');return t}async render(){try{this.data=await g(this.config.username,this.config.apiEndpoint),b(this.container,this.data,this.config.username,{showHeader:this.config.showHeader,showFooter:this.config.showFooter,showThumbnail:this.config.showThumbnail}),this.config.theme&&v(this.container,this.config.theme),this.config.onDataLoaded?.(this.data);}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null;}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container)),this.render()}};export{C as CONTRIBUTION_LEVELS,h as DAY_LABELS,u as DEFAULT_API_ENDPOINT,f as GitHubContributionWidget,m as REPO_URL,c as THEME_PRESETS,w as addMonths,H as addWeeks,v as applyTheme,P as createCanvas,x as createCard,N as createFooter,M as createHeader,L as createTable,R as createThumbnail,g as fetchContributionData,G as getThemeCSS,O as getThemePresets,b as renderWidget};//# sourceMappingURL=index.js.map | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","response","data","createTable","table","thead","tbody","firstCell","cell","addMonths","months","i","totalWeeks","label","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","link","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionWidget","el","error"],"mappings":"AAKO,IAAMA,CAAAA,CAAuB,mEAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,EAAa,CAAC,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,MAAO,EAAE,CAAA,CAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,QAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,YAAa,SACf,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,UAAW,SA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AAA,CAAK,IAAA,CAAM,KAAK,MAAA,CAAO,QAAA,CAAU,CAC5D,UAAA,CAAY,IAAA,CAAK,OAAO,UAAA,CACxB,UAAA,CAAY,IAAA,CAAK,MAAA,CAAO,UAAA,CACxB,aAAA,CAAe,KAAK,MAAA,CAAO,aAC7B,CAAC,CAAA,CAEG,IAAA,CAAK,OAAO,KAAA,EACdW,CAAAA,CAAW,IAAA,CAAK,SAAA,CAAW,IAAA,CAAK,MAAA,CAAO,KAAK,CAAA,CAG9C,IAAA,CAAK,OAAO,YAAA,GAAe,IAAA,CAAK,IAAI,EACtC,CAAA,MAASY,CAAAA,CAAO,CACd,IAAA,CAAK,SAAA,CAAU,UACb,kEAAA,CACF,IAAA,CAAK,OAAO,OAAA,GACVA,CAAAA,YAAiB,MAAQA,CAAAA,CAAQ,IAAI,KAAA,CAAM,eAAe,CAC5D,EACF,CACF,CAKA,MAAM,SAAyB,CAC7B,OAAO,KAAK,MAAA,EACd,CAKA,OAAA,EAA6B,CAC3B,OAAO,KAAK,IACd,CAKA,SAAgB,CACd,IAAA,CAAK,UAAU,SAAA,CAAY,EAAA,CAC3B,IAAA,CAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOT,CAAAA,CAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,EAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CAAA,CAGlD,IAAA,CAAK,MAAA,EACd,CACF","file":"index.js","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://github-contribution-graph.netlify.app/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '30');\n svg.setAttribute('height', '30');\n svg.style.marginTop = '15px';\n svg.style.opacity = '0.6';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"]} | ||
| {"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","response","data","createTable","table","thead","tbody","firstCell","cell","addMonths","months","i","totalWeeks","label","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","link","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionWidget","el","error"],"mappings":"AAKO,IAAMA,CAAAA,CAAuB,0DAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,EAAa,CAAC,EAAA,C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,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CAAA,CAGlD,IAAA,CAAK,MAAA,EACd,CACF","file":"index.js","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"]} |
+1
-1
@@ -1,3 +0,3 @@ | ||
| 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var T="https://github-contribution-graph.netlify.app/api/ghcg/fetch-data",P="https://github.com/iamjr15/github-contribution-graph",U=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],y=["","Mon","","Wed","","Fri",""],m={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function b(t,o=T){if(!t||typeof t!="string")throw new Error("Username is required");let e=`${o}?login=${encodeURIComponent(t.trim())}`,r=await fetch(e);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function I(){let t=document.createElement("table");t.className="ghCalendarTable";let o=t.createTHead(),e=t.createTBody(),n=o.insertRow().insertCell();n.style.width="28px";for(let a=0;a<7;a++){let i=e.insertRow().insertCell();y[a]&&(i.innerHTML=`<span class="ghCalendarLabel">${y[a]}</span>`);}return {table:t,thead:o,tbody:e}}function _(t,o){for(let e=0;e<o.length-1;e++){let r=o[e].totalWeeks;if(r>=2){let n=t.rows[0].insertCell(),a=document.createElement("span");a.textContent=o[e].name,a.className="ghCalendarLabel",n.appendChild(a),n.colSpan=r;}}}function O(t,o){for(let e of o)for(let r of e.contributionDays){let n=document.createElement("span"),a=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${a.toDateString()}`;let l=t.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function k(){let t=document.createElement("div");return t.className="ghCalendarCard",t}function F(){let t=document.createElement("div");return t.className="ghCalendarCanvas",t}function $(t,o,e){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${t} contributions in the last year`;let a=document.createElement("div");return a.innerHTML=`<a href="https://github.com/${o}">${o}</a><img src="${e}" alt="${o}'s avatar">`,r.appendChild(n),r.appendChild(a),r}function W(){let t=document.createElement("div");t.className="ghCalendarCardFooter";let o=document.createElement("div");o.className="ghCalendarCardFooterColors";let e=document.createElement("span");e.textContent="Less";let r=document.createElement("span");r.textContent="More",o.appendChild(e);for(let n of U){let a=document.createElement("div");a.className="ghCalendarDayCell",a.dataset.level=n,o.appendChild(a);}return o.appendChild(r),t.appendChild(o),t}function B(){let t=document.createElement("div");t.className="ghThumbNail";let o=document.createElement("a");o.href=P,o.target="_blank",o.rel="noopener noreferrer";let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 98 96"),e.setAttribute("width","30"),e.setAttribute("height","30"),e.style.marginTop="15px",e.style.opacity="0.6",e.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),e.appendChild(r),o.appendChild(e),t.appendChild(o),t}function R(t,o,e,r={}){let{showHeader:n=true,showFooter:a=true,showThumbnail:l=true}=r;t.innerHTML="";let i=o.contributionsCollection.contributionCalendar,{table:p,thead:d,tbody:u}=I();O(u,i.weeks),_(d,i.months);let c=k(),f=F();if(f.appendChild(p),a){let s=W();f.appendChild(s);}if(c.appendChild(f),n){let s=$(i.totalContributions,e,o.avatarUrl);t.appendChild(s);}if(t.appendChild(c),l){let s=B();t.appendChild(s);}}function j(t){return t.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`)}function v(t,o){let e=typeof o=="string"?m[o]:o;e&&(e.bgColor&&t.style.setProperty("--gh-bg-color",e.bgColor),e.textColor&&t.style.setProperty("--gh-text-default-color",e.textColor),e.cellLevel0&&t.style.setProperty("--gh-cell-level0-color",e.cellLevel0),e.cellLevel1&&t.style.setProperty("--gh-cell-level1-color",e.cellLevel1),e.cellLevel2&&t.style.setProperty("--gh-cell-level2-color",e.cellLevel2),e.cellLevel3&&t.style.setProperty("--gh-cell-level3-color",e.cellLevel3),e.cellLevel4&&t.style.setProperty("--gh-cell-level4-color",e.cellLevel4),e.borderColor&&t.style.setProperty("--gh-border-card-color",e.borderColor),e.fontFamily&&t.style.setProperty("--gh-font-default-family",e.fontFamily));}function Q(t){let o=typeof t=="string"?m[t]:t;if(!o)return "";let e=[];for(let[r,n]of Object.entries(o))if(n){let a=`--gh-${j(r).replace("color","-color")}`;e.push(`${a}: ${n};`);}return e.join(` | ||
| 'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var T="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",P="https://github.com/iamjr15/github-contribution-graph",U=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],y=["","Mon","","Wed","","Fri",""],m={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function b(t,o=T){if(!t||typeof t!="string")throw new Error("Username is required");let e=`${o}?login=${encodeURIComponent(t.trim())}`,r=await fetch(e);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function I(){let t=document.createElement("table");t.className="ghCalendarTable";let o=t.createTHead(),e=t.createTBody(),n=o.insertRow().insertCell();n.style.width="28px";for(let a=0;a<7;a++){let i=e.insertRow().insertCell();y[a]&&(i.innerHTML=`<span class="ghCalendarLabel">${y[a]}</span>`);}return {table:t,thead:o,tbody:e}}function _(t,o){for(let e=0;e<o.length-1;e++){let r=o[e].totalWeeks;if(r>=2){let n=t.rows[0].insertCell(),a=document.createElement("span");a.textContent=o[e].name,a.className="ghCalendarLabel",n.appendChild(a),n.colSpan=r;}}}function O(t,o){for(let e of o)for(let r of e.contributionDays){let n=document.createElement("span"),a=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${a.toDateString()}`;let l=t.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function k(){let t=document.createElement("div");return t.className="ghCalendarCard",t}function F(){let t=document.createElement("div");return t.className="ghCalendarCanvas",t}function $(t,o,e){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${t} contributions in the last year`;let a=document.createElement("div");return a.innerHTML=`<a href="https://github.com/${o}">${o}</a><img src="${e}" alt="${o}'s avatar">`,r.appendChild(n),r.appendChild(a),r}function W(){let t=document.createElement("div");t.className="ghCalendarCardFooter";let o=document.createElement("div");o.className="ghCalendarCardFooterColors";let e=document.createElement("span");e.textContent="Less";let r=document.createElement("span");r.textContent="More",o.appendChild(e);for(let n of U){let a=document.createElement("div");a.className="ghCalendarDayCell",a.dataset.level=n,o.appendChild(a);}return o.appendChild(r),t.appendChild(o),t}function B(){let t=document.createElement("div");t.className="ghThumbNail";let o=document.createElement("a");o.href=P,o.target="_blank",o.rel="noopener noreferrer";let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 98 96"),e.setAttribute("width","18"),e.setAttribute("height","18"),e.style.marginTop="10px",e.style.opacity="0.5",e.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),e.appendChild(r),o.appendChild(e),t.appendChild(o),t}function R(t,o,e,r={}){let{showHeader:n=true,showFooter:a=true,showThumbnail:l=true}=r;t.innerHTML="";let i=o.contributionsCollection.contributionCalendar,{table:p,thead:d,tbody:u}=I();O(u,i.weeks),_(d,i.months);let c=k(),f=F();if(f.appendChild(p),a){let s=W();f.appendChild(s);}if(c.appendChild(f),n){let s=$(i.totalContributions,e,o.avatarUrl);t.appendChild(s);}if(t.appendChild(c),l){let s=B();t.appendChild(s);}}function j(t){return t.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`)}function v(t,o){let e=typeof o=="string"?m[o]:o;e&&(e.bgColor&&t.style.setProperty("--gh-bg-color",e.bgColor),e.textColor&&t.style.setProperty("--gh-text-default-color",e.textColor),e.cellLevel0&&t.style.setProperty("--gh-cell-level0-color",e.cellLevel0),e.cellLevel1&&t.style.setProperty("--gh-cell-level1-color",e.cellLevel1),e.cellLevel2&&t.style.setProperty("--gh-cell-level2-color",e.cellLevel2),e.cellLevel3&&t.style.setProperty("--gh-cell-level3-color",e.cellLevel3),e.cellLevel4&&t.style.setProperty("--gh-cell-level4-color",e.cellLevel4),e.borderColor&&t.style.setProperty("--gh-border-card-color",e.borderColor),e.fontFamily&&t.style.setProperty("--gh-font-default-family",e.fontFamily));}function Q(t){let o=typeof t=="string"?m[t]:t;if(!o)return "";let e=[];for(let[r,n]of Object.entries(o))if(n){let a=`--gh-${j(r).replace("color","-color")}`;e.push(`${a}: ${n};`);}return e.join(` | ||
| `)}function q(){return Object.keys(m)}var G=react.forwardRef((t,o)=>{let{username:e,apiEndpoint:r,theme:n="default",showHeader:a=true,showFooter:l=true,showThumbnail:i=true,className:p,style:d,onDataLoaded:u,onError:c,onLoading:f}=t,s=react.useRef(null),[C,S]=react.useState(null),[M,g]=react.useState(true),[A,E]=react.useState(null),x=async()=>{if(!e){E(new Error("Username is required")),g(false);return}g(true),f?.(true),E(null);try{let h=await b(e,r);S(h),u?.(h);}catch(h){let D=h instanceof Error?h:new Error("Unknown error");E(D),c?.(D);}finally{g(false),f?.(false);}};return react.useEffect(()=>{x();},[e,r]),react.useEffect(()=>{C&&s.current&&(R(s.current,C,e,{showHeader:a,showFooter:l,showThumbnail:i}),v(s.current,n));},[C,n,a,l,i,e]),react.useImperativeHandle(o,()=>({refresh:x,getData:()=>C})),A?jsxRuntime.jsx("div",{className:p,style:d,children:jsxRuntime.jsx("p",{style:{color:"#f85149"},children:"Failed to load contribution data."})}):jsxRuntime.jsx("div",{ref:s,className:p,style:d,"data-loading":M})});G.displayName="GitHubContributionGraph";function J(t,o={}){let{apiEndpoint:e,autoFetch:r=true}=o,[n,a]=react.useState(null),[l,i]=react.useState(r),[p,d]=react.useState(null),u=react.useCallback(async()=>{if(!t){d(new Error("Username is required"));return}i(true),d(null);try{let c=await b(t,e);a(c);}catch(c){d(c instanceof Error?c:new Error("Unknown error"));}finally{i(false);}},[t,e]);return react.useEffect(()=>{r&&t&&u();},[r,t,u]),{data:n,loading:l,error:p,refetch:u}}exports.DEFAULT_API_ENDPOINT=T;exports.GitHubContributionGraph=G;exports.THEME_PRESETS=m;exports.applyTheme=v;exports.fetchContributionData=b;exports.getThemeCSS=Q;exports.getThemePresets=q;exports.useContributionData=J;//# sourceMappingURL=react.cjs.map | ||
| //# sourceMappingURL=react.cjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/react/GitHubContributionGraph.tsx","../src/react/useContributionData.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","response","data","createTable","table","thead","tbody","firstCell","i","cell","addMonths","months","totalWeeks","label","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","link","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionGraph","forwardRef","props","ref","className","style","onDataLoaded","onError","onLoading","containerRef","useRef","setData","useState","loading","setLoading","error","setError","fetchData","userData","err","fetchError","useEffect","useImperativeHandle","jsx","useContributionData","autoFetch","refetch","useCallback"],"mappings":"gFAKO,IAAMA,EAAuB,mEAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,iBACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,CAAAA,CAAa,CAAC,GAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAE,EAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,EACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,KAAA,CAAO,CACL,QAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,QAAA,CAAU,CACR,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,UACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,YAAa,S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AA,CAAMsE,CAAO,EAAIC,cAAAA,CAA4B,IAAI,EAClD,CAACC,CAAAA,CAASC,CAAU,CAAA,CAAIF,cAAAA,CAASa,CAAS,CAAA,CAC1C,CAACV,CAAAA,CAAOC,CAAQ,EAAIJ,cAAAA,CAAuB,IAAI,EAE/Cc,CAAAA,CAAUC,iBAAAA,CAAY,SAAY,CACtC,GAAI,CAAC1F,CAAAA,CAAU,CACb+E,EAAS,IAAI,KAAA,CAAM,sBAAsB,CAAC,CAAA,CAC1C,MACF,CAEAF,EAAW,IAAI,CAAA,CACfE,EAAS,IAAI,CAAA,CAEb,GAAI,CACF,IAAME,EAAW,MAAMlF,CAAAA,CAAsBC,EAAUC,CAAW,CAAA,CAClEyE,EAAQO,CAAQ,EAClB,OAASC,CAAAA,CAAK,CACZH,CAAAA,CAASG,CAAAA,YAAe,MAAQA,CAAAA,CAAM,IAAI,MAAM,eAAe,CAAC,EAClE,CAAA,OAAE,CACAL,EAAW,KAAK,EAClB,CACF,CAAA,CAAG,CAAC7E,EAAUC,CAAW,CAAC,EAE1B,OAAAmF,eAAAA,CAAU,IAAM,CACVI,CAAAA,EAAaxF,GACfyF,CAAAA,GAEJ,EAAG,CAACD,CAAAA,CAAWxF,EAAUyF,CAAO,CAAC,EAE1B,CAAE,IAAA,CAAArF,EAAM,OAAA,CAAAwE,CAAAA,CAAS,MAAAE,CAAAA,CAAO,OAAA,CAAAW,CAAQ,CACzC","file":"react.cjs","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://github-contribution-graph.netlify.app/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '30');\n svg.setAttribute('height', '30');\n svg.style.marginTop = '15px';\n svg.style.opacity = '0.6';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import React, {\n useRef,\n useEffect,\n useState,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport { applyTheme } from '../styles/themes';\nimport type { GitHubUser, ThemePreset, ThemeConfig } from '../core/types';\n\nexport interface GitHubContributionGraphProps {\n /**\n * GitHub username to display contributions for\n */\n username: string;\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Theme preset name or custom theme configuration\n */\n theme?: ThemePreset | ThemeConfig;\n /**\n * Whether to show the header with total contributions\n * @default true\n */\n showHeader?: boolean;\n /**\n * Whether to show the footer legend\n * @default true\n */\n showFooter?: boolean;\n /**\n * Whether to show the GitHub thumbnail/attribution\n * @default true\n */\n showThumbnail?: boolean;\n /**\n * Additional CSS class name\n */\n className?: string;\n /**\n * Inline styles\n */\n style?: React.CSSProperties;\n /**\n * Callback when data is successfully loaded\n */\n onDataLoaded?: (data: GitHubUser) => void;\n /**\n * Callback when an error occurs\n */\n onError?: (error: Error) => void;\n /**\n * Callback when loading state changes\n */\n onLoading?: (isLoading: boolean) => void;\n}\n\nexport interface GitHubContributionGraphRef {\n /**\n * Manually refresh the contribution data\n */\n refresh: () => Promise<void>;\n /**\n * Get the currently loaded data\n */\n getData: () => GitHubUser | null;\n}\n\n/**\n * React component for displaying GitHub contribution graphs\n *\n * @example\n * ```tsx\n * import { GitHubContributionGraph } from 'github-contribution-graph/react';\n * import 'github-contribution-graph/styles.css';\n *\n * function App() {\n * return (\n * <GitHubContributionGraph\n * username=\"octocat\"\n * theme=\"midnight\"\n * onDataLoaded={(data) => console.log('Loaded!', data)}\n * />\n * );\n * }\n * ```\n */\nexport const GitHubContributionGraph = forwardRef<\n GitHubContributionGraphRef,\n GitHubContributionGraphProps\n>((props, ref) => {\n const {\n username,\n apiEndpoint,\n theme = 'default',\n showHeader = true,\n showFooter = true,\n showThumbnail = true,\n className,\n style,\n onDataLoaded,\n onError,\n onLoading,\n } = props;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchData = async () => {\n if (!username) {\n setError(new Error('Username is required'));\n setLoading(false);\n return;\n }\n\n setLoading(true);\n onLoading?.(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n onDataLoaded?.(userData);\n } catch (err) {\n const fetchError = err instanceof Error ? err : new Error('Unknown error');\n setError(fetchError);\n onError?.(fetchError);\n } finally {\n setLoading(false);\n onLoading?.(false);\n }\n };\n\n // Fetch data when username or apiEndpoint changes\n useEffect(() => {\n fetchData();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [username, apiEndpoint]);\n\n // Render widget when data or options change\n useEffect(() => {\n if (data && containerRef.current) {\n renderWidget(containerRef.current, data, username, {\n showHeader,\n showFooter,\n showThumbnail,\n });\n applyTheme(containerRef.current, theme);\n }\n }, [data, theme, showHeader, showFooter, showThumbnail, username]);\n\n // Expose ref methods\n useImperativeHandle(ref, () => ({\n refresh: fetchData,\n getData: () => data,\n }));\n\n if (error) {\n return (\n <div className={className} style={style}>\n <p style={{ color: '#f85149' }}>Failed to load contribution data.</p>\n </div>\n );\n }\n\n return (\n <div\n ref={containerRef}\n className={className}\n style={style}\n data-loading={loading}\n />\n );\n});\n\nGitHubContributionGraph.displayName = 'GitHubContributionGraph';\n","import { useState, useEffect, useCallback } from 'react';\nimport { fetchContributionData } from '../core/api';\nimport type { GitHubUser } from '../core/types';\n\nexport interface UseContributionDataOptions {\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Whether to fetch data automatically on mount\n * @default true\n */\n autoFetch?: boolean;\n}\n\nexport interface UseContributionDataResult {\n /**\n * The fetched user data, null if not loaded\n */\n data: GitHubUser | null;\n /**\n * Whether data is currently being fetched\n */\n loading: boolean;\n /**\n * Error object if fetch failed\n */\n error: Error | null;\n /**\n * Function to manually refetch data\n */\n refetch: () => Promise<void>;\n}\n\n/**\n * React hook for fetching GitHub contribution data\n *\n * @param username - GitHub username\n * @param options - Hook options\n * @returns Object containing data, loading state, error, and refetch function\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { data, loading, error, refetch } = useContributionData('octocat');\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <p>Total: {data?.contributionsCollection.contributionCalendar.totalContributions}</p>\n * <button onClick={refetch}>Refresh</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useContributionData(\n username: string,\n options: UseContributionDataOptions = {}\n): UseContributionDataResult {\n const { apiEndpoint, autoFetch = true } = options;\n\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(autoFetch);\n const [error, setError] = useState<Error | null>(null);\n\n const refetch = useCallback(async () => {\n if (!username) {\n setError(new Error('Username is required'));\n return;\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Unknown error'));\n } finally {\n setLoading(false);\n }\n }, [username, apiEndpoint]);\n\n useEffect(() => {\n if (autoFetch && username) {\n refetch();\n }\n }, [autoFetch, username, refetch]);\n\n return { data, loading, error, refetch };\n}\n"]} | ||
| {"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/react/GitHubContributionGraph.tsx","../src/react/useContributionData.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","response","data","createTable","table","thead","tbody","firstCell","i","cell","addMonths","months","totalWeeks","label","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","link","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionGraph","forwardRef","props","ref","className","style","onDataLoaded","onError","onLoading","containerRef","useRef","setData","useState","loading","setLoading","error","setError","fetchData","userData","err","fetchError","useEffect","useImperativeHandle","jsx","useContributionData","autoFetch","refetch","useCallback"],"mappings":"gFAKO,IAAMA,EAAuB,0DAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,iBACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,CAAAA,CAAa,CAAC,GAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAE,EAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,EACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,KAAA,CAAO,CACL,QAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,QAAA,CAAU,CACR,OAAA,CA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CC3H/B,SAASwB,CAAAA,CACdvF,EACA6C,CAAAA,CAAsC,EAAC,CACZ,CAC3B,GAAM,CAAE,WAAA,CAAA5C,EAAa,SAAA,CAAAuF,CAAAA,CAAY,IAAK,CAAA,CAAI3C,CAAAA,CAEpC,CAACzC,CAAAA,CAAMsE,CAAO,EAAIC,cAAAA,CAA4B,IAAI,EAClD,CAACC,CAAAA,CAASC,CAAU,CAAA,CAAIF,cAAAA,CAASa,CAAS,CAAA,CAC1C,CAACV,CAAAA,CAAOC,CAAQ,EAAIJ,cAAAA,CAAuB,IAAI,EAE/Cc,CAAAA,CAAUC,iBAAAA,CAAY,SAAY,CACtC,GAAI,CAAC1F,CAAAA,CAAU,CACb+E,EAAS,IAAI,KAAA,CAAM,sBAAsB,CAAC,CAAA,CAC1C,MACF,CAEAF,EAAW,IAAI,CAAA,CACfE,EAAS,IAAI,CAAA,CAEb,GAAI,CACF,IAAME,EAAW,MAAMlF,CAAAA,CAAsBC,EAAUC,CAAW,CAAA,CAClEyE,EAAQO,CAAQ,EAClB,OAASC,CAAAA,CAAK,CACZH,CAAAA,CAASG,CAAAA,YAAe,MAAQA,CAAAA,CAAM,IAAI,MAAM,eAAe,CAAC,EAClE,CAAA,OAAE,CACAL,EAAW,KAAK,EAClB,CACF,CAAA,CAAG,CAAC7E,EAAUC,CAAW,CAAC,EAE1B,OAAAmF,eAAAA,CAAU,IAAM,CACVI,CAAAA,EAAaxF,GACfyF,CAAAA,GAEJ,EAAG,CAACD,CAAAA,CAAWxF,EAAUyF,CAAO,CAAC,EAE1B,CAAE,IAAA,CAAArF,EAAM,OAAA,CAAAwE,CAAAA,CAAS,MAAAE,CAAAA,CAAO,OAAA,CAAAW,CAAQ,CACzC","file":"react.cjs","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import React, {\n useRef,\n useEffect,\n useState,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport { applyTheme } from '../styles/themes';\nimport type { GitHubUser, ThemePreset, ThemeConfig } from '../core/types';\n\nexport interface GitHubContributionGraphProps {\n /**\n * GitHub username to display contributions for\n */\n username: string;\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Theme preset name or custom theme configuration\n */\n theme?: ThemePreset | ThemeConfig;\n /**\n * Whether to show the header with total contributions\n * @default true\n */\n showHeader?: boolean;\n /**\n * Whether to show the footer legend\n * @default true\n */\n showFooter?: boolean;\n /**\n * Whether to show the GitHub thumbnail/attribution\n * @default true\n */\n showThumbnail?: boolean;\n /**\n * Additional CSS class name\n */\n className?: string;\n /**\n * Inline styles\n */\n style?: React.CSSProperties;\n /**\n * Callback when data is successfully loaded\n */\n onDataLoaded?: (data: GitHubUser) => void;\n /**\n * Callback when an error occurs\n */\n onError?: (error: Error) => void;\n /**\n * Callback when loading state changes\n */\n onLoading?: (isLoading: boolean) => void;\n}\n\nexport interface GitHubContributionGraphRef {\n /**\n * Manually refresh the contribution data\n */\n refresh: () => Promise<void>;\n /**\n * Get the currently loaded data\n */\n getData: () => GitHubUser | null;\n}\n\n/**\n * React component for displaying GitHub contribution graphs\n *\n * @example\n * ```tsx\n * import { GitHubContributionGraph } from 'github-contribution-graph/react';\n * import 'github-contribution-graph/styles.css';\n *\n * function App() {\n * return (\n * <GitHubContributionGraph\n * username=\"octocat\"\n * theme=\"midnight\"\n * onDataLoaded={(data) => console.log('Loaded!', data)}\n * />\n * );\n * }\n * ```\n */\nexport const GitHubContributionGraph = forwardRef<\n GitHubContributionGraphRef,\n GitHubContributionGraphProps\n>((props, ref) => {\n const {\n username,\n apiEndpoint,\n theme = 'default',\n showHeader = true,\n showFooter = true,\n showThumbnail = true,\n className,\n style,\n onDataLoaded,\n onError,\n onLoading,\n } = props;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchData = async () => {\n if (!username) {\n setError(new Error('Username is required'));\n setLoading(false);\n return;\n }\n\n setLoading(true);\n onLoading?.(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n onDataLoaded?.(userData);\n } catch (err) {\n const fetchError = err instanceof Error ? err : new Error('Unknown error');\n setError(fetchError);\n onError?.(fetchError);\n } finally {\n setLoading(false);\n onLoading?.(false);\n }\n };\n\n // Fetch data when username or apiEndpoint changes\n useEffect(() => {\n fetchData();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [username, apiEndpoint]);\n\n // Render widget when data or options change\n useEffect(() => {\n if (data && containerRef.current) {\n renderWidget(containerRef.current, data, username, {\n showHeader,\n showFooter,\n showThumbnail,\n });\n applyTheme(containerRef.current, theme);\n }\n }, [data, theme, showHeader, showFooter, showThumbnail, username]);\n\n // Expose ref methods\n useImperativeHandle(ref, () => ({\n refresh: fetchData,\n getData: () => data,\n }));\n\n if (error) {\n return (\n <div className={className} style={style}>\n <p style={{ color: '#f85149' }}>Failed to load contribution data.</p>\n </div>\n );\n }\n\n return (\n <div\n ref={containerRef}\n className={className}\n style={style}\n data-loading={loading}\n />\n );\n});\n\nGitHubContributionGraph.displayName = 'GitHubContributionGraph';\n","import { useState, useEffect, useCallback } from 'react';\nimport { fetchContributionData } from '../core/api';\nimport type { GitHubUser } from '../core/types';\n\nexport interface UseContributionDataOptions {\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Whether to fetch data automatically on mount\n * @default true\n */\n autoFetch?: boolean;\n}\n\nexport interface UseContributionDataResult {\n /**\n * The fetched user data, null if not loaded\n */\n data: GitHubUser | null;\n /**\n * Whether data is currently being fetched\n */\n loading: boolean;\n /**\n * Error object if fetch failed\n */\n error: Error | null;\n /**\n * Function to manually refetch data\n */\n refetch: () => Promise<void>;\n}\n\n/**\n * React hook for fetching GitHub contribution data\n *\n * @param username - GitHub username\n * @param options - Hook options\n * @returns Object containing data, loading state, error, and refetch function\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { data, loading, error, refetch } = useContributionData('octocat');\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <p>Total: {data?.contributionsCollection.contributionCalendar.totalContributions}</p>\n * <button onClick={refetch}>Refresh</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useContributionData(\n username: string,\n options: UseContributionDataOptions = {}\n): UseContributionDataResult {\n const { apiEndpoint, autoFetch = true } = options;\n\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(autoFetch);\n const [error, setError] = useState<Error | null>(null);\n\n const refetch = useCallback(async () => {\n if (!username) {\n setError(new Error('Username is required'));\n return;\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Unknown error'));\n } finally {\n setLoading(false);\n }\n }, [username, apiEndpoint]);\n\n useEffect(() => {\n if (autoFetch && username) {\n refetch();\n }\n }, [autoFetch, username, refetch]);\n\n return { data, loading, error, refetch };\n}\n"]} |
+2
-2
| import React from 'react'; | ||
| import { T as ThemePreset, a as ThemeConfig, G as GitHubUser } from './themes-C8Fy4Stl.cjs'; | ||
| export { C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, d as THEME_PRESETS, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-C8Fy4Stl.cjs'; | ||
| import { T as ThemePreset, a as ThemeConfig, G as GitHubUser } from './themes-DbIjuNDH.cjs'; | ||
| export { C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, d as THEME_PRESETS, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-DbIjuNDH.cjs'; | ||
@@ -5,0 +5,0 @@ interface GitHubContributionGraphProps { |
+2
-2
| import React from 'react'; | ||
| import { T as ThemePreset, a as ThemeConfig, G as GitHubUser } from './themes-C8Fy4Stl.js'; | ||
| export { C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, d as THEME_PRESETS, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-C8Fy4Stl.js'; | ||
| import { T as ThemePreset, a as ThemeConfig, G as GitHubUser } from './themes-DbIjuNDH.js'; | ||
| export { C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, d as THEME_PRESETS, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-DbIjuNDH.js'; | ||
@@ -5,0 +5,0 @@ interface GitHubContributionGraphProps { |
+1
-1
@@ -1,3 +0,3 @@ | ||
| import {forwardRef,useRef,useState,useEffect,useImperativeHandle,useCallback}from'react';import {jsx}from'react/jsx-runtime';var T="https://github-contribution-graph.netlify.app/api/ghcg/fetch-data",P="https://github.com/iamjr15/github-contribution-graph",U=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],y=["","Mon","","Wed","","Fri",""],m={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function b(t,o=T){if(!t||typeof t!="string")throw new Error("Username is required");let e=`${o}?login=${encodeURIComponent(t.trim())}`,r=await fetch(e);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function I(){let t=document.createElement("table");t.className="ghCalendarTable";let o=t.createTHead(),e=t.createTBody(),n=o.insertRow().insertCell();n.style.width="28px";for(let a=0;a<7;a++){let i=e.insertRow().insertCell();y[a]&&(i.innerHTML=`<span class="ghCalendarLabel">${y[a]}</span>`);}return {table:t,thead:o,tbody:e}}function _(t,o){for(let e=0;e<o.length-1;e++){let r=o[e].totalWeeks;if(r>=2){let n=t.rows[0].insertCell(),a=document.createElement("span");a.textContent=o[e].name,a.className="ghCalendarLabel",n.appendChild(a),n.colSpan=r;}}}function O(t,o){for(let e of o)for(let r of e.contributionDays){let n=document.createElement("span"),a=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${a.toDateString()}`;let l=t.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function k(){let t=document.createElement("div");return t.className="ghCalendarCard",t}function F(){let t=document.createElement("div");return t.className="ghCalendarCanvas",t}function $(t,o,e){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${t} contributions in the last year`;let a=document.createElement("div");return a.innerHTML=`<a href="https://github.com/${o}">${o}</a><img src="${e}" alt="${o}'s avatar">`,r.appendChild(n),r.appendChild(a),r}function W(){let t=document.createElement("div");t.className="ghCalendarCardFooter";let o=document.createElement("div");o.className="ghCalendarCardFooterColors";let e=document.createElement("span");e.textContent="Less";let r=document.createElement("span");r.textContent="More",o.appendChild(e);for(let n of U){let a=document.createElement("div");a.className="ghCalendarDayCell",a.dataset.level=n,o.appendChild(a);}return o.appendChild(r),t.appendChild(o),t}function B(){let t=document.createElement("div");t.className="ghThumbNail";let o=document.createElement("a");o.href=P,o.target="_blank",o.rel="noopener noreferrer";let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 98 96"),e.setAttribute("width","30"),e.setAttribute("height","30"),e.style.marginTop="15px",e.style.opacity="0.6",e.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),e.appendChild(r),o.appendChild(e),t.appendChild(o),t}function R(t,o,e,r={}){let{showHeader:n=true,showFooter:a=true,showThumbnail:l=true}=r;t.innerHTML="";let i=o.contributionsCollection.contributionCalendar,{table:p,thead:d,tbody:u}=I();O(u,i.weeks),_(d,i.months);let c=k(),f=F();if(f.appendChild(p),a){let s=W();f.appendChild(s);}if(c.appendChild(f),n){let s=$(i.totalContributions,e,o.avatarUrl);t.appendChild(s);}if(t.appendChild(c),l){let s=B();t.appendChild(s);}}function j(t){return t.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`)}function v(t,o){let e=typeof o=="string"?m[o]:o;e&&(e.bgColor&&t.style.setProperty("--gh-bg-color",e.bgColor),e.textColor&&t.style.setProperty("--gh-text-default-color",e.textColor),e.cellLevel0&&t.style.setProperty("--gh-cell-level0-color",e.cellLevel0),e.cellLevel1&&t.style.setProperty("--gh-cell-level1-color",e.cellLevel1),e.cellLevel2&&t.style.setProperty("--gh-cell-level2-color",e.cellLevel2),e.cellLevel3&&t.style.setProperty("--gh-cell-level3-color",e.cellLevel3),e.cellLevel4&&t.style.setProperty("--gh-cell-level4-color",e.cellLevel4),e.borderColor&&t.style.setProperty("--gh-border-card-color",e.borderColor),e.fontFamily&&t.style.setProperty("--gh-font-default-family",e.fontFamily));}function Q(t){let o=typeof t=="string"?m[t]:t;if(!o)return "";let e=[];for(let[r,n]of Object.entries(o))if(n){let a=`--gh-${j(r).replace("color","-color")}`;e.push(`${a}: ${n};`);}return e.join(` | ||
| import {forwardRef,useRef,useState,useEffect,useImperativeHandle,useCallback}from'react';import {jsx}from'react/jsx-runtime';var T="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",P="https://github.com/iamjr15/github-contribution-graph",U=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],y=["","Mon","","Wed","","Fri",""],m={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function b(t,o=T){if(!t||typeof t!="string")throw new Error("Username is required");let e=`${o}?login=${encodeURIComponent(t.trim())}`,r=await fetch(e);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function I(){let t=document.createElement("table");t.className="ghCalendarTable";let o=t.createTHead(),e=t.createTBody(),n=o.insertRow().insertCell();n.style.width="28px";for(let a=0;a<7;a++){let i=e.insertRow().insertCell();y[a]&&(i.innerHTML=`<span class="ghCalendarLabel">${y[a]}</span>`);}return {table:t,thead:o,tbody:e}}function _(t,o){for(let e=0;e<o.length-1;e++){let r=o[e].totalWeeks;if(r>=2){let n=t.rows[0].insertCell(),a=document.createElement("span");a.textContent=o[e].name,a.className="ghCalendarLabel",n.appendChild(a),n.colSpan=r;}}}function O(t,o){for(let e of o)for(let r of e.contributionDays){let n=document.createElement("span"),a=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${a.toDateString()}`;let l=t.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function k(){let t=document.createElement("div");return t.className="ghCalendarCard",t}function F(){let t=document.createElement("div");return t.className="ghCalendarCanvas",t}function $(t,o,e){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${t} contributions in the last year`;let a=document.createElement("div");return a.innerHTML=`<a href="https://github.com/${o}">${o}</a><img src="${e}" alt="${o}'s avatar">`,r.appendChild(n),r.appendChild(a),r}function W(){let t=document.createElement("div");t.className="ghCalendarCardFooter";let o=document.createElement("div");o.className="ghCalendarCardFooterColors";let e=document.createElement("span");e.textContent="Less";let r=document.createElement("span");r.textContent="More",o.appendChild(e);for(let n of U){let a=document.createElement("div");a.className="ghCalendarDayCell",a.dataset.level=n,o.appendChild(a);}return o.appendChild(r),t.appendChild(o),t}function B(){let t=document.createElement("div");t.className="ghThumbNail";let o=document.createElement("a");o.href=P,o.target="_blank",o.rel="noopener noreferrer";let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 98 96"),e.setAttribute("width","18"),e.setAttribute("height","18"),e.style.marginTop="10px",e.style.opacity="0.5",e.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),e.appendChild(r),o.appendChild(e),t.appendChild(o),t}function R(t,o,e,r={}){let{showHeader:n=true,showFooter:a=true,showThumbnail:l=true}=r;t.innerHTML="";let i=o.contributionsCollection.contributionCalendar,{table:p,thead:d,tbody:u}=I();O(u,i.weeks),_(d,i.months);let c=k(),f=F();if(f.appendChild(p),a){let s=W();f.appendChild(s);}if(c.appendChild(f),n){let s=$(i.totalContributions,e,o.avatarUrl);t.appendChild(s);}if(t.appendChild(c),l){let s=B();t.appendChild(s);}}function j(t){return t.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`)}function v(t,o){let e=typeof o=="string"?m[o]:o;e&&(e.bgColor&&t.style.setProperty("--gh-bg-color",e.bgColor),e.textColor&&t.style.setProperty("--gh-text-default-color",e.textColor),e.cellLevel0&&t.style.setProperty("--gh-cell-level0-color",e.cellLevel0),e.cellLevel1&&t.style.setProperty("--gh-cell-level1-color",e.cellLevel1),e.cellLevel2&&t.style.setProperty("--gh-cell-level2-color",e.cellLevel2),e.cellLevel3&&t.style.setProperty("--gh-cell-level3-color",e.cellLevel3),e.cellLevel4&&t.style.setProperty("--gh-cell-level4-color",e.cellLevel4),e.borderColor&&t.style.setProperty("--gh-border-card-color",e.borderColor),e.fontFamily&&t.style.setProperty("--gh-font-default-family",e.fontFamily));}function Q(t){let o=typeof t=="string"?m[t]:t;if(!o)return "";let e=[];for(let[r,n]of Object.entries(o))if(n){let a=`--gh-${j(r).replace("color","-color")}`;e.push(`${a}: ${n};`);}return e.join(` | ||
| `)}function q(){return Object.keys(m)}var G=forwardRef((t,o)=>{let{username:e,apiEndpoint:r,theme:n="default",showHeader:a=true,showFooter:l=true,showThumbnail:i=true,className:p,style:d,onDataLoaded:u,onError:c,onLoading:f}=t,s=useRef(null),[C,S]=useState(null),[M,g]=useState(true),[A,E]=useState(null),x=async()=>{if(!e){E(new Error("Username is required")),g(false);return}g(true),f?.(true),E(null);try{let h=await b(e,r);S(h),u?.(h);}catch(h){let D=h instanceof Error?h:new Error("Unknown error");E(D),c?.(D);}finally{g(false),f?.(false);}};return useEffect(()=>{x();},[e,r]),useEffect(()=>{C&&s.current&&(R(s.current,C,e,{showHeader:a,showFooter:l,showThumbnail:i}),v(s.current,n));},[C,n,a,l,i,e]),useImperativeHandle(o,()=>({refresh:x,getData:()=>C})),A?jsx("div",{className:p,style:d,children:jsx("p",{style:{color:"#f85149"},children:"Failed to load contribution data."})}):jsx("div",{ref:s,className:p,style:d,"data-loading":M})});G.displayName="GitHubContributionGraph";function J(t,o={}){let{apiEndpoint:e,autoFetch:r=true}=o,[n,a]=useState(null),[l,i]=useState(r),[p,d]=useState(null),u=useCallback(async()=>{if(!t){d(new Error("Username is required"));return}i(true),d(null);try{let c=await b(t,e);a(c);}catch(c){d(c instanceof Error?c:new Error("Unknown error"));}finally{i(false);}},[t,e]);return useEffect(()=>{r&&t&&u();},[r,t,u]),{data:n,loading:l,error:p,refetch:u}}export{T as DEFAULT_API_ENDPOINT,G as GitHubContributionGraph,m as THEME_PRESETS,v as applyTheme,b as fetchContributionData,Q as getThemeCSS,q as getThemePresets,J as useContributionData};//# sourceMappingURL=react.js.map | ||
| //# sourceMappingURL=react.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/react/GitHubContributionGraph.tsx","../src/react/useContributionData.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","response","data","createTable","table","thead","tbody","firstCell","i","cell","addMonths","months","totalWeeks","label","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","link","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionGraph","forwardRef","props","ref","className","style","onDataLoaded","onError","onLoading","containerRef","useRef","setData","useState","loading","setLoading","error","setError","fetchData","userData","err","fetchError","useEffect","useImperativeHandle","jsx","useContributionData","autoFetch","refetch","useCallback"],"mappings":"6HAKO,IAAMA,EAAuB,mEAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,iBACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,CAAAA,CAAa,CAAC,GAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAE,EAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,EACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,KAAA,CAAO,CACL,QAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,QAAA,CAAU,CACR,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,UACX,UAAA,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AAA,CAAsC,EAAC,CACZ,CAC3B,GAAM,CAAE,WAAA,CAAA5C,EAAa,SAAA,CAAAuF,CAAAA,CAAY,IAAK,CAAA,CAAI3C,CAAAA,CAEpC,CAACzC,CAAAA,CAAMsE,CAAO,EAAIC,QAAAA,CAA4B,IAAI,EAClD,CAACC,CAAAA,CAASC,CAAU,CAAA,CAAIF,QAAAA,CAASa,CAAS,CAAA,CAC1C,CAACV,CAAAA,CAAOC,CAAQ,EAAIJ,QAAAA,CAAuB,IAAI,EAE/Cc,CAAAA,CAAUC,WAAAA,CAAY,SAAY,CACtC,GAAI,CAAC1F,CAAAA,CAAU,CACb+E,EAAS,IAAI,KAAA,CAAM,sBAAsB,CAAC,CAAA,CAC1C,MACF,CAEAF,EAAW,IAAI,CAAA,CACfE,EAAS,IAAI,CAAA,CAEb,GAAI,CACF,IAAME,EAAW,MAAMlF,CAAAA,CAAsBC,EAAUC,CAAW,CAAA,CAClEyE,EAAQO,CAAQ,EAClB,OAASC,CAAAA,CAAK,CACZH,CAAAA,CAASG,CAAAA,YAAe,MAAQA,CAAAA,CAAM,IAAI,MAAM,eAAe,CAAC,EAClE,CAAA,OAAE,CACAL,EAAW,KAAK,EAClB,CACF,CAAA,CAAG,CAAC7E,EAAUC,CAAW,CAAC,EAE1B,OAAAmF,SAAAA,CAAU,IAAM,CACVI,CAAAA,EAAaxF,GACfyF,CAAAA,GAEJ,EAAG,CAACD,CAAAA,CAAWxF,EAAUyF,CAAO,CAAC,EAE1B,CAAE,IAAA,CAAArF,EAAM,OAAA,CAAAwE,CAAAA,CAAS,MAAAE,CAAAA,CAAO,OAAA,CAAAW,CAAQ,CACzC","file":"react.js","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://github-contribution-graph.netlify.app/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '30');\n svg.setAttribute('height', '30');\n svg.style.marginTop = '15px';\n svg.style.opacity = '0.6';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import React, {\n useRef,\n useEffect,\n useState,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport { applyTheme } from '../styles/themes';\nimport type { GitHubUser, ThemePreset, ThemeConfig } from '../core/types';\n\nexport interface GitHubContributionGraphProps {\n /**\n * GitHub username to display contributions for\n */\n username: string;\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Theme preset name or custom theme configuration\n */\n theme?: ThemePreset | ThemeConfig;\n /**\n * Whether to show the header with total contributions\n * @default true\n */\n showHeader?: boolean;\n /**\n * Whether to show the footer legend\n * @default true\n */\n showFooter?: boolean;\n /**\n * Whether to show the GitHub thumbnail/attribution\n * @default true\n */\n showThumbnail?: boolean;\n /**\n * Additional CSS class name\n */\n className?: string;\n /**\n * Inline styles\n */\n style?: React.CSSProperties;\n /**\n * Callback when data is successfully loaded\n */\n onDataLoaded?: (data: GitHubUser) => void;\n /**\n * Callback when an error occurs\n */\n onError?: (error: Error) => void;\n /**\n * Callback when loading state changes\n */\n onLoading?: (isLoading: boolean) => void;\n}\n\nexport interface GitHubContributionGraphRef {\n /**\n * Manually refresh the contribution data\n */\n refresh: () => Promise<void>;\n /**\n * Get the currently loaded data\n */\n getData: () => GitHubUser | null;\n}\n\n/**\n * React component for displaying GitHub contribution graphs\n *\n * @example\n * ```tsx\n * import { GitHubContributionGraph } from 'github-contribution-graph/react';\n * import 'github-contribution-graph/styles.css';\n *\n * function App() {\n * return (\n * <GitHubContributionGraph\n * username=\"octocat\"\n * theme=\"midnight\"\n * onDataLoaded={(data) => console.log('Loaded!', data)}\n * />\n * );\n * }\n * ```\n */\nexport const GitHubContributionGraph = forwardRef<\n GitHubContributionGraphRef,\n GitHubContributionGraphProps\n>((props, ref) => {\n const {\n username,\n apiEndpoint,\n theme = 'default',\n showHeader = true,\n showFooter = true,\n showThumbnail = true,\n className,\n style,\n onDataLoaded,\n onError,\n onLoading,\n } = props;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchData = async () => {\n if (!username) {\n setError(new Error('Username is required'));\n setLoading(false);\n return;\n }\n\n setLoading(true);\n onLoading?.(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n onDataLoaded?.(userData);\n } catch (err) {\n const fetchError = err instanceof Error ? err : new Error('Unknown error');\n setError(fetchError);\n onError?.(fetchError);\n } finally {\n setLoading(false);\n onLoading?.(false);\n }\n };\n\n // Fetch data when username or apiEndpoint changes\n useEffect(() => {\n fetchData();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [username, apiEndpoint]);\n\n // Render widget when data or options change\n useEffect(() => {\n if (data && containerRef.current) {\n renderWidget(containerRef.current, data, username, {\n showHeader,\n showFooter,\n showThumbnail,\n });\n applyTheme(containerRef.current, theme);\n }\n }, [data, theme, showHeader, showFooter, showThumbnail, username]);\n\n // Expose ref methods\n useImperativeHandle(ref, () => ({\n refresh: fetchData,\n getData: () => data,\n }));\n\n if (error) {\n return (\n <div className={className} style={style}>\n <p style={{ color: '#f85149' }}>Failed to load contribution data.</p>\n </div>\n );\n }\n\n return (\n <div\n ref={containerRef}\n className={className}\n style={style}\n data-loading={loading}\n />\n );\n});\n\nGitHubContributionGraph.displayName = 'GitHubContributionGraph';\n","import { useState, useEffect, useCallback } from 'react';\nimport { fetchContributionData } from '../core/api';\nimport type { GitHubUser } from '../core/types';\n\nexport interface UseContributionDataOptions {\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Whether to fetch data automatically on mount\n * @default true\n */\n autoFetch?: boolean;\n}\n\nexport interface UseContributionDataResult {\n /**\n * The fetched user data, null if not loaded\n */\n data: GitHubUser | null;\n /**\n * Whether data is currently being fetched\n */\n loading: boolean;\n /**\n * Error object if fetch failed\n */\n error: Error | null;\n /**\n * Function to manually refetch data\n */\n refetch: () => Promise<void>;\n}\n\n/**\n * React hook for fetching GitHub contribution data\n *\n * @param username - GitHub username\n * @param options - Hook options\n * @returns Object containing data, loading state, error, and refetch function\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { data, loading, error, refetch } = useContributionData('octocat');\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <p>Total: {data?.contributionsCollection.contributionCalendar.totalContributions}</p>\n * <button onClick={refetch}>Refresh</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useContributionData(\n username: string,\n options: UseContributionDataOptions = {}\n): UseContributionDataResult {\n const { apiEndpoint, autoFetch = true } = options;\n\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(autoFetch);\n const [error, setError] = useState<Error | null>(null);\n\n const refetch = useCallback(async () => {\n if (!username) {\n setError(new Error('Username is required'));\n return;\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Unknown error'));\n } finally {\n setLoading(false);\n }\n }, [username, apiEndpoint]);\n\n useEffect(() => {\n if (autoFetch && username) {\n refetch();\n }\n }, [autoFetch, username, refetch]);\n\n return { data, loading, error, refetch };\n}\n"]} | ||
| {"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/react/GitHubContributionGraph.tsx","../src/react/useContributionData.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","response","data","createTable","table","thead","tbody","firstCell","i","cell","addMonths","months","totalWeeks","label","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","link","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionGraph","forwardRef","props","ref","className","style","onDataLoaded","onError","onLoading","containerRef","useRef","setData","useState","loading","setLoading","error","setError","fetchData","userData","err","fetchError","useEffect","useImperativeHandle","jsx","useContributionData","autoFetch","refetch","useCallback"],"mappings":"6HAKO,IAAMA,EAAuB,0DAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,iBACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,CAAAA,CAAa,CAAC,GAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAE,EAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,EACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,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fig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import React, {\n useRef,\n useEffect,\n useState,\n forwardRef,\n useImperativeHandle,\n} from 'react';\nimport { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport { applyTheme } from '../styles/themes';\nimport type { GitHubUser, ThemePreset, ThemeConfig } from '../core/types';\n\nexport interface GitHubContributionGraphProps {\n /**\n * GitHub username to display contributions for\n */\n username: string;\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Theme preset name or custom theme configuration\n */\n theme?: ThemePreset | ThemeConfig;\n /**\n * Whether to show the header with total contributions\n * @default true\n */\n showHeader?: boolean;\n /**\n * Whether to show the footer legend\n * @default true\n */\n showFooter?: boolean;\n /**\n * Whether to show the GitHub thumbnail/attribution\n * @default true\n */\n showThumbnail?: boolean;\n /**\n * Additional CSS class name\n */\n className?: string;\n /**\n * Inline styles\n */\n style?: React.CSSProperties;\n /**\n * Callback when data is successfully loaded\n */\n onDataLoaded?: (data: GitHubUser) => void;\n /**\n * Callback when an error occurs\n */\n onError?: (error: Error) => void;\n /**\n * Callback when loading state changes\n */\n onLoading?: (isLoading: boolean) => void;\n}\n\nexport interface GitHubContributionGraphRef {\n /**\n * Manually refresh the contribution data\n */\n refresh: () => Promise<void>;\n /**\n * Get the currently loaded data\n */\n getData: () => GitHubUser | null;\n}\n\n/**\n * React component for displaying GitHub contribution graphs\n *\n * @example\n * ```tsx\n * import { GitHubContributionGraph } from 'github-contribution-graph/react';\n * import 'github-contribution-graph/styles.css';\n *\n * function App() {\n * return (\n * <GitHubContributionGraph\n * username=\"octocat\"\n * theme=\"midnight\"\n * onDataLoaded={(data) => console.log('Loaded!', data)}\n * />\n * );\n * }\n * ```\n */\nexport const GitHubContributionGraph = forwardRef<\n GitHubContributionGraphRef,\n GitHubContributionGraphProps\n>((props, ref) => {\n const {\n username,\n apiEndpoint,\n theme = 'default',\n showHeader = true,\n showFooter = true,\n showThumbnail = true,\n className,\n style,\n onDataLoaded,\n onError,\n onLoading,\n } = props;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchData = async () => {\n if (!username) {\n setError(new Error('Username is required'));\n setLoading(false);\n return;\n }\n\n setLoading(true);\n onLoading?.(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n onDataLoaded?.(userData);\n } catch (err) {\n const fetchError = err instanceof Error ? err : new Error('Unknown error');\n setError(fetchError);\n onError?.(fetchError);\n } finally {\n setLoading(false);\n onLoading?.(false);\n }\n };\n\n // Fetch data when username or apiEndpoint changes\n useEffect(() => {\n fetchData();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [username, apiEndpoint]);\n\n // Render widget when data or options change\n useEffect(() => {\n if (data && containerRef.current) {\n renderWidget(containerRef.current, data, username, {\n showHeader,\n showFooter,\n showThumbnail,\n });\n applyTheme(containerRef.current, theme);\n }\n }, [data, theme, showHeader, showFooter, showThumbnail, username]);\n\n // Expose ref methods\n useImperativeHandle(ref, () => ({\n refresh: fetchData,\n getData: () => data,\n }));\n\n if (error) {\n return (\n <div className={className} style={style}>\n <p style={{ color: '#f85149' }}>Failed to load contribution data.</p>\n </div>\n );\n }\n\n return (\n <div\n ref={containerRef}\n className={className}\n style={style}\n data-loading={loading}\n />\n );\n});\n\nGitHubContributionGraph.displayName = 'GitHubContributionGraph';\n","import { useState, useEffect, useCallback } from 'react';\nimport { fetchContributionData } from '../core/api';\nimport type { GitHubUser } from '../core/types';\n\nexport interface UseContributionDataOptions {\n /**\n * Custom API endpoint for fetching data\n */\n apiEndpoint?: string;\n /**\n * Whether to fetch data automatically on mount\n * @default true\n */\n autoFetch?: boolean;\n}\n\nexport interface UseContributionDataResult {\n /**\n * The fetched user data, null if not loaded\n */\n data: GitHubUser | null;\n /**\n * Whether data is currently being fetched\n */\n loading: boolean;\n /**\n * Error object if fetch failed\n */\n error: Error | null;\n /**\n * Function to manually refetch data\n */\n refetch: () => Promise<void>;\n}\n\n/**\n * React hook for fetching GitHub contribution data\n *\n * @param username - GitHub username\n * @param options - Hook options\n * @returns Object containing data, loading state, error, and refetch function\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { data, loading, error, refetch } = useContributionData('octocat');\n *\n * if (loading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div>\n * <p>Total: {data?.contributionsCollection.contributionCalendar.totalContributions}</p>\n * <button onClick={refetch}>Refresh</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useContributionData(\n username: string,\n options: UseContributionDataOptions = {}\n): UseContributionDataResult {\n const { apiEndpoint, autoFetch = true } = options;\n\n const [data, setData] = useState<GitHubUser | null>(null);\n const [loading, setLoading] = useState(autoFetch);\n const [error, setError] = useState<Error | null>(null);\n\n const refetch = useCallback(async () => {\n if (!username) {\n setError(new Error('Username is required'));\n return;\n }\n\n setLoading(true);\n setError(null);\n\n try {\n const userData = await fetchContributionData(username, apiEndpoint);\n setData(userData);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Unknown error'));\n } finally {\n setLoading(false);\n }\n }, [username, apiEndpoint]);\n\n useEffect(() => {\n if (autoFetch && username) {\n refetch();\n }\n }, [autoFetch, username, refetch]);\n\n return { data, loading, error, refetch };\n}\n"]} |
+1
-1
@@ -1,3 +0,3 @@ | ||
| 'use strict';var h="https://github-contribution-graph.netlify.app/api/ghcg/fetch-data",b="https://github.com/iamjr15/github-contribution-graph",T=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],p=["","Mon","","Wed","","Fri",""],c={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function f(o,e=h){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=await fetch(t);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function L(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),n=e.insertRow().insertCell();n.style.width="28px";for(let i=0;i<7;i++){let a=t.insertRow().insertCell();p[i]&&(a.innerHTML=`<span class="ghCalendarLabel">${p[i]}</span>`);}return {table:o,thead:e,tbody:t}}function w(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let n=o.rows[0].insertCell(),i=document.createElement("span");i.textContent=e[t].name,i.className="ghCalendarLabel",n.appendChild(i),n.colSpan=r;}}}function H(o,e){for(let t of e)for(let r of t.contributionDays){let n=document.createElement("span"),i=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${i.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function x(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function P(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function M(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${o} contributions in the last year`;let i=document.createElement("div");return i.innerHTML=`<a href="https://github.com/${e}">${e}</a><img src="${t}" alt="${e}'s avatar">`,r.appendChild(n),r.appendChild(i),r}function N(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let n of T){let i=document.createElement("div");i.className="ghCalendarDayCell",i.dataset.level=n,e.appendChild(i);}return e.appendChild(r),o.appendChild(e),o}function R(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=b,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","30"),t.setAttribute("height","30"),t.style.marginTop="15px",t.style.opacity="0.6",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function u(o,e,t,r={}){let{showHeader:n=true,showFooter:i=true,showThumbnail:l=true}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:E,thead:v,tbody:y}=L();H(y,a.weeks),w(v,a.months);let g=x(),d=P();if(d.appendChild(E),i){let s=N();d.appendChild(s);}if(g.appendChild(d),n){let s=M(a.totalContributions,t,e.avatarUrl);o.appendChild(s);}if(o.appendChild(g),l){let s=R();o.appendChild(s);}}function S(o){return o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function m(o,e){let t=typeof e=="string"?c[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily));}function D(o){let e=typeof o=="string"?c[o]:o;if(!e)return "";let t=[];for(let[r,n]of Object.entries(e))if(n){let i=`--gh-${S(r).replace("color","-color")}`;t.push(`${i}: ${n};`);}return t.join(` | ||
| 'use strict';var h="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",b="https://github.com/iamjr15/github-contribution-graph",T=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],p=["","Mon","","Wed","","Fri",""],c={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function f(o,e=h){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=await fetch(t);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function L(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),n=e.insertRow().insertCell();n.style.width="28px";for(let i=0;i<7;i++){let a=t.insertRow().insertCell();p[i]&&(a.innerHTML=`<span class="ghCalendarLabel">${p[i]}</span>`);}return {table:o,thead:e,tbody:t}}function w(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let n=o.rows[0].insertCell(),i=document.createElement("span");i.textContent=e[t].name,i.className="ghCalendarLabel",n.appendChild(i),n.colSpan=r;}}}function H(o,e){for(let t of e)for(let r of t.contributionDays){let n=document.createElement("span"),i=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${i.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function x(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function P(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function M(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${o} contributions in the last year`;let i=document.createElement("div");return i.innerHTML=`<a href="https://github.com/${e}">${e}</a><img src="${t}" alt="${e}'s avatar">`,r.appendChild(n),r.appendChild(i),r}function N(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let n of T){let i=document.createElement("div");i.className="ghCalendarDayCell",i.dataset.level=n,e.appendChild(i);}return e.appendChild(r),o.appendChild(e),o}function R(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=b,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.style.marginTop="10px",t.style.opacity="0.5",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function u(o,e,t,r={}){let{showHeader:n=true,showFooter:i=true,showThumbnail:l=true}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:E,thead:v,tbody:y}=L();H(y,a.weeks),w(v,a.months);let g=x(),d=P();if(d.appendChild(E),i){let s=N();d.appendChild(s);}if(g.appendChild(d),n){let s=M(a.totalContributions,t,e.avatarUrl);o.appendChild(s);}if(o.appendChild(g),l){let s=R();o.appendChild(s);}}function S(o){return o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function m(o,e){let t=typeof e=="string"?c[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily));}function D(o){let e=typeof o=="string"?c[o]:o;if(!e)return "";let t=[];for(let[r,n]of Object.entries(e))if(n){let i=`--gh-${S(r).replace("color","-color")}`;t.push(`${i}: ${n};`);}return t.join(` | ||
| `)}function U(){return Object.keys(c)}var C=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container);}resolveContainer(e){if(typeof e=="string"){let r=document.querySelector(e);if(!r)throw new Error(`Container not found: ${e}`);return r}if(e instanceof HTMLElement)return e;let t=document.getElementById("gh");if(!t)throw new Error('No container found. Specify container in config or add element with id="gh"');return t}async render(){try{this.data=await f(this.config.username,this.config.apiEndpoint),u(this.container,this.data,this.config.username,{showHeader:this.config.showHeader,showFooter:this.config.showFooter,showThumbnail:this.config.showThumbnail}),this.config.theme&&m(this.container,this.config.theme),this.config.onDataLoaded?.(this.data);}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null;}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container)),this.render()}};exports.DEFAULT_API_ENDPOINT=h;exports.GitHubContributionWidget=C;exports.THEME_PRESETS=c;exports.applyTheme=m;exports.fetchContributionData=f;exports.getThemeCSS=D;exports.getThemePresets=U;exports.renderWidget=u;//# sourceMappingURL=vanilla.cjs.map | ||
| //# sourceMappingURL=vanilla.cjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","response","data","createTable","table","thead","tbody","firstCell","cell","addMonths","months","i","totalWeeks","label","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","link","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionWidget","el","error"],"mappings":"aAKO,IAAMA,CAAAA,CAAuB,mEAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,EAAa,CAAC,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,MAAO,EAAE,CAAA,CAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,QAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,YAAa,SACf,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,MAAO,CACL,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,UACZ,WAAA,CAAa,SACf,CAAA,CACA,QAAA,CAAU,CACR,OAAA,CAAS,UACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,EACA,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,KAAA,CAAO,CACL,QAAS,SAAA,CACT,SAAA,CA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AA,CAAU,UACb,kEAAA,CACF,IAAA,CAAK,OAAO,OAAA,GACVA,CAAAA,YAAiB,MAAQA,CAAAA,CAAQ,IAAI,KAAA,CAAM,eAAe,CAC5D,EACF,CACF,CAKA,MAAM,SAAyB,CAC7B,OAAO,KAAK,MAAA,EACd,CAKA,OAAA,EAA6B,CAC3B,OAAO,KAAK,IACd,CAKA,SAAgB,CACd,IAAA,CAAK,UAAU,SAAA,CAAY,EAAA,CAC3B,IAAA,CAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOT,CAAAA,CAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,EAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CAAA,CAGlD,IAAA,CAAK,MAAA,EACd,CACF","file":"vanilla.cjs","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://github-contribution-graph.netlify.app/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '30');\n svg.setAttribute('height', '30');\n svg.style.marginTop = '15px';\n svg.style.opacity = '0.6';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"]} | ||
| {"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","response","data","createTable","table","thead","tbody","firstCell","cell","addMonths","months","i","totalWeeks","label","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","link","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionWidget","el","error"],"mappings":"aAKO,IAAMA,CAAAA,CAAuB,0DAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,EAAa,CAAC,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,MAAO,EAAE,CAAA,CAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,QAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,YAAa,SACf,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,MAAO,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CAAY,IAAA,CAAK,OAAO,UAAA,CACxB,UAAA,CAAY,IAAA,CAAK,MAAA,CAAO,UAAA,CACxB,aAAA,CAAe,KAAK,MAAA,CAAO,aAC7B,CAAC,CAAA,CAEG,IAAA,CAAK,OAAO,KAAA,EACdW,CAAAA,CAAW,IAAA,CAAK,SAAA,CAAW,IAAA,CAAK,MAAA,CAAO,KAAK,CAAA,CAG9C,IAAA,CAAK,OAAO,YAAA,GAAe,IAAA,CAAK,IAAI,EACtC,CAAA,MAASY,CAAAA,CAAO,CACd,IAAA,CAAK,SAAA,CAAU,UACb,kEAAA,CACF,IAAA,CAAK,OAAO,OAAA,GACVA,CAAAA,YAAiB,MAAQA,CAAAA,CAAQ,IAAI,KAAA,CAAM,eAAe,CAC5D,EACF,CACF,CAKA,MAAM,SAAyB,CAC7B,OAAO,KAAK,MAAA,EACd,CAKA,OAAA,EAA6B,CAC3B,OAAO,KAAK,IACd,CAKA,SAAgB,CACd,IAAA,CAAK,UAAU,SAAA,CAAY,EAAA,CAC3B,IAAA,CAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOT,CAAAA,CAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,EAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CAAA,CAGlD,IAAA,CAAK,MAAA,EACd,CACF","file":"vanilla.cjs","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"]} |
| export { GitHubContributionWidget, renderWidget } from './index.cjs'; | ||
| export { C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, j as GitHubContributionGraphConfig, G as GitHubUser, R as RenderOptions, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-C8Fy4Stl.cjs'; | ||
| export { C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, j as GitHubContributionGraphConfig, G as GitHubUser, R as RenderOptions, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-DbIjuNDH.cjs'; |
| export { GitHubContributionWidget, renderWidget } from './index.js'; | ||
| export { C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, j as GitHubContributionGraphConfig, G as GitHubUser, R as RenderOptions, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-C8Fy4Stl.js'; | ||
| export { C as ContributionCalendar, e as ContributionDay, i as ContributionMonth, h as ContributionWeek, D as DEFAULT_API_ENDPOINT, j as GitHubContributionGraphConfig, G as GitHubUser, R as RenderOptions, d as THEME_PRESETS, a as ThemeConfig, T as ThemePreset, b as applyTheme, f as fetchContributionData, c as getThemeCSS, g as getThemePresets } from './themes-DbIjuNDH.js'; |
+1
-1
@@ -1,3 +0,3 @@ | ||
| var h="https://github-contribution-graph.netlify.app/api/ghcg/fetch-data",b="https://github.com/iamjr15/github-contribution-graph",T=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],p=["","Mon","","Wed","","Fri",""],c={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function f(o,e=h){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=await fetch(t);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function L(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),n=e.insertRow().insertCell();n.style.width="28px";for(let i=0;i<7;i++){let a=t.insertRow().insertCell();p[i]&&(a.innerHTML=`<span class="ghCalendarLabel">${p[i]}</span>`);}return {table:o,thead:e,tbody:t}}function w(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let n=o.rows[0].insertCell(),i=document.createElement("span");i.textContent=e[t].name,i.className="ghCalendarLabel",n.appendChild(i),n.colSpan=r;}}}function H(o,e){for(let t of e)for(let r of t.contributionDays){let n=document.createElement("span"),i=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${i.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function x(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function P(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function M(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${o} contributions in the last year`;let i=document.createElement("div");return i.innerHTML=`<a href="https://github.com/${e}">${e}</a><img src="${t}" alt="${e}'s avatar">`,r.appendChild(n),r.appendChild(i),r}function N(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let n of T){let i=document.createElement("div");i.className="ghCalendarDayCell",i.dataset.level=n,e.appendChild(i);}return e.appendChild(r),o.appendChild(e),o}function R(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=b,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","30"),t.setAttribute("height","30"),t.style.marginTop="15px",t.style.opacity="0.6",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function u(o,e,t,r={}){let{showHeader:n=true,showFooter:i=true,showThumbnail:l=true}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:E,thead:v,tbody:y}=L();H(y,a.weeks),w(v,a.months);let g=x(),d=P();if(d.appendChild(E),i){let s=N();d.appendChild(s);}if(g.appendChild(d),n){let s=M(a.totalContributions,t,e.avatarUrl);o.appendChild(s);}if(o.appendChild(g),l){let s=R();o.appendChild(s);}}function S(o){return o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function m(o,e){let t=typeof e=="string"?c[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily));}function D(o){let e=typeof o=="string"?c[o]:o;if(!e)return "";let t=[];for(let[r,n]of Object.entries(e))if(n){let i=`--gh-${S(r).replace("color","-color")}`;t.push(`${i}: ${n};`);}return t.join(` | ||
| var h="https://githubgraph.jigyansurout.com/api/ghcg/fetch-data",b="https://github.com/iamjr15/github-contribution-graph",T=["NONE","FIRST_QUARTILE","SECOND_QUARTILE","THIRD_QUARTILE","FOURTH_QUARTILE"],p=["","Mon","","Wed","","Fri",""],c={default:{bgColor:"#0d1117",textColor:"#e6edf3",cellLevel0:"#21262d",cellLevel1:"#0e4429",cellLevel2:"#006d32",cellLevel3:"#26a641",cellLevel4:"#39d353",borderColor:"#30363d"},void:{bgColor:"#000000",textColor:"#ffffff",cellLevel0:"#111111",borderColor:"#333333"},slate:{bgColor:"#141414",textColor:"#eeeeee",cellLevel0:"#222222",borderColor:"#333333"},midnight:{bgColor:"#0f1016",textColor:"#f1f5f9",cellLevel0:"#1e202e",borderColor:"#2d2a45"},glacier:{bgColor:"#ffffff",textColor:"#334155",cellLevel0:"#f1f5f9",borderColor:"#e2e8f0"},cyber:{bgColor:"#000000",textColor:"#00ff41",cellLevel0:"#001a00",borderColor:"#003b00"}};async function f(o,e=h){if(!o||typeof o!="string")throw new Error("Username is required");let t=`${e}?login=${encodeURIComponent(o.trim())}`,r=await fetch(t);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let n=await r.json();if(!n.user)throw new Error(n.error||"User not found");return n.user}function L(){let o=document.createElement("table");o.className="ghCalendarTable";let e=o.createTHead(),t=o.createTBody(),n=e.insertRow().insertCell();n.style.width="28px";for(let i=0;i<7;i++){let a=t.insertRow().insertCell();p[i]&&(a.innerHTML=`<span class="ghCalendarLabel">${p[i]}</span>`);}return {table:o,thead:e,tbody:t}}function w(o,e){for(let t=0;t<e.length-1;t++){let r=e[t].totalWeeks;if(r>=2){let n=o.rows[0].insertCell(),i=document.createElement("span");i.textContent=e[t].name,i.className="ghCalendarLabel",n.appendChild(i),n.colSpan=r;}}}function H(o,e){for(let t of e)for(let r of t.contributionDays){let n=document.createElement("span"),i=new Date(r.date);n.textContent=`${r.contributionCount} contributions on ${i.toDateString()}`;let l=o.rows[r.weekday].insertCell();l.appendChild(n),l.className="ghCalendarDayCell",l.dataset.date=r.date,l.dataset.count=String(r.contributionCount),l.dataset.level=r.contributionLevel;}}function x(){let o=document.createElement("div");return o.className="ghCalendarCard",o}function P(){let o=document.createElement("div");return o.className="ghCalendarCanvas",o}function M(o,e,t){let r=document.createElement("div");r.className="ghCalendarHeader";let n=document.createElement("span");n.textContent=`${o} contributions in the last year`;let i=document.createElement("div");return i.innerHTML=`<a href="https://github.com/${e}">${e}</a><img src="${t}" alt="${e}'s avatar">`,r.appendChild(n),r.appendChild(i),r}function N(){let o=document.createElement("div");o.className="ghCalendarCardFooter";let e=document.createElement("div");e.className="ghCalendarCardFooterColors";let t=document.createElement("span");t.textContent="Less";let r=document.createElement("span");r.textContent="More",e.appendChild(t);for(let n of T){let i=document.createElement("div");i.className="ghCalendarDayCell",i.dataset.level=n,e.appendChild(i);}return e.appendChild(r),o.appendChild(e),o}function R(){let o=document.createElement("div");o.className="ghThumbNail";let e=document.createElement("a");e.href=b,e.target="_blank",e.rel="noopener noreferrer";let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 98 96"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.style.marginTop="10px",t.style.opacity="0.5",t.style.fill="var(--gh-text-default-color, #333)";let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("d","M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"),t.appendChild(r),e.appendChild(t),o.appendChild(e),o}function u(o,e,t,r={}){let{showHeader:n=true,showFooter:i=true,showThumbnail:l=true}=r;o.innerHTML="";let a=e.contributionsCollection.contributionCalendar,{table:E,thead:v,tbody:y}=L();H(y,a.weeks),w(v,a.months);let g=x(),d=P();if(d.appendChild(E),i){let s=N();d.appendChild(s);}if(g.appendChild(d),n){let s=M(a.totalContributions,t,e.avatarUrl);o.appendChild(s);}if(o.appendChild(g),l){let s=R();o.appendChild(s);}}function S(o){return o.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function m(o,e){let t=typeof e=="string"?c[e]:e;t&&(t.bgColor&&o.style.setProperty("--gh-bg-color",t.bgColor),t.textColor&&o.style.setProperty("--gh-text-default-color",t.textColor),t.cellLevel0&&o.style.setProperty("--gh-cell-level0-color",t.cellLevel0),t.cellLevel1&&o.style.setProperty("--gh-cell-level1-color",t.cellLevel1),t.cellLevel2&&o.style.setProperty("--gh-cell-level2-color",t.cellLevel2),t.cellLevel3&&o.style.setProperty("--gh-cell-level3-color",t.cellLevel3),t.cellLevel4&&o.style.setProperty("--gh-cell-level4-color",t.cellLevel4),t.borderColor&&o.style.setProperty("--gh-border-card-color",t.borderColor),t.fontFamily&&o.style.setProperty("--gh-font-default-family",t.fontFamily));}function D(o){let e=typeof o=="string"?c[o]:o;if(!e)return "";let t=[];for(let[r,n]of Object.entries(e))if(n){let i=`--gh-${S(r).replace("color","-color")}`;t.push(`${i}: ${n};`);}return t.join(` | ||
| `)}function U(){return Object.keys(c)}var C=class{constructor(e){this.data=null;this.config=e,this.container=this.resolveContainer(e.container);}resolveContainer(e){if(typeof e=="string"){let r=document.querySelector(e);if(!r)throw new Error(`Container not found: ${e}`);return r}if(e instanceof HTMLElement)return e;let t=document.getElementById("gh");if(!t)throw new Error('No container found. Specify container in config or add element with id="gh"');return t}async render(){try{this.data=await f(this.config.username,this.config.apiEndpoint),u(this.container,this.data,this.config.username,{showHeader:this.config.showHeader,showFooter:this.config.showFooter,showThumbnail:this.config.showThumbnail}),this.config.theme&&m(this.container,this.config.theme),this.config.onDataLoaded?.(this.data);}catch(e){this.container.innerHTML='<p style="color: #f85149;">Failed to load contribution data.</p>',this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async refresh(){return this.render()}getData(){return this.data}destroy(){this.container.innerHTML="",this.data=null;}async update(e){return this.config={...this.config,...e},e.container&&(this.container=this.resolveContainer(e.container)),this.render()}};export{h as DEFAULT_API_ENDPOINT,C as GitHubContributionWidget,c as THEME_PRESETS,m as applyTheme,f as fetchContributionData,D as getThemeCSS,U as getThemePresets,u as renderWidget};//# sourceMappingURL=vanilla.js.map | ||
| //# sourceMappingURL=vanilla.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","response","data","createTable","table","thead","tbody","firstCell","cell","addMonths","months","i","totalWeeks","label","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","link","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionWidget","el","error"],"mappings":"AAKO,IAAMA,CAAAA,CAAuB,mEAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,EAAa,CAAC,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,MAAO,EAAE,CAAA,CAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,QAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,YAAa,SACf,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,MAAO,CACL,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,UACZ,WAAA,CAAa,SACf,CAAA,CACA,QAAA,CAAU,CACR,OAAA,CAAS,UACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,EACA,OAAA,CAAS,CACP,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,KAAA,CAAO,CACL,QAAS,SAAA,CACT,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CAAK,SAAA,CAAU,UACb,kEAAA,CACF,IAAA,CAAK,OAAO,OAAA,GACVA,CAAAA,YAAiB,MAAQA,CAAAA,CAAQ,IAAI,KAAA,CAAM,eAAe,CAC5D,EACF,CACF,CAKA,MAAM,SAAyB,CAC7B,OAAO,KAAK,MAAA,EACd,CAKA,OAAA,EAA6B,CAC3B,OAAO,KAAK,IACd,CAKA,SAAgB,CACd,IAAA,CAAK,UAAU,SAAA,CAAY,EAAA,CAC3B,IAAA,CAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOT,CAAAA,CAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,EAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CAAA,CAGlD,IAAA,CAAK,MAAA,EACd,CACF","file":"vanilla.js","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://github-contribution-graph.netlify.app/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '30');\n svg.setAttribute('height', '30');\n svg.style.marginTop = '15px';\n svg.style.opacity = '0.6';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"]} | ||
| {"version":3,"sources":["../src/core/constants.ts","../src/core/api.ts","../src/core/renderer.ts","../src/styles/themes.ts","../src/vanilla/widget.ts"],"names":["DEFAULT_API_ENDPOINT","REPO_URL","CONTRIBUTION_LEVELS","DAY_LABELS","THEME_PRESETS","fetchContributionData","username","apiEndpoint","url","response","data","createTable","table","thead","tbody","firstCell","cell","addMonths","months","i","totalWeeks","label","addWeeks","weeks","week","day","date","createCard","card","createCanvas","canvas","createHeader","totalContributions","avatarUrl","header","total","profile","createFooter","footer","colors","less","more","level","createThumbnail","thumbnail","link","svg","path","renderWidget","container","user","options","showHeader","showFooter","showThumbnail","calendar","camelToKebab","str","letter","applyTheme","element","theme","config","getThemeCSS","cssVars","key","value","cssKey","getThemePresets","GitHubContributionWidget","el","error"],"mappings":"AAKO,IAAMA,CAAAA,CAAuB,0DAAA,CAKvBC,CAAAA,CAAW,sDAAA,CAKXC,CAAAA,CAA2C,CACtD,MAAA,CACA,gBAAA,CACA,iBAAA,CACA,gBAAA,CACA,iBACF,CAAA,CAKaC,EAAa,CAAC,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,KAAA,CAAO,EAAA,CAAI,MAAO,EAAE,CAAA,CAKjDC,CAAAA,CAAkD,CAC7D,OAAA,CAAS,CACP,QAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,UACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,YAAa,SACf,CAAA,CACA,IAAA,CAAM,CACJ,OAAA,CAAS,SAAA,CACT,UAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,WAAA,CAAa,SACf,CAAA,CACA,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UAAA,CAAY,IAAA,CAAK,OAAO,UAAA,CACxB,UAAA,CAAY,IAAA,CAAK,MAAA,CAAO,UAAA,CACxB,aAAA,CAAe,KAAK,MAAA,CAAO,aAC7B,CAAC,CAAA,CAEG,IAAA,CAAK,OAAO,KAAA,EACdW,CAAAA,CAAW,IAAA,CAAK,SAAA,CAAW,IAAA,CAAK,MAAA,CAAO,KAAK,CAAA,CAG9C,IAAA,CAAK,OAAO,YAAA,GAAe,IAAA,CAAK,IAAI,EACtC,CAAA,MAASY,CAAAA,CAAO,CACd,IAAA,CAAK,SAAA,CAAU,UACb,kEAAA,CACF,IAAA,CAAK,OAAO,OAAA,GACVA,CAAAA,YAAiB,MAAQA,CAAAA,CAAQ,IAAI,KAAA,CAAM,eAAe,CAC5D,EACF,CACF,CAKA,MAAM,SAAyB,CAC7B,OAAO,KAAK,MAAA,EACd,CAKA,OAAA,EAA6B,CAC3B,OAAO,KAAK,IACd,CAKA,SAAgB,CACd,IAAA,CAAK,UAAU,SAAA,CAAY,EAAA,CAC3B,IAAA,CAAK,IAAA,CAAO,KACd,CAKA,MAAM,MAAA,CAAOT,CAAAA,CAA+D,CAC1E,OAAA,IAAA,CAAK,MAAA,CAAS,CAAE,GAAG,IAAA,CAAK,MAAA,CAAQ,GAAGA,CAAO,CAAA,CAEtCA,EAAO,SAAA,GACT,IAAA,CAAK,SAAA,CAAY,IAAA,CAAK,gBAAA,CAAiBA,CAAAA,CAAO,SAAS,CAAA,CAAA,CAGlD,IAAA,CAAK,MAAA,EACd,CACF","file":"vanilla.js","sourcesContent":["import type { ContributionLevel, ThemeConfig, ThemePreset } from './types';\n\n/**\n * Default API endpoint for fetching contribution data\n */\nexport const DEFAULT_API_ENDPOINT = 'https://githubgraph.jigyansurout.com/api/ghcg/fetch-data';\n\n/**\n * Repository URL for the widget\n */\nexport const REPO_URL = 'https://github.com/iamjr15/github-contribution-graph';\n\n/**\n * Contribution level values in order\n */\nexport const CONTRIBUTION_LEVELS: ContributionLevel[] = [\n 'NONE',\n 'FIRST_QUARTILE',\n 'SECOND_QUARTILE',\n 'THIRD_QUARTILE',\n 'FOURTH_QUARTILE',\n];\n\n/**\n * Day labels for the calendar rows\n */\nexport const DAY_LABELS = ['', 'Mon', '', 'Wed', '', 'Fri', ''];\n\n/**\n * Theme presets with CSS variable values\n */\nexport const THEME_PRESETS: Record<ThemePreset, ThemeConfig> = {\n default: {\n bgColor: '#0d1117',\n textColor: '#e6edf3',\n cellLevel0: '#21262d',\n cellLevel1: '#0e4429',\n cellLevel2: '#006d32',\n cellLevel3: '#26a641',\n cellLevel4: '#39d353',\n borderColor: '#30363d',\n },\n void: {\n bgColor: '#000000',\n textColor: '#ffffff',\n cellLevel0: '#111111',\n borderColor: '#333333',\n },\n slate: {\n bgColor: '#141414',\n textColor: '#eeeeee',\n cellLevel0: '#222222',\n borderColor: '#333333',\n },\n midnight: {\n bgColor: '#0f1016',\n textColor: '#f1f5f9',\n cellLevel0: '#1e202e',\n borderColor: '#2d2a45',\n },\n glacier: {\n bgColor: '#ffffff',\n textColor: '#334155',\n cellLevel0: '#f1f5f9',\n borderColor: '#e2e8f0',\n },\n cyber: {\n bgColor: '#000000',\n textColor: '#00ff41',\n cellLevel0: '#001a00',\n borderColor: '#003b00',\n },\n};\n","import { DEFAULT_API_ENDPOINT } from './constants';\nimport type { APIResponse, GitHubUser } from './types';\n\n/**\n * Fetch contribution data for a GitHub user\n *\n * @param username - GitHub username\n * @param apiEndpoint - Optional custom API endpoint\n * @returns Promise resolving to user data\n * @throws Error if user not found or network error\n *\n * @example\n * ```ts\n * const userData = await fetchContributionData('octocat');\n * console.log(userData.contributionsCollection.contributionCalendar.totalContributions);\n * ```\n */\nexport async function fetchContributionData(\n username: string,\n apiEndpoint: string = DEFAULT_API_ENDPOINT\n): Promise<GitHubUser> {\n if (!username || typeof username !== 'string') {\n throw new Error('Username is required');\n }\n\n const url = `${apiEndpoint}?login=${encodeURIComponent(username.trim())}`;\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const data: APIResponse = await response.json();\n\n if (!data.user) {\n throw new Error(data.error || 'User not found');\n }\n\n return data.user;\n}\n","import { CONTRIBUTION_LEVELS, DAY_LABELS, REPO_URL } from './constants';\nimport type {\n ContributionMonth,\n ContributionWeek,\n GitHubUser,\n RenderOptions,\n} from './types';\n\n/**\n * Create the base table structure for the contribution calendar\n */\nexport function createTable(): {\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n} {\n const table = document.createElement('table');\n table.className = 'ghCalendarTable';\n\n const thead = table.createTHead();\n const tbody = table.createTBody();\n\n const headerRow = thead.insertRow();\n const firstCell = headerRow.insertCell();\n firstCell.style.width = '28px';\n\n for (let i = 0; i < 7; i++) {\n const row = tbody.insertRow();\n const cell = row.insertCell();\n if (DAY_LABELS[i]) {\n cell.innerHTML = `<span class=\"ghCalendarLabel\">${DAY_LABELS[i]}</span>`;\n }\n }\n\n return { table, thead, tbody };\n}\n\n/**\n * Add month labels to the table header\n */\nexport function addMonths(\n thead: HTMLTableSectionElement,\n months: ContributionMonth[]\n): void {\n for (let i = 0; i < months.length - 1; i++) {\n const totalWeeks = months[i].totalWeeks;\n // Bug fix: was `=>` instead of `>=`\n if (totalWeeks >= 2) {\n const cell = thead.rows[0].insertCell();\n const label = document.createElement('span');\n label.textContent = months[i].name;\n label.className = 'ghCalendarLabel';\n cell.appendChild(label);\n cell.colSpan = totalWeeks;\n }\n }\n}\n\n/**\n * Add contribution days to the table body\n */\nexport function addWeeks(\n tbody: HTMLTableSectionElement,\n weeks: ContributionWeek[]\n): void {\n for (const week of weeks) {\n for (const day of week.contributionDays) {\n const data = document.createElement('span');\n // Bug fix: added `const` declaration\n const date = new Date(day.date);\n data.textContent = `${day.contributionCount} contributions on ${date.toDateString()}`;\n\n const cell = tbody.rows[day.weekday].insertCell();\n cell.appendChild(data);\n cell.className = 'ghCalendarDayCell';\n cell.dataset.date = day.date;\n cell.dataset.count = String(day.contributionCount);\n cell.dataset.level = day.contributionLevel;\n }\n }\n}\n\n/**\n * Create the card container\n */\nexport function createCard(): HTMLDivElement {\n const card = document.createElement('div');\n card.className = 'ghCalendarCard';\n return card;\n}\n\n/**\n * Create the canvas wrapper for table and footer\n */\nexport function createCanvas(): HTMLDivElement {\n const canvas = document.createElement('div');\n canvas.className = 'ghCalendarCanvas';\n return canvas;\n}\n\n/**\n * Create the header with total contributions and user profile\n */\nexport function createHeader(\n totalContributions: number,\n username: string,\n avatarUrl: string\n): HTMLDivElement {\n const header = document.createElement('div');\n header.className = 'ghCalendarHeader';\n\n const total = document.createElement('span');\n total.textContent = `${totalContributions} contributions in the last year`;\n\n const profile = document.createElement('div');\n profile.innerHTML = `<a href=\"https://github.com/${username}\">${username}</a><img src=\"${avatarUrl}\" alt=\"${username}'s avatar\">`;\n\n header.appendChild(total);\n header.appendChild(profile);\n\n return header;\n}\n\n/**\n * Create the footer with contribution level legend\n */\nexport function createFooter(): HTMLDivElement {\n const footer = document.createElement('div');\n footer.className = 'ghCalendarCardFooter';\n\n const colors = document.createElement('div');\n colors.className = 'ghCalendarCardFooterColors';\n\n const less = document.createElement('span');\n less.textContent = 'Less';\n\n const more = document.createElement('span');\n more.textContent = 'More';\n\n colors.appendChild(less);\n\n for (const level of CONTRIBUTION_LEVELS) {\n const cell = document.createElement('div');\n cell.className = 'ghCalendarDayCell';\n cell.dataset.level = level;\n colors.appendChild(cell);\n }\n\n colors.appendChild(more);\n footer.appendChild(colors);\n\n return footer;\n}\n\n/**\n * Create the thumbnail/attribution link\n */\nexport function createThumbnail(): HTMLDivElement {\n const thumbnail = document.createElement('div');\n thumbnail.className = 'ghThumbNail';\n\n const link = document.createElement('a');\n link.href = REPO_URL;\n link.target = '_blank';\n link.rel = 'noopener noreferrer';\n\n // GitHub logo SVG\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n svg.setAttribute('viewBox', '0 0 98 96');\n svg.setAttribute('width', '18');\n svg.setAttribute('height', '18');\n svg.style.marginTop = '10px';\n svg.style.opacity = '0.5';\n svg.style.fill = 'var(--gh-text-default-color, #333)';\n\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('clip-rule', 'evenodd');\n path.setAttribute(\n 'd',\n 'M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z'\n );\n\n svg.appendChild(path);\n link.appendChild(svg);\n thumbnail.appendChild(link);\n\n return thumbnail;\n}\n\n/**\n * Render the complete widget into a container\n */\nexport function renderWidget(\n container: HTMLElement,\n user: GitHubUser,\n username: string,\n options: RenderOptions = {}\n): void {\n const { showHeader = true, showFooter = true, showThumbnail = true } = options;\n\n // Clear existing content\n container.innerHTML = '';\n\n const calendar = user.contributionsCollection.contributionCalendar;\n const { table, thead, tbody } = createTable();\n\n addWeeks(tbody, calendar.weeks);\n addMonths(thead, calendar.months);\n\n const card = createCard();\n const canvas = createCanvas();\n\n canvas.appendChild(table);\n\n if (showFooter) {\n const footer = createFooter();\n canvas.appendChild(footer);\n }\n\n card.appendChild(canvas);\n\n if (showHeader) {\n const header = createHeader(calendar.totalContributions, username, user.avatarUrl);\n container.appendChild(header);\n }\n\n container.appendChild(card);\n\n if (showThumbnail) {\n const thumbnail = createThumbnail();\n container.appendChild(thumbnail);\n }\n}\n","import { THEME_PRESETS } from '../core/constants';\nimport type { ThemeConfig, ThemePreset } from '../core/types';\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Apply a theme to an element by setting CSS custom properties\n *\n * @param element - The element to apply theme to\n * @param theme - Theme preset name or custom config\n *\n * @example\n * ```ts\n * applyTheme(container, 'void');\n * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' });\n * ```\n */\nexport function applyTheme(\n element: HTMLElement,\n theme: ThemePreset | ThemeConfig\n): void {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return;\n\n if (config.bgColor) {\n element.style.setProperty('--gh-bg-color', config.bgColor);\n }\n if (config.textColor) {\n element.style.setProperty('--gh-text-default-color', config.textColor);\n }\n if (config.cellLevel0) {\n element.style.setProperty('--gh-cell-level0-color', config.cellLevel0);\n }\n if (config.cellLevel1) {\n element.style.setProperty('--gh-cell-level1-color', config.cellLevel1);\n }\n if (config.cellLevel2) {\n element.style.setProperty('--gh-cell-level2-color', config.cellLevel2);\n }\n if (config.cellLevel3) {\n element.style.setProperty('--gh-cell-level3-color', config.cellLevel3);\n }\n if (config.cellLevel4) {\n element.style.setProperty('--gh-cell-level4-color', config.cellLevel4);\n }\n if (config.borderColor) {\n element.style.setProperty('--gh-border-card-color', config.borderColor);\n }\n if (config.fontFamily) {\n element.style.setProperty('--gh-font-default-family', config.fontFamily);\n }\n}\n\n/**\n * Generate CSS string from a theme configuration\n *\n * @param theme - Theme preset name or custom config\n * @returns CSS custom properties string\n */\nexport function getThemeCSS(theme: ThemePreset | ThemeConfig): string {\n const config = typeof theme === 'string' ? THEME_PRESETS[theme] : theme;\n\n if (!config) return '';\n\n const cssVars: string[] = [];\n\n for (const [key, value] of Object.entries(config)) {\n if (value) {\n const cssKey = `--gh-${camelToKebab(key).replace('color', '-color')}`;\n cssVars.push(`${cssKey}: ${value};`);\n }\n }\n\n return cssVars.join('\\n');\n}\n\n/**\n * Get all available theme preset names\n */\nexport function getThemePresets(): ThemePreset[] {\n return Object.keys(THEME_PRESETS) as ThemePreset[];\n}\n","import { fetchContributionData } from '../core/api';\nimport { renderWidget } from '../core/renderer';\nimport type { GitHubContributionGraphConfig, GitHubUser } from '../core/types';\nimport { applyTheme } from '../styles/themes';\n\n/**\n * GitHub Contribution Widget class for vanilla JavaScript usage\n *\n * @example\n * ```ts\n * const widget = new GitHubContributionWidget({\n * username: 'octocat',\n * container: '#my-graph',\n * theme: 'void',\n * });\n * widget.render();\n * ```\n */\nexport class GitHubContributionWidget {\n private container: HTMLElement;\n private config: GitHubContributionGraphConfig;\n private data: GitHubUser | null = null;\n\n constructor(config: GitHubContributionGraphConfig) {\n this.config = config;\n this.container = this.resolveContainer(config.container);\n }\n\n /**\n * Resolve the container element from config\n */\n private resolveContainer(container?: string | HTMLElement): HTMLElement {\n if (typeof container === 'string') {\n const el = document.querySelector(container);\n if (!el) {\n throw new Error(`Container not found: ${container}`);\n }\n return el as HTMLElement;\n }\n\n if (container instanceof HTMLElement) {\n return container;\n }\n\n // Default fallback for backward compatibility\n const el = document.getElementById('gh');\n if (!el) {\n throw new Error(\n 'No container found. Specify container in config or add element with id=\"gh\"'\n );\n }\n return el;\n }\n\n /**\n * Render the contribution graph\n */\n async render(): Promise<void> {\n try {\n this.data = await fetchContributionData(\n this.config.username,\n this.config.apiEndpoint\n );\n\n renderWidget(this.container, this.data, this.config.username, {\n showHeader: this.config.showHeader,\n showFooter: this.config.showFooter,\n showThumbnail: this.config.showThumbnail,\n });\n\n if (this.config.theme) {\n applyTheme(this.container, this.config.theme);\n }\n\n this.config.onDataLoaded?.(this.data);\n } catch (error) {\n this.container.innerHTML =\n '<p style=\"color: #f85149;\">Failed to load contribution data.</p>';\n this.config.onError?.(\n error instanceof Error ? error : new Error('Unknown error')\n );\n }\n }\n\n /**\n * Refresh the contribution graph\n */\n async refresh(): Promise<void> {\n return this.render();\n }\n\n /**\n * Get the currently loaded data\n */\n getData(): GitHubUser | null {\n return this.data;\n }\n\n /**\n * Destroy the widget and clear content\n */\n destroy(): void {\n this.container.innerHTML = '';\n this.data = null;\n }\n\n /**\n * Update configuration and re-render\n */\n async update(config: Partial<GitHubContributionGraphConfig>): Promise<void> {\n this.config = { ...this.config, ...config };\n\n if (config.container) {\n this.container = this.resolveContainer(config.container);\n }\n\n return this.render();\n }\n}\n"]} |
+2
-2
| { | ||
| "name": "github-contrib-graph", | ||
| "version": "3.0.1", | ||
| "version": "3.0.2", | ||
| "description": "Lightweight, customizable GitHub contribution graph widget for any website", | ||
@@ -21,3 +21,3 @@ "keywords": [ | ||
| }, | ||
| "homepage": "https://github-contribution-graph.netlify.app", | ||
| "homepage": "https://githubgraph.jigyansurout.com", | ||
| "bugs": { | ||
@@ -24,0 +24,0 @@ "url": "https://github.com/iamjr15/github-contribution-graph/issues" |
+15
-2
@@ -53,6 +53,19 @@ # github-contribution-graph | ||
| <link rel="stylesheet" href="https://unpkg.com/github-contribution-graph/dist/gh.css"> | ||
| <div id="gh" data-login="octocat"></div> | ||
| <div id="gh" | ||
| data-login="octocat" | ||
| data-show-thumbnail="true" | ||
| data-show-header="true" | ||
| data-show-footer="true"></div> | ||
| <script src="https://unpkg.com/github-contribution-graph/dist/browser.global.js"></script> | ||
| ``` | ||
| #### Data Attributes | ||
| | Attribute | Default | Description | | ||
| |-----------|---------|-------------| | ||
| | `data-login` | required | GitHub username | | ||
| | `data-show-thumbnail` | `"true"` | Show/hide GitHub logo below graph | | ||
| | `data-show-header` | `"true"` | Show/hide contribution count header | | ||
| | `data-show-footer` | `"true"` | Show/hide legend footer | | ||
| ## React API | ||
@@ -161,3 +174,3 @@ | ||
| By default, the widget uses the hosted API at `github-contribution-graph.netlify.app`. To self-host: | ||
| By default, the widget uses the hosted API at `githubgraph.jigyansurout.com`. To self-host: | ||
@@ -164,0 +177,0 @@ 1. Clone the repository |
| /** | ||
| * Contribution level indicating activity intensity | ||
| */ | ||
| type ContributionLevel = 'NONE' | 'FIRST_QUARTILE' | 'SECOND_QUARTILE' | 'THIRD_QUARTILE' | 'FOURTH_QUARTILE'; | ||
| /** | ||
| * A single day's contribution data | ||
| */ | ||
| interface ContributionDay { | ||
| date: string; | ||
| contributionCount: number; | ||
| contributionLevel: ContributionLevel; | ||
| weekday: number; | ||
| } | ||
| /** | ||
| * A week of contribution data | ||
| */ | ||
| interface ContributionWeek { | ||
| contributionDays: ContributionDay[]; | ||
| } | ||
| /** | ||
| * A month label in the calendar | ||
| */ | ||
| interface ContributionMonth { | ||
| name: string; | ||
| totalWeeks: number; | ||
| } | ||
| /** | ||
| * The full contribution calendar data | ||
| */ | ||
| interface ContributionCalendar { | ||
| totalContributions: number; | ||
| months: ContributionMonth[]; | ||
| weeks: ContributionWeek[]; | ||
| } | ||
| /** | ||
| * GitHub user data from API response | ||
| */ | ||
| interface GitHubUser { | ||
| avatarUrl: string; | ||
| contributionsCollection: { | ||
| contributionCalendar: ContributionCalendar; | ||
| }; | ||
| } | ||
| /** | ||
| * API response structure | ||
| */ | ||
| interface APIResponse { | ||
| user: GitHubUser | null; | ||
| error?: string; | ||
| } | ||
| /** | ||
| * Available theme presets | ||
| */ | ||
| type ThemePreset = 'default' | 'void' | 'slate' | 'midnight' | 'glacier' | 'cyber'; | ||
| /** | ||
| * Custom theme configuration | ||
| */ | ||
| interface ThemeConfig { | ||
| bgColor?: string; | ||
| textColor?: string; | ||
| cellLevel0?: string; | ||
| cellLevel1?: string; | ||
| cellLevel2?: string; | ||
| cellLevel3?: string; | ||
| cellLevel4?: string; | ||
| borderColor?: string; | ||
| fontFamily?: string; | ||
| } | ||
| /** | ||
| * Widget render options | ||
| */ | ||
| interface RenderOptions { | ||
| showHeader?: boolean; | ||
| showFooter?: boolean; | ||
| showThumbnail?: boolean; | ||
| } | ||
| /** | ||
| * Configuration for the widget | ||
| */ | ||
| interface GitHubContributionGraphConfig extends RenderOptions { | ||
| username: string; | ||
| apiEndpoint?: string; | ||
| container?: string | HTMLElement; | ||
| theme?: ThemePreset | ThemeConfig; | ||
| onDataLoaded?: (data: GitHubUser) => void; | ||
| onError?: (error: Error) => void; | ||
| } | ||
| /** | ||
| * Default API endpoint for fetching contribution data | ||
| */ | ||
| declare const DEFAULT_API_ENDPOINT = "https://github-contribution-graph.netlify.app/api/ghcg/fetch-data"; | ||
| /** | ||
| * Repository URL for the widget | ||
| */ | ||
| declare const REPO_URL = "https://github.com/iamjr15/github-contribution-graph"; | ||
| /** | ||
| * Contribution level values in order | ||
| */ | ||
| declare const CONTRIBUTION_LEVELS: ContributionLevel[]; | ||
| /** | ||
| * Day labels for the calendar rows | ||
| */ | ||
| declare const DAY_LABELS: string[]; | ||
| /** | ||
| * Theme presets with CSS variable values | ||
| */ | ||
| declare const THEME_PRESETS: Record<ThemePreset, ThemeConfig>; | ||
| /** | ||
| * Fetch contribution data for a GitHub user | ||
| * | ||
| * @param username - GitHub username | ||
| * @param apiEndpoint - Optional custom API endpoint | ||
| * @returns Promise resolving to user data | ||
| * @throws Error if user not found or network error | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const userData = await fetchContributionData('octocat'); | ||
| * console.log(userData.contributionsCollection.contributionCalendar.totalContributions); | ||
| * ``` | ||
| */ | ||
| declare function fetchContributionData(username: string, apiEndpoint?: string): Promise<GitHubUser>; | ||
| /** | ||
| * Apply a theme to an element by setting CSS custom properties | ||
| * | ||
| * @param element - The element to apply theme to | ||
| * @param theme - Theme preset name or custom config | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * applyTheme(container, 'void'); | ||
| * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' }); | ||
| * ``` | ||
| */ | ||
| declare function applyTheme(element: HTMLElement, theme: ThemePreset | ThemeConfig): void; | ||
| /** | ||
| * Generate CSS string from a theme configuration | ||
| * | ||
| * @param theme - Theme preset name or custom config | ||
| * @returns CSS custom properties string | ||
| */ | ||
| declare function getThemeCSS(theme: ThemePreset | ThemeConfig): string; | ||
| /** | ||
| * Get all available theme preset names | ||
| */ | ||
| declare function getThemePresets(): ThemePreset[]; | ||
| export { type APIResponse as A, type ContributionCalendar as C, DEFAULT_API_ENDPOINT as D, type GitHubUser as G, type RenderOptions as R, type ThemePreset as T, type ThemeConfig as a, applyTheme as b, getThemeCSS as c, THEME_PRESETS as d, type ContributionDay as e, fetchContributionData as f, getThemePresets as g, type ContributionWeek as h, type ContributionMonth as i, type GitHubContributionGraphConfig as j, type ContributionLevel as k, REPO_URL as l, CONTRIBUTION_LEVELS as m, DAY_LABELS as n }; |
| /** | ||
| * Contribution level indicating activity intensity | ||
| */ | ||
| type ContributionLevel = 'NONE' | 'FIRST_QUARTILE' | 'SECOND_QUARTILE' | 'THIRD_QUARTILE' | 'FOURTH_QUARTILE'; | ||
| /** | ||
| * A single day's contribution data | ||
| */ | ||
| interface ContributionDay { | ||
| date: string; | ||
| contributionCount: number; | ||
| contributionLevel: ContributionLevel; | ||
| weekday: number; | ||
| } | ||
| /** | ||
| * A week of contribution data | ||
| */ | ||
| interface ContributionWeek { | ||
| contributionDays: ContributionDay[]; | ||
| } | ||
| /** | ||
| * A month label in the calendar | ||
| */ | ||
| interface ContributionMonth { | ||
| name: string; | ||
| totalWeeks: number; | ||
| } | ||
| /** | ||
| * The full contribution calendar data | ||
| */ | ||
| interface ContributionCalendar { | ||
| totalContributions: number; | ||
| months: ContributionMonth[]; | ||
| weeks: ContributionWeek[]; | ||
| } | ||
| /** | ||
| * GitHub user data from API response | ||
| */ | ||
| interface GitHubUser { | ||
| avatarUrl: string; | ||
| contributionsCollection: { | ||
| contributionCalendar: ContributionCalendar; | ||
| }; | ||
| } | ||
| /** | ||
| * API response structure | ||
| */ | ||
| interface APIResponse { | ||
| user: GitHubUser | null; | ||
| error?: string; | ||
| } | ||
| /** | ||
| * Available theme presets | ||
| */ | ||
| type ThemePreset = 'default' | 'void' | 'slate' | 'midnight' | 'glacier' | 'cyber'; | ||
| /** | ||
| * Custom theme configuration | ||
| */ | ||
| interface ThemeConfig { | ||
| bgColor?: string; | ||
| textColor?: string; | ||
| cellLevel0?: string; | ||
| cellLevel1?: string; | ||
| cellLevel2?: string; | ||
| cellLevel3?: string; | ||
| cellLevel4?: string; | ||
| borderColor?: string; | ||
| fontFamily?: string; | ||
| } | ||
| /** | ||
| * Widget render options | ||
| */ | ||
| interface RenderOptions { | ||
| showHeader?: boolean; | ||
| showFooter?: boolean; | ||
| showThumbnail?: boolean; | ||
| } | ||
| /** | ||
| * Configuration for the widget | ||
| */ | ||
| interface GitHubContributionGraphConfig extends RenderOptions { | ||
| username: string; | ||
| apiEndpoint?: string; | ||
| container?: string | HTMLElement; | ||
| theme?: ThemePreset | ThemeConfig; | ||
| onDataLoaded?: (data: GitHubUser) => void; | ||
| onError?: (error: Error) => void; | ||
| } | ||
| /** | ||
| * Default API endpoint for fetching contribution data | ||
| */ | ||
| declare const DEFAULT_API_ENDPOINT = "https://github-contribution-graph.netlify.app/api/ghcg/fetch-data"; | ||
| /** | ||
| * Repository URL for the widget | ||
| */ | ||
| declare const REPO_URL = "https://github.com/iamjr15/github-contribution-graph"; | ||
| /** | ||
| * Contribution level values in order | ||
| */ | ||
| declare const CONTRIBUTION_LEVELS: ContributionLevel[]; | ||
| /** | ||
| * Day labels for the calendar rows | ||
| */ | ||
| declare const DAY_LABELS: string[]; | ||
| /** | ||
| * Theme presets with CSS variable values | ||
| */ | ||
| declare const THEME_PRESETS: Record<ThemePreset, ThemeConfig>; | ||
| /** | ||
| * Fetch contribution data for a GitHub user | ||
| * | ||
| * @param username - GitHub username | ||
| * @param apiEndpoint - Optional custom API endpoint | ||
| * @returns Promise resolving to user data | ||
| * @throws Error if user not found or network error | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const userData = await fetchContributionData('octocat'); | ||
| * console.log(userData.contributionsCollection.contributionCalendar.totalContributions); | ||
| * ``` | ||
| */ | ||
| declare function fetchContributionData(username: string, apiEndpoint?: string): Promise<GitHubUser>; | ||
| /** | ||
| * Apply a theme to an element by setting CSS custom properties | ||
| * | ||
| * @param element - The element to apply theme to | ||
| * @param theme - Theme preset name or custom config | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * applyTheme(container, 'void'); | ||
| * applyTheme(container, { bgColor: '#1a1a1a', textColor: '#fff' }); | ||
| * ``` | ||
| */ | ||
| declare function applyTheme(element: HTMLElement, theme: ThemePreset | ThemeConfig): void; | ||
| /** | ||
| * Generate CSS string from a theme configuration | ||
| * | ||
| * @param theme - Theme preset name or custom config | ||
| * @returns CSS custom properties string | ||
| */ | ||
| declare function getThemeCSS(theme: ThemePreset | ThemeConfig): string; | ||
| /** | ||
| * Get all available theme preset names | ||
| */ | ||
| declare function getThemePresets(): ThemePreset[]; | ||
| export { type APIResponse as A, type ContributionCalendar as C, DEFAULT_API_ENDPOINT as D, type GitHubUser as G, type RenderOptions as R, type ThemePreset as T, type ThemeConfig as a, applyTheme as b, getThemeCSS as c, THEME_PRESETS as d, type ContributionDay as e, fetchContributionData as f, getThemePresets as g, type ContributionWeek as h, type ContributionMonth as i, type GitHubContributionGraphConfig as j, type ContributionLevel as k, REPO_URL as l, CONTRIBUTION_LEVELS as m, DAY_LABELS as n }; |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
No website
QualityPackage does not have a website.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
284502
0.31%753
0.13%7
-12.5%188
7.43%