diff --git a/action.ts b/action.ts index 6b0ccb3..5110e73 100644 --- a/action.ts +++ b/action.ts @@ -19,22 +19,25 @@ async function main() { // Fetch Code::Stats API const profile = await fetchProfile(username); const toplang = await fetchTopLanguages(username); - const history = await fetchHistory(username, 32); + const history = await fetchHistory( + username, + parseNumber(core.getInput("history_card_days_count")) + ); // Generate Profile Summary Card const profilecard = ReactDOMServer.renderToStaticMarkup( new ProfileCard(profile.username, profile.xp, profile.recentXp, { - hide: parseArray(core.getInput("hide")), - show_icons: parseBoolean(core.getInput("show_icons")), - hide_rank: parseBoolean(core.getInput("hide_rank")), - line_height: parseNumber(core.getInput("line_height")), - title: `Code::Stats of ${username}`, // core.getInput("title"), - title_color: core.getInput("title_color"), - icon_color: core.getInput("icon_color"), - text_color: core.getInput("text_color"), - bg_color: core.getInput("bg_color"), - hide_title: parseBoolean(core.getInput("hide_title")), - hide_border: parseBoolean(core.getInput("hide_border")), + hide: parseArray(core.getInput("profile_card_hide_lines")), + show_icons: parseBoolean(core.getInput("profile_card_show_icons")), + hide_rank: parseBoolean(core.getInput("profile_card_hide_rank")), + line_height: parseNumber(core.getInput("profile_card_line_height")), + title: core.getInput("profile_card_title"), + title_color: core.getInput("common_title_color"), + icon_color: core.getInput("common_icon_color"), + text_color: core.getInput("common_text_color"), + bg_color: core.getInput("common_bg_color"), + hide_title: parseBoolean(core.getInput("common_hide_title")), + hide_border: parseBoolean(core.getInput("common_hide_border")), }).render() ); @@ -44,19 +47,20 @@ async function main() { // Generate Top Languages Card const toplangcard = ReactDOMServer.renderToStaticMarkup( new TopLanguagesCard(username, toplang.langs, { - hide: parseArray(core.getInput("hide")), - language_count: parseNumber(core.getInput("language_count")), - card_width: clampValue( - parseNumber(core.getInput("card_width")) || 300, - 500 + hide: parseArray(core.getInput("common_hide_languages")), + language_count: parseNumber( + core.getInput("toplangs_card_language_count") ), - layout: core.getInput("layout"), - title: `Code::Stats of ${username}`, // core.getInput("title"), - title_color: core.getInput("title_color"), - text_color: core.getInput("text_color"), - bg_color: core.getInput("bg_color"), - hide_title: parseBoolean(core.getInput("hide_title")), - hide_border: parseBoolean(core.getInput("hide_border")), + card_width: 500, + layout: parseBoolean(core.getInput("toplangs_card_compact_layout")) + ? "compact" + : undefined, + title: core.getInput("toplangs_card_title"), + title_color: core.getInput("common_title_color"), + text_color: core.getInput("common_text_color"), + bg_color: core.getInput("common_bg_color"), + hide_title: parseBoolean(core.getInput("common_hide_title")), + hide_border: parseBoolean(core.getInput("common_hide_border")), }).render() ); @@ -66,18 +70,24 @@ async function main() { // Generate History Card const historycard = ReactDOMServer.renderToStaticMarkup( new HistoryCard(username, history, { - hide: parseArray(core.getInput("hide")), - language_count: parseNumber(core.getInput("language_count")), - hide_legend: parseBoolean(core.getInput("hide_legend")), - reverse_order: parseBoolean(core.getInput("reverse_order")), - width: clampValue(parseNumber(core.getInput("card_width")) || 300, 500), - height: clampValue(parseNumber(core.getInput("card_height")) || 300, 200), - title_color: core.getInput("title_color"), - text_color: core.getInput("text_color"), - bg_color: core.getInput("bg_color"), - layout: undefined, // core.getInput("layout") - hide_title: parseBoolean(core.getInput("hide_title")), - hide_border: parseBoolean(core.getInput("hide_border")), + hide: parseArray(core.getInput("common_hide_languages")), + language_count: parseNumber( + core.getInput("history_card_language_count") + ), + hide_legend: parseBoolean(core.getInput("history_card_hide_legend")), + reverse_order: parseBoolean( + core.getInput("history_card_reverse_order") + ), + width: 500, + height: 300, + title_color: core.getInput("common_title_color"), + text_color: core.getInput("common_text_color"), + bg_color: core.getInput("common_bg_color"), + layout: parseBoolean(core.getInput("history_card_horizontal_layout")) + ? "horizontal" + : undefined, + hide_title: parseBoolean(core.getInput("common_hide_title")), + hide_border: parseBoolean(core.getInput("common_hide_border")), }).render() ); diff --git a/action.yml b/action.yml index 05edb4f..1cead99 100644 --- a/action.yml +++ b/action.yml @@ -13,97 +13,118 @@ inputs: type: string default: domai-tb - show_icons: - description: Generate profile card with icons + profile_card_title: + description: Change the cards title + required: false + type: string + default: `Code::Stats of ${username}` + + profile_card_hide_lines: + description: "Hide specific line, eg: `xp` or `xp,recent_xp`" + required: false + type: string + default: undefiend + + profile_card_show_icons: + description: Shows icons before each lines required: false type: boolean default: true - hide_rank: - description: Generate profile card without level / rank + profile_card_hide_rank: + description: Hide the rank circle required: false type: boolean default: false - hide_title: - description: Generate cards without title - required: false - type: boolean - default: false - - hide_border: - description: Generate cards without border - required: false - type: boolean - default: false - - line_height: - description: Line hight for profile card + profile_card_line_height: + description: Change the line height of each lines required: false type: number default: 45 - title_color: - description: Color of profile card title + toplangs_card_title: + description: Change the cards title required: false type: string + default: `Code::Stats of ${username}` - icon_color: - description: Color of profile card icons - required: false - type: string - - text_color: - description: Color of profile card text - required: false - type: string - - bg_color: - description: Color of top language card background - required: false - type: string - - language_count: - description: Number of language to display on cards + toplangs_card_language_count: + description: Change the number of languages shown before going to Others required: false type: number - default: 21 + default: 8 - hide: - description: Hide specific language from top lang card + toplangs_card_compact_layout: + description: Make the layout more compact required: false - type: string - default: 'scminput,Log,Plain text' + type: boolean + default: false - card_width: - description: Width of top languages card in px + history_card_language_count: + description: Change the number of languages shown before going to Others required: false type: number - default: 300 + default: 8 - card_height: - description: Higths of top languages card in px - required: false - type: number - default: 300 - - layout: - description: Layout of top lang card - required: false - type: choice - options: - - compact - - undefiend - default: compact - - hide_legend: + history_card_hide_legend: description: Generate history card without legend required: false type: boolean default: false - reverse_order: + history_card_reverse_order: description: Order history from old to new required: false type: boolean - default: false \ No newline at end of file + default: false + + history_card_horizontal_layout: + description: Change the layout to the horizontal + required: false + type: boolean + default: false + + history_card_days_count: + description: Change the number of days shown + required: false + type: number + default: 14 + + common_hide_languages: + description: "Hide specific line, eg: `scminput,Log,Plain text`" + required: false + type: string + default: 'scminput,Log,Plain text' + + common_hide_title: + description: Hide the title + required: false + type: boolean + default: false + + common_hide_border: + description: Hide the border + required: false + type: boolean + default: false + + common_title_color: + description: Color of profile card title + required: false + type: string + + common_icon_color: + description: Color of profile card icons + required: false + type: string + + common_text_color: + description: "Change the text colors, eg: 123456" + required: false + type: string + + common_bg_color: + description: "Change the background color, eg: 654321" + required: false + type: string \ No newline at end of file diff --git a/src/common/utils.ts b/src/common/utils.ts index 698569c..8b3d257 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -145,13 +145,13 @@ export function trunc(number: number, digits = 0) { return Math.round(number * pow) / pow } -export function parseNumber(number: string | number | undefined): number | undefined { +export function parseNumber(number: string | number | undefined): number { if (typeof number === 'undefined' || typeof number === 'number') { - return number + return 0 } const n = parseFloat(number) if (isNaN(n)) { - return undefined + return 0 } return n }