@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.
Files changed (95) hide show
  1. package/CHANGELOG.md +15014 -0
  2. package/GithubCalendar/GithubCalendar.d.ts +7 -0
  3. package/GithubCalendar/GithubCalendar.js +330 -0
  4. package/GithubCalendar/index.d.ts +2 -0
  5. package/GithubCalendar/index.js +2 -0
  6. package/GithubCalendar/package.json +6 -0
  7. package/GithubEvents/EventTypes/CreateEvent.d.ts +7 -0
  8. package/GithubEvents/EventTypes/CreateEvent.js +72 -0
  9. package/GithubEvents/EventTypes/DeleteEvent.d.ts +7 -0
  10. package/GithubEvents/EventTypes/DeleteEvent.js +65 -0
  11. package/GithubEvents/EventTypes/ForkEvent.d.ts +7 -0
  12. package/GithubEvents/EventTypes/ForkEvent.js +77 -0
  13. package/GithubEvents/EventTypes/IssueCommentEvent.d.ts +7 -0
  14. package/GithubEvents/EventTypes/IssueCommentEvent.js +210 -0
  15. package/GithubEvents/EventTypes/IssuesEvent.d.ts +7 -0
  16. package/GithubEvents/EventTypes/IssuesEvent.js +97 -0
  17. package/GithubEvents/EventTypes/ProjectsV2ColumnEvent.d.ts +7 -0
  18. package/GithubEvents/EventTypes/ProjectsV2ColumnEvent.js +69 -0
  19. package/GithubEvents/EventTypes/ProjectsV2Event.d.ts +7 -0
  20. package/GithubEvents/EventTypes/ProjectsV2Event.js +74 -0
  21. package/GithubEvents/EventTypes/ProjectsV2FieldEvent.d.ts +7 -0
  22. package/GithubEvents/EventTypes/ProjectsV2FieldEvent.js +77 -0
  23. package/GithubEvents/EventTypes/ProjectsV2ItemEvent.d.ts +7 -0
  24. package/GithubEvents/EventTypes/ProjectsV2ItemEvent.js +79 -0
  25. package/GithubEvents/EventTypes/PullRequest/CommitsList.d.ts +17 -0
  26. package/GithubEvents/EventTypes/PullRequest/CommitsList.js +99 -0
  27. package/GithubEvents/EventTypes/PullRequest/FileChanges.d.ts +17 -0
  28. package/GithubEvents/EventTypes/PullRequest/FileChanges.js +182 -0
  29. package/GithubEvents/EventTypes/PullRequest/PullRequestEvent.d.ts +8 -0
  30. package/GithubEvents/EventTypes/PullRequest/PullRequestEvent.js +374 -0
  31. package/GithubEvents/EventTypes/PullRequest/PullRequestView.d.ts +29 -0
  32. package/GithubEvents/EventTypes/PullRequest/PullRequestView.js +132 -0
  33. package/GithubEvents/EventTypes/PushEvent.d.ts +7 -0
  34. package/GithubEvents/EventTypes/PushEvent.js +106 -0
  35. package/GithubEvents/GithubEvents.d.ts +49 -0
  36. package/GithubEvents/GithubEvents.js +1454 -0
  37. package/GithubEvents/index.d.ts +2 -0
  38. package/GithubEvents/index.js +2 -0
  39. package/GithubEvents/package.json +6 -0
  40. package/LICENSE +21 -0
  41. package/README.md +29 -0
  42. package/apiHandlers/getPullRequestDetails.d.ts +7 -0
  43. package/apiHandlers/getPullRequestDetails.js +120 -0
  44. package/apiHandlers/index.d.ts +1 -0
  45. package/apiHandlers/index.js +1 -0
  46. package/apiHandlers/package.json +6 -0
  47. package/index.d.ts +3 -0
  48. package/index.js +10 -0
  49. package/modern/GithubCalendar/GithubCalendar.js +330 -0
  50. package/modern/GithubCalendar/index.js +2 -0
  51. package/modern/GithubEvents/EventTypes/CreateEvent.js +72 -0
  52. package/modern/GithubEvents/EventTypes/DeleteEvent.js +65 -0
  53. package/modern/GithubEvents/EventTypes/ForkEvent.js +77 -0
  54. package/modern/GithubEvents/EventTypes/IssueCommentEvent.js +210 -0
  55. package/modern/GithubEvents/EventTypes/IssuesEvent.js +97 -0
  56. package/modern/GithubEvents/EventTypes/ProjectsV2ColumnEvent.js +69 -0
  57. package/modern/GithubEvents/EventTypes/ProjectsV2Event.js +74 -0
  58. package/modern/GithubEvents/EventTypes/ProjectsV2FieldEvent.js +77 -0
  59. package/modern/GithubEvents/EventTypes/ProjectsV2ItemEvent.js +79 -0
  60. package/modern/GithubEvents/EventTypes/PullRequest/CommitsList.js +99 -0
  61. package/modern/GithubEvents/EventTypes/PullRequest/FileChanges.js +182 -0
  62. package/modern/GithubEvents/EventTypes/PullRequest/PullRequestEvent.js +374 -0
  63. package/modern/GithubEvents/EventTypes/PullRequest/PullRequestView.js +132 -0
  64. package/modern/GithubEvents/EventTypes/PushEvent.js +106 -0
  65. package/modern/GithubEvents/GithubEvents.js +1454 -0
  66. package/modern/GithubEvents/index.js +2 -0
  67. package/modern/apiHandlers/getPullRequestDetails.js +120 -0
  68. package/modern/apiHandlers/index.js +1 -0
  69. package/modern/index.js +10 -0
  70. package/modern/types/github.js +1 -0
  71. package/node/GithubCalendar/GithubCalendar.js +337 -0
  72. package/node/GithubCalendar/index.js +9 -0
  73. package/node/GithubEvents/EventTypes/CreateEvent.js +80 -0
  74. package/node/GithubEvents/EventTypes/DeleteEvent.js +73 -0
  75. package/node/GithubEvents/EventTypes/ForkEvent.js +85 -0
  76. package/node/GithubEvents/EventTypes/IssueCommentEvent.js +218 -0
  77. package/node/GithubEvents/EventTypes/IssuesEvent.js +105 -0
  78. package/node/GithubEvents/EventTypes/ProjectsV2ColumnEvent.js +77 -0
  79. package/node/GithubEvents/EventTypes/ProjectsV2Event.js +82 -0
  80. package/node/GithubEvents/EventTypes/ProjectsV2FieldEvent.js +85 -0
  81. package/node/GithubEvents/EventTypes/ProjectsV2ItemEvent.js +87 -0
  82. package/node/GithubEvents/EventTypes/PullRequest/CommitsList.js +107 -0
  83. package/node/GithubEvents/EventTypes/PullRequest/FileChanges.js +188 -0
  84. package/node/GithubEvents/EventTypes/PullRequest/PullRequestEvent.js +381 -0
  85. package/node/GithubEvents/EventTypes/PullRequest/PullRequestView.js +138 -0
  86. package/node/GithubEvents/EventTypes/PushEvent.js +114 -0
  87. package/node/GithubEvents/GithubEvents.js +1463 -0
  88. package/node/GithubEvents/index.js +9 -0
  89. package/node/apiHandlers/getPullRequestDetails.js +127 -0
  90. package/node/apiHandlers/index.js +13 -0
  91. package/node/index.js +27 -0
  92. package/node/types/github.js +5 -0
  93. package/package.json +71 -0
  94. package/types/github.d.ts +107 -0
  95. package/types/github.js +1 -0
