@@ -39,53 +39,46 @@ const getLongestLang = (arr) =>
39
39
* Creates a node to display usage of a programming language in percentage
40
40
* using text and a horizontal progress bar.
41
41
*
42
- * @param {object } props Function properties.
42
+ * @param {object[] } props Function properties.
43
43
* @param {number } props.width The card width
44
44
* @param {string } props.name Name of the programming language.
45
45
* @param {string } props.color Color of the programming language.
46
46
* @param {string } props.progress Usage of the programming language in percentage.
47
- * @param {number } props.index Index of the programming language.
48
47
* @returns {string } Programming language SVG node.
49
48
*/
50
- const createProgressTextNode = ( { width, color, name, progress, index } ) => {
51
- const staggerDelay = ( index + 3 ) * 150 ;
49
+ const createProgressTextNode = ( { width, color, name, progress } ) => {
52
50
const paddingRight = 95 ;
53
51
const progressTextX = width - paddingRight + 10 ;
54
52
const progressWidth = width - paddingRight ;
55
53
56
54
return `
57
- <g class="stagger" style="animation-delay: ${ staggerDelay } ms">
58
- <text data-testid="lang-name" x="2" y="15" class="lang-name">${ name } </text>
59
- <text x="${ progressTextX } " y="34" class="lang-name">${ progress } %</text>
60
- ${ createProgressNode ( {
61
- x : 0 ,
62
- y : 25 ,
63
- color,
64
- width : progressWidth ,
65
- progress,
66
- progressBarBackgroundColor : "#ddd" ,
67
- delay : staggerDelay + 300 ,
68
- } ) }
69
- </g>
55
+ <text data-testid="lang-name" x="2" y="15" class="lang-name">${ name } </text>
56
+ <text x="${ progressTextX } " y="34" class="lang-name">${ progress } %</text>
57
+ ${ createProgressNode ( {
58
+ x : 0 ,
59
+ y : 25 ,
60
+ color,
61
+ width : progressWidth ,
62
+ progress,
63
+ progressBarBackgroundColor : "#ddd" ,
64
+ } ) }
70
65
` ;
71
66
} ;
72
67
73
68
/**
74
69
* Creates a text only node to display usage of a programming language in percentage.
75
70
*
76
- * @param {object } props Function properties.
71
+ * @param {object[] } props Function properties.
77
72
* @param {Lang } props.lang Programming language object.
78
73
* @param {number } props.totalSize Total size of all languages.
79
- * @param {number } props.index Index of the programming language.
80
74
* @returns {string } Compact layout programming language SVG node.
81
75
*/
82
- const createCompactLangNode = ( { lang, totalSize, index } ) => {
76
+ const createCompactLangNode = ( { lang, totalSize } ) => {
83
77
const percentage = ( ( lang . size / totalSize ) * 100 ) . toFixed ( 2 ) ;
84
- const staggerDelay = ( index + 3 ) * 150 ;
85
78
const color = lang . color || "#858585" ;
86
79
87
80
return `
88
- <g class="stagger" style="animation-delay: ${ staggerDelay } ms" >
81
+ <g>
89
82
<circle cx="5" cy="6" r="5" fill="${ color } " />
90
83
<text data-testid="lang-name" x="15" y="10" class='lang-name'>
91
84
${ lang . name } ${ percentage } %
@@ -111,6 +104,7 @@ const createLanguageTextNode = ({ langs, totalSize }) => {
111
104
createCompactLangNode ( {
112
105
lang,
113
106
totalSize,
107
+ // @ts -ignore
114
108
index,
115
109
} ) ,
116
110
) ;
@@ -140,13 +134,12 @@ const createLanguageTextNode = ({ langs, totalSize }) => {
140
134
*/
141
135
const renderNormalLayout = ( langs , width , totalLanguageSize ) => {
142
136
return flexLayout ( {
143
- items : langs . map ( ( lang , index ) => {
137
+ items : langs . map ( ( lang ) => {
144
138
return createProgressTextNode ( {
145
- width,
139
+ width : width ,
146
140
name : lang . name ,
147
141
color : lang . color || DEFAULT_LANG_COLOR ,
148
142
progress : ( ( lang . size / totalLanguageSize ) * 100 ) . toFixed ( 2 ) ,
149
- index,
150
143
} ) ;
151
144
} ) ,
152
145
gap : 40 ,
@@ -194,7 +187,7 @@ const renderCompactLayout = (langs, width, totalLanguageSize) => {
194
187
195
188
return `
196
189
<mask id="rect-mask">
197
- <rect x="0" y="0" width="${ offsetWidth } " height="8" fill="white" rx="5"/>
190
+ <rect x="0" y="0" width="${ offsetWidth } " height="8" fill="white" rx="5" />
198
191
</mask>
199
192
${ compactProgressBar }
200
193
@@ -283,7 +276,6 @@ const renderTopLanguages = (topLangs, options = {}) => {
283
276
langs_count = DEFAULT_LANGS_COUNT ,
284
277
border_radius,
285
278
border_color,
286
- disable_animations,
287
279
} = options ;
288
280
289
281
const i18n = new I18n ( {
@@ -332,43 +324,11 @@ const renderTopLanguages = (topLangs, options = {}) => {
332
324
colors,
333
325
} ) ;
334
326
335
- if ( disable_animations ) card . disableAnimations ( ) ;
336
-
327
+ card . disableAnimations ( ) ;
337
328
card . setHideBorder ( hide_border ) ;
338
329
card . setHideTitle ( hide_title ) ;
339
330
card . setCSS (
340
- `
341
- @keyframes slideInAnimation {
342
- from {
343
- width: 0;
344
- }
345
- to {
346
- width: calc(100%-100px);
347
- }
348
- }
349
- @keyframes growWidthAnimation {
350
- from {
351
- width: 0;
352
- }
353
- to {
354
- width: 100%;
355
- }
356
- }
357
- .lang-name {
358
- font: 400 11px "Segoe UI", Ubuntu, Sans-Serif;
359
- fill: ${ colors . textColor } ;
360
- }
361
- .stagger {
362
- opacity: 0;
363
- animation: fadeInAnimation 0.3s ease-in-out forwards;
364
- }
365
- #rect-mask rect{
366
- animation: slideInAnimation 1s ease-in-out forwards;
367
- }
368
- .lang-progress{
369
- animation: growWidthAnimation 0.6s ease-in-out forwards;
370
- }
371
- ` ,
331
+ `.lang-name { font: 400 11px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${ colors . textColor } }` ,
372
332
) ;
373
333
374
334
return card . render ( `
0 commit comments