@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,16 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import type { WakaTimeData } from "../fetchers/types.js";
|
|
2
|
+
import type { CommonOptions } from "./common-options.js";
|
|
3
|
+
type WakaTimeLayout = "compact" | "normal";
|
|
4
|
+
type DisplayFormat = "time" | "percent";
|
|
5
|
+
interface WakaTimeOptions extends CommonOptions {
|
|
6
|
+
hide_title: boolean;
|
|
7
|
+
hide: Array<string>;
|
|
8
|
+
card_width: number;
|
|
9
|
+
line_height: number | string;
|
|
10
|
+
hide_progress: boolean;
|
|
11
|
+
custom_title: string;
|
|
12
|
+
layout: WakaTimeLayout;
|
|
13
|
+
langs_count: number;
|
|
14
|
+
display_format: DisplayFormat;
|
|
15
|
+
disable_animations: boolean;
|
|
16
|
+
}
|
|
8
17
|
/**
|
|
9
18
|
* Renders WakaTime card.
|
|
10
19
|
*
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @returns
|
|
20
|
+
* @param stats WakaTime stats.
|
|
21
|
+
* @param options Card options.
|
|
22
|
+
* @returns WakaTime card SVG.
|
|
14
23
|
*/
|
|
15
|
-
|
|
24
|
+
declare const renderWakatimeCard: (stats?: Partial<WakaTimeData>, options?: Partial<WakaTimeOptions>) => string;
|
|
25
|
+
export { renderWakatimeCard };
|
|
16
26
|
//# sourceMappingURL=wakatime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wakatime.d.ts","sourceRoot":"","sources":["../../src/cards/wakatime.
|
|
1
|
+
{"version":3,"file":"wakatime.d.ts","sourceRoot":"","sources":["../../src/cards/wakatime.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,sBAAsB,CAAC;AAGvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAWzD,KAAK,cAAc,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC3C,KAAK,aAAa,GAAG,MAAM,GAAG,SAAS,CAAC;AAExC,UAAU,eAAgB,SAAQ,aAAa;IAC7C,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,aAAa,CAAC;IAC9B,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAoPD;;;;;;GAMG;AACH,QAAA,MAAM,kBAAkB,GACtB,QAAO,OAAO,CAAC,YAAY,CAAM,EACjC,UAAS,OAAO,CAAC,eAAe,CAAgB,KAC/C,MAgNF,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/build/cards/wakatime.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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
8
|
import { wakatimeCardLocales } from "../translations.js";
|
|
@@ -17,54 +17,46 @@ const TOTAL_TEXT_WIDTH = 275;
|
|
|
17
17
|
/**
|
|
18
18
|
* Creates the no coding activity SVG node.
|
|
19
19
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
23
|
-
* @returns {string} No coding activity SVG node string.
|
|
20
|
+
* @param props The function properties.
|
|
21
|
+
* @param props.text No coding activity translated text.
|
|
22
|
+
* @returns No coding activity SVG node string.
|
|
24
23
|
*/
|
|
25
|
-
const noCodingActivityNode = ({
|
|
26
|
-
if (!isPrefixedHexColor(color)) {
|
|
27
|
-
throw new Error(`Invalid text color: "${color}"`);
|
|
28
|
-
}
|
|
24
|
+
const noCodingActivityNode = ({ text }) => {
|
|
29
25
|
return `
|
|
30
|
-
<text x="25" y="11" class="stat bold"
|
|
26
|
+
<text x="25" y="11" class="stat bold">${encodeHTML(text)}</text>
|
|
31
27
|
`;
|
|
32
28
|
};
|
|
33
|
-
/**
|
|
34
|
-
* @typedef {import('../fetchers/types').WakaTimeLang} WakaTimeLang
|
|
35
|
-
*/
|
|
36
29
|
/**
|
|
37
30
|
* Format language value.
|
|
38
31
|
*
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @returns
|
|
32
|
+
* @param args The function arguments.
|
|
33
|
+
* @param args.lang The language object.
|
|
34
|
+
* @param args.display_format The display format of the language node.
|
|
35
|
+
* @returns The formatted language value.
|
|
43
36
|
*/
|
|
44
|
-
const formatLanguageValue = ({ display_format, lang }) => {
|
|
37
|
+
const formatLanguageValue = ({ display_format, lang, }) => {
|
|
45
38
|
return display_format === "percent"
|
|
46
|
-
? `${lang.percent.toFixed(2)
|
|
39
|
+
? `${lang.percent.toFixed(2)} %`
|
|
47
40
|
: lang.text;
|
|
48
41
|
};
|
|
49
42
|
/**
|
|
50
43
|
* Create compact WakaTime layout.
|
|
51
44
|
*
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
54
|
-
* @param
|
|
55
|
-
* @param
|
|
56
|
-
* @param
|
|
57
|
-
* @returns
|
|
45
|
+
* @param args The function arguments.
|
|
46
|
+
* @param args.lang The languages array.
|
|
47
|
+
* @param args.x The x position of the language node.
|
|
48
|
+
* @param args.y The y position of the language node.
|
|
49
|
+
* @param args.display_format The display format of the language node.
|
|
50
|
+
* @returns The compact layout language SVG node.
|
|
58
51
|
*/
|
|
59
|
-
const createCompactLangNode = ({ lang, x, y, display_format }) => {
|
|
52
|
+
const createCompactLangNode = ({ lang, x, y, display_format, }) => {
|
|
60
53
|
if (!Number.isFinite(x)) {
|
|
61
54
|
throw new Error(`Invalid x: "${x}"`);
|
|
62
55
|
}
|
|
63
56
|
if (!Number.isFinite(y)) {
|
|
64
57
|
throw new Error(`Invalid y: "${y}"`);
|
|
65
58
|
}
|
|
66
|
-
|
|
67
|
-
const color = languageColors[lang.name] || "#858585";
|
|
59
|
+
const color = getLanguageColor(lang.name);
|
|
68
60
|
const value = formatLanguageValue({ display_format, lang });
|
|
69
61
|
return `
|
|
70
62
|
<g transform="translate(${x}, ${y})">
|
|
@@ -78,14 +70,14 @@ const createCompactLangNode = ({ lang, x, y, display_format }) => {
|
|
|
78
70
|
/**
|
|
79
71
|
* Create WakaTime language text node item.
|
|
80
72
|
*
|
|
81
|
-
* @param
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
84
|
-
* @param
|
|
85
|
-
* @param
|
|
86
|
-
* @returns
|
|
73
|
+
* @param args The function arguments.
|
|
74
|
+
* @param args.langs The language objects.
|
|
75
|
+
* @param args.y The y position of the language node.
|
|
76
|
+
* @param args.display_format The display format of the language node.
|
|
77
|
+
* @param args.card_width Width in px of the card.
|
|
78
|
+
* @returns The language text node items.
|
|
87
79
|
*/
|
|
88
|
-
const createLanguageTextNode = ({ langs, y, display_format, card_width }) => {
|
|
80
|
+
const createLanguageTextNode = ({ langs, y, display_format, card_width, }) => {
|
|
89
81
|
const LEFT_X = 25;
|
|
90
82
|
const RIGHT_X_BASE = 230;
|
|
91
83
|
const rightOffset = (card_width - DEFAULT_CARD_WIDTH) / 2;
|
|
@@ -103,19 +95,17 @@ const createLanguageTextNode = ({ langs, y, display_format, card_width }) => {
|
|
|
103
95
|
/**
|
|
104
96
|
* Create WakaTime text item.
|
|
105
97
|
*
|
|
106
|
-
* @param
|
|
107
|
-
* @param
|
|
108
|
-
* @param
|
|
109
|
-
* @param
|
|
110
|
-
* @param
|
|
111
|
-
* @param
|
|
112
|
-
* @param
|
|
113
|
-
* @param
|
|
114
|
-
* @
|
|
115
|
-
* @param {number} args.progressBarWidth The width of the progress bar.
|
|
116
|
-
* @returns {string} The text SVG node.
|
|
98
|
+
* @param args The function arguments.
|
|
99
|
+
* @param args.id The id of the text node item.
|
|
100
|
+
* @param args.label The label of the text node item.
|
|
101
|
+
* @param args.value The value of the text node item.
|
|
102
|
+
* @param args.index The index of the text node item.
|
|
103
|
+
* @param args.percent Percentage of the text node item.
|
|
104
|
+
* @param args.hideProgress Whether to hide the progress bar.
|
|
105
|
+
* @param args.progressBarWidth The width of the progress bar.
|
|
106
|
+
* @returns The text SVG node.
|
|
117
107
|
*/
|
|
118
|
-
const createTextNode = ({ id, label, value, index, percent, hideProgress,
|
|
108
|
+
const createTextNode = ({ id, label, value, index, percent, hideProgress, progressBarWidth, }) => {
|
|
119
109
|
if (!Number.isFinite(index)) {
|
|
120
110
|
throw new Error(`Invalid index: "${index}"`);
|
|
121
111
|
}
|
|
@@ -129,11 +119,7 @@ const createTextNode = ({ id, label, value, index, percent, hideProgress, progre
|
|
|
129
119
|
x: 110,
|
|
130
120
|
y: 4,
|
|
131
121
|
progress: percent,
|
|
132
|
-
color: progressBarColor,
|
|
133
122
|
width: progressBarWidth,
|
|
134
|
-
// @ts-ignore
|
|
135
|
-
name: label,
|
|
136
|
-
progressBarBackgroundColor,
|
|
137
123
|
delay: staggerDelay + 300,
|
|
138
124
|
});
|
|
139
125
|
return `
|
|
@@ -144,7 +130,7 @@ const createTextNode = ({ id, label, value, index, percent, hideProgress, progre
|
|
|
144
130
|
x="${hideProgress ? HIDDEN_PROGRESSBAR_PADDING : PROGRESSBAR_PADDING + progressBarWidth}"
|
|
145
131
|
y="12.5"
|
|
146
132
|
>${encodeHTML(value)}</text>
|
|
147
|
-
${cardProgress}
|
|
133
|
+
${String(cardProgress)}
|
|
148
134
|
</g>
|
|
149
135
|
`;
|
|
150
136
|
};
|
|
@@ -152,8 +138,7 @@ const createTextNode = ({ id, label, value, index, percent, hideProgress, progre
|
|
|
152
138
|
* Recalculating percentages so that, compact layout's progress bar does not break when
|
|
153
139
|
* hiding languages.
|
|
154
140
|
*
|
|
155
|
-
* @param
|
|
156
|
-
* @returns {void} The recalculated languages array.
|
|
141
|
+
* @param languages The languages array.
|
|
157
142
|
*/
|
|
158
143
|
const recalculatePercentages = (languages) => {
|
|
159
144
|
const totalSum = languages.reduce((totalSum, language) => totalSum + language.percent, 0);
|
|
@@ -165,14 +150,11 @@ const recalculatePercentages = (languages) => {
|
|
|
165
150
|
/**
|
|
166
151
|
* Retrieves CSS styles for a card.
|
|
167
152
|
*
|
|
168
|
-
* @param
|
|
169
|
-
* @param
|
|
170
|
-
* @
|
|
171
|
-
* @returns {string} Card CSS styles.
|
|
153
|
+
* @param colors The colors to use for the card.
|
|
154
|
+
* @param colors.textColor The text color.
|
|
155
|
+
* @returns Card CSS styles.
|
|
172
156
|
*/
|
|
173
|
-
const getStyles =
|
|
174
|
-
// eslint-disable-next-line no-unused-vars
|
|
175
|
-
titleColor, textColor, }) {
|
|
157
|
+
const getStyles = ({ textColor }) => {
|
|
176
158
|
if (!isPrefixedHexColor(textColor)) {
|
|
177
159
|
throw new Error(`Invalid text color: "${textColor}"`);
|
|
178
160
|
}
|
|
@@ -195,31 +177,27 @@ titleColor, textColor, }) {
|
|
|
195
177
|
/**
|
|
196
178
|
* Normalize incoming width (string or number) and clamp to minimum.
|
|
197
179
|
*
|
|
198
|
-
* @param
|
|
199
|
-
* @param
|
|
200
|
-
* @param
|
|
201
|
-
* @returns
|
|
180
|
+
* @param args The function arguments.
|
|
181
|
+
* @param args.layout The incoming layout value.
|
|
182
|
+
* @param args.value The incoming width value.
|
|
183
|
+
* @returns The normalized width value.
|
|
202
184
|
*/
|
|
203
|
-
const normalizeCardWidth = ({ value, layout }) => {
|
|
204
|
-
if (value === undefined ||
|
|
185
|
+
const normalizeCardWidth = ({ value, layout, }) => {
|
|
186
|
+
if (value === undefined || isNaN(value)) {
|
|
205
187
|
return DEFAULT_CARD_WIDTH;
|
|
206
188
|
}
|
|
207
189
|
return Math.max(layout === "compact" ? COMPACT_LAYOUT_MIN_WIDTH : MIN_CARD_WIDTH, value);
|
|
208
190
|
};
|
|
209
|
-
/**
|
|
210
|
-
* @typedef {import('../fetchers/types').WakaTimeData} WakaTimeData
|
|
211
|
-
* @typedef {import('./types').WakaTimeOptions} WakaTimeOptions
|
|
212
|
-
*/
|
|
213
191
|
/**
|
|
214
192
|
* Renders WakaTime card.
|
|
215
193
|
*
|
|
216
|
-
* @param
|
|
217
|
-
* @param
|
|
218
|
-
* @returns
|
|
194
|
+
* @param stats WakaTime stats.
|
|
195
|
+
* @param options Card options.
|
|
196
|
+
* @returns WakaTime card SVG.
|
|
219
197
|
*/
|
|
220
198
|
const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
221
199
|
let { languages = [] } = stats;
|
|
222
|
-
const { hide_title = false, hide_border = false, card_width, hide, line_height = DEFAULT_LINE_HEIGHT,
|
|
200
|
+
const { hide_title = false, hide_border = false, card_width, hide, line_height = DEFAULT_LINE_HEIGHT, hide_progress, custom_title, locale, layout, langs_count = languages.length, border_radius, display_format = "time", disable_animations, } = options;
|
|
223
201
|
const normalizedWidth = normalizeCardWidth({ value: card_width, layout });
|
|
224
202
|
const shouldHideLangs = Array.isArray(hide) && hide.length > 0;
|
|
225
203
|
if (shouldHideLangs) {
|
|
@@ -236,25 +214,14 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
236
214
|
});
|
|
237
215
|
const lheight = parseInt(String(line_height), 10);
|
|
238
216
|
const langsCount = clampValue(langs_count, 1, langs_count);
|
|
239
|
-
|
|
240
|
-
const { titleColor, textColor
|
|
241
|
-
title_color,
|
|
242
|
-
icon_color,
|
|
243
|
-
text_color,
|
|
244
|
-
bg_color,
|
|
245
|
-
border_color,
|
|
246
|
-
theme,
|
|
247
|
-
});
|
|
217
|
+
const { lightColors, darkColors } = getLightDarkColors(options);
|
|
218
|
+
const { titleColor, textColor } = lightColors;
|
|
248
219
|
const filteredLanguages = languages
|
|
249
220
|
.filter((language) => language.hours || language.minutes)
|
|
250
221
|
.slice(0, langsCount);
|
|
251
222
|
// Calculate the card height depending on how many items there are
|
|
252
223
|
// but if rank circle is visible clamp the minimum height to `150`
|
|
253
224
|
let height = Math.max(45 + (filteredLanguages.length + 1) * lheight, 150);
|
|
254
|
-
const cssStyles = getStyles({
|
|
255
|
-
titleColor,
|
|
256
|
-
textColor,
|
|
257
|
-
});
|
|
258
225
|
let finalLayout;
|
|
259
226
|
// RENDER COMPACT LAYOUT
|
|
260
227
|
if (layout === "compact") {
|
|
@@ -268,8 +235,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
268
235
|
.map((language) => {
|
|
269
236
|
const progress = ((width - COMPACT_LAYOUT_PROGRESSBAR_PADDING) * language.percent) /
|
|
270
237
|
100;
|
|
271
|
-
|
|
272
|
-
const languageColor = languageColors[language.name] || "#858585";
|
|
238
|
+
const languageColor = getLanguageColor(language.name);
|
|
273
239
|
const output = `
|
|
274
240
|
<rect
|
|
275
241
|
mask="url(#rect-mask)"
|
|
@@ -298,8 +264,6 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
298
264
|
card_width: normalizedWidth,
|
|
299
265
|
}).join("")
|
|
300
266
|
: noCodingActivityNode({
|
|
301
|
-
// @ts-ignore
|
|
302
|
-
color: textColor,
|
|
303
267
|
text: stats.is_coding_activity_visible
|
|
304
268
|
? stats.is_other_usage_visible
|
|
305
269
|
? i18n.t("wakatimecard.nocodingactivity")
|
|
@@ -318,20 +282,12 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
318
282
|
value: formatLanguageValue({ display_format, lang: language }),
|
|
319
283
|
index,
|
|
320
284
|
percent: language.percent,
|
|
321
|
-
// @ts-ignore
|
|
322
|
-
progressBarColor: titleColor,
|
|
323
|
-
// @ts-ignore
|
|
324
|
-
progressBarBackgroundColor: textColor === titleColor
|
|
325
|
-
? "#fff0" // transparent
|
|
326
|
-
: textColor,
|
|
327
285
|
hideProgress: hide_progress,
|
|
328
286
|
progressBarWidth: normalizedWidth - TOTAL_TEXT_WIDTH,
|
|
329
287
|
});
|
|
330
288
|
})
|
|
331
289
|
: [
|
|
332
290
|
noCodingActivityNode({
|
|
333
|
-
// @ts-ignore
|
|
334
|
-
color: textColor,
|
|
335
291
|
text: stats.is_coding_activity_visible
|
|
336
292
|
? stats.is_other_usage_visible
|
|
337
293
|
? i18n.t("wakatimecard.nocodingactivity")
|
|
@@ -359,21 +315,16 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
359
315
|
width: normalizedWidth,
|
|
360
316
|
height,
|
|
361
317
|
border_radius,
|
|
362
|
-
colors: {
|
|
363
|
-
titleColor,
|
|
364
|
-
textColor,
|
|
365
|
-
iconColor,
|
|
366
|
-
bgColor,
|
|
367
|
-
borderColor,
|
|
368
|
-
},
|
|
318
|
+
colors: { light: lightColors, dark: darkColors },
|
|
369
319
|
});
|
|
370
320
|
if (disable_animations) {
|
|
371
321
|
card.disableAnimations();
|
|
372
322
|
}
|
|
373
323
|
card.setHideBorder(hide_border);
|
|
374
324
|
card.setHideTitle(hide_title);
|
|
375
|
-
card.setCSS(
|
|
376
|
-
|
|
325
|
+
card.setCSS({
|
|
326
|
+
light: `
|
|
327
|
+
${getStyles({ textColor })}
|
|
377
328
|
@keyframes slideInAnimation {
|
|
378
329
|
from {
|
|
379
330
|
width: 0;
|
|
@@ -396,8 +347,19 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
396
347
|
}
|
|
397
348
|
.lang-progress{
|
|
398
349
|
animation: growWidthAnimation 0.6s ease-in-out forwards;
|
|
350
|
+
fill: ${titleColor};
|
|
399
351
|
}
|
|
400
|
-
|
|
352
|
+
.progress-background { fill: ${textColor === titleColor ? "#fff0" /* transparent */ : textColor}; }
|
|
353
|
+
`,
|
|
354
|
+
dark: darkColors
|
|
355
|
+
? `
|
|
356
|
+
${getStyles({ textColor: darkColors.textColor })}
|
|
357
|
+
.lang-name { fill: ${darkColors.textColor} }
|
|
358
|
+
.lang-progress { fill: ${darkColors.titleColor}; }
|
|
359
|
+
.progress-background { fill: ${darkColors.textColor === darkColors.titleColor ? "#fff0" /* transparent */ : darkColors.textColor}; }
|
|
360
|
+
`
|
|
361
|
+
: null,
|
|
362
|
+
});
|
|
401
363
|
return card.render(`
|
|
402
364
|
<svg x="0" y="0" width="100%">
|
|
403
365
|
${finalLayout}
|
package/build/common/Card.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
interface CardColors {
|
|
2
2
|
/** Card title color. */
|
|
3
|
-
titleColor
|
|
3
|
+
titleColor: string;
|
|
4
4
|
/** Card text color. */
|
|
5
|
-
textColor
|
|
5
|
+
textColor: string;
|
|
6
6
|
/** Card icon color. */
|
|
7
|
-
iconColor
|
|
7
|
+
iconColor: string;
|
|
8
8
|
/** Card background color. */
|
|
9
|
-
bgColor
|
|
9
|
+
bgColor: string | Array<string>;
|
|
10
10
|
/** Card border color. */
|
|
11
|
-
borderColor
|
|
11
|
+
borderColor: string;
|
|
12
12
|
}
|
|
13
13
|
declare class Card {
|
|
14
14
|
width: number;
|
|
@@ -16,9 +16,13 @@ declare class Card {
|
|
|
16
16
|
hideBorder: boolean;
|
|
17
17
|
hideTitle: boolean;
|
|
18
18
|
border_radius: number;
|
|
19
|
-
colors:
|
|
19
|
+
colors: {
|
|
20
|
+
light: CardColors;
|
|
21
|
+
dark: CardColors | null;
|
|
22
|
+
};
|
|
20
23
|
title: string;
|
|
21
24
|
css: string;
|
|
25
|
+
darkCss: string;
|
|
22
26
|
paddingX: number;
|
|
23
27
|
paddingY: number;
|
|
24
28
|
titlePrefixIcon: string | undefined;
|
|
@@ -34,7 +38,9 @@ declare class Card {
|
|
|
34
38
|
* @param props.width Card width.
|
|
35
39
|
* @param props.height Card height.
|
|
36
40
|
* @param props.border_radius Card border radius.
|
|
37
|
-
* @param props.colors Card colors
|
|
41
|
+
* @param props.colors Card colors for light and dark mode.
|
|
42
|
+
* @param props.colors.light Card colors for light mode.
|
|
43
|
+
* @param props.colors.dark Card colors for dark mode, or `null` when no dark-mode override is needed.
|
|
38
44
|
* @param props.customTitle Card custom title.
|
|
39
45
|
* @param props.defaultTitle Card default title.
|
|
40
46
|
* @param props.titlePrefixIcon Sanitized card title prefix icon.
|
|
@@ -42,9 +48,12 @@ declare class Card {
|
|
|
42
48
|
constructor({ width, height, border_radius, colors, customTitle, defaultTitle, titlePrefixIcon, }: {
|
|
43
49
|
width?: number;
|
|
44
50
|
height?: number;
|
|
45
|
-
border_radius?: number;
|
|
46
|
-
colors?:
|
|
47
|
-
|
|
51
|
+
border_radius?: number | undefined;
|
|
52
|
+
colors?: {
|
|
53
|
+
light: CardColors;
|
|
54
|
+
dark: CardColors | null;
|
|
55
|
+
};
|
|
56
|
+
customTitle?: string | undefined;
|
|
48
57
|
defaultTitle?: string;
|
|
49
58
|
titlePrefixIcon?: string;
|
|
50
59
|
});
|
|
@@ -59,11 +68,18 @@ declare class Card {
|
|
|
59
68
|
desc: string;
|
|
60
69
|
}): void;
|
|
61
70
|
/**
|
|
62
|
-
*
|
|
71
|
+
* Sets the card CSS for light and dark mode.
|
|
63
72
|
*
|
|
64
|
-
*
|
|
73
|
+
* The caller must ensure that the passed CSS strings are properly sanitized!
|
|
74
|
+
*
|
|
75
|
+
* @param props The props object.
|
|
76
|
+
* @param props.light CSS applied unconditionally (light/default mode).
|
|
77
|
+
* @param props.dark CSS placed inside a `@media (prefers-color-scheme: dark)` block. Pass `null` when not needed.
|
|
65
78
|
*/
|
|
66
|
-
setCSS(
|
|
79
|
+
setCSS({ light, dark }: {
|
|
80
|
+
light: string;
|
|
81
|
+
dark?: string | null;
|
|
82
|
+
}): void;
|
|
67
83
|
/**
|
|
68
84
|
* @param value Whether to hide the border or not.
|
|
69
85
|
*/
|
|
@@ -90,6 +106,11 @@ declare class Card {
|
|
|
90
106
|
* @returns Animation css.
|
|
91
107
|
*/
|
|
92
108
|
getAnimations: () => string;
|
|
109
|
+
/**
|
|
110
|
+
* Builds the @media (prefers-color-scheme: dark) CSS block for the card.
|
|
111
|
+
* Returns an empty string when no dark colors are set.
|
|
112
|
+
*/
|
|
113
|
+
private renderDarkMediaBlock;
|
|
93
114
|
/**
|
|
94
115
|
* The caller must ensure that the passed `body` string is properly sanitized!
|
|
95
116
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/common/Card.ts"],"names":[],"mappings":"AAIA,UAAU,UAAU;IAClB,wBAAwB;IACxB,UAAU,
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/common/Card.ts"],"names":[],"mappings":"AAIA,UAAU,UAAU;IAClB,wBAAwB;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,cAAM,IAAI;IACR,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE;QAAE,KAAK,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;KAAE,CAAC;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;;;;;;;;;;OAeG;gBACS,EACV,KAAW,EACX,MAAY,EACZ,aAAmB,EACnB,MAAiD,EACjD,WAAW,EACX,YAAiB,EACjB,eAAe,GAChB,EAAE;QACD,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAEhB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACnC,MAAM,CAAC,EAAE;YAAE,KAAK,EAAE,UAAU,CAAC;YAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;SAAE,CAAC;QACxD,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACjC,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B;IAuBD,iBAAiB,IAAI,IAAI;IAIzB;;;;OAIG;IACH,qBAAqB,CAAC,EACpB,KAAK,EACL,IAAI,GACL,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,IAAI;IAKR;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI;IAKtE;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAInC;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAUlC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI5B;;OAEG;IACH,WAAW,IAAI,MAAM;IAoCrB;;OAEG;IACH,cAAc,IAAI,MAAM;IA4CxB;;;;OAIG;IACH,aAAa,QAAO,MAAM,CAoBxB;IAEF;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAkB5B;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAuF7B;AAED,OAAO,EAAE,IAAI,EAAE,CAAC;AAChB,eAAe,IAAI,CAAC"}
|