@@ -0,0 +1,2 @@
1
+ import GithubEvents from './GithubEvents';
2
+ export default GithubEvents;
@@ -0,0 +1,2 @@
1
+ import GithubEvents from './GithubEvents';
2
+ export default GithubEvents;
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/GithubEvents/index.js",
5
+ "types": "./index.d.ts"
6
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Call-Em-All
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Stoked UI - Github
2
+
3
+ This package contains Stoked UI's Github components.
4
+ It's part of [Stoked UI](https://stoked-ui.com/stoked-ui/docs), an open-sourced component library.
5
+
6
+ ## Installation
7
+
8
+ Install the package in your project directory with:
9
+
10
+ ```bash
11
+ npm install @stoked-ui/github
12
+ ```
13
+
14
+ This component has the following peer dependencies that you will need to install as well.
15
+
16
+ ```json
17
+ "peerDependencies": {
18
+ "@emotion/react": "^11.9.0",
19
+ "@emotion/styled": "^11.8.1",
20
+ "@mui/icons-material": "^5.15.21",
21
+ "@mui/material": "^5.15.21",
22
+ "react": "18.3.1",
23
+ "react-dom": "^18.0.0"
24
+ },
25
+ ```
26
+
27
+ ## Documentation
28
+
29
+ Visit [https://stoked-ui.com/github/docs](https://stoked-ui.com/github/docs/) to view the full documentation.
@@ -0,0 +1,7 @@
1
+ import { RequestError } from '@octokit/request-error';
2
+ import { PullRequestDetails } from '../types/github';
3
+ export default function getPullRequestDetails(params: {
4
+ owner: string;
5
+ repo: string;
6
+ pull_number: number;
7
+ }): Promise<PullRequestDetails | RequestError | null>;
@@ -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';
@@ -0,0 +1 @@
1
+ export { default as getPullRequestDetails } from './getPullRequestDetails';
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/apiHandlers/index.js",
5
+ "types": "./index.d.ts"
6
+ }
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import GithubCalendar from './GithubCalendar';
2
+ import GithubEvents from './GithubEvents';
3
+ export { GithubCalendar, GithubEvents };
package/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,330 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { Box } from "@mui/material";
4
+ import { ActivityCalendar } from "react-activity-calendar";
5
+ import { useTheme } from '@mui/material/styles';
6
+ import { useResize } from '@stoked-ui/common';
7
+ import { useResizeWindow } from '@stoked-ui/common';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const defaultActivityData = {
10
+ total: {},
11
+ contributions: [],
12
+ countLabel: 'Loading...'
13
+ };
14
+ function sleep(duration) {
15
+ return new Promise(resolve => {
16
+ setTimeout(() => {
17
+ resolve(void 0);
18
+ }, duration);
19
+ });
20
+ }
21
+ export default function GithubCalendar({
22
+ windowMode = false,
23
+ containerMode = false,
24
+ blockSize: inputBlockSize = 12,
25
+ fx = undefined,
26
+ startImage = undefined
27
+ }) {
28
+ const [activityTheme, setActivityTheme] = React.useState('light');
29
+ const [activityData, setActivityData] = React.useState(defaultActivityData);
30
+ const [activityLoading, setActivityLoading] = React.useState(true);
31
+ const [activityHover, setActivityHover] = React.useState(false);
32
+ const [activityLabels, setActivityLabels] = React.useState(false);
33
+ const [activityClass, setActivityClass] = React.useState('activity');
34
+ const [labelsTimer, setLabelsTimer] = React.useState(null);
35
+ const theme = useTheme();
36
+ const elementRef = React.useRef(null);
37
+ const [windowWidth, _] = useResizeWindow();
38
+ const elemSize = useResize(elementRef);
39
+ React.useEffect(() => {
40
+ if (inputBlockSize) {
41
+ return;
42
+ }
43
+ if (activityData.totalWeeks) {
44
+ if (windowMode) {
45
+ activityData.blockSize = Math.max(10, Math.floor(windowWidth / activityData.totalWeeks));
46
+ setActivityData(_extends({}, activityData));
47
+ } else if (containerMode) {
48
+ if (elemSize.width) {
49
+ activityData.blockSize = Math.max(10, Math.floor(elemSize.width / activityData.totalWeeks));
50
+ setActivityData(_extends({}, activityData));
51
+ }
52
+ }
53
+ }
54
+ }, [elemSize.width, windowWidth]);
55
+ React.useEffect(() => {
56
+ if (activityHover && !activityLabels) {
57
+ setLabelsTimer(setTimeout(() => {
58
+ setActivityLabels(true);
59
+ }, 200));
60
+ } else if (!activityHover && (activityLabels || labelsTimer)) {
61
+ setActivityLabels(false);
62
+ if (labelsTimer) {
63
+ clearTimeout(labelsTimer);
64
+ }
65
+ }
66
+ setActivityClass('activity ' + (activityLabels ? 'hover labels' : activityHover ? 'hover' : ''));
67
+ }, [activityHover, activityLabels]);
68
+
69
+ // Scroll activity all the way to the right on mount
70
+ React.useEffect(() => {
71
+ if (!activityLoading) {
72
+ setTimeout(() => {
73
+ const activityContainer = document.querySelector('.react-activity-calendar__scroll-container');
74
+ if (activityContainer) {
75
+ activityContainer.scrollLeft = activityContainer.scrollWidth;
76
+ }
77
+ }, 200);
78
+ }
79
+ }, [activityLoading]);
80
+ const fetchActivityData = async () => {
81
+ setActivityLoading(true);
82
+ try {
83
+ const response = await fetch('https://github-contributions-api.jogruber.de/v4/brian-stoker?yr=last');
84
+ if (!response.ok) {
85
+ throw new Error(`API error: ${response.status}`);
86
+ }
87
+ const data = await response.json();
88
+ function compare(a, b) {
89
+ if (a.date < b.date) {
90
+ return -1;
91
+ }
92
+ if (a.date > b.date) {
93
+ return 1;
94
+ }
95
+ return 0;
96
+ }
97
+ const earliestDate = data.contributions.filter(item => item.count > 0) // Filter items with count > 0
98
+ .reduce((earliest, current) => {
99
+ return !earliest || new Date(current.date) < new Date(earliest.date) ? current : earliest;
100
+ }, null);
101
+ const today = new Date();
102
+ const year = today.getFullYear();
103
+ const month = String(today.getMonth() + 1).padStart(2, '0'); // Month is 0-indexed
104
+ const day = String(today.getDate()).padStart(2, '0');
105
+ const formattedDate = `${year}-${month}-${day}`;
106
+ const contribs = data.contributions.filter(contrib => contrib.date < formattedDate && (!earliestDate || contrib.date >= earliestDate.date));
107
+ data.contributions = contribs.sort(compare);
108
+ const allJansSet = contribs.map(contrib => {
109
+ return contrib.date.slice(2, 7);
110
+ }).filter(yymm => yymm.slice(-2) === '01');
111
+ const allJans = new Set(allJansSet);
112
+ console.log('allJans', [...allJans]);
113
+ const all = Object.values(data.total).reduce((acc, curr) => acc + curr, 0);
114
+ const totalKeys = Object.keys(data.total);
115
+ data.countLabel = `${all} contributions from ${totalKeys[0]} to ${totalKeys[totalKeys.length - 1]}`;
116
+ data.totalWeeks = data.contributions.length / 7;
117
+ if (inputBlockSize) {
118
+ data.blockSize = inputBlockSize;
119
+ } else if (windowMode) {
120
+ data.blockSize = Math.max(10, Math.floor(windowWidth / data.totalWeeks));
121
+ } else {
122
+ if (elemSize.width) {
123
+ data.blockSize = Math.max(10, Math.floor(elemSize.width / data.totalWeeks));
124
+ }
125
+ }
126
+ setActivityData(data);
127
+ } catch (err) {
128
+ console.error(`Error fetching activity data: ${err instanceof Error ? err.message : String(err)}`);
129
+ // Use fallback data if API fails
130
+ setActivityData(defaultActivityData);
131
+ } finally {
132
+ setActivityLoading(false);
133
+ }
134
+ };
135
+
136
+ // Initial load
137
+ React.useEffect(() => {
138
+ async function setup() {
139
+ await fetchActivityData();
140
+ await sleep(800);
141
+ setupRectAnimations();
142
+ window.addEventListener('resize', handleResize);
143
+ }
144
+ if (!fx) {
145
+ fetchActivityData().catch(() => console.error('Error fetching activity data'));
146
+ } else {
147
+ setup().catch(() => console.error('Error fetching activity data'));
148
+ }
149
+ if (startImage) {
150
+ const startImageContainer = document.querySelector('.react-activity-calendar__scroll-container');
151
+ if (startImageContainer) {
152
+ const startImageEl = document.createElement('img');
153
+ startImageEl.src = startImage;
154
+ startImageEl.alt = 'hbngha';
155
+ startImageEl.style.position = 'absolute';
156
+ startImageEl.style.top = '0';
157
+ startImageEl.style.left = '0';
158
+ startImageEl.style.marginTop = '25px';
159
+ startImageEl.style.width = `${(activityData.blockSize || 12) * 7}px`;
160
+ startImageEl.style.height = `${(activityData.blockSize || 12) * 7}px`;
161
+ const div = document.createElement('div');
162
+ div.style.position = 'relative';
163
+ div.appendChild(startImageEl);
164
+ startImageContainer.insertBefore(div, startImageContainer.firstChild);
165
+ }
166
+ }
167
+ return () => {
168
+ if (fx) {
169
+ var _elementRef$current;
170
+ window.removeEventListener('resize', handleResize);
171
+
172
+ // Clean up any active timeouts
173
+ const svg = (_elementRef$current = elementRef.current) == null ? void 0 : _elementRef$current.querySelector('svg');
174
+ if (svg) {
175
+ const rects = svg.querySelectorAll('rect');
176
+ rects.forEach(rect => {
177
+ if (rect.dataset.timeoutId) {
178
+ clearTimeout(parseInt(rect.dataset.timeoutId));
179
+ }
180
+ });
181
+ }
182
+ }
183
+ };
184
+ }, []);
185
+ const handleResize = () => {
186
+ var _elementRef$current2;
187
+ // Clear all animations first
188
+ const svg = (_elementRef$current2 = elementRef.current) == null ? void 0 : _elementRef$current2.querySelector('svg');
189
+ if (svg) {
190
+ const rects = svg.querySelectorAll('rect');
191
+ rects.forEach(rect => {
192
+ rect.classList.remove('rect-animated');
193
+ if (rect.dataset.timeoutId) {
194
+ clearTimeout(parseInt(rect.dataset.timeoutId));
195
+ delete rect.dataset.timeoutId;
196
+ }
197
+ });
198
+ }
199
+
200
+ // Recalculate positions
201
+ setupRectAnimations();
202
+ };
203
+ function setupRectAnimations() {
204
+ var _elementRef$current3;
205
+ // Get the SVG container
206
+ const svg = (_elementRef$current3 = elementRef.current) == null ? void 0 : _elementRef$current3.querySelector('svg');
207
+ if (!svg) return;
208
+
209
+ // Calculate center of the SVG
210
+ const svgRect = svg.getBoundingClientRect();
211
+ const centerX = svgRect.width / 2;
212
+ const centerY = svgRect.height / 2;
213
+
214
+ // Get all rect elements
215
+ const rects = svg.querySelectorAll('rect');
216
+ rects.forEach(rect => {
217
+ if (fx === 'punch') {
218
+ var _rect$parentNode;
219
+ // Calculate the translate value
220
+ const rectRect = rect.getBoundingClientRect();
221
+ const rectCenterY = rectRect.top + rectRect.height / 2 - svgRect.top;
222
+ const rectCenterX = rectRect.left + rectRect.width / 2 - svgRect.left;
223
+
224
+ // Calculate distance from center
225
+ const distanceFromCenterX = svgRect.width / 2 / (rectCenterX - centerX);
226
+ const distanceFromCenterY = svgRect.height / 2 / (rectCenterY - centerY);
227
+ const translateFactorX = 6;
228
+ const translateFactorY = 0.02;
229
+ const randomX = Math.random() * 10 - 5;
230
+ const randomY = Math.random() * 10 - 5;
231
+ const translateX = distanceFromCenterX * translateFactorX + randomX;
232
+ const translateY = distanceFromCenterY * translateFactorY + randomY;
233
+ // Set the custom property
234
+ rect.style.setProperty('--translate-x', `${translateX}px`);
235
+ rect.style.setProperty('--translate-y', `${translateY - 200}px`);
236
+ // Remove existing event listeners (if possible)
237
+ const oldRect = rect.cloneNode(true);
238
+ (_rect$parentNode = rect.parentNode) == null || _rect$parentNode.replaceChild(oldRect, rect);
239
+
240
+ // Add mouseenter event
241
+ oldRect.addEventListener('mouseenter', () => {
242
+ // Clear any existing timeout
243
+ if (oldRect != null && oldRect.dataset.timeoutId) {
244
+ clearTimeout(parseInt(oldRect == null ? void 0 : oldRect.dataset.timeoutId));
245
+ }
246
+ oldRect.style.position = 'relative';
247
+ // Add the animated class
248
+ oldRect == null || oldRect.classList.add('rect-animated');
249
+
250
+ // Set a timeout to return after random delay
251
+ const minDelay = 100;
252
+ const randomDelay = Math.random() * 1000 + minDelay;
253
+ const timeoutId = setTimeout(() => {
254
+ oldRect == null || oldRect.classList.remove('rect-animated');
255
+ oldRect == null || delete oldRect.dataset.timeoutId;
256
+ }, randomDelay);
257
+
258
+ // Store the timeout ID
259
+ if (oldRect != null && oldRect.dataset) {
260
+ oldRect.dataset.timeoutId = timeoutId.toString();
261
+ }
262
+ });
263
+ } else {
264
+ var _rect$parentNode2;
265
+ const oldRect = rect.cloneNode(true);
266
+ (_rect$parentNode2 = rect.parentNode) == null || _rect$parentNode2.replaceChild(oldRect, rect);
267
+ // Add mouseenter event
268
+ rect.addEventListener('mouseenter', () => {
269
+ // Clear any existing timeout
270
+ if (rect != null && rect.dataset.timeoutId) {
271
+ clearTimeout(parseInt(rect == null ? void 0 : rect.dataset.timeoutId));
272
+ }
273
+ rect.style.position = 'relative';
274
+ // Add the animated class
275
+ rect == null || rect.classList.add('rect-highlight');
276
+ // Add the animated class
277
+ //oldRect?.classList.add('rect-animated');
278
+
279
+ // Set a timeout to return after random delay
280
+ const minDelay = 100;
281
+ const randomDelay = Math.random() * 1000 + minDelay;
282
+ const timeoutId = setTimeout(() => {
283
+ rect == null || rect.classList.remove('rect-highlight');
284
+ rect == null || delete rect.dataset.timeoutId;
285
+ }, randomDelay);
286
+
287
+ // Store the timeout ID
288
+ if (rect != null && rect.dataset) {
289
+ rect.dataset.timeoutId = timeoutId.toString();
290
+ }
291
+ });
292
+ }
293
+ });
294
+ }
295
+ React.useEffect(() => {
296
+ setActivityTheme(theme.palette.mode === 'dark' ? 'dark' : 'light');
297
+ }, [theme.palette.mode]);
298
+ return /*#__PURE__*/_jsx(Box, {
299
+ ref: elementRef,
300
+ onMouseEnter: () => setActivityHover(true),
301
+ onMouseLeave: () => {
302
+ setActivityHover(false);
303
+ setActivityLabels(false);
304
+ },
305
+ className: `${activityClass} ${activityLoading ? 'loading' : ''}`,
306
+ sx: {
307
+ '& .activity > *': {
308
+ transition: '1s ease-in-out'
309
+ },
310
+ position: 'sticky'
311
+ },
312
+ children: /*#__PURE__*/_jsx(ActivityCalendar, {
313
+ data: activityData.contributions,
314
+ theme: {
315
+ light: activityTheme === 'light' ? ['hsl(0, 0%, 92%)', theme.palette.primary.dark] : ['hsl(0, 0%, 12%)', theme.palette.primary.light],
316
+ dark: activityTheme === 'light' ? ['hsl(0, 0%, 92%)', theme.palette.primary.dark] : ['hsl(0, 0%, 12%)', theme.palette.primary.light]
317
+ },
318
+ loading: activityLoading,
319
+ blockMargin: 0.5,
320
+ blockRadius: 0,
321
+ blockSize: activityData.blockSize || 12,
322
+ style: {
323
+ backgroundColor: theme.palette.background.paper
324
+ },
325
+ labels: {
326
+ totalCount: activityData.countLabel
327
+ }
328
+ })
329
+ });
330
+ }
@@ -0,0 +1,2 @@
1
+ import GithubCalendar from './GithubCalendar';
2
+ export default GithubCalendar;
@@ -0,0 +1,72 @@
1
+ import * as React from 'react';
2
+ import Box from '@mui/material/Box';
3
+ import Typography from '@mui/material/Typography';
4
+ import Link from '@mui/material/Link';
5
+ import Chip from '@mui/material/Chip';
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ export default function CreateEvent({
8
+ event
9
+ }) {
10
+ var _event$payload, _event$payload2, _event$payload3;
11
+ if (!(event != null && event.date)) {
12
+ return null;
13
+ }
14
+ const refType = ((_event$payload = event.payload) == null ? void 0 : _event$payload.ref_type) || 'unknown';
15
+ const refName = ((_event$payload2 = event.payload) == null ? void 0 : _event$payload2.ref) || 'unknown';
16
+ const repoUrl = `https://github.com/${event.repo}`;
17
+ const description = (_event$payload3 = event.payload) == null ? void 0 : _event$payload3.description;
18
+ return /*#__PURE__*/_jsxs(Box, {
19
+ sx: {
20
+ p: '16px'
21
+ },
22
+ children: [/*#__PURE__*/_jsxs(Box, {
23
+ sx: {
24
+ display: 'flex',
25
+ alignItems: 'center',
26
+ gap: 1,
27
+ mb: 2
28
+ },
29
+ children: [/*#__PURE__*/_jsx(Typography, {
30
+ variant: "caption",
31
+ color: "text.secondary",
32
+ children: event.date
33
+ }), /*#__PURE__*/_jsx(Chip, {
34
+ label: refType,
35
+ size: "small",
36
+ color: "success"
37
+ })]
38
+ }), /*#__PURE__*/_jsx(Typography, {
39
+ variant: "h6",
40
+ component: "h3",
41
+ sx: {
42
+ mb: 1
43
+ },
44
+ children: /*#__PURE__*/_jsxs(Link, {
45
+ href: repoUrl,
46
+ target: "_blank",
47
+ rel: "noopener noreferrer",
48
+ sx: {
49
+ textDecoration: 'none'
50
+ },
51
+ children: ["Created ", refType, " ", refName]
52
+ })
53
+ }), description && /*#__PURE__*/_jsx(Typography, {
54
+ variant: "body2",
55
+ sx: {
56
+ mb: 2
57
+ },
58
+ children: description
59
+ }), /*#__PURE__*/_jsx(Box, {
60
+ sx: {
61
+ display: 'flex',
62
+ alignItems: 'center',
63
+ gap: 1
64
+ },
65
+ children: /*#__PURE__*/_jsxs(Typography, {
66
+ variant: "body2",
67
+ color: "text.secondary",
68
+ children: ["in ", event.repo]
69
+ })
70
+ })]
71
+ });
72
+ }