@@ -12,7 +12,7 @@ import {
12
12
} from "../common/utils.js" ;
13
13
import { langCardLocales } from "../translations.js" ;
14
14
15
-
15
+ const DEFAULT_CARD_WIDTH = 300 ;
16
16
const MIN_CARD_WIDTH = 280 ;
17
17
const DEFAULT_LANG_COLOR = "#858585" ;
18
18
const CARD_PADDING = 25 ;
@@ -218,14 +218,14 @@ const createProgressTextNode = ({ width, color, name, progress, index }) => {
218
218
<text data-testid="lang-name" x="2" y="15" class="lang-name">${ name } </text>
219
219
<text x="${ progressTextX } " y="34" class="lang-name">${ progress } %</text>
220
220
${ createProgressNode ( {
221
- x : 0 ,
222
- y : 25 ,
223
- color,
224
- width : progressWidth ,
225
- progress,
226
- progressBarBackgroundColor : "#ddd" ,
227
- delay : staggerDelay + 300 ,
228
- } ) }
221
+ x : 0 ,
222
+ y : 25 ,
223
+ color,
224
+ width : progressWidth ,
225
+ progress,
226
+ progressBarBackgroundColor : "#ddd" ,
227
+ delay : staggerDelay + 300 ,
228
+ } ) }
229
229
</g>
230
230
` ;
231
231
} ;
@@ -382,22 +382,21 @@ const renderCompactLayout = (langs, width, totalLanguageSize, hideProgress) => {
382
382
. join ( "" ) ;
383
383
384
384
return `
385
- ${
386
- ! hideProgress
387
- ? `
388
- <mask id="rect-mask">
389
- <rect x="0" y="0" width="${ offsetWidth } " height="8" fill="white" rx="5"/>
390
- </mask>
391
- ${ compactProgressBar }
392
- `
393
- : ""
394
- }
385
+ ${ hideProgress
386
+ ? ""
387
+ : `
388
+ <mask id="rect-mask">
389
+ <rect x="0" y="0" width="${ offsetWidth } " height="8" fill="white" rx="5"/>
390
+ </mask>
391
+ ${ compactProgressBar }
392
+ `
393
+ }
395
394
<g transform="translate(0, ${ hideProgress ? "0" : "25" } )">
396
395
${ createLanguageTextNode ( {
397
- langs,
398
- totalSize : totalLanguageSize ,
399
- hideProgress,
400
- } ) }
396
+ langs,
397
+ totalSize : totalLanguageSize ,
398
+ hideProgress,
399
+ } ) }
401
400
</g>
402
401
` ;
403
402
} ;
@@ -431,7 +430,7 @@ const renderDonutVerticalLayout = (langs, totalLanguageSize) => {
431
430
432
431
circles . push ( `
433
432
<g class="stagger" style="animation-delay: ${ delay } ms">
434
- <circle
433
+ <circle
435
434
cx="150"
436
435
cy="100"
437
436
r="${ radius } "
@@ -462,10 +461,10 @@ const renderDonutVerticalLayout = (langs, totalLanguageSize) => {
462
461
<g transform="translate(0, 220)">
463
462
<svg data-testid="lang-names" x="${ CARD_PADDING } ">
464
463
${ createLanguageTextNode ( {
465
- langs,
466
- totalSize : totalLanguageSize ,
467
- hideProgress : false ,
468
- } ) }
464
+ langs,
465
+ totalSize : totalLanguageSize ,
466
+ hideProgress : false ,
467
+ } ) }
469
468
</svg>
470
469
</g>
471
470
</svg>
@@ -557,10 +556,10 @@ const renderPieLayout = (langs, totalLanguageSize) => {
557
556
<g transform="translate(0, 220)">
558
557
<svg data-testid="lang-names" x="${ CARD_PADDING } ">
559
558
${ createLanguageTextNode ( {
560
- langs,
561
- totalSize : totalLanguageSize ,
562
- hideProgress : false ,
563
- } ) }
559
+ langs,
560
+ totalSize : totalLanguageSize ,
561
+ hideProgress : false ,
562
+ } ) }
564
563
</svg>
565
564
</g>
566
565
</svg>
@@ -629,11 +628,11 @@ const renderDonutLayout = (langs, width, totalLanguageSize) => {
629
628
langs . length === 1
630
629
? `<circle cx="${ centerX } " cy="${ centerY } " r="${ radius } " stroke="${ colors [ 0 ] } " fill="none" stroke-width="${ strokeWidth } " data-testid="lang-donut" size="100"/>`
631
630
: langPaths
632
- . map ( ( section , index ) => {
633
- const staggerDelay = ( index + 3 ) * 100 ;
634
- const delay = staggerDelay + 300 ;
631
+ . map ( ( section , index ) => {
632
+ const staggerDelay = ( index + 3 ) * 100 ;
633
+ const delay = staggerDelay + 300 ;
635
634
636
- const output = `
635
+ const output = `
637
636
<g class="stagger" style="animation-delay: ${ delay } ms">
638
637
<path
639
638
data-testid="lang-donut"
@@ -646,9 +645,9 @@ const renderDonutLayout = (langs, width, totalLanguageSize) => {
646
645
</g>
647
646
` ;
648
647
649
- return output ;
650
- } )
651
- . join ( "" ) ;
648
+ return output ;
649
+ } )
650
+ . join ( "" ) ;
652
651
653
652
const donut = `<svg width="${ width } " height="${ width } ">${ donutPaths } </svg>` ;
654
653
@@ -681,8 +680,7 @@ const renderDonutLayout = (langs, width, totalLanguageSize) => {
681
680
*/
682
681
const noLanguagesDataNode = ( { color, text, layout } ) => {
683
682
return `
684
- <text x="${
685
- layout === "pie" || layout === "donut-vertical" ? CARD_PADDING : 0
683
+ <text x="${ layout === "pie" || layout === "donut-vertical" ? CARD_PADDING : 0
686
684
} " y="11" class="stat bold" fill="${ color } ">${ text } </text>
687
685
` ;
688
686
} ;
@@ -734,8 +732,6 @@ const renderTopLanguages = (topLangs, options = {}) => {
734
732
layout,
735
733
custom_title,
736
734
locale,
737
- card_width = DEFAULT_CARD_WIDTH ,
738
- card_height = calculateNormalLayoutHeight ( topLangs . length ) ,
739
735
langs_count = getDefaultLanguagesCountByLayout ( { layout, hide_progress } ) ,
740
736
border_radius,
741
737
border_color,
@@ -757,8 +753,8 @@ const renderTopLanguages = (topLangs, options = {}) => {
757
753
? isNaN ( card_width )
758
754
? DEFAULT_CARD_WIDTH
759
755
: card_width < MIN_CARD_WIDTH
760
- ? MIN_CARD_WIDTH
761
- : card_width
756
+ ? MIN_CARD_WIDTH
757
+ : card_width
762
758
: DEFAULT_CARD_WIDTH ;
763
759
let height = calculateNormalLayoutHeight ( langs . length ) ;
764
760
@@ -806,8 +802,8 @@ const renderTopLanguages = (topLangs, options = {}) => {
806
802
const card = new Card ( {
807
803
customTitle : custom_title ,
808
804
defaultTitle : i18n . t ( "langcard.title" ) ,
809
- width : card_width ,
810
- height : card_height ,
805
+ width,
806
+ height,
811
807
border_radius,
812
808
colors,
813
809
} ) ;
0 commit comments