@@ -39,41 +39,36 @@ 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
74
* @param {boolean } props.hideProgress Whether to hide percentage.
@@ -82,11 +77,10 @@ const createProgressTextNode = ({ width, color, name, progress, index }) => {
82
77
*/
83
78
const createCompactLangNode = ( { lang, totalSize, hideProgress, index } ) => {
84
79
const percentage = ( ( lang . size / totalSize ) * 100 ) . toFixed ( 2 ) ;
85
- const staggerDelay = ( index + 3 ) * 150 ;
86
80
const color = lang . color || "#858585" ;
87
81
88
82
return `
89
- <g class="stagger" style="animation-delay: ${ staggerDelay } ms" >
83
+ <g>
90
84
<circle cx="5" cy="6" r="5" fill="${ color } " />
91
85
<text data-testid="lang-name" x="15" y="10" class='lang-name'>
92
86
${ lang . name } ${ hideProgress ? "" : percentage + "%" }
@@ -143,13 +137,12 @@ const createLanguageTextNode = ({ langs, totalSize, hideProgress }) => {
143
137
*/
144
138
const renderNormalLayout = ( langs , width , totalLanguageSize ) => {
145
139
return flexLayout ( {
146
- items : langs . map ( ( lang , index ) => {
140
+ items : langs . map ( ( lang ) => {
147
141
return createProgressTextNode ( {
148
- width,
142
+ width : width ,
149
143
name : lang . name ,
150
144
color : lang . color || DEFAULT_LANG_COLOR ,
151
145
progress : ( ( lang . size / totalLanguageSize ) * 100 ) . toFixed ( 2 ) ,
152
- index,
153
146
} ) ;
154
147
} ) ,
155
148
gap : 40 ,
@@ -294,7 +287,6 @@ const renderTopLanguages = (topLangs, options = {}) => {
294
287
langs_count = DEFAULT_LANGS_COUNT ,
295
288
border_radius,
296
289
border_color,
297
- disable_animations,
298
290
} = options ;
299
291
300
292
const i18n = new I18n ( {
@@ -348,43 +340,11 @@ const renderTopLanguages = (topLangs, options = {}) => {
348
340
colors,
349
341
} ) ;
350
342
351
- if ( disable_animations ) card . disableAnimations ( ) ;
352
-
343
+ card . disableAnimations ( ) ;
353
344
card . setHideBorder ( hide_border ) ;
354
345
card . setHideTitle ( hide_title ) ;
355
346
card . setCSS (
356
- `
357
- @keyframes slideInAnimation {
358
- from {
359
- width: 0;
360
- }
361
- to {
362
- width: calc(100%-100px);
363
- }
364
- }
365
- @keyframes growWidthAnimation {
366
- from {
367
- width: 0;
368
- }
369
- to {
370
- width: 100%;
371
- }
372
- }
373
- .lang-name {
374
- font: 400 11px "Segoe UI", Ubuntu, Sans-Serif;
375
- fill: ${ colors . textColor } ;
376
- }
377
- .stagger {
378
- opacity: 0;
379
- animation: fadeInAnimation 0.3s ease-in-out forwards;
380
- }
381
- #rect-mask rect{
382
- animation: slideInAnimation 1s ease-in-out forwards;
383
- }
384
- .lang-progress{
385
- animation: growWidthAnimation 0.6s ease-in-out forwards;
386
- }
387
- ` ,
347
+ `.lang-name { font: 400 11px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${ colors . textColor } }` ,
388
348
) ;
389
349
390
350
return card . render ( `
0 commit comments