GitHubRepos Stuff
Some checks are pending
Sync to Codeberg / Sync Codeberg and Github (push) Waiting to run
Test / Test (push) Waiting to run

This commit is contained in:
thororen1234 2025-03-18 21:27:48 -04:00
parent 178062ac41
commit f2462a9baa
No known key found for this signature in database
9 changed files with 77 additions and 38 deletions

View file

@ -1,3 +1,9 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
export function getLanguageColor(language: string): string {
const colors: Record<string, string> = {
"JavaScript": "#f1e05a",
@ -58,4 +64,4 @@ export function getLanguageColor(language: string): string {
};
return colors[language] || "#858585";
}
}

View file

@ -8,9 +8,9 @@ import { Flex } from "@components/Flex";
import { openModal } from "@utils/modal";
import { React, useEffect, UserProfileStore, useState } from "@webpack/common";
import { fetchReposByUserId, fetchReposByUsername, fetchUserInfo, GitHubUserInfo } from "../services/githubApi";
import { settings } from "..";
import { fetchReposByUserId, fetchReposByUsername, fetchUserInfo, GitHubUserInfo } from "../githubApi";
import { GitHubRepo } from "../types";
import { settings } from "../utils/settings";
import { RepoCard } from "./RepoCard";
import { ReposModal } from "./ReposModal";

View file

@ -1,8 +1,15 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { Flex } from "@components/Flex";
import { React } from "@webpack/common";
import { getLanguageColor } from "../colors";
import { RepoCardProps } from "../types";
import { getLanguageColor } from "../utils/colors";
import { Star } from "./icons/Star";
import { Star } from "./Star";
export function RepoCard({ repo, theme, showStars, showLanguage }: RepoCardProps) {
const handleClick = () => window.open(repo.html_url, "_blank");
@ -48,4 +55,4 @@ export function RepoCard({ repo, theme, showStars, showLanguage }: RepoCardProps
{renderLanguage()}
</div>
);
}
}

View file

@ -1,8 +1,15 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { ModalContent, ModalFooter, ModalHeader, ModalRoot } from "@utils/modal";
import { Button, Forms, React } from "@webpack/common";
import { getLanguageColor } from "../colors";
import { GitHubRepo } from "../types";
import { getLanguageColor } from "../utils/colors";
import { Star } from "./icons/Star";
import { Star } from "./Star";
interface ReposModalProps {
repos: GitHubRepo[];
@ -91,4 +98,4 @@ export function ReposModal({ repos, username, rootProps }: ReposModalProps) {
</ModalFooter>
</ModalRoot>
);
}
}

View file

@ -1,5 +1,12 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { React } from "@webpack/common";
import { IconProps } from "../../types";
import { IconProps } from "../types";
export function Star({ className, width = 16, height = 16 }: IconProps) {
return (
@ -14,4 +21,4 @@ export function Star({ className, width = 16, height = 16 }: IconProps) {
<path d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25z" />
</svg>
);
}
}

View file

@ -1,6 +1,13 @@
import { GitHubRepo } from "../types";
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { Logger } from "@utils/Logger";
import { GitHubRepo } from "./types";
const logger = new Logger("GitHubRepos");
export interface GitHubUserInfo {
@ -55,4 +62,4 @@ export async function fetchReposByUsername(username: string, perPage: number = 3
function sortReposByStars(repos: GitHubRepo[]): GitHubRepo[] {
return repos.sort((a, b) => b.stargazers_count - a.stargazers_count);
}
}

View file

@ -6,16 +6,35 @@
import "./styles.css";
import { definePluginSettings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { EquicordDevs } from "@utils/constants";
import { Logger } from "@utils/Logger";
import definePlugin from "@utils/types";
import definePlugin, { OptionType } from "@utils/types";
import { findByCodeLazy } from "@webpack";
import { React } from "@webpack/common";
import { User } from "discord-types/general";
import { GitHubReposComponent } from "./components/GitHubReposComponent";
import { settings } from "./utils/settings";
export const settings = definePluginSettings({
showStars: {
type: OptionType.BOOLEAN,
description: "Show repository stars",
default: true
},
showLanguage: {
type: OptionType.BOOLEAN,
description: "Show repository language",
default: true
},
showInMiniProfile: {
type: OptionType.BOOLEAN,
description: "Only show a button in the mini profile",
default: true
},
});
const getProfileThemeProps = findByCodeLazy(".getPreviewThemeColors", "primaryColor:");
@ -58,8 +77,8 @@ export default definePlugin({
{
find: "action:\"PRESS_APP_CONNECTION\"",
replacement: {
match: /(?<=user:(\i).{0,15}displayProfile:(\i).*?#{intl::USER_PROFILE_MEMBER_SINCE}.{0,90}\}\)\}\))/,
replace: "$&,$self.ProfilePopoutComponent({ user: $1, displayProfile: $2 }),"
match: /(?<=user:(\i).{0,15}displayProfile:(\i).*?CONNECTIONS.{0,100}\}\)\}\))/,
replace: ",$self.ProfilePopoutComponent({ user: $1, displayProfile: $2 })"
}
}
],

View file

@ -1,3 +1,9 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
export interface GitHubRepo {
id: number;
name: string;
@ -19,4 +25,4 @@ export interface RepoCardProps {
theme: string;
showStars: boolean;
showLanguage: boolean;
}
}

View file

@ -1,20 +0,0 @@
import { definePluginSettings } from "@api/Settings";
import { OptionType } from "@utils/types";
export const settings = definePluginSettings({
showStars: {
type: OptionType.BOOLEAN,
description: "Show repository stars",
default: true
},
showLanguage: {
type: OptionType.BOOLEAN,
description: "Show repository language",
default: true
},
showInMiniProfile: {
type: OptionType.BOOLEAN,
description: "Only show a button in the mini profile",
default: true
},
});