mirror of
https://github.com/Aviortheking/codestats-readme.git
synced 2025-04-22 10:42:08 +00:00
fix: hide parameter array implementation (#162)
* fix: hide paramter array implementation * chore: parseArray str check * docs: updated readme * chore: add codecov threshold * docs: update docs
This commit is contained in:
parent
c2adcfd6fe
commit
aa44bd7615
@ -2,7 +2,7 @@ require("dotenv").config();
|
|||||||
const {
|
const {
|
||||||
renderError,
|
renderError,
|
||||||
parseBoolean,
|
parseBoolean,
|
||||||
parseJSON,
|
parseArray,
|
||||||
clampValue,
|
clampValue,
|
||||||
CONSTANTS,
|
CONSTANTS,
|
||||||
} = require("../src/utils");
|
} = require("../src/utils");
|
||||||
@ -45,7 +45,7 @@ module.exports = async (req, res) => {
|
|||||||
|
|
||||||
res.send(
|
res.send(
|
||||||
renderStatsCard(stats, {
|
renderStatsCard(stats, {
|
||||||
hide: parseJSON(hide),
|
hide: parseArray(hide),
|
||||||
show_icons: parseBoolean(show_icons),
|
show_icons: parseBoolean(show_icons),
|
||||||
hide_title: parseBoolean(hide_title),
|
hide_title: parseBoolean(hide_title),
|
||||||
hide_border: parseBoolean(hide_border),
|
hide_border: parseBoolean(hide_border),
|
||||||
|
@ -3,7 +3,7 @@ const {
|
|||||||
renderError,
|
renderError,
|
||||||
clampValue,
|
clampValue,
|
||||||
parseBoolean,
|
parseBoolean,
|
||||||
parseJSON,
|
parseArray,
|
||||||
CONSTANTS,
|
CONSTANTS,
|
||||||
} = require("../src/utils");
|
} = require("../src/utils");
|
||||||
const fetchTopLanguages = require("../src/fetchTopLanguages");
|
const fetchTopLanguages = require("../src/fetchTopLanguages");
|
||||||
@ -44,7 +44,7 @@ module.exports = async (req, res) => {
|
|||||||
theme,
|
theme,
|
||||||
hide_title: parseBoolean(hide_title),
|
hide_title: parseBoolean(hide_title),
|
||||||
card_width: parseInt(card_width, 10),
|
card_width: parseInt(card_width, 10),
|
||||||
hide: parseJSON(hide),
|
hide: parseArray(hide),
|
||||||
title_color,
|
title_color,
|
||||||
text_color,
|
text_color,
|
||||||
bg_color,
|
bg_color,
|
||||||
|
@ -7,4 +7,7 @@ coverage:
|
|||||||
range: "70...100"
|
range: "70...100"
|
||||||
|
|
||||||
status:
|
status:
|
||||||
|
project:
|
||||||
|
default:
|
||||||
|
threshold: 5
|
||||||
patch: false
|
patch: false
|
||||||
|
18
readme.md
18
readme.md
@ -57,12 +57,12 @@ _Note: Ranks are calculated based on user's stats, see [src/calculateRank.js](./
|
|||||||
|
|
||||||
### Hiding individual stats
|
### Hiding individual stats
|
||||||
|
|
||||||
To hide any specific stats, you can pass a query parameter `?hide=` with an array of items you wanna hide.
|
To hide any specific stats, you can pass a query parameter `?hide=` with comma seperated values.
|
||||||
|
|
||||||
> Options: `&hide=["stars","commits","prs","issues","contribs"]`
|
> Options: `&hide=stars,commits,prs,issues,contribs`
|
||||||
|
|
||||||
```md
|
```md
|
||||||

|

|
||||||
```
|
```
|
||||||
|
|
||||||
### Showing icons
|
### Showing icons
|
||||||
@ -98,13 +98,13 @@ You can customize the appearance of your `Stats Card` or `Repo Card` however you
|
|||||||
Customization Options:
|
Customization Options:
|
||||||
|
|
||||||
| Option | type | description | Stats Card (default) | Repo Card (default) | Top Lang Card (default) |
|
| Option | type | description | Stats Card (default) | Repo Card (default) | Top Lang Card (default) |
|
||||||
| ------------- | ---------- | -------------------------------------- | -------------------- | ------------------- | ----------------------- |
|
| ------------- | --------- | ------------------------------------ | -------------------- | ------------------- | ----------------------- |
|
||||||
| title_color | hex color | title color | 2f80ed | 2f80ed | 2f80ed |
|
| title_color | hex color | title color | 2f80ed | 2f80ed | 2f80ed |
|
||||||
| text_color | hex color | body color | 333 | 333 | 333 |
|
| text_color | hex color | body color | 333 | 333 | 333 |
|
||||||
| icon_color | hex color | icon color | 4c71f2 | 586069 | 586069 |
|
| icon_color | hex color | icon color | 4c71f2 | 586069 | 586069 |
|
||||||
| bg_color | hex color | card bg color | FFFEFE | FFFEFE | FFFEFE |
|
| bg_color | hex color | card bg color | FFFEFE | FFFEFE | FFFEFE |
|
||||||
| line_height | number | control the line-height between text | 30 | N/A | N/A |
|
| line_height | number | control the line-height between text | 30 | N/A | N/A |
|
||||||
| hide | JSON array | hides the items specified on the array | [] | N/A | [] |
|
| hide | CSV | hides the items specified | undefined | N/A | undefined |
|
||||||
| hide_rank | boolean | hides the ranking | false | N/A | N/A |
|
| hide_rank | boolean | hides the ranking | false | N/A | N/A |
|
||||||
| hide_title | boolean | hides the stats title | false | N/A | false |
|
| hide_title | boolean | hides the stats title | false | N/A | false |
|
||||||
| hide_border | boolean | hides the stats card border | false | N/A | N/A |
|
| hide_border | boolean | hides the stats card border | false | N/A | N/A |
|
||||||
@ -157,10 +157,10 @@ Endpoint: `api/top-langs?username=anuraghazra`
|
|||||||
|
|
||||||
### Hide individual languages
|
### Hide individual languages
|
||||||
|
|
||||||
You can use `?hide=["language1","language2"]` parameter to hide languages below a specified threshold percentage.
|
You can use `?hide=language1,language2` parameter to hide individual languages.
|
||||||
|
|
||||||
```md
|
```md
|
||||||
[](https://github.com/anuraghazra/github-readme-stats)
|
[](https://github.com/anuraghazra/github-readme-stats)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Demo
|
### Demo
|
||||||
@ -177,11 +177,11 @@ You can use `?hide=["language1","language2"]` parameter to hide languages below
|
|||||||
|
|
||||||
- Hiding specific stats
|
- Hiding specific stats
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
- Showing icons
|
- Showing icons
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
- Themes
|
- Themes
|
||||||
|
|
||||||
|
11
src/utils.js
11
src/utils.js
@ -44,12 +44,9 @@ function parseBoolean(value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseJSON(str) {
|
function parseArray(str) {
|
||||||
try {
|
if (!str) return [];
|
||||||
return JSON.parse(str);
|
return str.split(",");
|
||||||
} catch (err) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clampValue(number, min, max) {
|
function clampValue(number, min, max) {
|
||||||
@ -141,7 +138,7 @@ module.exports = {
|
|||||||
encodeHTML,
|
encodeHTML,
|
||||||
isValidHexColor,
|
isValidHexColor,
|
||||||
request,
|
request,
|
||||||
parseJSON,
|
parseArray,
|
||||||
parseBoolean,
|
parseBoolean,
|
||||||
fallbackColor,
|
fallbackColor,
|
||||||
FlexLayout,
|
FlexLayout,
|
||||||
|
@ -98,7 +98,7 @@ describe("Test /api/", () => {
|
|||||||
const { req, res } = faker(
|
const { req, res } = faker(
|
||||||
{
|
{
|
||||||
username: "anuraghazra",
|
username: "anuraghazra",
|
||||||
hide: `["issues","prs","contribs"]`,
|
hide: "issues,prs,contribs",
|
||||||
show_icons: true,
|
show_icons: true,
|
||||||
hide_border: true,
|
hide_border: true,
|
||||||
line_height: 100,
|
line_height: 100,
|
||||||
|
@ -55,7 +55,7 @@ describe("Test renderStatsCard", () => {
|
|||||||
|
|
||||||
it("should hide individual stats", () => {
|
it("should hide individual stats", () => {
|
||||||
document.body.innerHTML = renderStatsCard(stats, {
|
document.body.innerHTML = renderStatsCard(stats, {
|
||||||
hide: "['issues', 'prs', 'contribs']",
|
hide: ["issues", "prs", "contribs"],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user