@@ -23,10 +23,10 @@ const CARD_PADDING = 25;
23
23
*/
24
24
25
25
/**
26
- * Retrieves the programming language whose name is the longest
26
+ * Retrieves the programming language whose name is the longest.
27
27
*
28
- * @param {Lang[] } arr
29
- * @returns {Object } longest lang obj
28
+ * @param {Lang[] } arr Array of programming languages.
29
+ * @returns {Object } Longest programming language object.
30
30
*/
31
31
const getLongestLang = ( arr ) =>
32
32
arr . reduce (
@@ -37,15 +37,14 @@ const getLongestLang = (arr) =>
37
37
38
38
/**
39
39
* Creates a node to display usage of a programming language in percentage
40
- * using text and a horizontal progress bar
40
+ * using text and a horizontal progress bar.
41
41
*
42
- * @param {{
43
- * width: number,
44
- * color: string,
45
- * name: string,
46
- * progress: string
47
- * }} props
48
- * @returns {string } progress text node
42
+ * @param {object[] } props Function properties.
43
+ * @param {number } props.width The card width
44
+ * @param {string } props.name Name of the programming language.
45
+ * @param {string } props.color Color of the programming language.
46
+ * @param {string } props.progress Usage of the programming language in percentage.
47
+ * @returns {string } Programming language SVG node.
49
48
*/
50
49
const createProgressTextNode = ( { width, color, name, progress } ) => {
51
50
const paddingRight = 95 ;
@@ -67,10 +66,12 @@ const createProgressTextNode = ({ width, color, name, progress }) => {
67
66
} ;
68
67
69
68
/**
70
- * Creates a text only node to display usage of a programming language in percentage
69
+ * Creates a text only node to display usage of a programming language in percentage.
71
70
*
72
- * @param {{ lang: Lang, totalSize: number } } props
73
- * @returns {string } text node
71
+ * @param {object[] } props Function properties.
72
+ * @param {Lang } props.lang Programming language object.
73
+ * @param {number } props.totalSize Total size of all languages.
74
+ * @returns {string } Compact layout programming language SVG node.
74
75
*/
75
76
const createCompactLangNode = ( { lang, totalSize } ) => {
76
77
const percentage = ( ( lang . size / totalSize ) * 100 ) . toFixed ( 2 ) ;
@@ -87,10 +88,12 @@ const createCompactLangNode = ({ lang, totalSize }) => {
87
88
} ;
88
89
89
90
/**
90
- * Creates compact layout of text only language nodes
91
+ * Creates compact layout of text only language nodes.
91
92
*
92
- * @param {{ langs: Lang[], totalSize: number } } props
93
- * @returns {string } text nodes layout
93
+ * @param {object[] } props Function properties.
94
+ * @param {Lang[] } props.langs Array of programming languages.
95
+ * @param {number } props.totalSize Total size of all languages.
96
+ * @returns {string } Programming languages SVG node.
94
97
*/
95
98
const createLanguageTextNode = ( { langs, totalSize } ) => {
96
99
const longestLang = getLongestLang ( langs ) ;
@@ -122,12 +125,12 @@ const createLanguageTextNode = ({ langs, totalSize }) => {
122
125
} ;
123
126
124
127
/**
125
- * Renders layout to display user's most frequently used programming languages
128
+ * Renders layout to display user's most frequently used programming languages.
126
129
*
127
- * @param {Lang[] } langs
128
- * @param {number } width
129
- * @param {number } totalLanguageSize
130
- * @returns {string } normal layout
130
+ * @param {Lang[] } langs Array of programming languages.
131
+ * @param {number } width Card width.
132
+ * @param {number } totalLanguageSize Total size of all languages.
133
+ * @returns {string } Normal layout card SVG object.
131
134
*/
132
135
const renderNormalLayout = ( langs , width , totalLanguageSize ) => {
133
136
return flexLayout ( {
@@ -145,12 +148,12 @@ const renderNormalLayout = (langs, width, totalLanguageSize) => {
145
148
} ;
146
149
147
150
/**
148
- * Renders compact layout to display user's most frequently used programming languages
151
+ * Renders compact layout to display user's most frequently used programming languages.
149
152
*
150
- * @param {Lang[] } langs
151
- * @param {number } width
152
- * @param {number } totalLanguageSize
153
- * @returns {string } compact layout
153
+ * @param {Lang[] } langs Array of programming languages.
154
+ * @param {number } width Card width.
155
+ * @param {number } totalLanguageSize Total size of all languages.
156
+ * @returns {string } Compact layout card SVG object.
154
157
*/
155
158
const renderCompactLayout = ( langs , width , totalLanguageSize ) => {
156
159
const paddingRight = 50 ;
@@ -198,30 +201,31 @@ const renderCompactLayout = (langs, width, totalLanguageSize) => {
198
201
} ;
199
202
200
203
/**
201
- * Calculates height for the compact layout
204
+ * Calculates height for the compact layout.
202
205
*
203
- * @param {number } totalLangs
204
- * @returns {number } height
206
+ * @param {number } totalLangs Total number of languages.
207
+ * @returns {number } Card height.
205
208
*/
206
209
const calculateCompactLayoutHeight = ( totalLangs ) => {
207
210
return 90 + Math . round ( totalLangs / 2 ) * 25 ;
208
211
} ;
209
212
210
213
/**
211
- * Calculates height for the normal layout
214
+ * Calculates height for the normal layout.
212
215
*
213
- * @param {number } totalLangs
214
- * @returns {number } height
216
+ * @param {number } totalLangs Total number of languages.
217
+ * @returns {number } Card height.
215
218
*/
216
219
const calculateNormalLayoutHeight = ( totalLangs ) => {
217
220
return 45 + ( totalLangs + 1 ) * 40 ;
218
221
} ;
219
222
220
223
/**
221
- *
222
- * @param {Record<string, Lang> } topLangs
223
- * @param {string[] } hide
224
- * @param {string } langs_count
224
+ * Hides languages and trims the list to show only the top N languages.
225
+ *
226
+ * @param {Record<string, Lang> } topLangs Top languages.
227
+ * @param {string[] } hide Languages to hide.
228
+ * @param {string } langs_count Number of languages to show.
225
229
*/
226
230
const useLanguages = ( topLangs , hide , langs_count ) => {
227
231
let langs = Object . values ( topLangs ) ;
@@ -250,11 +254,11 @@ const useLanguages = (topLangs, hide, langs_count) => {
250
254
} ;
251
255
252
256
/**
253
- * Renders card to display user's most frequently used programming languages
257
+ * Renders card to display user's most frequently used programming languages.
254
258
*
255
- * @param {import('../fetchers/types').TopLangData } topLangs
256
- * @param {Partial<import("./types").TopLangOptions> } options
257
- * @returns {string }
259
+ * @param {import('../fetchers/types').TopLangData } topLangs User's most frequently used programming languages.
260
+ * @param {Partial<import("./types").TopLangOptions> } options Card options.
261
+ * @returns {string } Language card SVG object.
258
262
*/
259
263
const renderTopLanguages = ( topLangs , options = { } ) => {
260
264
const {
0 commit comments