@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.
Files changed (169) hide show
  1. package/build/api/gist.d.ts +2 -7
  2. package/build/api/gist.d.ts.map +1 -1
  3. package/build/api/gist.js +9 -41
  4. package/build/api/index.d.ts +3 -8
  5. package/build/api/index.d.ts.map +1 -1
  6. package/build/api/index.js +23 -45
  7. package/build/api/pin.d.ts +2 -7
  8. package/build/api/pin.d.ts.map +1 -1
  9. package/build/api/pin.js +9 -41
  10. package/build/api/top-langs.d.ts +2 -7
  11. package/build/api/top-langs.d.ts.map +1 -1
  12. package/build/api/top-langs.js +11 -55
  13. package/build/api/wakatime.d.ts +2 -7
  14. package/build/api/wakatime.d.ts.map +1 -1
  15. package/build/api/wakatime.js +9 -41
  16. package/build/cards/common-options.d.ts +13 -0
  17. package/build/cards/common-options.d.ts.map +1 -0
  18. package/build/cards/common-options.js +1 -0
  19. package/build/cards/gist.d.ts +11 -16
  20. package/build/cards/gist.d.ts.map +1 -1
  21. package/build/cards/gist.js +26 -31
  22. package/build/cards/repo.d.ts +19 -16
  23. package/build/cards/repo.d.ts.map +1 -1
  24. package/build/cards/repo.js +58 -60
  25. package/build/cards/stats.d.ts +29 -46
  26. package/build/cards/stats.d.ts.map +1 -1
  27. package/build/cards/stats.js +113 -181
  28. package/build/cards/top-languages.d.ts +81 -77
  29. package/build/cards/top-languages.d.ts.map +1 -1
  30. package/build/cards/top-languages.js +174 -200
  31. package/build/cards/wakatime.d.ts +21 -11
  32. package/build/cards/wakatime.d.ts.map +1 -1
  33. package/build/cards/wakatime.js +73 -111
  34. package/build/common/Card.d.ts +34 -13
  35. package/build/common/Card.d.ts.map +1 -1
  36. package/build/common/Card.js +73 -40
  37. package/build/common/I18n.d.ts +4 -2
  38. package/build/common/I18n.d.ts.map +1 -1
  39. package/build/common/color.d.ts +60 -18
  40. package/build/common/color.d.ts.map +1 -1
  41. package/build/common/color.js +102 -5
  42. package/build/common/config.d.ts +2 -1
  43. package/build/common/config.d.ts.map +1 -1
  44. package/build/common/config.js +16 -26
  45. package/build/common/constants.d.ts +2 -1
  46. package/build/common/constants.d.ts.map +1 -1
  47. package/build/common/date.d.ts +37 -0
  48. package/build/common/date.d.ts.map +1 -0
  49. package/build/common/date.js +31 -0
  50. package/build/common/http.d.ts +25 -2
  51. package/build/common/http.d.ts.map +1 -1
  52. package/build/common/http.js +26 -3
  53. package/build/common/icons.d.ts +1 -0
  54. package/build/common/icons.d.ts.map +1 -1
  55. package/build/common/icons.js +1 -0
  56. package/build/common/languageColors.d.ts +11 -0
  57. package/build/common/languageColors.d.ts.map +1 -0
  58. package/build/common/languageColors.js +15 -0
  59. package/build/common/languageColors.json +1 -0
  60. package/build/common/ops.d.ts +3 -10
  61. package/build/common/ops.d.ts.map +1 -1
  62. package/build/common/ops.js +3 -15
  63. package/build/common/render.d.ts +43 -6
  64. package/build/common/render.d.ts.map +1 -1
  65. package/build/common/render.js +77 -11
  66. package/build/common/retryer.d.ts +3 -2
  67. package/build/common/retryer.d.ts.map +1 -1
  68. package/build/common/retryer.js +1 -0
  69. package/build/fetchers/gist.d.ts.map +1 -1
  70. package/build/fetchers/gist.js +8 -39
  71. package/build/fetchers/repo.d.ts +12 -11
  72. package/build/fetchers/repo.d.ts.map +1 -1
  73. package/build/fetchers/repo.js +26 -67
  74. package/build/fetchers/stats.d.ts +24 -17
  75. package/build/fetchers/stats.d.ts.map +1 -1
  76. package/build/fetchers/stats.js +302 -183
  77. package/build/fetchers/top-languages.d.ts +10 -15
  78. package/build/fetchers/top-languages.d.ts.map +1 -1
  79. package/build/fetchers/top-languages.js +52 -103
  80. package/build/fetchers/types.d.ts +24 -20
  81. package/build/fetchers/types.d.ts.map +1 -1
  82. package/build/fetchers/wakatime.d.ts +9 -5
  83. package/build/fetchers/wakatime.d.ts.map +1 -1
  84. package/build/fetchers/wakatime.js +8 -4
  85. package/build/graphql/contributionsDocument.d.ts +18 -0
  86. package/build/graphql/contributionsDocument.d.ts.map +1 -0
  87. package/build/graphql/contributionsDocument.js +30 -0
  88. package/build/graphql/generated/common.d.ts +42 -0
  89. package/build/graphql/generated/common.d.ts.map +1 -0
  90. package/build/graphql/generated/common.js +2 -0
  91. package/build/graphql/generated/gist.d.ts +44 -0
  92. package/build/graphql/generated/gist.d.ts.map +1 -0
  93. package/build/graphql/generated/gist.js +27 -0
  94. package/build/graphql/generated/repo.d.ts +67 -0
  95. package/build/graphql/generated/repo.d.ts.map +1 -0
  96. package/build/graphql/generated/repo.js +30 -0
  97. package/build/graphql/generated/stats.d.ts +150 -0
  98. package/build/graphql/generated/stats.d.ts.map +1 -0
  99. package/build/graphql/generated/stats.js +95 -0
  100. package/build/graphql/generated/top-languages.d.ts +54 -0
  101. package/build/graphql/generated/top-languages.d.ts.map +1 -0
  102. package/build/graphql/generated/top-languages.js +27 -0
  103. package/build/graphql/graphqlDocument.d.ts +22 -0
  104. package/build/graphql/graphqlDocument.d.ts.map +1 -0
  105. package/build/graphql/graphqlDocument.js +8 -0
  106. package/build/graphql/reposContributedToDocument.d.ts +27 -0
  107. package/build/graphql/reposContributedToDocument.d.ts.map +1 -0
  108. package/build/graphql/reposContributedToDocument.js +59 -0
  109. package/build/index.d.ts +3 -1
  110. package/build/index.d.ts.map +1 -1
  111. package/build/index.js +2 -1
  112. package/build/themes/index.d.ts +32 -0
  113. package/build/themes/index.d.ts.map +1 -1
  114. package/build/themes/index.js +28 -0
  115. package/build/translations.d.ts +17 -0
  116. package/build/translations.d.ts.map +1 -1
  117. package/build/translations.js +17 -0
  118. package/package.json +13 -7
  119. package/src/_github-username-regex.d.ts +4 -0
  120. package/src/api/gist.js +10 -46
  121. package/src/api/index.js +30 -51
  122. package/src/api/pin.js +10 -46
  123. package/src/api/top-langs.js +13 -60
  124. package/src/api/wakatime.js +10 -46
  125. package/src/cards/common-options.ts +13 -0
  126. package/src/cards/{gist.js → gist.ts} +37 -37
  127. package/src/cards/{repo.js → repo.ts} +86 -68
  128. package/src/cards/{stats.js → stats.ts} +168 -219
  129. package/src/cards/{top-languages.js → top-languages.ts} +309 -265
  130. package/src/cards/{wakatime.js → wakatime.ts} +136 -130
  131. package/src/common/Card.ts +94 -49
  132. package/src/common/I18n.ts +6 -2
  133. package/src/common/color.ts +163 -14
  134. package/src/common/config.ts +22 -29
  135. package/src/common/constants.ts +3 -1
  136. package/src/common/date.ts +45 -0
  137. package/src/common/http.ts +43 -3
  138. package/src/common/icons.ts +1 -0
  139. package/src/common/languageColors.json +1 -0
  140. package/src/common/languageColors.ts +19 -0
  141. package/src/common/ops.ts +8 -18
  142. package/src/common/render.ts +114 -14
  143. package/src/common/retryer.ts +6 -5
  144. package/src/fetchers/gist.ts +15 -72
  145. package/src/fetchers/repo.ts +114 -0
  146. package/src/fetchers/stats.ts +743 -0
  147. package/src/fetchers/top-languages.ts +135 -0
  148. package/src/fetchers/types.ts +28 -20
  149. package/src/fetchers/{wakatime.js → wakatime.ts} +19 -5
  150. package/src/graphql/contributionsDocument.ts +44 -0
  151. package/src/graphql/generated/common.ts +26 -0
  152. package/src/graphql/generated/gist.ts +59 -0
  153. package/src/graphql/generated/repo.ts +90 -0
  154. package/src/graphql/generated/stats.ts +194 -0
  155. package/src/graphql/generated/top-languages.ts +75 -0
  156. package/src/graphql/graphqlDocument.ts +25 -0
  157. package/src/graphql/queries/gist.graphql +25 -0
  158. package/src/graphql/queries/repo.graphql +28 -0
  159. package/src/graphql/queries/stats.graphql +120 -0
  160. package/src/graphql/queries/top-languages.graphql +34 -0
  161. package/src/graphql/reposContributedToDocument.ts +86 -0
  162. package/src/index.ts +3 -1
  163. package/src/themes/index.ts +33 -0
  164. package/src/translations.ts +17 -0
  165. package/src/cards/types.d.ts +0 -78
  166. package/src/fetchers/repo.js +0 -161
  167. package/src/fetchers/stats.js +0 -473
  168. package/src/fetchers/top-languages.js +0 -175
  169. 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 { getCardColors, isPrefixedHexColor } from "../common/color.js";
