@stats-organization/github-readme-stats-core 2.1.5 → 2.2.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/build/api/gist.d.ts +2 -7
- package/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +9 -41
- package/build/api/index.d.ts +3 -8
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +23 -45
- package/build/api/pin.d.ts +2 -7
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +9 -41
- package/build/api/top-langs.d.ts +2 -7
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +11 -55
- package/build/api/wakatime.d.ts +2 -7
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +9 -41
- package/build/cards/common-options.d.ts +13 -0
- package/build/cards/common-options.d.ts.map +1 -0
- package/build/cards/common-options.js +1 -0
- package/build/cards/gist.d.ts +11 -16
- package/build/cards/gist.d.ts.map +1 -1
- package/build/cards/gist.js +26 -31
- package/build/cards/repo.d.ts +19 -16
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +58 -60
- package/build/cards/stats.d.ts +29 -46
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +113 -181
- package/build/cards/top-languages.d.ts +81 -77
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +174 -200
- package/build/cards/wakatime.d.ts +21 -11
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +73 -111
- package/build/common/Card.d.ts +34 -13
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +73 -40
- package/build/common/I18n.d.ts +4 -2
- package/build/common/I18n.d.ts.map +1 -1
- package/build/common/color.d.ts +60 -18
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +102 -5
- package/build/common/config.d.ts +2 -1
- package/build/common/config.d.ts.map +1 -1
- package/build/common/config.js +16 -26
- package/build/common/constants.d.ts +2 -1
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/date.d.ts +37 -0
- package/build/common/date.d.ts.map +1 -0
- package/build/common/date.js +31 -0
- package/build/common/http.d.ts +25 -2
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +26 -3
- package/build/common/icons.d.ts +1 -0
- package/build/common/icons.d.ts.map +1 -1
- package/build/common/icons.js +1 -0
- package/build/common/languageColors.d.ts +11 -0
- package/build/common/languageColors.d.ts.map +1 -0
- package/build/common/languageColors.js +15 -0
- package/build/common/languageColors.json +1 -0
- package/build/common/ops.d.ts +3 -10
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +3 -15
- package/build/common/render.d.ts +43 -6
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +77 -11
- package/build/common/retryer.d.ts +3 -2
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +1 -0
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +8 -39
- package/build/fetchers/repo.d.ts +12 -11
- package/build/fetchers/repo.d.ts.map +1 -1
- package/build/fetchers/repo.js +26 -67
- package/build/fetchers/stats.d.ts +24 -17
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +302 -183
- package/build/fetchers/top-languages.d.ts +10 -15
- package/build/fetchers/top-languages.d.ts.map +1 -1
- package/build/fetchers/top-languages.js +52 -103
- package/build/fetchers/types.d.ts +24 -20
- package/build/fetchers/types.d.ts.map +1 -1
- package/build/fetchers/wakatime.d.ts +9 -5
- package/build/fetchers/wakatime.d.ts.map +1 -1
- package/build/fetchers/wakatime.js +8 -4
- package/build/graphql/contributionsDocument.d.ts +18 -0
- package/build/graphql/contributionsDocument.d.ts.map +1 -0
- package/build/graphql/contributionsDocument.js +30 -0
- package/build/graphql/generated/common.d.ts +42 -0
- package/build/graphql/generated/common.d.ts.map +1 -0
- package/build/graphql/generated/common.js +2 -0
- package/build/graphql/generated/gist.d.ts +44 -0
- package/build/graphql/generated/gist.d.ts.map +1 -0
- package/build/graphql/generated/gist.js +27 -0
- package/build/graphql/generated/repo.d.ts +67 -0
- package/build/graphql/generated/repo.d.ts.map +1 -0
- package/build/graphql/generated/repo.js +30 -0
- package/build/graphql/generated/stats.d.ts +150 -0
- package/build/graphql/generated/stats.d.ts.map +1 -0
- package/build/graphql/generated/stats.js +95 -0
- package/build/graphql/generated/top-languages.d.ts +54 -0
- package/build/graphql/generated/top-languages.d.ts.map +1 -0
- package/build/graphql/generated/top-languages.js +27 -0
- package/build/graphql/graphqlDocument.d.ts +22 -0
- package/build/graphql/graphqlDocument.d.ts.map +1 -0
- package/build/graphql/graphqlDocument.js +8 -0
- package/build/graphql/reposContributedToDocument.d.ts +27 -0
- package/build/graphql/reposContributedToDocument.d.ts.map +1 -0
- package/build/graphql/reposContributedToDocument.js +59 -0
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -1
- package/build/themes/index.d.ts +32 -0
- package/build/themes/index.d.ts.map +1 -1
- package/build/themes/index.js +28 -0
- package/build/translations.d.ts +17 -0
- package/build/translations.d.ts.map +1 -1
- package/build/translations.js +17 -0
- package/package.json +13 -7
- package/src/_github-username-regex.d.ts +4 -0
- package/src/api/gist.js +10 -46
- package/src/api/index.js +30 -51
- package/src/api/pin.js +10 -46
- package/src/api/top-langs.js +13 -60
- package/src/api/wakatime.js +10 -46
- package/src/cards/common-options.ts +13 -0
- package/src/cards/{gist.js → gist.ts} +37 -37
- package/src/cards/{repo.js → repo.ts} +86 -68
- package/src/cards/{stats.js → stats.ts} +168 -219
- package/src/cards/{top-languages.js → top-languages.ts} +309 -265
- package/src/cards/{wakatime.js → wakatime.ts} +136 -130
- package/src/common/Card.ts +94 -49
- package/src/common/I18n.ts +6 -2
- package/src/common/color.ts +163 -14
- package/src/common/config.ts +22 -29
- package/src/common/constants.ts +3 -1
- package/src/common/date.ts +45 -0
- package/src/common/http.ts +43 -3
- package/src/common/icons.ts +1 -0
- package/src/common/languageColors.json +1 -0
- package/src/common/languageColors.ts +19 -0
- package/src/common/ops.ts +8 -18
- package/src/common/render.ts +114 -14
- package/src/common/retryer.ts +6 -5
- package/src/fetchers/gist.ts +15 -72
- package/src/fetchers/repo.ts +114 -0
- package/src/fetchers/stats.ts +743 -0
- package/src/fetchers/top-languages.ts +135 -0
- package/src/fetchers/types.ts +28 -20
- package/src/fetchers/{wakatime.js → wakatime.ts} +19 -5
- package/src/graphql/contributionsDocument.ts +44 -0
- package/src/graphql/generated/common.ts +26 -0
- package/src/graphql/generated/gist.ts +59 -0
- package/src/graphql/generated/repo.ts +90 -0
- package/src/graphql/generated/stats.ts +194 -0
- package/src/graphql/generated/top-languages.ts +75 -0
- package/src/graphql/graphqlDocument.ts +25 -0
- package/src/graphql/queries/gist.graphql +25 -0
- package/src/graphql/queries/repo.graphql +28 -0
- package/src/graphql/queries/stats.graphql +120 -0
- package/src/graphql/queries/top-languages.graphql +34 -0
- package/src/graphql/reposContributedToDocument.ts +86 -0
- package/src/index.ts +3 -1
- package/src/themes/index.ts +33 -0
- package/src/translations.ts +17 -0
- package/src/cards/types.d.ts +0 -78
- package/src/fetchers/repo.js +0 -161
- package/src/fetchers/stats.js +0 -473
- package/src/fetchers/top-languages.js +0 -175
- package/src/themes/README.md +0 -229
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Card } from "../common/Card.js";
|
|
2
2
|
import { I18n } from "../common/I18n.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getLightDarkColors, isPrefixedHexColor } from "../common/color.js";
|
|
4
4
|
import { encodeHTML } from "../common/html.js";
|
|
5
|
-
import
|
|
5
|
+
import { getLanguageColor } from "../common/languageColors.js";
|
|
6
6
|
import { clampValue, lowercaseTrim } from "../common/ops.js";
|
|
7
7
|
import { createProgressNode, flexLayout } from "../common/render.js";
|
|
8
|
+
import type { WakaTimeData, WakaTimeLang } from "../fetchers/types.js";
|
|
8
9
|
import { wakatimeCardLocales } from "../translations.js";
|
|
9
10
|
|
|
11
|
+
import type { CommonOptions } from "./common-options.js";
|
|
12
|
+
|
|
10
13
|
const DEFAULT_CARD_WIDTH = 495;
|
|
11
14
|
const MIN_CARD_WIDTH = 250;
|
|
12
15
|
const COMPACT_LAYOUT_MIN_WIDTH = 400;
|
|
@@ -16,53 +19,76 @@ const HIDDEN_PROGRESSBAR_PADDING = 170;
|
|
|
16
19
|
const COMPACT_LAYOUT_PROGRESSBAR_PADDING = 25;
|
|
17
20
|
const TOTAL_TEXT_WIDTH = 275;
|
|
18
21
|
|
|
22
|
+
type WakaTimeLayout = "compact" | "normal";
|
|
23
|
+
type DisplayFormat = "time" | "percent";
|
|
24
|
+
|
|
25
|
+
interface WakaTimeOptions extends CommonOptions {
|
|
26
|
+
hide_title: boolean;
|
|
27
|
+
hide: Array<string>;
|
|
28
|
+
card_width: number;
|
|
29
|
+
line_height: number | string;
|
|
30
|
+
hide_progress: boolean;
|
|
31
|
+
custom_title: string;
|
|
32
|
+
layout: WakaTimeLayout;
|
|
33
|
+
langs_count: number;
|
|
34
|
+
display_format: DisplayFormat;
|
|
35
|
+
disable_animations: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
19
38
|
/**
|
|
20
39
|
* Creates the no coding activity SVG node.
|
|
21
40
|
*
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @
|
|
25
|
-
* @returns {string} No coding activity SVG node string.
|
|
41
|
+
* @param props The function properties.
|
|
42
|
+
* @param props.text No coding activity translated text.
|
|
43
|
+
* @returns No coding activity SVG node string.
|
|
26
44
|
*/
|
|
27
|
-
const noCodingActivityNode = ({
|
|
28
|
-
if (!isPrefixedHexColor(color)) {
|
|
29
|
-
throw new Error(`Invalid text color: "${color}"`);
|
|
30
|
-
}
|
|
31
|
-
|
|
45
|
+
const noCodingActivityNode = ({ text }: { text: string }): string => {
|
|
32
46
|
return `
|
|
33
|
-
<text x="25" y="11" class="stat bold"
|
|
47
|
+
<text x="25" y="11" class="stat bold">${encodeHTML(text)}</text>
|
|
34
48
|
`;
|
|
35
49
|
};
|
|
36
50
|
|
|
37
|
-
/**
|
|
38
|
-
* @typedef {import('../fetchers/types').WakaTimeLang} WakaTimeLang
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
51
|
/**
|
|
42
52
|
* Format language value.
|
|
43
53
|
*
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
47
|
-
* @returns
|
|
54
|
+
* @param args The function arguments.
|
|
55
|
+
* @param args.lang The language object.
|
|
56
|
+
* @param args.display_format The display format of the language node.
|
|
57
|
+
* @returns The formatted language value.
|
|
48
58
|
*/
|
|
49
|
-
const formatLanguageValue = ({
|
|
59
|
+
const formatLanguageValue = ({
|
|
60
|
+
display_format,
|
|
61
|
+
lang,
|
|
62
|
+
}: {
|
|
63
|
+
display_format: DisplayFormat;
|
|
64
|
+
lang: WakaTimeLang;
|
|
65
|
+
}): string => {
|
|
50
66
|
return display_format === "percent"
|
|
51
|
-
? `${lang.percent.toFixed(2)
|
|
67
|
+
? `${lang.percent.toFixed(2)} %`
|
|
52
68
|
: lang.text;
|
|
53
69
|
};
|
|
54
70
|
|
|
55
71
|
/**
|
|
56
72
|
* Create compact WakaTime layout.
|
|
57
73
|
*
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
60
|
-
* @param
|
|
61
|
-
* @param
|
|
62
|
-
* @param
|
|
63
|
-
* @returns
|
|
74
|
+
* @param args The function arguments.
|
|
75
|
+
* @param args.lang The languages array.
|
|
76
|
+
* @param args.x The x position of the language node.
|
|
77
|
+
* @param args.y The y position of the language node.
|
|
78
|
+
* @param args.display_format The display format of the language node.
|
|
79
|
+
* @returns The compact layout language SVG node.
|
|
64
80
|
*/
|
|
65
|
-
const createCompactLangNode = ({
|
|
81
|
+
const createCompactLangNode = ({
|
|
82
|
+
lang,
|
|
83
|
+
x,
|
|
84
|
+
y,
|
|
85
|
+
display_format,
|
|
86
|
+
}: {
|
|
87
|
+
lang: WakaTimeLang;
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
display_format: DisplayFormat;
|
|
91
|
+
}): string => {
|
|
66
92
|
if (!Number.isFinite(x)) {
|
|
67
93
|
throw new Error(`Invalid x: "${x}"`);
|
|
68
94
|
}
|
|
@@ -70,8 +96,7 @@ const createCompactLangNode = ({ lang, x, y, display_format }) => {
|
|
|
70
96
|
throw new Error(`Invalid y: "${y}"`);
|
|
71
97
|
}
|
|
72
98
|
|
|
73
|
-
|
|
74
|
-
const color = languageColors[lang.name] || "#858585";
|
|
99
|
+
const color = getLanguageColor(lang.name);
|
|
75
100
|
const value = formatLanguageValue({ display_format, lang });
|
|
76
101
|
|
|
77
102
|
return `
|
|
@@ -87,14 +112,24 @@ const createCompactLangNode = ({ lang, x, y, display_format }) => {
|
|
|
87
112
|
/**
|
|
88
113
|
* Create WakaTime language text node item.
|
|
89
114
|
*
|
|
90
|
-
* @param
|
|
91
|
-
* @param
|
|
92
|
-
* @param
|
|
93
|
-
* @param
|
|
94
|
-
* @param
|
|
95
|
-
* @returns
|
|
115
|
+
* @param args The function arguments.
|
|
116
|
+
* @param args.langs The language objects.
|
|
117
|
+
* @param args.y The y position of the language node.
|
|
118
|
+
* @param args.display_format The display format of the language node.
|
|
119
|
+
* @param args.card_width Width in px of the card.
|
|
120
|
+
* @returns The language text node items.
|
|
96
121
|
*/
|
|
97
|
-
const createLanguageTextNode = ({
|
|
122
|
+
const createLanguageTextNode = ({
|
|
123
|
+
langs,
|
|
124
|
+
y,
|
|
125
|
+
display_format,
|
|
126
|
+
card_width,
|
|
127
|
+
}: {
|
|
128
|
+
langs: Array<WakaTimeLang>;
|
|
129
|
+
y: number;
|
|
130
|
+
display_format: DisplayFormat;
|
|
131
|
+
card_width: number;
|
|
132
|
+
}): Array<string> => {
|
|
98
133
|
const LEFT_X = 25;
|
|
99
134
|
const RIGHT_X_BASE = 230;
|
|
100
135
|
const rightOffset = (card_width - DEFAULT_CARD_WIDTH) / 2;
|
|
@@ -114,17 +149,15 @@ const createLanguageTextNode = ({ langs, y, display_format, card_width }) => {
|
|
|
114
149
|
/**
|
|
115
150
|
* Create WakaTime text item.
|
|
116
151
|
*
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
119
|
-
* @param
|
|
120
|
-
* @param
|
|
121
|
-
* @param
|
|
122
|
-
* @param
|
|
123
|
-
* @param
|
|
124
|
-
* @param
|
|
125
|
-
* @
|
|
126
|
-
* @param {number} args.progressBarWidth The width of the progress bar.
|
|
127
|
-
* @returns {string} The text SVG node.
|
|
152
|
+
* @param args The function arguments.
|
|
153
|
+
* @param args.id The id of the text node item.
|
|
154
|
+
* @param args.label The label of the text node item.
|
|
155
|
+
* @param args.value The value of the text node item.
|
|
156
|
+
* @param args.index The index of the text node item.
|
|
157
|
+
* @param args.percent Percentage of the text node item.
|
|
158
|
+
* @param args.hideProgress Whether to hide the progress bar.
|
|
159
|
+
* @param args.progressBarWidth The width of the progress bar.
|
|
160
|
+
* @returns The text SVG node.
|
|
128
161
|
*/
|
|
129
162
|
const createTextNode = ({
|
|
130
163
|
id,
|
|
@@ -133,10 +166,16 @@ const createTextNode = ({
|
|
|
133
166
|
index,
|
|
134
167
|
percent,
|
|
135
168
|
hideProgress,
|
|
136
|
-
progressBarColor,
|
|
137
|
-
progressBarBackgroundColor,
|
|
138
169
|
progressBarWidth,
|
|
139
|
-
}
|
|
170
|
+
}: {
|
|
171
|
+
id: string;
|
|
172
|
+
label: string;
|
|
173
|
+
value: string;
|
|
174
|
+
index: number;
|
|
175
|
+
percent: number;
|
|
176
|
+
hideProgress?: boolean | undefined;
|
|
177
|
+
progressBarWidth: number;
|
|
178
|
+
}): string => {
|
|
140
179
|
if (!Number.isFinite(index)) {
|
|
141
180
|
throw new Error(`Invalid index: "${index}"`);
|
|
142
181
|
}
|
|
@@ -151,11 +190,7 @@ const createTextNode = ({
|
|
|
151
190
|
x: 110,
|
|
152
191
|
y: 4,
|
|
153
192
|
progress: percent,
|
|
154
|
-
color: progressBarColor,
|
|
155
193
|
width: progressBarWidth,
|
|
156
|
-
// @ts-ignore
|
|
157
|
-
name: label,
|
|
158
|
-
progressBarBackgroundColor,
|
|
159
194
|
delay: staggerDelay + 300,
|
|
160
195
|
});
|
|
161
196
|
|
|
@@ -167,7 +202,7 @@ const createTextNode = ({
|
|
|
167
202
|
x="${hideProgress ? HIDDEN_PROGRESSBAR_PADDING : PROGRESSBAR_PADDING + progressBarWidth}"
|
|
168
203
|
y="12.5"
|
|
169
204
|
>${encodeHTML(value)}</text>
|
|
170
|
-
${cardProgress}
|
|
205
|
+
${String(cardProgress)}
|
|
171
206
|
</g>
|
|
172
207
|
`;
|
|
173
208
|
};
|
|
@@ -176,10 +211,9 @@ const createTextNode = ({
|
|
|
176
211
|
* Recalculating percentages so that, compact layout's progress bar does not break when
|
|
177
212
|
* hiding languages.
|
|
178
213
|
*
|
|
179
|
-
* @param
|
|
180
|
-
* @returns {void} The recalculated languages array.
|
|
214
|
+
* @param languages The languages array.
|
|
181
215
|
*/
|
|
182
|
-
const recalculatePercentages = (languages) => {
|
|
216
|
+
const recalculatePercentages = (languages: Array<WakaTimeLang>): void => {
|
|
183
217
|
const totalSum = languages.reduce(
|
|
184
218
|
(totalSum, language) => totalSum + language.percent,
|
|
185
219
|
0,
|
|
@@ -193,16 +227,11 @@ const recalculatePercentages = (languages) => {
|
|
|
193
227
|
/**
|
|
194
228
|
* Retrieves CSS styles for a card.
|
|
195
229
|
*
|
|
196
|
-
* @param
|
|
197
|
-
* @param
|
|
198
|
-
* @
|
|
199
|
-
* @returns {string} Card CSS styles.
|
|
230
|
+
* @param colors The colors to use for the card.
|
|
231
|
+
* @param colors.textColor The text color.
|
|
232
|
+
* @returns Card CSS styles.
|
|
200
233
|
*/
|
|
201
|
-
const getStyles =
|
|
202
|
-
// eslint-disable-next-line no-unused-vars
|
|
203
|
-
titleColor,
|
|
204
|
-
textColor,
|
|
205
|
-
}) {
|
|
234
|
+
const getStyles = ({ textColor }: { textColor: string }): string => {
|
|
206
235
|
if (!isPrefixedHexColor(textColor)) {
|
|
207
236
|
throw new Error(`Invalid text color: "${textColor}"`);
|
|
208
237
|
}
|
|
@@ -227,13 +256,19 @@ const getStyles = function ({
|
|
|
227
256
|
/**
|
|
228
257
|
* Normalize incoming width (string or number) and clamp to minimum.
|
|
229
258
|
*
|
|
230
|
-
* @param
|
|
231
|
-
* @param
|
|
232
|
-
* @param
|
|
233
|
-
* @returns
|
|
259
|
+
* @param args The function arguments.
|
|
260
|
+
* @param args.layout The incoming layout value.
|
|
261
|
+
* @param args.value The incoming width value.
|
|
262
|
+
* @returns The normalized width value.
|
|
234
263
|
*/
|
|
235
|
-
const normalizeCardWidth = ({
|
|
236
|
-
|
|
264
|
+
const normalizeCardWidth = ({
|
|
265
|
+
value,
|
|
266
|
+
layout,
|
|
267
|
+
}: {
|
|
268
|
+
value?: number | undefined;
|
|
269
|
+
layout?: WakaTimeLayout | undefined;
|
|
270
|
+
}): number => {
|
|
271
|
+
if (value === undefined || isNaN(value)) {
|
|
237
272
|
return DEFAULT_CARD_WIDTH;
|
|
238
273
|
}
|
|
239
274
|
return Math.max(
|
|
@@ -242,19 +277,17 @@ const normalizeCardWidth = ({ value, layout }) => {
|
|
|
242
277
|
);
|
|
243
278
|
};
|
|
244
279
|
|
|
245
|
-
/**
|
|
246
|
-
* @typedef {import('../fetchers/types').WakaTimeData} WakaTimeData
|
|
247
|
-
* @typedef {import('./types').WakaTimeOptions} WakaTimeOptions
|
|
248
|
-
*/
|
|
249
|
-
|
|
250
280
|
/**
|
|
251
281
|
* Renders WakaTime card.
|
|
252
282
|
*
|
|
253
|
-
* @param
|
|
254
|
-
* @param
|
|
255
|
-
* @returns
|
|
283
|
+
* @param stats WakaTime stats.
|
|
284
|
+
* @param options Card options.
|
|
285
|
+
* @returns WakaTime card SVG.
|
|
256
286
|
*/
|
|
257
|
-
const renderWakatimeCard = (
|
|
287
|
+
const renderWakatimeCard = (
|
|
288
|
+
stats: Partial<WakaTimeData> = {},
|
|
289
|
+
options: Partial<WakaTimeOptions> = { hide: [] },
|
|
290
|
+
): string => {
|
|
258
291
|
let { languages = [] } = stats;
|
|
259
292
|
const {
|
|
260
293
|
hide_title = false,
|
|
@@ -262,18 +295,12 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
262
295
|
card_width,
|
|
263
296
|
hide,
|
|
264
297
|
line_height = DEFAULT_LINE_HEIGHT,
|
|
265
|
-
title_color,
|
|
266
|
-
icon_color,
|
|
267
|
-
text_color,
|
|
268
|
-
bg_color,
|
|
269
|
-
theme = "default",
|
|
270
298
|
hide_progress,
|
|
271
299
|
custom_title,
|
|
272
300
|
locale,
|
|
273
301
|
layout,
|
|
274
302
|
langs_count = languages.length,
|
|
275
303
|
border_radius,
|
|
276
|
-
border_color,
|
|
277
304
|
display_format = "time",
|
|
278
305
|
disable_animations,
|
|
279
306
|
} = options;
|
|
@@ -302,16 +329,8 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
302
329
|
|
|
303
330
|
const langsCount = clampValue(langs_count, 1, langs_count);
|
|
304
331
|
|
|
305
|
-
|
|
306
|
-
const { titleColor, textColor
|
|
307
|
-
getCardColors({
|
|
308
|
-
title_color,
|
|
309
|
-
icon_color,
|
|
310
|
-
text_color,
|
|
311
|
-
bg_color,
|
|
312
|
-
border_color,
|
|
313
|
-
theme,
|
|
314
|
-
});
|
|
332
|
+
const { lightColors, darkColors } = getLightDarkColors(options);
|
|
333
|
+
const { titleColor, textColor } = lightColors;
|
|
315
334
|
|
|
316
335
|
const filteredLanguages = languages
|
|
317
336
|
.filter((language) => language.hours || language.minutes)
|
|
@@ -321,12 +340,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
321
340
|
// but if rank circle is visible clamp the minimum height to `150`
|
|
322
341
|
let height = Math.max(45 + (filteredLanguages.length + 1) * lheight, 150);
|
|
323
342
|
|
|
324
|
-
|
|
325
|
-
titleColor,
|
|
326
|
-
textColor,
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
let finalLayout;
|
|
343
|
+
let finalLayout: string;
|
|
330
344
|
|
|
331
345
|
// RENDER COMPACT LAYOUT
|
|
332
346
|
if (layout === "compact") {
|
|
@@ -343,8 +357,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
343
357
|
((width - COMPACT_LAYOUT_PROGRESSBAR_PADDING) * language.percent) /
|
|
344
358
|
100;
|
|
345
359
|
|
|
346
|
-
|
|
347
|
-
const languageColor = languageColors[language.name] || "#858585";
|
|
360
|
+
const languageColor = getLanguageColor(language.name);
|
|
348
361
|
|
|
349
362
|
const output = `
|
|
350
363
|
<rect
|
|
@@ -376,8 +389,6 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
376
389
|
card_width: normalizedWidth,
|
|
377
390
|
}).join("")
|
|
378
391
|
: noCodingActivityNode({
|
|
379
|
-
// @ts-ignore
|
|
380
|
-
color: textColor,
|
|
381
392
|
text: stats.is_coding_activity_visible
|
|
382
393
|
? stats.is_other_usage_visible
|
|
383
394
|
? i18n.t("wakatimecard.nocodingactivity")
|
|
@@ -396,21 +407,12 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
396
407
|
value: formatLanguageValue({ display_format, lang: language }),
|
|
397
408
|
index,
|
|
398
409
|
percent: language.percent,
|
|
399
|
-
// @ts-ignore
|
|
400
|
-
progressBarColor: titleColor,
|
|
401
|
-
// @ts-ignore
|
|
402
|
-
progressBarBackgroundColor:
|
|
403
|
-
textColor === titleColor
|
|
404
|
-
? "#fff0" // transparent
|
|
405
|
-
: textColor,
|
|
406
410
|
hideProgress: hide_progress,
|
|
407
411
|
progressBarWidth: normalizedWidth - TOTAL_TEXT_WIDTH,
|
|
408
412
|
});
|
|
409
413
|
})
|
|
410
414
|
: [
|
|
411
415
|
noCodingActivityNode({
|
|
412
|
-
// @ts-ignore
|
|
413
|
-
color: textColor,
|
|
414
416
|
text: stats.is_coding_activity_visible
|
|
415
417
|
? stats.is_other_usage_visible
|
|
416
418
|
? i18n.t("wakatimecard.nocodingactivity")
|
|
@@ -440,13 +442,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
440
442
|
width: normalizedWidth,
|
|
441
443
|
height,
|
|
442
444
|
border_radius,
|
|
443
|
-
colors: {
|
|
444
|
-
titleColor,
|
|
445
|
-
textColor,
|
|
446
|
-
iconColor,
|
|
447
|
-
bgColor,
|
|
448
|
-
borderColor,
|
|
449
|
-
},
|
|
445
|
+
colors: { light: lightColors, dark: darkColors },
|
|
450
446
|
});
|
|
451
447
|
|
|
452
448
|
if (disable_animations) {
|
|
@@ -455,9 +451,9 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
455
451
|
|
|
456
452
|
card.setHideBorder(hide_border);
|
|
457
453
|
card.setHideTitle(hide_title);
|
|
458
|
-
card.setCSS(
|
|
459
|
-
`
|
|
460
|
-
${
|
|
454
|
+
card.setCSS({
|
|
455
|
+
light: `
|
|
456
|
+
${getStyles({ textColor })}
|
|
461
457
|
@keyframes slideInAnimation {
|
|
462
458
|
from {
|
|
463
459
|
width: 0;
|
|
@@ -480,9 +476,19 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
480
476
|
}
|
|
481
477
|
.lang-progress{
|
|
482
478
|
animation: growWidthAnimation 0.6s ease-in-out forwards;
|
|
479
|
+
fill: ${titleColor};
|
|
483
480
|
}
|
|
481
|
+
.progress-background { fill: ${textColor === titleColor ? "#fff0" /* transparent */ : textColor}; }
|
|
484
482
|
`,
|
|
485
|
-
|
|
483
|
+
dark: darkColors
|
|
484
|
+
? `
|
|
485
|
+
${getStyles({ textColor: darkColors.textColor })}
|
|
486
|
+
.lang-name { fill: ${darkColors.textColor} }
|
|
487
|
+
.lang-progress { fill: ${darkColors.titleColor}; }
|
|
488
|
+
.progress-background { fill: ${darkColors.textColor === darkColors.titleColor ? "#fff0" /* transparent */ : darkColors.textColor}; }
|
|
489
|
+
`
|
|
490
|
+
: null,
|
|
491
|
+
});
|
|
486
492
|
|
|
487
493
|
return card.render(`
|
|
488
494
|
<svg x="0" y="0" width="100%">
|