mirror of
https://github.com/Equicord/Equicord.git
synced 2025-04-01 13:11:57 -04:00
add option to just show a button on mini user profiles (#188)
This commit is contained in:
parent
1fbc2bfcb2
commit
178062ac41
3 changed files with 24 additions and 3 deletions
|
@ -19,6 +19,7 @@ export function GitHubReposComponent({ id, theme }: { id: string, theme: string;
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [userInfo, setUserInfo] = useState<GitHubUserInfo | null>(null);
|
const [userInfo, setUserInfo] = useState<GitHubUserInfo | null>(null);
|
||||||
|
const [returnJustButton, setReturnJustButton] = useState(false);
|
||||||
|
|
||||||
const openReposModal = () => {
|
const openReposModal = () => {
|
||||||
if (!userInfo) return;
|
if (!userInfo) return;
|
||||||
|
@ -62,6 +63,8 @@ export function GitHubReposComponent({ id, theme }: { id: string, theme: string;
|
||||||
|
|
||||||
const githubId = githubConnection.id;
|
const githubId = githubConnection.id;
|
||||||
|
|
||||||
|
if (!settings.store.showInMiniProfile) setReturnJustButton(true);
|
||||||
|
|
||||||
// Try to fetch by ID first, fall back to username
|
// Try to fetch by ID first, fall back to username
|
||||||
const reposById = await fetchReposByUserId(githubId);
|
const reposById = await fetchReposByUserId(githubId);
|
||||||
if (reposById) {
|
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 (error) return <div className="vc-github-repos-error">Error: {error}</div>;
|
||||||
if (!repos.length) return null;
|
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);
|
const topRepos = repos.slice(0, 3);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -70,6 +70,7 @@
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vc-github-button,
|
||||||
.vc-github-repos-show-more {
|
.vc-github-repos-show-more {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
color: var(--text-normal);
|
color: var(--text-normal);
|
||||||
|
@ -82,6 +83,7 @@
|
||||||
transition: background-color 0.2s ease, border-color 0.2s ease;
|
transition: background-color 0.2s ease, border-color 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vc-github-button:hover,
|
||||||
.vc-github-repos-show-more:hover {
|
.vc-github-repos-show-more:hover {
|
||||||
background-color: var(--background-modifier-hover);
|
background-color: var(--background-modifier-hover);
|
||||||
border-color: var(--background-modifier-selected);
|
border-color: var(--background-modifier-selected);
|
||||||
|
@ -284,4 +286,4 @@
|
||||||
|
|
||||||
.vc-github-repos-table-star-icon {
|
.vc-github-repos-table-star-icon {
|
||||||
color: var(--text-warning);
|
color: var(--text-warning);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,5 +11,10 @@ export const settings = definePluginSettings({
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Show repository language",
|
description: "Show repository language",
|
||||||
default: true
|
default: true
|
||||||
}
|
},
|
||||||
});
|
showInMiniProfile: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Only show a button in the mini profile",
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue