@stats-forge/github-stats-forge-core 0.0.2 → 0.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/README.md +0 -10
- package/build/api/api-result.d.ts +6 -7
- package/build/api/api-result.d.ts.map +1 -1
- package/build/api/api-result.js +4 -5
- package/build/api/contributed-to.d.ts +23 -0
- package/build/api/contributed-to.d.ts.map +1 -0
- package/build/api/contributed-to.js +43 -0
- package/build/api/gist.d.ts +8 -22
- package/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +14 -36
- package/build/api/handler.d.ts +16 -0
- package/build/api/handler.d.ts.map +1 -0
- package/build/api/handler.js +29 -0
- package/build/api/index.d.ts +13 -12
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +1 -0
- package/build/api/params.d.ts +21 -12
- package/build/api/params.d.ts.map +1 -1
- package/build/api/params.js +41 -19
- package/build/api/pin.d.ts +11 -31
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +35 -63
- package/build/api/stats.d.ts +15 -16
- package/build/api/stats.d.ts.map +1 -1
- package/build/api/stats.js +60 -99
- package/build/api/top-langs.d.ts +13 -18
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +35 -72
- package/build/api/wakatime.d.ts +11 -17
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +27 -64
- package/build/calculateRank.d.ts +0 -9
- package/build/calculateRank.d.ts.map +1 -1
- package/build/calculateRank.js +12 -17
- package/build/cards/contributed-to.d.ts +19 -0
- package/build/cards/contributed-to.d.ts.map +1 -0
- package/build/cards/contributed-to.js +242 -0
- package/build/cards/gist.d.ts +3 -4
- package/build/cards/gist.d.ts.map +1 -1
- package/build/cards/gist.js +38 -43
- package/build/cards/options.d.ts +1 -1
- package/build/cards/repo.d.ts +14 -5
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +93 -103
- package/build/cards/stats.d.ts +18 -11
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +191 -222
- package/build/cards/top-languages.d.ts +18 -33
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +196 -387
- package/build/cards/wakatime.d.ts +17 -8
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +133 -187
- package/build/common/Card.d.ts +20 -59
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +131 -198
- package/build/common/I18n.d.ts +1 -7
- package/build/common/I18n.d.ts.map +1 -1
- package/build/common/I18n.js +7 -8
- package/build/common/brand.d.ts +76 -0
- package/build/common/brand.d.ts.map +1 -0
- package/build/common/brand.js +73 -0
- package/build/common/color.d.ts +4 -17
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +67 -49
- package/build/common/config.d.ts +4 -14
- package/build/common/config.d.ts.map +1 -1
- package/build/common/config.js +3 -16
- package/build/common/constants.d.ts +6 -2
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/constants.js +5 -1
- package/build/common/date.d.ts +50 -5
- package/build/common/date.d.ts.map +1 -1
- package/build/common/date.js +104 -4
- package/build/common/emojiMap.d.ts +8 -0
- package/build/common/emojiMap.d.ts.map +1 -0
- package/build/common/emojiMap.js +10 -0
- package/build/common/emojiMap.json +1915 -0
- package/build/common/error.d.ts +1 -10
- package/build/common/error.d.ts.map +1 -1
- package/build/common/error.js +1 -10
- package/build/common/fmt.d.ts +3 -15
- package/build/common/fmt.d.ts.map +1 -1
- package/build/common/fmt.js +7 -35
- package/build/common/http.d.ts +2 -7
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +8 -17
- package/build/common/icons.d.ts +20 -20
- package/build/common/icons.d.ts.map +1 -1
- package/build/common/icons.js +108 -67
- package/build/common/languageColors.d.ts +0 -1
- package/build/common/languageColors.d.ts.map +1 -1
- package/build/common/languageColors.js +1 -4
- package/build/common/languageColors.json +18 -2
- package/build/common/ops.d.ts +11 -17
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +22 -39
- package/build/common/render.d.ts +34 -82
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +225 -259
- package/build/common/retryer.d.ts +2 -7
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +4 -11
- package/build/fetchers/contributed-to.d.ts +62 -0
- package/build/fetchers/contributed-to.d.ts.map +1 -0
- package/build/fetchers/contributed-to.js +184 -0
- package/build/fetchers/gist.d.ts +2 -5
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +1 -5
- package/build/fetchers/graphql-error.d.ts +13 -0
- package/build/fetchers/graphql-error.d.ts.map +1 -0
- package/build/fetchers/graphql-error.js +29 -0
- package/build/fetchers/index.d.ts +13 -12
- package/build/fetchers/index.d.ts.map +1 -1
- package/build/fetchers/index.js +1 -0
- package/build/fetchers/repo.d.ts +2 -11
- package/build/fetchers/repo.d.ts.map +1 -1
- package/build/fetchers/repo.js +20 -33
- package/build/fetchers/stats.d.ts +16 -40
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +89 -271
- package/build/fetchers/top-languages.d.ts +2 -9
- package/build/fetchers/top-languages.d.ts.map +1 -1
- package/build/fetchers/top-languages.js +16 -47
- package/build/fetchers/types.d.ts +25 -1
- package/build/fetchers/types.d.ts.map +1 -1
- package/build/fetchers/wakatime.d.ts +2 -6
- package/build/fetchers/wakatime.d.ts.map +1 -1
- package/build/fetchers/wakatime.js +1 -5
- package/build/graphql/contributionsCollection.d.ts +9 -0
- package/build/graphql/contributionsCollection.d.ts.map +1 -0
- package/build/graphql/contributionsCollection.js +12 -0
- package/build/graphql/contributionsDocument.d.ts +6 -6
- package/build/graphql/contributionsDocument.d.ts.map +1 -1
- package/build/graphql/contributionsDocument.js +8 -16
- package/build/graphql/generated/contributed-to.d.ts +22 -0
- package/build/graphql/generated/contributed-to.d.ts.map +1 -0
- package/build/graphql/generated/contributed-to.js +11 -0
- package/build/graphql/generated/gist.d.ts +1 -1
- package/build/graphql/generated/repo.d.ts +1 -1
- package/build/graphql/generated/stats.d.ts +16 -4
- package/build/graphql/generated/stats.d.ts.map +1 -1
- package/build/graphql/generated/stats.js +2 -2
- package/build/graphql/generated/top-languages.d.ts +2 -2
- package/build/graphql/graphqlDocument.d.ts +1 -2
- package/build/graphql/graphqlDocument.d.ts.map +1 -1
- package/build/graphql/graphqlDocument.js +0 -1
- package/build/graphql/reposContributedToDocument.d.ts +4 -5
- package/build/graphql/reposContributedToDocument.d.ts.map +1 -1
- package/build/graphql/reposContributedToDocument.js +11 -7
- package/build/markup/css.d.ts +35 -0
- package/build/markup/css.d.ts.map +1 -0
- package/build/markup/css.js +64 -0
- package/build/markup/element.d.ts +41 -0
- package/build/markup/element.d.ts.map +1 -0
- package/build/markup/element.js +127 -0
- package/build/markup/html.d.ts +13 -0
- package/build/markup/html.d.ts.map +1 -0
- package/build/markup/html.js +27 -0
- package/build/markup/index.d.ts +9 -0
- package/build/markup/index.d.ts.map +1 -0
- package/build/markup/index.js +6 -0
- package/build/markup/serialize.d.ts +16 -0
- package/build/markup/serialize.d.ts.map +1 -0
- package/build/markup/serialize.js +17 -0
- package/build/themes/index.d.ts +332 -333
- package/build/themes/index.d.ts.map +1 -1
- package/build/themes/index.js +1 -1
- package/build/translations.d.ts +66 -7
- package/build/translations.d.ts.map +1 -1
- package/build/translations.js +686 -629
- package/package.json +17 -26
- package/src/api/api-result.ts +10 -9
- package/src/api/contributed-to.ts +84 -0
- package/src/api/gist.ts +22 -46
- package/src/api/handler.ts +42 -0
- package/src/api/index.ts +13 -12
- package/src/api/params.ts +74 -29
- package/src/api/pin.ts +38 -65
- package/src/api/stats.ts +81 -118
- package/src/api/top-langs.ts +38 -80
- package/src/api/wakatime.ts +35 -73
- package/src/calculateRank.ts +12 -23
- package/src/cards/contributed-to.ts +373 -0
- package/src/cards/gist.ts +55 -49
- package/src/cards/options.ts +1 -1
- package/src/cards/repo.ts +134 -120
- package/src/cards/stats.ts +262 -252
- package/src/cards/top-languages.ts +315 -422
- package/src/cards/wakatime.ts +207 -225
- package/src/common/Card.ts +207 -214
- package/src/common/I18n.ts +7 -8
- package/src/common/brand.ts +109 -0
- package/src/common/color.ts +80 -57
- package/src/common/config.ts +5 -18
- package/src/common/constants.ts +8 -2
- package/src/common/date.ts +135 -5
- package/src/common/emojiMap.json +1915 -0
- package/src/common/emojiMap.ts +13 -0
- package/src/common/error.ts +2 -11
- package/src/common/fmt.ts +7 -44
- package/src/common/http.ts +9 -15
- package/src/common/icons.ts +122 -42
- package/src/common/languageColors.json +18 -2
- package/src/common/languageColors.ts +1 -4
- package/src/common/ops.ts +31 -48
- package/src/common/render.ts +334 -284
- package/src/common/retryer.ts +8 -15
- package/src/fetchers/contributed-to.ts +271 -0
- package/src/fetchers/gist.ts +8 -12
- package/src/fetchers/graphql-error.ts +36 -0
- package/src/fetchers/index.ts +15 -12
- package/src/fetchers/repo.ts +27 -40
- package/src/fetchers/stats.ts +157 -366
- package/src/fetchers/top-languages.ts +27 -55
- package/src/fetchers/types.ts +27 -1
- package/src/fetchers/wakatime.ts +5 -9
- package/src/graphql/contributionsCollection.ts +18 -0
- package/src/graphql/contributionsDocument.ts +14 -19
- package/src/graphql/generated/contributed-to.ts +25 -0
- package/src/graphql/generated/gist.ts +1 -1
- package/src/graphql/generated/repo.ts +1 -1
- package/src/graphql/generated/stats.ts +21 -8
- package/src/graphql/generated/top-languages.ts +2 -2
- package/src/graphql/graphqlDocument.ts +1 -2
- package/src/graphql/queries/contributed-to.graphql +8 -0
- package/src/graphql/queries/stats.graphql +14 -2
- package/src/graphql/reposContributedToDocument.ts +16 -15
- package/src/markup/css.ts +118 -0
- package/src/markup/element.ts +246 -0
- package/src/markup/html.ts +34 -0
- package/src/markup/index.ts +9 -0
- package/src/markup/serialize.ts +27 -0
- package/src/themes/index.ts +1 -1
- package/src/translations.ts +699 -629
- package/build/cards/index.d.ts +0 -11
- package/build/cards/index.d.ts.map +0 -1
- package/build/cards/index.js +0 -7
- package/build/common/html.d.ts +0 -8
- package/build/common/html.d.ts.map +0 -1
- package/build/common/html.js +0 -14
- package/build/index.d.ts +0 -15
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -10
- package/src/_emoji-name-map.d.ts +0 -10
- package/src/_github-username-regex.d.ts +0 -4
- package/src/cards/index.ts +0 -21
- package/src/common/html.ts +0 -17
- package/src/index.ts +0 -18
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { WakaTimeData } from '../fetchers/types.
|
|
2
|
-
import type { CardOptions, CommonCardOptions } from './options.
|
|
1
|
+
import type { WakaTimeData } from '../fetchers/types.ts';
|
|
2
|
+
import type { CardOptions, CommonCardOptions } from './options.ts';
|
|
3
3
|
/** Layouts the card can draw; the api validates `layout` against this. */
|
|
4
|
-
declare const WAKATIME_LAYOUTS: readonly [
|
|
4
|
+
declare const WAKATIME_LAYOUTS: readonly ['compact', 'normal'];
|
|
5
5
|
type WakaTimeLayout = (typeof WAKATIME_LAYOUTS)[number];
|
|
6
6
|
/** How a language's time is written; the api validates `display_format` against this. */
|
|
7
|
-
declare const DISPLAY_FORMATS: readonly [
|
|
7
|
+
declare const DISPLAY_FORMATS: readonly ['time', 'percent'];
|
|
8
8
|
type DisplayFormat = (typeof DISPLAY_FORMATS)[number];
|
|
9
9
|
interface WakaTimeOptions extends CommonCardOptions {
|
|
10
10
|
locale: string;
|
|
@@ -22,10 +22,19 @@ interface WakaTimeOptions extends CommonCardOptions {
|
|
|
22
22
|
/**
|
|
23
23
|
* Renders WakaTime card.
|
|
24
24
|
*
|
|
25
|
-
* @param stats WakaTime stats.
|
|
26
|
-
* @param options Card options.
|
|
27
25
|
* @returns WakaTime card SVG.
|
|
28
26
|
*/
|
|
29
|
-
declare const
|
|
30
|
-
|
|
27
|
+
declare const renderCard: (stats?: Partial<WakaTimeData>, options?: CardOptions<WakaTimeOptions>) => string;
|
|
28
|
+
/**
|
|
29
|
+
* The card, and the values each of its options accepts, keyed by the option's own name.
|
|
30
|
+
* They ride on the renderer so a list cannot be found without what draws it;
|
|
31
|
+
* the api handler forwards them onto its own export, which is what a UI reads.
|
|
32
|
+
*/
|
|
33
|
+
declare const renderWakatimeCard: typeof renderCard & {
|
|
34
|
+
OPTIONS: {
|
|
35
|
+
layout: readonly ["compact", "normal"];
|
|
36
|
+
display_format: readonly ["time", "percent"];
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export { renderWakatimeCard };
|
|
31
40
|
//# sourceMappingURL=wakatime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wakatime.d.ts","sourceRoot":"","sources":["../../src/cards/wakatime.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"wakatime.d.ts","sourceRoot":"","sources":["../../src/cards/wakatime.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,sBAAsB,CAAC;AAKvE,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAWnE,0EAA0E;AAC1E,QAAA,MAAM,gBAAgB,YAAI,SAAS,EAAE,QAAQ,CAAU,CAAC;AACxD,KAAK,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,yFAAyF;AACzF,QAAA,MAAM,eAAe,YAAI,MAAM,EAAE,SAAS,CAAU,CAAC;AACrD,KAAK,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD,UAAU,eAAgB,SAAQ,iBAAiB;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,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;AAgND;;;;GAIG;AACH,QAAA,MAAM,UAAU,WACP,OAAO,CAAC,YAAY,CAAC,YACnB,WAAW,CAAC,eAAe,CAAC,KACpC,MAiNF,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,kBAAkB;;QAEpB,MAAM;QACN,cAAc;;CAEhB,CAAC;AAEH,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/build/cards/wakatime.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { CARD_ICON, CARD_WIDTH, FONT_WEIGHT, firefoxFontSize, font } from '../common/brand.js';
|
|
1
2
|
import { Card } from '../common/Card.js';
|
|
2
3
|
import { getLightDarkColors, isPrefixedHexColor } from '../common/color.js';
|
|
3
|
-
import { encodeHTML } from '../common/html.js';
|
|
4
4
|
import { I18n } from '../common/I18n.js';
|
|
5
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 { atRule, el, rule } from '../markup/index.js';
|
|
8
9
|
import { wakatimeCardLocales } from '../translations.js';
|
|
9
|
-
const DEFAULT_CARD_WIDTH =
|
|
10
|
+
const DEFAULT_CARD_WIDTH = CARD_WIDTH.wide;
|
|
10
11
|
const MIN_CARD_WIDTH = 250;
|
|
11
12
|
const COMPACT_LAYOUT_MIN_WIDTH = 400;
|
|
12
13
|
const DEFAULT_LINE_HEIGHT = 25;
|
|
@@ -21,62 +22,34 @@ const DISPLAY_FORMATS = ['time', 'percent'];
|
|
|
21
22
|
/**
|
|
22
23
|
* Creates the no coding activity SVG node.
|
|
23
24
|
*
|
|
24
|
-
* @param props The function properties.
|
|
25
|
-
* @param props.text No coding activity translated text.
|
|
26
25
|
* @returns No coding activity SVG node string.
|
|
27
26
|
*/
|
|
28
|
-
const noCodingActivityNode = ({ text }) => {
|
|
29
|
-
return `
|
|
30
|
-
<text x="25" y="11" class="stat bold">${encodeHTML(text)}</text>
|
|
31
|
-
`;
|
|
32
|
-
};
|
|
27
|
+
const noCodingActivityNode = ({ text }) => el('text', { x: 25, y: 11, class: 'stat bold' }, text);
|
|
33
28
|
/**
|
|
34
29
|
* Format language value.
|
|
35
30
|
*
|
|
36
|
-
* @param args The function arguments.
|
|
37
|
-
* @param args.lang The language object.
|
|
38
|
-
* @param args.display_format The display format of the language node.
|
|
39
31
|
* @returns The formatted language value.
|
|
40
32
|
*/
|
|
41
|
-
const formatLanguageValue = ({ display_format, lang, }) => {
|
|
42
|
-
return display_format === 'percent' ? `${lang.percent.toFixed(2)} %` : lang.text;
|
|
43
|
-
};
|
|
33
|
+
const formatLanguageValue = ({ display_format, lang, }) => (display_format === 'percent' ? `${lang.percent.toFixed(2)} %` : lang.text);
|
|
44
34
|
/**
|
|
45
35
|
* Create compact WakaTime layout.
|
|
46
36
|
*
|
|
47
|
-
* @param args The function arguments.
|
|
48
|
-
* @param args.lang The languages array.
|
|
49
|
-
* @param args.x The x position of the language node.
|
|
50
|
-
* @param args.y The y position of the language node.
|
|
51
|
-
* @param args.display_format The display format of the language node.
|
|
52
37
|
* @returns The compact layout language SVG node.
|
|
53
38
|
*/
|
|
54
39
|
const createCompactLangNode = ({ lang, x, y, display_format, }) => {
|
|
55
40
|
if (!Number.isFinite(x)) {
|
|
56
|
-
throw new
|
|
41
|
+
throw new TypeError(`Invalid x: "${x}"`);
|
|
57
42
|
}
|
|
58
43
|
if (!Number.isFinite(y)) {
|
|
59
|
-
throw new
|
|
44
|
+
throw new TypeError(`Invalid y: "${y}"`);
|
|
60
45
|
}
|
|
61
46
|
const color = getLanguageColor(lang.name);
|
|
62
47
|
const value = formatLanguageValue({ display_format, lang });
|
|
63
|
-
return `
|
|
64
|
-
<g transform="translate(${x}, ${y})">
|
|
65
|
-
<circle cx="5" cy="6" r="5" fill="${color}" />
|
|
66
|
-
<text data-testid="lang-name" x="15" y="10" class='lang-name'>
|
|
67
|
-
${encodeHTML(lang.name)} - ${encodeHTML(value)}
|
|
68
|
-
</text>
|
|
69
|
-
</g>
|
|
70
|
-
`;
|
|
48
|
+
return el('g', { transform: `translate(${x}, ${y})` }, el('circle', { cx: 5, cy: 6, r: 5, fill: color }), el('text', { 'data-testid': 'lang-name', x: 15, y: 10, class: 'lang-name' }, `${lang.name} - ${value}`));
|
|
71
49
|
};
|
|
72
50
|
/**
|
|
73
51
|
* Create WakaTime language text node item.
|
|
74
52
|
*
|
|
75
|
-
* @param args The function arguments.
|
|
76
|
-
* @param args.langs The language objects.
|
|
77
|
-
* @param args.y The y position of the language node.
|
|
78
|
-
* @param args.display_format The display format of the language node.
|
|
79
|
-
* @param args.card_width Width in px of the card.
|
|
80
53
|
* @returns The language text node items.
|
|
81
54
|
*/
|
|
82
55
|
const createLanguageTextNode = ({ langs, y, display_format, card_width, }) => {
|
|
@@ -97,95 +70,73 @@ const createLanguageTextNode = ({ langs, y, display_format, card_width, }) => {
|
|
|
97
70
|
/**
|
|
98
71
|
* Create WakaTime text item.
|
|
99
72
|
*
|
|
100
|
-
* @param args The function arguments.
|
|
101
|
-
* @param args.id The id of the text node item.
|
|
102
|
-
* @param args.label The label of the text node item.
|
|
103
|
-
* @param args.value The value of the text node item.
|
|
104
|
-
* @param args.index The index of the text node item.
|
|
105
|
-
* @param args.percent Percentage of the text node item.
|
|
106
|
-
* @param args.hideProgress Whether to hide the progress bar.
|
|
107
|
-
* @param args.progressBarWidth The width of the progress bar.
|
|
108
73
|
* @returns The text SVG node.
|
|
109
74
|
*/
|
|
110
75
|
const createTextNode = ({ id, label, value, index, percent, hideProgress, progressBarWidth, }) => {
|
|
111
76
|
if (!Number.isFinite(index)) {
|
|
112
|
-
throw new
|
|
77
|
+
throw new TypeError(`Invalid index: "${index}"`);
|
|
113
78
|
}
|
|
114
79
|
if (!Number.isFinite(progressBarWidth)) {
|
|
115
|
-
throw new
|
|
80
|
+
throw new TypeError(`Invalid progressBarWidth: "${progressBarWidth}"`);
|
|
116
81
|
}
|
|
117
82
|
const staggerDelay = (index + 3) * 150;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
:
|
|
83
|
+
return el('g', {
|
|
84
|
+
class: 'stagger',
|
|
85
|
+
style: `animation-delay: ${staggerDelay}ms`,
|
|
86
|
+
transform: 'translate(25, 0)',
|
|
87
|
+
}, el('text', { class: 'stat bold', y: 12.5, 'data-testid': id }, `${label}:`), el('text', {
|
|
88
|
+
class: 'stat',
|
|
89
|
+
x: hideProgress ? HIDDEN_PROGRESSBAR_PADDING : PROGRESSBAR_PADDING + progressBarWidth,
|
|
90
|
+
y: 12.5,
|
|
91
|
+
}, value), !hideProgress &&
|
|
92
|
+
createProgressNode({
|
|
121
93
|
x: 110,
|
|
122
94
|
y: 4,
|
|
123
95
|
progress: percent,
|
|
124
96
|
width: progressBarWidth,
|
|
125
97
|
delay: staggerDelay + 300,
|
|
126
|
-
});
|
|
127
|
-
return `
|
|
128
|
-
<g class="stagger" style="animation-delay: ${staggerDelay}ms" transform="translate(25, 0)">
|
|
129
|
-
<text class="stat bold" y="12.5" data-testid="${encodeHTML(id)}">${encodeHTML(label)}:</text>
|
|
130
|
-
<text
|
|
131
|
-
class="stat"
|
|
132
|
-
x="${hideProgress ? HIDDEN_PROGRESSBAR_PADDING : PROGRESSBAR_PADDING + progressBarWidth}"
|
|
133
|
-
y="12.5"
|
|
134
|
-
>${encodeHTML(value)}</text>
|
|
135
|
-
${String(cardProgress)}
|
|
136
|
-
</g>
|
|
137
|
-
`;
|
|
98
|
+
}));
|
|
138
99
|
};
|
|
139
100
|
/**
|
|
140
101
|
* Recalculating percentages so that, compact layout's progress bar does not break when
|
|
141
102
|
* hiding languages.
|
|
142
|
-
*
|
|
143
|
-
* @param languages The languages array.
|
|
144
103
|
*/
|
|
145
104
|
const recalculatePercentages = (languages) => {
|
|
146
|
-
const totalSum = languages.reduce((
|
|
147
|
-
const weight =
|
|
148
|
-
|
|
149
|
-
language.percent =
|
|
150
|
-
}
|
|
105
|
+
const totalSum = languages.reduce((sum, language) => sum + language.percent, 0);
|
|
106
|
+
const weight = Number((100 / totalSum).toFixed(2));
|
|
107
|
+
for (const language of languages) {
|
|
108
|
+
language.percent = Number((language.percent * weight).toFixed(2));
|
|
109
|
+
}
|
|
151
110
|
};
|
|
152
111
|
/**
|
|
153
112
|
* Retrieves CSS styles for a card.
|
|
154
113
|
*
|
|
155
|
-
* @param colors The colors to use for the card.
|
|
156
|
-
* @param colors.textColor The text color.
|
|
157
114
|
* @returns Card CSS styles.
|
|
158
115
|
*/
|
|
159
116
|
const getStyles = ({ textColor }) => {
|
|
160
117
|
if (!isPrefixedHexColor(textColor)) {
|
|
161
118
|
throw new Error(`Invalid text color: "${textColor}"`);
|
|
162
119
|
}
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
animation: fadeInAnimation 0.3s ease-in-out forwards;
|
|
174
|
-
}
|
|
175
|
-
.not_bold { font-weight: 400 }
|
|
176
|
-
.bold { font-weight: 700 }
|
|
177
|
-
`;
|
|
120
|
+
return [
|
|
121
|
+
rule('.stat', {
|
|
122
|
+
font: font('regular', 'body'),
|
|
123
|
+
fill: textColor,
|
|
124
|
+
}),
|
|
125
|
+
firefoxFontSize(['.stat'], 'small'),
|
|
126
|
+
rule('.stagger', { opacity: 0, animation: 'fadeInAnimation 0.3s ease-in-out forwards' }),
|
|
127
|
+
rule('.not_bold', { 'font-weight': FONT_WEIGHT.regular }),
|
|
128
|
+
rule('.bold', { 'font-weight': FONT_WEIGHT.semibold }),
|
|
129
|
+
];
|
|
178
130
|
};
|
|
131
|
+
/** A bar the same color as the text behind it would be invisible, so it goes transparent. */
|
|
132
|
+
const progressBackground = (titleColor, textColor) => textColor === titleColor ? '#fff0' : textColor;
|
|
179
133
|
/**
|
|
180
134
|
* Normalize incoming width (string or number) and clamp to minimum.
|
|
181
135
|
*
|
|
182
|
-
* @param args The function arguments.
|
|
183
|
-
* @param args.layout The incoming layout value.
|
|
184
|
-
* @param args.value The incoming width value.
|
|
185
136
|
* @returns The normalized width value.
|
|
186
137
|
*/
|
|
187
138
|
const normalizeCardWidth = ({ value, layout, }) => {
|
|
188
|
-
if (value === undefined || isNaN(value)) {
|
|
139
|
+
if (value === undefined || Number.isNaN(value)) {
|
|
189
140
|
return DEFAULT_CARD_WIDTH;
|
|
190
141
|
}
|
|
191
142
|
return Math.max(layout === 'compact' ? COMPACT_LAYOUT_MIN_WIDTH : MIN_CARD_WIDTH, value);
|
|
@@ -193,11 +144,9 @@ const normalizeCardWidth = ({ value, layout, }) => {
|
|
|
193
144
|
/**
|
|
194
145
|
* Renders WakaTime card.
|
|
195
146
|
*
|
|
196
|
-
* @param stats WakaTime stats.
|
|
197
|
-
* @param options Card options.
|
|
198
147
|
* @returns WakaTime card SVG.
|
|
199
148
|
*/
|
|
200
|
-
const
|
|
149
|
+
const renderCard = (stats = {}, options = {}) => {
|
|
201
150
|
let { languages = [] } = stats;
|
|
202
151
|
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;
|
|
203
152
|
const normalizedWidth = normalizeCardWidth({ value: card_width, layout });
|
|
@@ -214,14 +163,13 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
214
163
|
locale,
|
|
215
164
|
translations: wakatimeCardLocales,
|
|
216
165
|
});
|
|
217
|
-
const lheight = parseInt(String(line_height), 10);
|
|
166
|
+
const lheight = Number.parseInt(String(line_height), 10);
|
|
218
167
|
const langsCount = clampValue(langs_count, 1, langs_count);
|
|
219
168
|
const { lightColors, darkColors } = getLightDarkColors(options);
|
|
220
169
|
const filteredLanguages = languages
|
|
221
170
|
.filter((language) => language.hours || language.minutes)
|
|
222
171
|
.slice(0, langsCount);
|
|
223
|
-
//
|
|
224
|
-
// but if rank circle is visible clamp the minimum height to `150`
|
|
172
|
+
// A short language list would otherwise draw a stub card, so 150 is the floor.
|
|
225
173
|
let height = Math.max(45 + (filteredLanguages.length + 1) * lheight, 150);
|
|
226
174
|
let finalLayout;
|
|
227
175
|
// RENDER COMPACT LAYOUT
|
|
@@ -231,60 +179,58 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
231
179
|
// progressOffset holds the previous language's width and used to offset the next language
|
|
232
180
|
// so that we can stack them one after another, like this: [--][----][---]
|
|
233
181
|
let progressOffset = 0;
|
|
234
|
-
const compactProgressBar = filteredLanguages
|
|
235
|
-
.map((language) => {
|
|
182
|
+
const compactProgressBar = filteredLanguages.map((language) => {
|
|
236
183
|
const progress = ((width - COMPACT_LAYOUT_PROGRESSBAR_PADDING) * language.percent) / 100;
|
|
237
|
-
const
|
|
238
|
-
const output = `
|
|
239
|
-
<rect
|
|
240
|
-
mask="url(#rect-mask)"
|
|
241
|
-
data-testid="lang-progress"
|
|
242
|
-
x="${progressOffset}"
|
|
243
|
-
y="0"
|
|
244
|
-
width="${progress}"
|
|
245
|
-
height="8"
|
|
246
|
-
fill="${languageColor}"
|
|
247
|
-
/>
|
|
248
|
-
`;
|
|
184
|
+
const x = progressOffset;
|
|
249
185
|
progressOffset += progress;
|
|
250
|
-
return
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
186
|
+
return el('rect', {
|
|
187
|
+
mask: 'url(#rect-mask)',
|
|
188
|
+
'data-testid': 'lang-progress',
|
|
189
|
+
x,
|
|
190
|
+
y: 0,
|
|
191
|
+
width: progress,
|
|
192
|
+
height: 8,
|
|
193
|
+
fill: getLanguageColor(language.name),
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
finalLayout = [
|
|
197
|
+
el('mask', { id: 'rect-mask' }, el('rect', {
|
|
198
|
+
x: COMPACT_LAYOUT_PROGRESSBAR_PADDING,
|
|
199
|
+
y: 0,
|
|
200
|
+
width: width - 2 * COMPACT_LAYOUT_PROGRESSBAR_PADDING,
|
|
201
|
+
height: 8,
|
|
202
|
+
fill: 'white',
|
|
203
|
+
rx: 5,
|
|
204
|
+
})),
|
|
205
|
+
compactProgressBar,
|
|
206
|
+
filteredLanguages.length > 0
|
|
207
|
+
? createLanguageTextNode({
|
|
208
|
+
y: 25,
|
|
209
|
+
langs: filteredLanguages,
|
|
210
|
+
display_format,
|
|
211
|
+
card_width: normalizedWidth,
|
|
212
|
+
})
|
|
213
|
+
: noCodingActivityNode({
|
|
214
|
+
text: stats.is_coding_activity_visible
|
|
215
|
+
? stats.is_other_usage_visible
|
|
216
|
+
? i18n.t('wakatimecard.nocodingactivity')
|
|
217
|
+
: i18n.t('wakatimecard.nocodedetails')
|
|
218
|
+
: i18n.t('wakatimecard.notpublic'),
|
|
219
|
+
}),
|
|
220
|
+
];
|
|
273
221
|
}
|
|
274
222
|
else {
|
|
275
223
|
finalLayout = flexLayout({
|
|
276
|
-
items: filteredLanguages.length
|
|
277
|
-
? filteredLanguages.map((language, index) => {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
});
|
|
287
|
-
})
|
|
224
|
+
items: filteredLanguages.length > 0
|
|
225
|
+
? filteredLanguages.map((language, index) => createTextNode({
|
|
226
|
+
id: language.name,
|
|
227
|
+
label: language.name,
|
|
228
|
+
value: formatLanguageValue({ display_format, lang: language }),
|
|
229
|
+
index,
|
|
230
|
+
percent: language.percent,
|
|
231
|
+
hideProgress: hide_progress,
|
|
232
|
+
progressBarWidth: normalizedWidth - TOTAL_TEXT_WIDTH,
|
|
233
|
+
}))
|
|
288
234
|
: [
|
|
289
235
|
noCodingActivityNode({
|
|
290
236
|
text: stats.is_coding_activity_visible
|
|
@@ -296,21 +242,27 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
296
242
|
],
|
|
297
243
|
gap: lheight,
|
|
298
244
|
direction: 'column',
|
|
299
|
-
})
|
|
245
|
+
});
|
|
300
246
|
}
|
|
301
247
|
// Get title range text
|
|
302
248
|
let titleText = i18n.t('wakatimecard.title');
|
|
303
249
|
switch (stats.range) {
|
|
304
|
-
case 'last_7_days':
|
|
250
|
+
case 'last_7_days': {
|
|
305
251
|
titleText += ` (${i18n.t('wakatimecard.last7days')})`;
|
|
306
252
|
break;
|
|
307
|
-
|
|
253
|
+
}
|
|
254
|
+
case 'last_year': {
|
|
308
255
|
titleText += ` (${i18n.t('wakatimecard.lastyear')})`;
|
|
309
256
|
break;
|
|
257
|
+
}
|
|
258
|
+
default: {
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
310
261
|
}
|
|
311
262
|
const card = new Card({
|
|
312
263
|
customTitle: custom_title,
|
|
313
264
|
defaultTitle: titleText,
|
|
265
|
+
titlePrefixIcon: CARD_ICON.wakatime,
|
|
314
266
|
width: normalizedWidth,
|
|
315
267
|
height,
|
|
316
268
|
border_radius,
|
|
@@ -322,55 +274,49 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
|
|
322
274
|
card.setHideBorder(hide_border);
|
|
323
275
|
card.setHideTitle(hide_title);
|
|
324
276
|
card.setCSS({
|
|
325
|
-
light: ({ titleColor, textColor }) =>
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
.lang-progress{
|
|
348
|
-
animation: growWidthAnimation 0.6s ease-in-out forwards;
|
|
349
|
-
fill: ${titleColor};
|
|
350
|
-
}
|
|
351
|
-
.progress-background { fill: ${textColor === titleColor ? '#fff0' /* transparent */ : textColor}; }
|
|
352
|
-
`,
|
|
353
|
-
dark: ({ titleColor, textColor }) => `
|
|
354
|
-
${getStyles({ textColor })}
|
|
355
|
-
.lang-name { fill: ${textColor} }
|
|
356
|
-
.lang-progress { fill: ${titleColor}; }
|
|
357
|
-
.progress-background { fill: ${textColor === titleColor ? '#fff0' /* transparent */ : textColor}; }
|
|
358
|
-
`,
|
|
277
|
+
light: ({ titleColor, textColor }) => [
|
|
278
|
+
getStyles({ textColor }),
|
|
279
|
+
atRule('@keyframes slideInAnimation', rule('from', { width: 0 }),
|
|
280
|
+
// Invalid on purpose — `calc` needs spaces around its `-`. Browsers drop the
|
|
281
|
+
// declaration and animate to the rect's own width, which is the reveal the mask wants.
|
|
282
|
+
rule('to', { width: 'calc(100%-100px)' })),
|
|
283
|
+
atRule('@keyframes growWidthAnimation', rule('from', { width: 0 }), rule('to', { width: '100%' })),
|
|
284
|
+
rule('.lang-name', { font: font('regular', 'micro'), fill: textColor }),
|
|
285
|
+
rule('#rect-mask rect', { animation: 'slideInAnimation 1s ease-in-out forwards' }),
|
|
286
|
+
rule('.lang-progress', {
|
|
287
|
+
animation: 'growWidthAnimation 0.6s ease-in-out forwards',
|
|
288
|
+
fill: titleColor,
|
|
289
|
+
}),
|
|
290
|
+
rule('.progress-background', { fill: progressBackground(titleColor, textColor) }),
|
|
291
|
+
],
|
|
292
|
+
dark: ({ titleColor, textColor }) => [
|
|
293
|
+
getStyles({ textColor }),
|
|
294
|
+
rule('.lang-name', { fill: textColor }),
|
|
295
|
+
rule('.lang-progress', { fill: titleColor }),
|
|
296
|
+
rule('.progress-background', { fill: progressBackground(titleColor, textColor) }),
|
|
297
|
+
],
|
|
359
298
|
});
|
|
360
299
|
// `role="img"` hides the inner text from assistive tech, so everything the card
|
|
361
300
|
// shows has to be repeated here.
|
|
362
301
|
card.setAccessibilityLabel({
|
|
363
302
|
title: card.title,
|
|
364
|
-
desc: filteredLanguages.length
|
|
303
|
+
desc: filteredLanguages.length > 0
|
|
365
304
|
? filteredLanguages
|
|
366
305
|
.map((lang) => `${lang.name}: ${formatLanguageValue({ display_format, lang })}`)
|
|
367
306
|
.join(', ')
|
|
368
307
|
: i18n.t('wakatimecard.nocodingactivity'),
|
|
369
308
|
});
|
|
370
|
-
return card.render(
|
|
371
|
-
<svg x="0" y="0" width="100%">
|
|
372
|
-
${finalLayout}
|
|
373
|
-
</svg>
|
|
374
|
-
`);
|
|
309
|
+
return card.render(el('svg', { x: 0, y: 0, width: '100%' }, finalLayout));
|
|
375
310
|
};
|
|
376
|
-
|
|
311
|
+
/**
|
|
312
|
+
* The card, and the values each of its options accepts, keyed by the option's own name.
|
|
313
|
+
* They ride on the renderer so a list cannot be found without what draws it;
|
|
314
|
+
* the api handler forwards them onto its own export, which is what a UI reads.
|
|
315
|
+
*/
|
|
316
|
+
const renderWakatimeCard = Object.assign(renderCard, {
|
|
317
|
+
OPTIONS: {
|
|
318
|
+
layout: WAKATIME_LAYOUTS,
|
|
319
|
+
display_format: DISPLAY_FORMATS,
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
export { renderWakatimeCard };
|
package/build/common/Card.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Child, CssChild, MarkupElement } from '../markup/index.ts';
|
|
2
|
+
import type { CardColors } from './color.ts';
|
|
2
3
|
/**
|
|
3
4
|
* Builds the card CSS for one color scheme from that scheme's resolved colors.
|
|
4
5
|
*/
|
|
5
|
-
type CardCSSBuilder = (colors: CardColors) =>
|
|
6
|
+
type CardCSSBuilder = (colors: CardColors) => Array<CssChild>;
|
|
6
7
|
declare class Card {
|
|
7
8
|
width: number;
|
|
8
9
|
height: number;
|
|
@@ -14,29 +15,16 @@ declare class Card {
|
|
|
14
15
|
dark: CardColors | null;
|
|
15
16
|
};
|
|
16
17
|
title: string;
|
|
17
|
-
css:
|
|
18
|
-
darkCss:
|
|
18
|
+
css: Array<CssChild>;
|
|
19
|
+
darkCss: Array<CssChild>;
|
|
19
20
|
paddingX: number;
|
|
20
21
|
paddingY: number;
|
|
21
|
-
titlePrefixIcon:
|
|
22
|
+
titlePrefixIcon: Child;
|
|
22
23
|
animations: boolean;
|
|
23
24
|
a11yTitle: string;
|
|
24
25
|
a11yDesc: string;
|
|
25
26
|
/**
|
|
26
27
|
* Creates a new card instance.
|
|
27
|
-
*
|
|
28
|
-
* The caller must ensure that the passed `titlePrefixIcon` is properly sanitized!
|
|
29
|
-
*
|
|
30
|
-
* @param props Card arguments.
|
|
31
|
-
* @param props.width Card width.
|
|
32
|
-
* @param props.height Card height.
|
|
33
|
-
* @param props.border_radius Card border radius.
|
|
34
|
-
* @param props.colors Card colors for light and dark mode.
|
|
35
|
-
* @param props.colors.light Card colors for light mode.
|
|
36
|
-
* @param props.colors.dark Card colors for dark mode, or `null` when no dark-mode override is needed.
|
|
37
|
-
* @param props.customTitle Card custom title.
|
|
38
|
-
* @param props.defaultTitle Card default title.
|
|
39
|
-
* @param props.titlePrefixIcon Sanitized card title prefix icon.
|
|
40
28
|
*/
|
|
41
29
|
constructor({ width, height, border_radius, colors, customTitle, defaultTitle, titlePrefixIcon, }: {
|
|
42
30
|
width?: number;
|
|
@@ -48,14 +36,9 @@ declare class Card {
|
|
|
48
36
|
};
|
|
49
37
|
customTitle?: string | undefined;
|
|
50
38
|
defaultTitle?: string;
|
|
51
|
-
titlePrefixIcon?:
|
|
39
|
+
titlePrefixIcon?: Child;
|
|
52
40
|
});
|
|
53
41
|
disableAnimations(): void;
|
|
54
|
-
/**
|
|
55
|
-
* @param props The props object.
|
|
56
|
-
* @param props.title Accessibility title.
|
|
57
|
-
* @param props.desc Accessibility description.
|
|
58
|
-
*/
|
|
59
42
|
setAccessibilityLabel({ title, desc }: {
|
|
60
43
|
title: string;
|
|
61
44
|
desc: string;
|
|
@@ -66,56 +49,34 @@ declare class Card {
|
|
|
66
49
|
* Each builder receives the colors of its own color scheme,
|
|
67
50
|
* so a card never handles a missing dark palette itself:
|
|
68
51
|
* `dark` runs only when the card has dark colors, and always with non-null ones.
|
|
69
|
-
*
|
|
70
|
-
* @warning The caller must ensure that the returned CSS strings are properly sanitized!
|
|
71
|
-
*
|
|
72
|
-
* @param props The props object.
|
|
73
|
-
* @param props.light Builds the CSS applied unconditionally (light/default mode).
|
|
74
|
-
* @param props.dark Builds the CSS placed inside a `@media (prefers-color-scheme: dark)` block.
|
|
75
52
|
*/
|
|
76
53
|
setCSS({ light, dark }: {
|
|
77
54
|
light: CardCSSBuilder;
|
|
78
55
|
dark: CardCSSBuilder;
|
|
79
56
|
}): void;
|
|
80
|
-
/**
|
|
81
|
-
* @param value Whether to hide the border or not.
|
|
82
|
-
*/
|
|
83
57
|
setHideBorder(value: boolean): void;
|
|
84
|
-
/**
|
|
85
|
-
* @param value Whether to hide the title or not.
|
|
86
|
-
*/
|
|
87
58
|
setHideTitle(value: boolean): void;
|
|
88
|
-
/**
|
|
89
|
-
* @param text The title to set.
|
|
90
|
-
*/
|
|
91
59
|
setTitle(text: string): void;
|
|
60
|
+
/** @returns The rendered card title. */
|
|
61
|
+
renderTitle(): MarkupElement;
|
|
62
|
+
/** Where the body starts, and so where the title band ends. */
|
|
63
|
+
private get bodyOffset();
|
|
92
64
|
/**
|
|
93
|
-
*
|
|
94
|
-
|
|
95
|
-
renderTitle(): string;
|
|
96
|
-
/**
|
|
97
|
-
* @returns The rendered card gradient.
|
|
98
|
-
*/
|
|
99
|
-
renderGradient(): string;
|
|
100
|
-
/**
|
|
101
|
-
* Retrieves css animations for a card.
|
|
65
|
+
* The band behind the title. Its top corners follow the card's own and its bottom
|
|
66
|
+
* ones stay square, so it meets the body as an edge rather than a floating box.
|
|
102
67
|
*
|
|
103
|
-
* @returns
|
|
68
|
+
* @returns The rendered title band.
|
|
104
69
|
*/
|
|
105
|
-
|
|
70
|
+
private renderTitleBand;
|
|
71
|
+
/** @returns The card's gradient definitions, or nothing when no color is a gradient. */
|
|
72
|
+
renderGradient(): Child;
|
|
106
73
|
/**
|
|
107
74
|
* Builds the @media (prefers-color-scheme: dark) CSS block for the card.
|
|
108
|
-
* Returns
|
|
75
|
+
* Returns nothing when no dark colors are set.
|
|
109
76
|
*/
|
|
110
77
|
private renderDarkMediaBlock;
|
|
111
|
-
/**
|
|
112
|
-
|
|
113
|
-
*
|
|
114
|
-
* @param body The sanitized inner body of the card.
|
|
115
|
-
* @returns The rendered card.
|
|
116
|
-
*/
|
|
117
|
-
render(body: string): string;
|
|
78
|
+
/** @returns The rendered card. */
|
|
79
|
+
render(body: Child): string;
|
|
118
80
|
}
|
|
119
81
|
export { Card };
|
|
120
|
-
export default Card;
|
|
121
82
|
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/common/Card.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/common/Card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;GAEG;AACH,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC;AA2C9D,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,KAAK,CAAC,QAAQ,CAAC,CAAC;IACrB,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,KAAK,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,YAAY,EACV,KAAW,EACX,MAAY,EACZ,aAAiB,EACjB,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,KAAK,CAAC;KACzB,EAqBA;IAED,iBAAiB,IAAI,IAAI,CAExB;IAED,qBAAqB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAG5E;IAED;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAAE,KAAK,EAAE,cAAc,CAAC;QAAC,IAAI,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI,CAG7E;IAED,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAElC;IAED,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAQjC;IAED,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE3B;IAED,wCAAwC;IACxC,WAAW,IAAI,aAAa,CAqC3B;IAED,+DAA+D;IAC/D,OAAO,KAAK,UAAU,GAErB;IAED;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAYvB,wFAAwF;IACxF,cAAc,IAAI,KAAK,CAwBtB;IAED;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAqB5B,kCAAkC;IAClC,MAAM,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM,CAoF1B;CACF;AAED,OAAO,EAAE,IAAI,EAAE,CAAC"}
|