Skip to content

Commit

Permalink
✨ feat: add github trophy
Browse files Browse the repository at this point in the history
  • Loading branch information
maurodesouza committed Dec 31, 2023
1 parent 2d37773 commit 0ed198e
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/app/config/general/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const general = {
stats: {
imageBaseUrl: 'https://github-readme-stats.vercel.app/api',
streakBaseUrl: 'https://streak-stats.demolab.com',
trophiBaseUrl: 'https://github-profile-trophy.vercel.app',
},

socials: {
Expand Down
12 changes: 12 additions & 0 deletions src/features/stats/default-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ const defaultStatsSectionConfig = {
show: false,
order: 3,
},

trophy: {
theme: 'dracula',
column: -1,
row: 1,
'margin-w': 8,
'margin-h': 8,
'no-bg': false,
'no-frame': false,
show: false,
order: 4,
},
},
},

Expand Down
7 changes: 7 additions & 0 deletions src/features/stats/panel/views/config/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ const views: Record<string, ComponentType> = {
() => () => null
)
),

trophy: dynamic(() =>
import('./trophy').then(
mod => mod.Trophy,
() => () => null
)
),
};

export { views };
99 changes: 99 additions & 0 deletions src/features/stats/panel/views/config/views/trophy/fields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { showField } from '../@shared';
import { Inputs } from 'types';

const groups = [
{
id: 1,
fields: [showField('trophy')],
},
{
id: 2,
label: 'Layout',
columns: 2,
fields: [
{
type: Inputs.SELECT,
path: 'content.graphs.trophy.theme',
label: 'Theme',
props: {
column: '1 / 3',
clearable: true,
options: [
{ label: 'Flat', value: 'flat' },
{ label: 'Onedark', value: 'onedark' },
{ label: 'Gruvbox', value: 'gruvbox' },
{ label: 'Dracula', value: 'dracula' },
{ label: 'Monokai', value: 'monokai' },
{ label: 'Chalk', value: 'chalk' },
{ label: 'Nord', value: 'nord' },
{ label: 'Alduin', value: 'alduin' },
{ label: 'Darkhub', value: 'darkhub' },
{ label: 'Juicyfresh', value: 'juicyfresh' },
{ label: 'Buddhism', value: 'buddhism' },
{ label: 'Oldie', value: 'oldie' },
{ label: 'Radical', value: 'radical' },
{ label: 'Onestar', value: 'onestar' },
{ label: 'Discord', value: 'discord' },
{ label: 'Algolia', value: 'algolia' },
{ label: 'Gitdimmed', value: 'gitdimmed' },
{ label: 'Tokyonight', value: 'tokyonight' },
{ label: 'Matrix', value: 'matrix' },
{ label: 'Apprentice', value: 'apprentice' },
{ label: 'Dark Dimmed', value: 'dark_dimmed' },
{ label: 'Dark Lover', value: 'dark_lover' },
{ label: 'Kimbie Dark', value: 'kimbie_dark' },
],
},
},

{
type: Inputs.TEXT,
path: `content.graphs.trophy.column`,
label: 'Columns',
props: {
type: 'number',
min: -1,
},
},
{
type: Inputs.TEXT,
path: `content.graphs.trophy.row`,
label: 'Rows',
props: {
type: 'number',
min: 1,
},
},
{
type: Inputs.TEXT,
path: `content.graphs.trophy.margin-w`,
label: 'Column gap',
props: {
type: 'number',
min: 0,
},
},
{
type: Inputs.TEXT,
path: `content.graphs.trophy.margin-h`,
label: 'Row gap',
props: {
type: 'number',
min: 0,
},
},
{
type: Inputs.SWITCH,
path: `content.graphs.trophy.no-frame`,
label: 'Hide border',
},
{
type: Inputs.SWITCH,
path: 'content.graphs.trophy.no-bg',
label: 'Transparent background',
},
],
},
];

export { groups };
14 changes: 14 additions & 0 deletions src/features/stats/panel/views/config/views/trophy/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { GroupFields } from 'components';
import { groups } from './fields';

const Trophy = () => {
return (
<>
{groups.map(group => (
<GroupFields key={group.id} {...group} />
))}
</>
);
};

export { Trophy };
4 changes: 3 additions & 1 deletion src/utils/getStatsUrl/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { general as generalConfig } from 'app/config/general';

const { imageBaseUrl, streakBaseUrl } = generalConfig.urls.sections.stats;
const { imageBaseUrl, streakBaseUrl, trophiBaseUrl } =
generalConfig.urls.sections.stats;

const urls = (value: string) => ({
stats: `${imageBaseUrl}?username=${value}`,
languages: `${imageBaseUrl}/top-langs?username=${value}`,
streak: `${streakBaseUrl}?user=${value}`,
trophy: `${trophiBaseUrl}?username=${value}`,
});

const getStatsUrl = (type: keyof typeof urls, github: string) =>
Expand Down

0 comments on commit 0ed198e

Please sign in to comment.