react-github-calendar
Advanced tools
Comparing version 4.5.0 to 4.5.1
@@ -24,10 +24,2 @@ 'use client'; | ||
const API_URL = 'https://github-contributions-api.jogruber.de/v4/'; | ||
// GitHub theme | ||
const DEFAULT_THEME = { | ||
light: ['#ebedf0', '#9be9a8', '#40c463', '#30a14e', '#216e39'], | ||
dark: ['#161b22', '#0e4429', '#006d32', '#26a641', '#39d353'] | ||
}; | ||
const transformData = (data, transformFn) => { | ||
@@ -57,3 +49,4 @@ if (typeof transformFn !== 'function') { | ||
async function fetchCalendarData(username, year) { | ||
const response = await fetch(`${API_URL}${username}?y=${year}`); | ||
const apiUrl = 'https://github-contributions-api.jogruber.de/v4/'; | ||
const response = await fetch(`${apiUrl}${username}?y=${year}`); | ||
const data = await response.json(); | ||
@@ -104,3 +97,3 @@ if (!response.ok) { | ||
} | ||
const theme = props.theme ?? DEFAULT_THEME; | ||
const theme = props.theme ?? gitHubTheme; | ||
const defaultLabels = { | ||
@@ -122,4 +115,8 @@ totalCount: `{{count}} contributions in ${year === 'last' ? 'the last year' : '{{year}}'}` | ||
GitHubCalendar.displayName = 'GitHubCalendar'; | ||
const gitHubTheme = { | ||
light: ['#ebedf0', '#9be9a8', '#40c463', '#30a14e', '#216e39'], | ||
dark: ['#161b22', '#0e4429', '#006d32', '#26a641', '#39d353'] | ||
}; | ||
exports.default = GitHubCalendar; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-github-calendar", | ||
"version": "4.5.0", | ||
"version": "4.5.1", | ||
"description": " React component to display a GitHub contributions calendar", | ||
@@ -26,3 +26,3 @@ "author": "Jonathan Gruber <gruberjonathan@gmail.com>", | ||
"dependencies": { | ||
"react-activity-calendar": "^2.7.0", | ||
"react-activity-calendar": "^2.7.1", | ||
"react-error-boundary": "^4.1.2" | ||
@@ -66,10 +66,4 @@ }, | ||
}, | ||
"files": [ | ||
"build" | ||
], | ||
"browserslist": [ | ||
"last 2 chrome version", | ||
"last 2 firefox version", | ||
"last 2 safari version" | ||
] | ||
"files": ["build"], | ||
"browserslist": ["last 2 chrome version", "last 2 firefox version", "last 2 safari version"] | ||
} |
@@ -9,3 +9,3 @@ # React GitHub Calendar | ||
![Screenshot](preview.png?v3) | ||
![Screenshot](preview.png) | ||
@@ -20,10 +20,34 @@ [Demo and documentation](https://grubersjoe.github.io/react-github-calendar/) | ||
## Known issues | ||
## Usage | ||
This component cannot be rendered on the server (SSR). Please refer to the | ||
[known issues](https://github.com/grubersjoe/react-activity-calendar/blob/main/README.md#known-issues) | ||
of `react-activity-calendar` for more details how to render it on the client only. | ||
```tsx | ||
import GitHubCalendar from 'react-github-calendar'; | ||
Create React App also is not supported. Again see the README. | ||
const App = () => <GitHubCalendar username="grubersjoe" />; | ||
``` | ||
## FAQ | ||
### Is server side rendering (SSR) supported? | ||
Yes. However, not with this component because it fetches data client-side. For SSR support, you can | ||
fetch the GitHub contribution data from a suitable | ||
[API](https://github.com/grubersjoe/github-contributions-api) server-side and pass it on to the | ||
internally used [`react-activity-calendar`](https://github.com/grubersjoe/react-activity-calendar) | ||
component. See the | ||
[source code](https://github.com/grubersjoe/react-github-calendar/blob/main/src/index.tsx) for the | ||
GitHub color theme. | ||
### Why is Create React App unsupported? | ||
Create React App (CRA) is considered | ||
[abandoned](https://github.com/facebook/create-react-app/discussions/11086), and you probably should | ||
not use it anymore (more | ||
[background](https://github.com/facebook/create-react-app/issues/11180#issuecomment-874748552)). | ||
Using this component inside CRA will lead to errors for reasons described in issue | ||
[#105](https://github.com/grubersjoe/react-activity-calendar/issues/105) of | ||
`react-activity-calendar`. This repo is not for CRA support questions. If you encounter issues, you | ||
need to fix those yourself given the maintenance state of CRA. Personally, I would recommend using | ||
[Vite](https://vitejs.dev/) instead of CRA. | ||
## Development | ||
@@ -48,3 +72,3 @@ | ||
## Publish a new release | ||
### Publish a new release | ||
@@ -51,0 +75,0 @@ ```shell |
Sorry, the diff of this file is not supported yet
19509
84
130