react-github-calendar
Advanced tools
Comparing version 4.1.1 to 4.1.2
import { FunctionComponent } from 'react'; | ||
import { | ||
Activity, | ||
Props as ActivityCalendarProps, | ||
} from 'react-activity-calendar'; | ||
import { Props as ActivityCalendarProps } from 'react-activity-calendar'; | ||
export interface Props extends Omit<ActivityCalendarProps, 'data'> { | ||
username: string; | ||
year?: number | 'last'; | ||
transformData?: (data: Array<Activity>) => Array<Activity>; | ||
transformTotalCount?: boolean; | ||
throwOnError?: boolean; | ||
errorMessage?: string; | ||
export interface Activity { | ||
date: string; | ||
count: number; | ||
level: 0 | 1 | 2 | 3 | 4; | ||
} | ||
export type Year = number | "last"; | ||
export type Color = string; | ||
export type ColorScale = [ | ||
Color, | ||
Color, | ||
Color, | ||
Color, | ||
Color | ||
]; | ||
export type ThemeInput = { | ||
light: ColorScale | [ | ||
from: Color, | ||
to: Color | ||
]; | ||
dark?: ColorScale | [ | ||
from: Color, | ||
to: Color | ||
]; | ||
} | { | ||
light?: ColorScale | [ | ||
from: Color, | ||
to: Color | ||
]; | ||
dark: ColorScale | [ | ||
from: Color, | ||
to: Color | ||
]; | ||
}; | ||
export interface Props extends Omit<ActivityCalendarProps, "data" | "theme"> { | ||
username: string; | ||
errorMessage?: string; | ||
theme?: ThemeInput; | ||
throwOnError?: boolean; | ||
transformData?: (data: Array<Activity>) => Array<Activity>; | ||
transformTotalCount?: boolean; | ||
year?: Year; | ||
} | ||
declare const GitHubCalendar: FunctionComponent<Props>; | ||
export default GitHubCalendar; | ||
export { | ||
GitHubCalendar as default, | ||
}; | ||
export {}; |
@@ -37,4 +37,2 @@ 'use client'; | ||
// noinspection SuspiciousTypeOfGuard The caller might not use TypeScript | ||
const transformData = (data, transformFn) => { | ||
@@ -83,7 +81,7 @@ if (typeof transformFn !== 'function') { | ||
const [loading, setLoading] = React.useState(false); | ||
const [fetchError, setFetchError] = React.useState(null); | ||
const [error, setError] = React.useState(null); | ||
const fetchData = React.useCallback(() => { | ||
setLoading(true); | ||
setFetchError(null); | ||
fetchCalendarData(username, year).then(setData).catch(setFetchError).finally(() => setLoading(false)); | ||
setError(null); | ||
fetchCalendarData(username, year).then(setData).catch(setError).finally(() => setLoading(false)); | ||
}, [username, year]); | ||
@@ -93,5 +91,5 @@ React.useEffect(fetchData, [fetchData]); | ||
// React error boundaries can't handle asynchronous code, so rethrow. | ||
if (fetchError) { | ||
if (error) { | ||
if (throwOnError) { | ||
throw fetchError; | ||
throw error; | ||
} else { | ||
@@ -98,0 +96,0 @@ return /*#__PURE__*/React__default.default.createElement("div", null, errorMessage); |
{ | ||
"name": "react-github-calendar", | ||
"version": "4.1.1", | ||
"description": " A flexible React component to display a GitHub contributions graph", | ||
"version": "4.1.2", | ||
"description": " React component to display a GitHub contributions calendar", | ||
"author": "Jonathan Gruber <gruberjonathan@gmail.com>", | ||
@@ -17,2 +17,3 @@ "license": "MIT", | ||
"lint": "eslint 'src/**/*' 'example/src/**/*'", | ||
"postbuild": "dts-bundle-generator src/index.tsx -o build/index.d.ts --no-check --no-banner", | ||
"predeploy": "cd example && ./sync-version.js && pnpm install && npm run build", | ||
@@ -38,2 +39,3 @@ "prepare": "npm run build", | ||
"@typescript-eslint/parser": "^6.18.1", | ||
"dts-bundle-generator": "^9.2.5", | ||
"eslint": "^8.56.0", | ||
@@ -48,3 +50,2 @@ "eslint-plugin-react": "^7.32.2", | ||
"rollup": "^4.9.5", | ||
"rollup-plugin-copy": "^3.3.0", | ||
"rollup-plugin-filesize": "^10.0.0", | ||
@@ -51,0 +52,0 @@ "rollup-plugin-peer-deps-external": "^2.2.2", |
Sorry, the diff of this file is not supported yet
17746
155