add option to just show a button on mini user profiles (#188)
Some checks are pending
Release / Build Equicord (push) Waiting to run
Sync to Codeberg / Sync Codeberg and Github (push) Waiting to run
Test / Test (push) Waiting to run

This commit is contained in:
Creation's 2025-03-18 20:22:00 -04:00 committed by GitHub
parent 1fbc2bfcb2
commit 178062ac41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 3 deletions

View file

@ -19,6 +19,7 @@ export function GitHubReposComponent({ id, theme }: { id: string, theme: string;
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const [userInfo, setUserInfo] = useState<GitHubUserInfo | null>(null);
const [returnJustButton, setReturnJustButton] = useState(false);
const openReposModal = () => {
if (!userInfo) return;
@ -62,6 +63,8 @@ export function GitHubReposComponent({ id, theme }: { id: string, theme: string;
const githubId = githubConnection.id;
if (!settings.store.showInMiniProfile) setReturnJustButton(true);
// Try to fetch by ID first, fall back to username
const reposById = await fetchReposByUserId(githubId);
if (reposById) {
@ -87,6 +90,17 @@ export function GitHubReposComponent({ id, theme }: { id: string, theme: string;
if (error) return <div className="vc-github-repos-error">Error: {error}</div>;
if (!repos.length) return null;
if (returnJustButton) {
return (
<button
className="vc-github-button"
onClick={openReposModal}
>
Show GitHub Repositories
</button>
);
}
const topRepos = repos.slice(0, 3);
return (

View file

@ -70,6 +70,7 @@
text-decoration: underline;
}
.vc-github-button,
.vc-github-repos-show-more {
background-color: transparent;
color: var(--text-normal);
@ -82,6 +83,7 @@
transition: background-color 0.2s ease, border-color 0.2s ease;
}
.vc-github-button:hover,
.vc-github-repos-show-more:hover {
background-color: var(--background-modifier-hover);
border-color: var(--background-modifier-selected);
@ -284,4 +286,4 @@
.vc-github-repos-table-star-icon {
color: var(--text-warning);
}
}

View file

@ -11,5 +11,10 @@ export const settings = definePluginSettings({
type: OptionType.BOOLEAN,
description: "Show repository language",
default: true
}
});
},
showInMiniProfile: {
type: OptionType.BOOLEAN,
description: "Only show a button in the mini profile",
default: true
},
});