Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfef8bc3

Browse files
committed
refactor: minor refactors
1 parentf8b0c87 commitfef8bc3

File tree

11 files changed

+76
-55
lines changed

11 files changed

+76
-55
lines changed

‎src/cards/repo-card.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const {
33
kFormatter,
44
encodeHTML,
55
getCardColors,
6-
FlexLayout,
6+
flexLayout,
77
wrapTextMultiline,
88
}=require("../common/utils");
99
constI18n=require("../common/I18n");
@@ -61,7 +61,13 @@ const renderRepoCard = (repo, options = {}) => {
6161
});
6262

6363
// returns theme based colors with proper overrides and defaults
64-
const{ titleColor, textColor, iconColor, bgColor, borderColor}=getCardColors({
64+
const{
65+
titleColor,
66+
textColor,
67+
iconColor,
68+
bgColor,
69+
borderColor,
70+
}=getCardColors({
6571
title_color,
6672
icon_color,
6773
text_color,
@@ -111,7 +117,7 @@ const renderRepoCard = (repo, options = {}) => {
111117
constsvgForks=
112118
forkCount>0&&iconWithLabel(icons.fork,totalForks,"forkcount");
113119

114-
conststarAndForkCount=FlexLayout({
120+
conststarAndForkCount=flexLayout({
115121
items:[svgStars,svgForks],
116122
gap:65,
117123
}).join("");

‎src/cards/stats-card.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { getStyles } = require("../getStyles");
55
const{ statCardLocales}=require("../translations");
66
const{
77
kFormatter,
8-
FlexLayout,
8+
flexLayout,
99
clampValue,
1010
measureText,
1111
getCardColors,
@@ -78,7 +78,13 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
7878
constlheight=parseInt(line_height,10);
7979

8080
// returns theme based colors with proper overrides and defaults
81-
const{ titleColor, textColor, iconColor, bgColor, borderColor}=getCardColors({
81+
const{
82+
titleColor,
83+
textColor,
84+
iconColor,
85+
bgColor,
86+
borderColor,
87+
}=getCardColors({
8288
title_color,
8389
icon_color,
8490
text_color,
@@ -131,7 +137,17 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
131137
},
132138
};
133139

134-
constlongLocales=["cn","es","fr","pt-br","ru","uk-ua","id","my","pl"];
140+
constlongLocales=[
141+
"cn",
142+
"es",
143+
"fr",
144+
"pt-br",
145+
"ru",
146+
"uk-ua",
147+
"id",
148+
"my",
149+
"pl",
150+
];
135151
constisLongLocale=longLocales.includes(locale)===true;
136152

137153
// filter out hidden stats defined by user & create the text nodes
@@ -223,7 +239,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
223239
${rankCircle}
224240
225241
<svg x="0" y="0">
226-
${FlexLayout({
242+
${flexLayout({
227243
items:statItems,
228244
gap:lheight,
229245
direction:"column",

‎src/cards/top-languages-card.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
constCard=require("../common/Card");
2-
const{ clampValue, getCardColors, FlexLayout}=require("../common/utils");
3-
const{ createProgressNode}=require("../common/createProgressNode");
4-
const{ langCardLocales}=require("../translations");
52
constI18n=require("../common/I18n");
3+
const{ langCardLocales}=require("../translations");
4+
const{ createProgressNode}=require("../common/createProgressNode");
5+
const{ clampValue, getCardColors, flexLayout}=require("../common/utils");
66

77
constcreateProgressTextNode=({ width, color, name, progress})=>{
88
constpaddingRight=95;
@@ -75,7 +75,7 @@ const renderTopLanguages = (topLangs, options = {}) => {
7575
locale,
7676
langs_count=5,
7777
border_radius,
78-
border_color
78+
border_color,
7979
}=options;
8080

8181
consti18n=newI18n({
@@ -171,7 +171,7 @@ const renderTopLanguages = (topLangs, options = {}) => {
171171
}).join("")}
172172
`;
173173
}else{
174-
finalLayout=FlexLayout({
174+
finalLayout=flexLayout({
175175
items:langs.map((lang)=>{
176176
returncreateProgressTextNode({
177177
width:width,

‎src/cards/wakatime-card.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ const Card = require("../common/Card");
22
constI18n=require("../common/I18n");
33
const{ getStyles}=require("../getStyles");
44
const{ wakatimeCardLocales}=require("../translations");
5-
const{ clampValue, getCardColors, FlexLayout}=require("../common/utils");
6-
const{ createProgressNode}=require("../common/createProgressNode");
75
constlanguageColors=require("../common/languageColors.json");
6+
const{ createProgressNode}=require("../common/createProgressNode");
7+
const{ clampValue, getCardColors, flexLayout}=require("../common/utils");
88

99
constnoCodingActivityNode=({ color, text})=>{
1010
return`
@@ -204,7 +204,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
204204
}).join("")}
205205
`;
206206
}else{
207-
finalLayout=FlexLayout({
207+
finalLayout=flexLayout({
208208
items:statItems.length
209209
?statItems
210210
:[

‎src/common/Card.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const{ FlexLayout, encodeHTML}=require("../common/utils");
21
const{ getAnimations}=require("../getStyles");
2+
const{ flexLayout, encodeHTML}=require("../common/utils");
33

44
classCard{
55
constructor({
@@ -85,7 +85,7 @@ class Card {
8585
data-testid="card-title"
8686
transform="translate(${this.paddingX},${this.paddingY})"
8787
>
88-
${FlexLayout({
88+
${flexLayout({
8989
items:[this.titlePrefixIcon&&prefixIcon,titleText],
9090
gap:25,
9191
}).join("")}

‎src/common/utils.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function request(data, headers) {
9797
* Auto layout utility, allows us to layout things
9898
* vertically or horizontally with proper gaping
9999
*/
100-
functionFlexLayout({ items, gap, direction}){
100+
functionflexLayout({ items, gap, direction}){
101101
// filter() for filtering out empty strings
102102
returnitems.filter(Boolean).map((item,i)=>{
103103
lettransform=`translate(${gap*i}, 0)`;
@@ -120,7 +120,8 @@ function getCardColors({
120120
}){
121121
constdefaultTheme=themes[fallbackTheme];
122122
constselectedTheme=themes[theme]||defaultTheme;
123-
constdefaultBorderColor=selectedTheme.border_color||defaultTheme.border_color;
123+
constdefaultBorderColor=
124+
selectedTheme.border_color||defaultTheme.border_color;
124125

125126
// get the color provided by the user else the theme color
126127
// finally if both colors are invalid fallback to default theme
@@ -239,7 +240,7 @@ module.exports = {
239240
parseArray,
240241
parseBoolean,
241242
fallbackColor,
242-
FlexLayout,
243+
flexLayout,
243244
getCardColors,
244245
clampValue,
245246
wrapTextMultiline,

‎src/fetchers/repo-fetcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const{ request}=require("../common/utils");
21
constretryer=require("../common/retryer");
2+
const{ request}=require("../common/utils");
33

44
constfetcher=(variables,token)=>{
55
returnrequest(

‎src/fetchers/stats-fetcher.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const{ request, logger, CustomError}=require("../common/utils");
21
constaxios=require("axios");
2+
constgithubUsernameRegex=require("github-username-regex");
3+
34
constretryer=require("../common/retryer");
45
constcalculateRank=require("../calculateRank");
5-
constgithubUsernameRegex=require("github-username-regex");
6+
const{ request, logger, CustomError}=require("../common/utils");
67

78
require("dotenv").config();
89

‎src/fetchers/top-languages-fetcher.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const{ request, logger, clampValue}=require("../common/utils");
1+
const{ request, logger}=require("../common/utils");
22
constretryer=require("../common/retryer");
33
require("dotenv").config();
44

@@ -34,11 +34,7 @@ const fetcher = (variables, token) => {
3434
);
3535
};
3636

37-
asyncfunctionfetchTopLanguages(
38-
username,
39-
exclude_repo=[],
40-
hide=[],
41-
){
37+
asyncfunctionfetchTopLanguages(username,exclude_repo=[]){
4238
if(!username)throwError("Invalid username");
4339

4440
constres=awaitretryer(fetcher,{login:username});

‎src/translations.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
const{ encodeHTML}=require("./common/utils");
22

33
conststatCardLocales=({ name, apostrophe})=>{
4+
constencodedName=encodeHTML(name);
45
return{
56
"statcard.title":{
6-
cn:`${encodeHTML(name)} 的 GitHub 统计数据`,
7-
cs:`GitHub statistiky uživatele${encodeHTML(name)}`,
8-
de:`${encodeHTML(name)+apostrophe} GitHub-Statistiken`,
9-
en:`${encodeHTML(name)}'${apostrophe} GitHub Stats`,
10-
es:`Estadísticas de GitHub de${encodeHTML(name)}`,
11-
fr:`Statistiques GitHub de${encodeHTML(name)}`,
12-
hu:`${encodeHTML(name)} GitHub statisztika`,
13-
it:`Statistiche GitHub di${encodeHTML(name)}`,
14-
ja:`${encodeHTML(name)}の GitHub 統計`,
15-
kr:`${encodeHTML(name)}의 GitHub 통계`,
16-
nl:`${encodeHTML(name)}'${apostrophe} GitHub Statistieken`,
17-
"pt-pt":`Estatísticas do GitHub de${encodeHTML(name)}`,
18-
"pt-br":`Estatísticas do GitHub de${encodeHTML(name)}`,
19-
np:`${encodeHTML(name)}'${apostrophe} गिटहब तथ्याङ्क`,
20-
el:`Στατιστικά GitHub του${encodeHTML(name)}`,
21-
ru:`Статистика GitHub пользователя${encodeHTML(name)}`,
22-
"uk-ua":`Статистика GitHub користувача${encodeHTML(name)}`,
23-
id:`Statistik GitHub${encodeHTML(name)}`,
24-
my:`Statistik GitHub${encodeHTML(name)}`,
25-
sk:`GitHub štatistiky používateľa${encodeHTML(name)}`,
26-
tr:`${encodeHTML(name)} Hesabının GitHub Yıldızları`,
27-
pl:`Statystyki GitHub użytkownika${encodeHTML(name)}`,
7+
cn:`${encodedName} 的 GitHub 统计数据`,
8+
cs:`GitHub statistiky uživatele${encodedName}`,
9+
de:`${encodedName+apostrophe} GitHub-Statistiken`,
10+
en:`${encodedName}'${apostrophe} GitHub Stats`,
11+
es:`Estadísticas de GitHub de${encodedName}`,
12+
fr:`Statistiques GitHub de${encodedName}`,
13+
hu:`${encodedName} GitHub statisztika`,
14+
it:`Statistiche GitHub di${encodedName}`,
15+
ja:`${encodedName}の GitHub 統計`,
16+
kr:`${encodedName}의 GitHub 통계`,
17+
nl:`${encodedName}'${apostrophe} GitHub Statistieken`,
18+
"pt-pt":`Estatísticas do GitHub de${encodedName}`,
19+
"pt-br":`Estatísticas do GitHub de${encodedName}`,
20+
np:`${encodedName}'${apostrophe} गिटहब तथ्याङ्क`,
21+
el:`Στατιστικά GitHub του${encodedName}`,
22+
ru:`Статистика GitHub пользователя${encodedName}`,
23+
"uk-ua":`Статистика GitHub користувача${encodedName}`,
24+
id:`Statistik GitHub${encodedName}`,
25+
my:`Statistik GitHub${encodedName}`,
26+
sk:`GitHub štatistiky používateľa${encodedName}`,
27+
tr:`${encodedName} Hesabının GitHub Yıldızları`,
28+
pl:`Statystyki GitHub użytkownika${encodedName}`,
2829
},
2930
"statcard.totalstars":{
3031
cn:"获标星数(star)",

‎tests/utils.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const {
33
kFormatter,
44
encodeHTML,
55
renderError,
6-
FlexLayout,
6+
flexLayout,
77
getCardColors,
88
wrapTextMultiline,
99
}=require("../src/common/utils");
@@ -44,8 +44,8 @@ describe("Test utils.js", () => {
4444
).toHaveTextContent(/SecondaryMessage/gim);
4545
});
4646

47-
it("should testFlexLayout",()=>{
48-
constlayout=FlexLayout({
47+
it("should testflexLayout",()=>{
48+
constlayout=flexLayout({
4949
items:["<text>1</text>","<text>2</text>"],
5050
gap:60,
5151
}).join("");
@@ -54,7 +54,7 @@ describe("Test utils.js", () => {
5454
`<g transform=\"translate(0, 0)\"><text>1</text></g><g transform=\"translate(60, 0)\"><text>2</text></g>`,
5555
);
5656

57-
constcolumns=FlexLayout({
57+
constcolumns=flexLayout({
5858
items:["<text>1</text>","<text>2</text>"],
5959
gap:60,
6060
direction:"column",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp