@stoked-ui/github 0.0.0-a.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15014 -0
- package/GithubCalendar/GithubCalendar.d.ts +7 -0
- package/GithubCalendar/GithubCalendar.js +330 -0
- package/GithubCalendar/index.d.ts +2 -0
- package/GithubCalendar/index.js +2 -0
- package/GithubCalendar/package.json +6 -0
- package/GithubEvents/EventTypes/CreateEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/CreateEvent.js +72 -0
- package/GithubEvents/EventTypes/DeleteEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/DeleteEvent.js +65 -0
- package/GithubEvents/EventTypes/ForkEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/ForkEvent.js +77 -0
- package/GithubEvents/EventTypes/IssueCommentEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/IssueCommentEvent.js +210 -0
- package/GithubEvents/EventTypes/IssuesEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/IssuesEvent.js +97 -0
- package/GithubEvents/EventTypes/ProjectsV2ColumnEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/ProjectsV2ColumnEvent.js +69 -0
- package/GithubEvents/EventTypes/ProjectsV2Event.d.ts +7 -0
- package/GithubEvents/EventTypes/ProjectsV2Event.js +74 -0
- package/GithubEvents/EventTypes/ProjectsV2FieldEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/ProjectsV2FieldEvent.js +77 -0
- package/GithubEvents/EventTypes/ProjectsV2ItemEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/ProjectsV2ItemEvent.js +79 -0
- package/GithubEvents/EventTypes/PullRequest/CommitsList.d.ts +17 -0
- package/GithubEvents/EventTypes/PullRequest/CommitsList.js +99 -0
- package/GithubEvents/EventTypes/PullRequest/FileChanges.d.ts +17 -0
- package/GithubEvents/EventTypes/PullRequest/FileChanges.js +182 -0
- package/GithubEvents/EventTypes/PullRequest/PullRequestEvent.d.ts +8 -0
- package/GithubEvents/EventTypes/PullRequest/PullRequestEvent.js +374 -0
- package/GithubEvents/EventTypes/PullRequest/PullRequestView.d.ts +29 -0
- package/GithubEvents/EventTypes/PullRequest/PullRequestView.js +132 -0
- package/GithubEvents/EventTypes/PushEvent.d.ts +7 -0
- package/GithubEvents/EventTypes/PushEvent.js +106 -0
- package/GithubEvents/GithubEvents.d.ts +49 -0
- package/GithubEvents/GithubEvents.js +1454 -0
- package/GithubEvents/index.d.ts +2 -0
- package/GithubEvents/index.js +2 -0
- package/GithubEvents/package.json +6 -0
- package/LICENSE +21 -0
- package/README.md +29 -0
- package/apiHandlers/getPullRequestDetails.d.ts +7 -0
- package/apiHandlers/getPullRequestDetails.js +120 -0
- package/apiHandlers/index.d.ts +1 -0
- package/apiHandlers/index.js +1 -0
- package/apiHandlers/package.json +6 -0
- package/index.d.ts +3 -0
- package/index.js +10 -0
- package/modern/GithubCalendar/GithubCalendar.js +330 -0
- package/modern/GithubCalendar/index.js +2 -0
- package/modern/GithubEvents/EventTypes/CreateEvent.js +72 -0
- package/modern/GithubEvents/EventTypes/DeleteEvent.js +65 -0
- package/modern/GithubEvents/EventTypes/ForkEvent.js +77 -0
- package/modern/GithubEvents/EventTypes/IssueCommentEvent.js +210 -0
- package/modern/GithubEvents/EventTypes/IssuesEvent.js +97 -0
- package/modern/GithubEvents/EventTypes/ProjectsV2ColumnEvent.js +69 -0
- package/modern/GithubEvents/EventTypes/ProjectsV2Event.js +74 -0
- package/modern/GithubEvents/EventTypes/ProjectsV2FieldEvent.js +77 -0
- package/modern/GithubEvents/EventTypes/ProjectsV2ItemEvent.js +79 -0
- package/modern/GithubEvents/EventTypes/PullRequest/CommitsList.js +99 -0
- package/modern/GithubEvents/EventTypes/PullRequest/FileChanges.js +182 -0
- package/modern/GithubEvents/EventTypes/PullRequest/PullRequestEvent.js +374 -0
- package/modern/GithubEvents/EventTypes/PullRequest/PullRequestView.js +132 -0
- package/modern/GithubEvents/EventTypes/PushEvent.js +106 -0
- package/modern/GithubEvents/GithubEvents.js +1454 -0
- package/modern/GithubEvents/index.js +2 -0
- package/modern/apiHandlers/getPullRequestDetails.js +120 -0
- package/modern/apiHandlers/index.js +1 -0
- package/modern/index.js +10 -0
- package/modern/types/github.js +1 -0
- package/node/GithubCalendar/GithubCalendar.js +337 -0
- package/node/GithubCalendar/index.js +9 -0
- package/node/GithubEvents/EventTypes/CreateEvent.js +80 -0
- package/node/GithubEvents/EventTypes/DeleteEvent.js +73 -0
- package/node/GithubEvents/EventTypes/ForkEvent.js +85 -0
- package/node/GithubEvents/EventTypes/IssueCommentEvent.js +218 -0
- package/node/GithubEvents/EventTypes/IssuesEvent.js +105 -0
- package/node/GithubEvents/EventTypes/ProjectsV2ColumnEvent.js +77 -0
- package/node/GithubEvents/EventTypes/ProjectsV2Event.js +82 -0
- package/node/GithubEvents/EventTypes/ProjectsV2FieldEvent.js +85 -0
- package/node/GithubEvents/EventTypes/ProjectsV2ItemEvent.js +87 -0
- package/node/GithubEvents/EventTypes/PullRequest/CommitsList.js +107 -0
- package/node/GithubEvents/EventTypes/PullRequest/FileChanges.js +188 -0
- package/node/GithubEvents/EventTypes/PullRequest/PullRequestEvent.js +381 -0
- package/node/GithubEvents/EventTypes/PullRequest/PullRequestView.js +138 -0
- package/node/GithubEvents/EventTypes/PushEvent.js +114 -0
- package/node/GithubEvents/GithubEvents.js +1463 -0
- package/node/GithubEvents/index.js +9 -0
- package/node/apiHandlers/getPullRequestDetails.js +127 -0
- package/node/apiHandlers/index.js +13 -0
- package/node/index.js +27 -0
- package/node/types/github.js +5 -0
- package/package.json +71 -0
- package/types/github.d.ts +107 -0
- package/types/github.js +1 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { RequestError } from '@octokit/request-error';
|
|
3
|
+
export default async function getPullRequestDetails(params) {
|
|
4
|
+
const requestErrorOptions = {
|
|
5
|
+
request: {
|
|
6
|
+
headers: {},
|
|
7
|
+
method: 'GET',
|
|
8
|
+
url: 'https://api.github.com/repos/${owner}/${repo}/pulls/${pull_number}'
|
|
9
|
+
},
|
|
10
|
+
response: {
|
|
11
|
+
status: 400,
|
|
12
|
+
data: {
|
|
13
|
+
message: 'Bad Request'
|
|
14
|
+
},
|
|
15
|
+
headers: {},
|
|
16
|
+
url: 'https://docs.github.com/en/rest/pulls?apiVersion=2022-11-28'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
try {
|
|
20
|
+
const {
|
|
21
|
+
owner,
|
|
22
|
+
repo,
|
|
23
|
+
pull_number
|
|
24
|
+
} = params;
|
|
25
|
+
if (!owner || !repo || !pull_number) {
|
|
26
|
+
console.error('Missing required parameters: owner, repo, pull_number');
|
|
27
|
+
return new RequestError('Missing required parameters: owner, repo, pull_number', 400, requestErrorOptions);
|
|
28
|
+
}
|
|
29
|
+
const githubToken = process.env.GITHUB_TOKEN;
|
|
30
|
+
//if (!githubToken) {
|
|
31
|
+
// return res.status(500).json({ message: 'GitHub token not configured' });
|
|
32
|
+
//}
|
|
33
|
+
|
|
34
|
+
let headers = {
|
|
35
|
+
'User-Agent': 'brianstoker.com-website'
|
|
36
|
+
};
|
|
37
|
+
if (githubToken) {
|
|
38
|
+
headers.Authorization = `token ${githubToken}`;
|
|
39
|
+
}
|
|
40
|
+
async function fetchWithRateLimit(url) {
|
|
41
|
+
const response = await fetch(url, {
|
|
42
|
+
headers
|
|
43
|
+
});
|
|
44
|
+
const rateLimit = {
|
|
45
|
+
limit: response.headers.get('x-ratelimit-limit'),
|
|
46
|
+
remaining: response.headers.get('x-ratelimit-remaining'),
|
|
47
|
+
reset: response.headers.get('x-ratelimit-reset')
|
|
48
|
+
};
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
if (response.status === 403 && rateLimit.remaining === '0') {
|
|
51
|
+
console.error('Rate limit exceeded. Resets at', rateLimit.reset);
|
|
52
|
+
const resetDate = new Date(Number(rateLimit.reset) * 1000);
|
|
53
|
+
throw new Error(`Rate limit exceeded. Resets at ${resetDate.toLocaleString()}`);
|
|
54
|
+
}
|
|
55
|
+
console.error('GitHub API error:', response.status, await response.text());
|
|
56
|
+
throw new Error(`GitHub API error: ${response.status} - ${await response.text()}`);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
data: await response.json(),
|
|
60
|
+
rateLimit
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Fetch basic PR information
|
|
65
|
+
const {
|
|
66
|
+
data: prData
|
|
67
|
+
} = await fetchWithRateLimit(`https://api.github.com/repos/${owner}/${repo}/pulls/${pull_number}`);
|
|
68
|
+
|
|
69
|
+
// Fetch commits for this PR
|
|
70
|
+
const {
|
|
71
|
+
data: commitsData
|
|
72
|
+
} = await fetchWithRateLimit(`https://api.github.com/repos/${owner}/${repo}/pulls/${pull_number}/commits`);
|
|
73
|
+
|
|
74
|
+
// Fetch file changes
|
|
75
|
+
const {
|
|
76
|
+
data: filesData
|
|
77
|
+
} = await fetchWithRateLimit(`https://api.github.com/repos/${owner}/${repo}/pulls/${pull_number}/files`);
|
|
78
|
+
|
|
79
|
+
// Process file changes to match our interface
|
|
80
|
+
const processedFiles = filesData.map(file => {
|
|
81
|
+
// Parse the patch into diff lines
|
|
82
|
+
const diff = file.patch ? file.patch.split('\n').map((line, index) => {
|
|
83
|
+
let type = 'context';
|
|
84
|
+
if (line.startsWith('+')) {
|
|
85
|
+
type = 'addition';
|
|
86
|
+
} else if (line.startsWith('-')) {
|
|
87
|
+
type = 'deletion';
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
type,
|
|
91
|
+
content: line,
|
|
92
|
+
lineNumber: index + 1
|
|
93
|
+
};
|
|
94
|
+
}) : [];
|
|
95
|
+
return {
|
|
96
|
+
path: file.filename,
|
|
97
|
+
type: file.status === 'added' ? 'added' : file.status === 'removed' ? 'deleted' : 'modified',
|
|
98
|
+
additions: file.additions,
|
|
99
|
+
deletions: file.deletions,
|
|
100
|
+
diff
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Combine all the data
|
|
105
|
+
const pullRequestDetails = _extends({}, prData, {
|
|
106
|
+
commits_list: commitsData,
|
|
107
|
+
files: processedFiles
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Include rate limit info in response headers
|
|
111
|
+
//res.setHeader('X-RateLimit-Limit', rateLimit.limit || '');
|
|
112
|
+
//res.setHeader('X-RateLimit-Remaining', rateLimit.remaining || '');
|
|
113
|
+
//res.setHeader('X-RateLimit-Reset', rateLimit.reset || '');
|
|
114
|
+
|
|
115
|
+
return pullRequestDetails;
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error('Error fetching pull request details:', error);
|
|
118
|
+
return new RequestError(error instanceof Error ? error.message : String(error), 500, requestErrorOptions);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as getPullRequestDetails } from './getPullRequestDetails';
|
package/modern/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @stoked-ui/github v0.0.0-a.0
|
|
3
|
+
*
|
|
4
|
+
* @license MIT
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import GithubCalendar from './GithubCalendar';
|
|
9
|
+
import GithubEvents from './GithubEvents';
|
|
10
|
+
export { GithubCalendar, GithubEvents };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = GithubCalendar;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _material = require("@mui/material");
|
|
11
|
+
var _reactActivityCalendar = require("react-activity-calendar");
|
|
12
|
+
var _styles = require("@mui/material/styles");
|
|
13
|
+
var _common = require("@stoked-ui/common");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
+
const defaultActivityData = {
|
|
17
|
+
total: {},
|
|
18
|
+
contributions: [],
|
|
19
|
+
countLabel: 'Loading...'
|
|
20
|
+
};
|
|
21
|
+
function sleep(duration) {
|
|
22
|
+
return new Promise(resolve => {
|
|
23
|
+
setTimeout(() => {
|
|
24
|
+
resolve(void 0);
|
|
25
|
+
}, duration);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function GithubCalendar({
|
|
29
|
+
windowMode = false,
|
|
30
|
+
containerMode = false,
|
|
31
|
+
blockSize: inputBlockSize = 12,
|
|
32
|
+
fx = undefined,
|
|
33
|
+
startImage = undefined
|
|
34
|
+
}) {
|
|
35
|
+
const [activityTheme, setActivityTheme] = React.useState('light');
|
|
36
|
+
const [activityData, setActivityData] = React.useState(defaultActivityData);
|
|
37
|
+
const [activityLoading, setActivityLoading] = React.useState(true);
|
|
38
|
+
const [activityHover, setActivityHover] = React.useState(false);
|
|
39
|
+
const [activityLabels, setActivityLabels] = React.useState(false);
|
|
40
|
+
const [activityClass, setActivityClass] = React.useState('activity');
|
|
41
|
+
const [labelsTimer, setLabelsTimer] = React.useState(null);
|
|
42
|
+
const theme = (0, _styles.useTheme)();
|
|
43
|
+
const elementRef = React.useRef(null);
|
|
44
|
+
const [windowWidth, _] = (0, _common.useResizeWindow)();
|
|
45
|
+
const elemSize = (0, _common.useResize)(elementRef);
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
if (inputBlockSize) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (activityData.totalWeeks) {
|
|
51
|
+
if (windowMode) {
|
|
52
|
+
activityData.blockSize = Math.max(10, Math.floor(windowWidth / activityData.totalWeeks));
|
|
53
|
+
setActivityData((0, _extends2.default)({}, activityData));
|
|
54
|
+
} else if (containerMode) {
|
|
55
|
+
if (elemSize.width) {
|
|
56
|
+
activityData.blockSize = Math.max(10, Math.floor(elemSize.width / activityData.totalWeeks));
|
|
57
|
+
setActivityData((0, _extends2.default)({}, activityData));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, [elemSize.width, windowWidth]);
|
|
62
|
+
React.useEffect(() => {
|
|
63
|
+
if (activityHover && !activityLabels) {
|
|
64
|
+
setLabelsTimer(setTimeout(() => {
|
|
65
|
+
setActivityLabels(true);
|
|
66
|
+
}, 200));
|
|
67
|
+
} else if (!activityHover && (activityLabels || labelsTimer)) {
|
|
68
|
+
setActivityLabels(false);
|
|
69
|
+
if (labelsTimer) {
|
|
70
|
+
clearTimeout(labelsTimer);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
setActivityClass('activity ' + (activityLabels ? 'hover labels' : activityHover ? 'hover' : ''));
|
|
74
|
+
}, [activityHover, activityLabels]);
|
|
75
|
+
|
|
76
|
+
// Scroll activity all the way to the right on mount
|
|
77
|
+
React.useEffect(() => {
|
|
78
|
+
if (!activityLoading) {
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
const activityContainer = document.querySelector('.react-activity-calendar__scroll-container');
|
|
81
|
+
if (activityContainer) {
|
|
82
|
+
activityContainer.scrollLeft = activityContainer.scrollWidth;
|
|
83
|
+
}
|
|
84
|
+
}, 200);
|
|
85
|
+
}
|
|
86
|
+
}, [activityLoading]);
|
|
87
|
+
const fetchActivityData = async () => {
|
|
88
|
+
setActivityLoading(true);
|
|
89
|
+
try {
|
|
90
|
+
const response = await fetch('https://github-contributions-api.jogruber.de/v4/brian-stoker?yr=last');
|
|
91
|
+
if (!response.ok) {
|
|
92
|
+
throw new Error(`API error: ${response.status}`);
|
|
93
|
+
}
|
|
94
|
+
const data = await response.json();
|
|
95
|
+
function compare(a, b) {
|
|
96
|
+
if (a.date < b.date) {
|
|
97
|
+
return -1;
|
|
98
|
+
}
|
|
99
|
+
if (a.date > b.date) {
|
|
100
|
+
return 1;
|
|
101
|
+
}
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
const earliestDate = data.contributions.filter(item => item.count > 0) // Filter items with count > 0
|
|
105
|
+
.reduce((earliest, current) => {
|
|
106
|
+
return !earliest || new Date(current.date) < new Date(earliest.date) ? current : earliest;
|
|
107
|
+
}, null);
|
|
108
|
+
const today = new Date();
|
|
109
|
+
const year = today.getFullYear();
|
|
110
|
+
const month = String(today.getMonth() + 1).padStart(2, '0'); // Month is 0-indexed
|
|
111
|
+
const day = String(today.getDate()).padStart(2, '0');
|
|
112
|
+
const formattedDate = `${year}-${month}-${day}`;
|
|
113
|
+
const contribs = data.contributions.filter(contrib => contrib.date < formattedDate && (!earliestDate || contrib.date >= earliestDate.date));
|
|
114
|
+
data.contributions = contribs.sort(compare);
|
|
115
|
+
const allJansSet = contribs.map(contrib => {
|
|
116
|
+
return contrib.date.slice(2, 7);
|
|
117
|
+
}).filter(yymm => yymm.slice(-2) === '01');
|
|
118
|
+
const allJans = new Set(allJansSet);
|
|
119
|
+
console.log('allJans', [...allJans]);
|
|
120
|
+
const all = Object.values(data.total).reduce((acc, curr) => acc + curr, 0);
|
|
121
|
+
const totalKeys = Object.keys(data.total);
|
|
122
|
+
data.countLabel = `${all} contributions from ${totalKeys[0]} to ${totalKeys[totalKeys.length - 1]}`;
|
|
123
|
+
data.totalWeeks = data.contributions.length / 7;
|
|
124
|
+
if (inputBlockSize) {
|
|
125
|
+
data.blockSize = inputBlockSize;
|
|
126
|
+
} else if (windowMode) {
|
|
127
|
+
data.blockSize = Math.max(10, Math.floor(windowWidth / data.totalWeeks));
|
|
128
|
+
} else {
|
|
129
|
+
if (elemSize.width) {
|
|
130
|
+
data.blockSize = Math.max(10, Math.floor(elemSize.width / data.totalWeeks));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
setActivityData(data);
|
|
134
|
+
} catch (err) {
|
|
135
|
+
console.error(`Error fetching activity data: ${err instanceof Error ? err.message : String(err)}`);
|
|
136
|
+
// Use fallback data if API fails
|
|
137
|
+
setActivityData(defaultActivityData);
|
|
138
|
+
} finally {
|
|
139
|
+
setActivityLoading(false);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// Initial load
|
|
144
|
+
React.useEffect(() => {
|
|
145
|
+
async function setup() {
|
|
146
|
+
await fetchActivityData();
|
|
147
|
+
await sleep(800);
|
|
148
|
+
setupRectAnimations();
|
|
149
|
+
window.addEventListener('resize', handleResize);
|
|
150
|
+
}
|
|
151
|
+
if (!fx) {
|
|
152
|
+
fetchActivityData().catch(() => console.error('Error fetching activity data'));
|
|
153
|
+
} else {
|
|
154
|
+
setup().catch(() => console.error('Error fetching activity data'));
|
|
155
|
+
}
|
|
156
|
+
if (startImage) {
|
|
157
|
+
const startImageContainer = document.querySelector('.react-activity-calendar__scroll-container');
|
|
158
|
+
if (startImageContainer) {
|
|
159
|
+
const startImageEl = document.createElement('img');
|
|
160
|
+
startImageEl.src = startImage;
|
|
161
|
+
startImageEl.alt = 'hbngha';
|
|
162
|
+
startImageEl.style.position = 'absolute';
|
|
163
|
+
startImageEl.style.top = '0';
|
|
164
|
+
startImageEl.style.left = '0';
|
|
165
|
+
startImageEl.style.marginTop = '25px';
|
|
166
|
+
startImageEl.style.width = `${(activityData.blockSize || 12) * 7}px`;
|
|
167
|
+
startImageEl.style.height = `${(activityData.blockSize || 12) * 7}px`;
|
|
168
|
+
const div = document.createElement('div');
|
|
169
|
+
div.style.position = 'relative';
|
|
170
|
+
div.appendChild(startImageEl);
|
|
171
|
+
startImageContainer.insertBefore(div, startImageContainer.firstChild);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return () => {
|
|
175
|
+
if (fx) {
|
|
176
|
+
var _elementRef$current;
|
|
177
|
+
window.removeEventListener('resize', handleResize);
|
|
178
|
+
|
|
179
|
+
// Clean up any active timeouts
|
|
180
|
+
const svg = (_elementRef$current = elementRef.current) == null ? void 0 : _elementRef$current.querySelector('svg');
|
|
181
|
+
if (svg) {
|
|
182
|
+
const rects = svg.querySelectorAll('rect');
|
|
183
|
+
rects.forEach(rect => {
|
|
184
|
+
if (rect.dataset.timeoutId) {
|
|
185
|
+
clearTimeout(parseInt(rect.dataset.timeoutId));
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
}, []);
|
|
192
|
+
const handleResize = () => {
|
|
193
|
+
var _elementRef$current2;
|
|
194
|
+
// Clear all animations first
|
|
195
|
+
const svg = (_elementRef$current2 = elementRef.current) == null ? void 0 : _elementRef$current2.querySelector('svg');
|
|
196
|
+
if (svg) {
|
|
197
|
+
const rects = svg.querySelectorAll('rect');
|
|
198
|
+
rects.forEach(rect => {
|
|
199
|
+
rect.classList.remove('rect-animated');
|
|
200
|
+
if (rect.dataset.timeoutId) {
|
|
201
|
+
clearTimeout(parseInt(rect.dataset.timeoutId));
|
|
202
|
+
delete rect.dataset.timeoutId;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Recalculate positions
|
|
208
|
+
setupRectAnimations();
|
|
209
|
+
};
|
|
210
|
+
function setupRectAnimations() {
|
|
211
|
+
var _elementRef$current3;
|
|
212
|
+
// Get the SVG container
|
|
213
|
+
const svg = (_elementRef$current3 = elementRef.current) == null ? void 0 : _elementRef$current3.querySelector('svg');
|
|
214
|
+
if (!svg) return;
|
|
215
|
+
|
|
216
|
+
// Calculate center of the SVG
|
|
217
|
+
const svgRect = svg.getBoundingClientRect();
|
|
218
|
+
const centerX = svgRect.width / 2;
|
|
219
|
+
const centerY = svgRect.height / 2;
|
|
220
|
+
|
|
221
|
+
// Get all rect elements
|
|
222
|
+
const rects = svg.querySelectorAll('rect');
|
|
223
|
+
rects.forEach(rect => {
|
|
224
|
+
if (fx === 'punch') {
|
|
225
|
+
var _rect$parentNode;
|
|
226
|
+
// Calculate the translate value
|
|
227
|
+
const rectRect = rect.getBoundingClientRect();
|
|
228
|
+
const rectCenterY = rectRect.top + rectRect.height / 2 - svgRect.top;
|
|
229
|
+
const rectCenterX = rectRect.left + rectRect.width / 2 - svgRect.left;
|
|
230
|
+
|
|
231
|
+
// Calculate distance from center
|
|
232
|
+
const distanceFromCenterX = svgRect.width / 2 / (rectCenterX - centerX);
|
|
233
|
+
const distanceFromCenterY = svgRect.height / 2 / (rectCenterY - centerY);
|
|
234
|
+
const translateFactorX = 6;
|
|
235
|
+
const translateFactorY = 0.02;
|
|
236
|
+
const randomX = Math.random() * 10 - 5;
|
|
237
|
+
const randomY = Math.random() * 10 - 5;
|
|
238
|
+
const translateX = distanceFromCenterX * translateFactorX + randomX;
|
|
239
|
+
const translateY = distanceFromCenterY * translateFactorY + randomY;
|
|
240
|
+
// Set the custom property
|
|
241
|
+
rect.style.setProperty('--translate-x', `${translateX}px`);
|
|
242
|
+
rect.style.setProperty('--translate-y', `${translateY - 200}px`);
|
|
243
|
+
// Remove existing event listeners (if possible)
|
|
244
|
+
const oldRect = rect.cloneNode(true);
|
|
245
|
+
(_rect$parentNode = rect.parentNode) == null || _rect$parentNode.replaceChild(oldRect, rect);
|
|
246
|
+
|
|
247
|
+
// Add mouseenter event
|
|
248
|
+
oldRect.addEventListener('mouseenter', () => {
|
|
249
|
+
// Clear any existing timeout
|
|
250
|
+
if (oldRect != null && oldRect.dataset.timeoutId) {
|
|
251
|
+
clearTimeout(parseInt(oldRect == null ? void 0 : oldRect.dataset.timeoutId));
|
|
252
|
+
}
|
|
253
|
+
oldRect.style.position = 'relative';
|
|
254
|
+
// Add the animated class
|
|
255
|
+
oldRect == null || oldRect.classList.add('rect-animated');
|
|
256
|
+
|
|
257
|
+
// Set a timeout to return after random delay
|
|
258
|
+
const minDelay = 100;
|
|
259
|
+
const randomDelay = Math.random() * 1000 + minDelay;
|
|
260
|
+
const timeoutId = setTimeout(() => {
|
|
261
|
+
oldRect == null || oldRect.classList.remove('rect-animated');
|
|
262
|
+
oldRect == null || delete oldRect.dataset.timeoutId;
|
|
263
|
+
}, randomDelay);
|
|
264
|
+
|
|
265
|
+
// Store the timeout ID
|
|
266
|
+
if (oldRect != null && oldRect.dataset) {
|
|
267
|
+
oldRect.dataset.timeoutId = timeoutId.toString();
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
} else {
|
|
271
|
+
var _rect$parentNode2;
|
|
272
|
+
const oldRect = rect.cloneNode(true);
|
|
273
|
+
(_rect$parentNode2 = rect.parentNode) == null || _rect$parentNode2.replaceChild(oldRect, rect);
|
|
274
|
+
// Add mouseenter event
|
|
275
|
+
rect.addEventListener('mouseenter', () => {
|
|
276
|
+
// Clear any existing timeout
|
|
277
|
+
if (rect != null && rect.dataset.timeoutId) {
|
|
278
|
+
clearTimeout(parseInt(rect == null ? void 0 : rect.dataset.timeoutId));
|
|
279
|
+
}
|
|
280
|
+
rect.style.position = 'relative';
|
|
281
|
+
// Add the animated class
|
|
282
|
+
rect == null || rect.classList.add('rect-highlight');
|
|
283
|
+
// Add the animated class
|
|
284
|
+
//oldRect?.classList.add('rect-animated');
|
|
285
|
+
|
|
286
|
+
// Set a timeout to return after random delay
|
|
287
|
+
const minDelay = 100;
|
|
288
|
+
const randomDelay = Math.random() * 1000 + minDelay;
|
|
289
|
+
const timeoutId = setTimeout(() => {
|
|
290
|
+
rect == null || rect.classList.remove('rect-highlight');
|
|
291
|
+
rect == null || delete rect.dataset.timeoutId;
|
|
292
|
+
}, randomDelay);
|
|
293
|
+
|
|
294
|
+
// Store the timeout ID
|
|
295
|
+
if (rect != null && rect.dataset) {
|
|
296
|
+
rect.dataset.timeoutId = timeoutId.toString();
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
React.useEffect(() => {
|
|
303
|
+
setActivityTheme(theme.palette.mode === 'dark' ? 'dark' : 'light');
|
|
304
|
+
}, [theme.palette.mode]);
|
|
305
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
306
|
+
ref: elementRef,
|
|
307
|
+
onMouseEnter: () => setActivityHover(true),
|
|
308
|
+
onMouseLeave: () => {
|
|
309
|
+
setActivityHover(false);
|
|
310
|
+
setActivityLabels(false);
|
|
311
|
+
},
|
|
312
|
+
className: `${activityClass} ${activityLoading ? 'loading' : ''}`,
|
|
313
|
+
sx: {
|
|
314
|
+
'& .activity > *': {
|
|
315
|
+
transition: '1s ease-in-out'
|
|
316
|
+
},
|
|
317
|
+
position: 'sticky'
|
|
318
|
+
},
|
|
319
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactActivityCalendar.ActivityCalendar, {
|
|
320
|
+
data: activityData.contributions,
|
|
321
|
+
theme: {
|
|
322
|
+
light: activityTheme === 'light' ? ['hsl(0, 0%, 92%)', theme.palette.primary.dark] : ['hsl(0, 0%, 12%)', theme.palette.primary.light],
|
|
323
|
+
dark: activityTheme === 'light' ? ['hsl(0, 0%, 92%)', theme.palette.primary.dark] : ['hsl(0, 0%, 12%)', theme.palette.primary.light]
|
|
324
|
+
},
|
|
325
|
+
loading: activityLoading,
|
|
326
|
+
blockMargin: 0.5,
|
|
327
|
+
blockRadius: 0,
|
|
328
|
+
blockSize: activityData.blockSize || 12,
|
|
329
|
+
style: {
|
|
330
|
+
backgroundColor: theme.palette.background.paper
|
|
331
|
+
},
|
|
332
|
+
labels: {
|
|
333
|
+
totalCount: activityData.countLabel
|
|
334
|
+
}
|
|
335
|
+
})
|
|
336
|
+
});
|
|
337
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _GithubCalendar = _interopRequireDefault(require("./GithubCalendar"));
|
|
9
|
+
var _default = exports.default = _GithubCalendar.default;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = CreateEvent;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
10
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
11
|
+
var _Link = _interopRequireDefault(require("@mui/material/Link"));
|
|
12
|
+
var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
|
+
function CreateEvent({
|
|
16
|
+
event
|
|
17
|
+
}) {
|
|
18
|
+
var _event$payload, _event$payload2, _event$payload3;
|
|
19
|
+
if (!(event != null && event.date)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const refType = ((_event$payload = event.payload) == null ? void 0 : _event$payload.ref_type) || 'unknown';
|
|
23
|
+
const refName = ((_event$payload2 = event.payload) == null ? void 0 : _event$payload2.ref) || 'unknown';
|
|
24
|
+
const repoUrl = `https://github.com/${event.repo}`;
|
|
25
|
+
const description = (_event$payload3 = event.payload) == null ? void 0 : _event$payload3.description;
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
27
|
+
sx: {
|
|
28
|
+
p: '16px'
|
|
29
|
+
},
|
|
30
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
31
|
+
sx: {
|
|
32
|
+
display: 'flex',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
gap: 1,
|
|
35
|
+
mb: 2
|
|
36
|
+
},
|
|
37
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
38
|
+
variant: "caption",
|
|
39
|
+
color: "text.secondary",
|
|
40
|
+
children: event.date
|
|
41
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
|
|
42
|
+
label: refType,
|
|
43
|
+
size: "small",
|
|
44
|
+
color: "success"
|
|
45
|
+
})]
|
|
46
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
47
|
+
variant: "h6",
|
|
48
|
+
component: "h3",
|
|
49
|
+
sx: {
|
|
50
|
+
mb: 1
|
|
51
|
+
},
|
|
52
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Link.default, {
|
|
53
|
+
href: repoUrl,
|
|
54
|
+
target: "_blank",
|
|
55
|
+
rel: "noopener noreferrer",
|
|
56
|
+
sx: {
|
|
57
|
+
textDecoration: 'none'
|
|
58
|
+
},
|
|
59
|
+
children: ["Created ", refType, " ", refName]
|
|
60
|
+
})
|
|
61
|
+
}), description && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
62
|
+
variant: "body2",
|
|
63
|
+
sx: {
|
|
64
|
+
mb: 2
|
|
65
|
+
},
|
|
66
|
+
children: description
|
|
67
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
68
|
+
sx: {
|
|
69
|
+
display: 'flex',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
gap: 1
|
|
72
|
+
},
|
|
73
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
|
|
74
|
+
variant: "body2",
|
|
75
|
+
color: "text.secondary",
|
|
76
|
+
children: ["in ", event.repo]
|
|
77
|
+
})
|
|
78
|
+
})]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = DeleteEvent;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
10
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
11
|
+
var _Link = _interopRequireDefault(require("@mui/material/Link"));
|
|
12
|
+
var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
|
+
function DeleteEvent({
|
|
16
|
+
event
|
|
17
|
+
}) {
|
|
18
|
+
var _event$payload, _event$payload2;
|
|
19
|
+
if (!(event != null && event.date)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const refType = ((_event$payload = event.payload) == null ? void 0 : _event$payload.ref_type) || 'unknown';
|
|
23
|
+
const refName = ((_event$payload2 = event.payload) == null ? void 0 : _event$payload2.ref) || 'unknown';
|
|
24
|
+
const repoUrl = `https://github.com/${event.repo}`;
|
|
25
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
26
|
+
sx: {
|
|
27
|
+
p: '16px'
|
|
28
|
+
},
|
|
29
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
30
|
+
sx: {
|
|
31
|
+
display: 'flex',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
gap: 1,
|
|
34
|
+
mb: 2
|
|
35
|
+
},
|
|
36
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
37
|
+
variant: "caption",
|
|
38
|
+
color: "text.secondary",
|
|
39
|
+
children: event.date
|
|
40
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
|
|
41
|
+
label: refType,
|
|
42
|
+
size: "small",
|
|
43
|
+
color: "error"
|
|
44
|
+
})]
|
|
45
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
46
|
+
variant: "h6",
|
|
47
|
+
component: "h3",
|
|
48
|
+
sx: {
|
|
49
|
+
mb: 1
|
|
50
|
+
},
|
|
51
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Link.default, {
|
|
52
|
+
href: repoUrl,
|
|
53
|
+
target: "_blank",
|
|
54
|
+
rel: "noopener noreferrer",
|
|
55
|
+
sx: {
|
|
56
|
+
textDecoration: 'none'
|
|
57
|
+
},
|
|
58
|
+
children: ["Deleted ", refType, " ", refName]
|
|
59
|
+
})
|
|
60
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
61
|
+
sx: {
|
|
62
|
+
display: 'flex',
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
gap: 1
|
|
65
|
+
},
|
|
66
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
|
|
67
|
+
variant: "body2",
|
|
68
|
+
color: "text.secondary",
|
|
69
|
+
children: ["from ", event.repo]
|
|
70
|
+
})
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
}
|