3
+ import { getLightDarkColors, isPrefixedHexColor } from "../common/color.js";
4
4
  import { encodeHTML } from "../common/html.js";
5
- import languageColors from "../common/languageColors.json" with { type: "json" };
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 {object} props The function properties.
23
- * @param {string} props.color No coding activity text color.
24
- * @param {string} props.text No coding activity translated text.
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 = ({ color, text }) => {
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" fill="${color}">${encodeHTML(text)}</text>
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 {Object} args The function arguments.
45
- * @param {WakaTimeLang} args.lang The language object.
46
- * @param {"time" | "percent"} args.display_format The display format of the language node.
47
- * @returns {string} The formatted language value.
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 = ({ display_format, lang }) => {
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).toString()} %`
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 {Object} args The function arguments.
59
- * @param {WakaTimeLang} args.lang The languages array.
60
- * @param {number} args.x The x position of the language node.
61
- * @param {number} args.y The y position of the language node.
62
- * @param {"time" | "percent"} args.display_format The display format of the language node.
63
- * @returns {string} The compact layout language SVG node.
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 = ({ lang, x, y, display_format }) => {
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
- // @ts-ignore
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 {Object} args The function arguments.
91
- * @param {WakaTimeLang[]} args.langs The language objects.
92
- * @param {number} args.y The y position of the language node.
93
- * @param {"time" | "percent"} args.display_format The display format of the language node.
94
- * @param {number} args.card_width Width in px of the card.
95
- * @returns {string[]} The language text node items.
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 = ({ langs, y, display_format, card_width }) => {
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 {Object} args The function arguments.
118
- * @param {string} args.id The id of the text node item.
119
- * @param {string} args.label The label of the text node item.
120
- * @param {string} args.value The value of the text node item.
121
- * @param {number} args.index The index of the text node item.
122
- * @param {number} args.percent Percentage of the text node item.
123
- * @param {boolean=} args.hideProgress Whether to hide the progress bar.
124
- * @param {string} args.progressBarColor The color of the progress bar.
125
- * @param {string} args.progressBarBackgroundColor The color of the progress bar background.
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 {WakaTimeLang[]} languages The languages array.
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 {Object} colors The colors to use for the card.
197
- * @param {string} colors.titleColor The title color.
198
- * @param {string} colors.textColor The text color.
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 = function ({
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 {Object} args The function arguments.
231
- * @param {WakaTimeOptions["layout"] | undefined} args.layout The incoming layout value.
232
- * @param {number|undefined} args.value The incoming width value.
233
- * @returns {number} The normalized width value.
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 = ({ value, layout }) => {
236
- if (value === undefined || value === null || isNaN(value)) {
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 {Partial<WakaTimeData>} stats WakaTime stats.
254
- * @param {Partial<WakaTimeOptions>} options Card options.
255
- * @returns {string} WakaTime card SVG.
283
+ * @param stats WakaTime stats.
284
+ * @param options Card options.
285
+ * @returns WakaTime card SVG.
256
286
  */
257
- const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
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
- // returns theme based colors with proper overrides and defaults
306
- const { titleColor, textColor, iconColor, bgColor, borderColor } =
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
- const cssStyles = getStyles({
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
- // @ts-ignore
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
- ${cssStyles}
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%">