mirror of
https://github.com/Equicord/Equicord.git
synced 2025-04-01 13:11:57 -04:00
GitHubRepos Stuff
This commit is contained in:
parent
178062ac41
commit
f2462a9baa
9 changed files with 77 additions and 38 deletions
|
@ -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 {
|
export function getLanguageColor(language: string): string {
|
||||||
const colors: Record<string, string> = {
|
const colors: Record<string, string> = {
|
||||||
"JavaScript": "#f1e05a",
|
"JavaScript": "#f1e05a",
|
||||||
|
@ -58,4 +64,4 @@ export function getLanguageColor(language: string): string {
|
||||||
};
|
};
|
||||||
|
|
||||||
return colors[language] || "#858585";
|
return colors[language] || "#858585";
|
||||||
}
|
}
|
|
@ -8,9 +8,9 @@ import { Flex } from "@components/Flex";
|
||||||
import { openModal } from "@utils/modal";
|
import { openModal } from "@utils/modal";
|
||||||
import { React, useEffect, UserProfileStore, useState } from "@webpack/common";
|
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 { GitHubRepo } from "../types";
|
||||||
import { settings } from "../utils/settings";
|
|
||||||
import { RepoCard } from "./RepoCard";
|
import { RepoCard } from "./RepoCard";
|
||||||
import { ReposModal } from "./ReposModal";
|
import { ReposModal } from "./ReposModal";
|
||||||
|
|
||||||
|
|
|
@ -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 { Flex } from "@components/Flex";
|
||||||
import { React } from "@webpack/common";
|
import { React } from "@webpack/common";
|
||||||
|
|
||||||
|
import { getLanguageColor } from "../colors";
|
||||||
import { RepoCardProps } from "../types";
|
import { RepoCardProps } from "../types";
|
||||||
import { getLanguageColor } from "../utils/colors";
|
import { Star } from "./Star";
|
||||||
import { Star } from "./icons/Star";
|
|
||||||
|
|
||||||
export function RepoCard({ repo, theme, showStars, showLanguage }: RepoCardProps) {
|
export function RepoCard({ repo, theme, showStars, showLanguage }: RepoCardProps) {
|
||||||
const handleClick = () => window.open(repo.html_url, "_blank");
|
const handleClick = () => window.open(repo.html_url, "_blank");
|
||||||
|
@ -48,4 +55,4 @@ export function RepoCard({ repo, theme, showStars, showLanguage }: RepoCardProps
|
||||||
{renderLanguage()}
|
{renderLanguage()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 { ModalContent, ModalFooter, ModalHeader, ModalRoot } from "@utils/modal";
|
||||||
import { Button, Forms, React } from "@webpack/common";
|
import { Button, Forms, React } from "@webpack/common";
|
||||||
|
|
||||||
|
import { getLanguageColor } from "../colors";
|
||||||
import { GitHubRepo } from "../types";
|
import { GitHubRepo } from "../types";
|
||||||
import { getLanguageColor } from "../utils/colors";
|
import { Star } from "./Star";
|
||||||
import { Star } from "./icons/Star";
|
|
||||||
|
|
||||||
interface ReposModalProps {
|
interface ReposModalProps {
|
||||||
repos: GitHubRepo[];
|
repos: GitHubRepo[];
|
||||||
|
@ -91,4 +98,4 @@ export function ReposModal({ repos, username, rootProps }: ReposModalProps) {
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
</ModalRoot>
|
</ModalRoot>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 { React } from "@webpack/common";
|
||||||
import { IconProps } from "../../types";
|
|
||||||
|
import { IconProps } from "../types";
|
||||||
|
|
||||||
export function Star({ className, width = 16, height = 16 }: IconProps) {
|
export function Star({ className, width = 16, height = 16 }: IconProps) {
|
||||||
return (
|
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" />
|
<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>
|
</svg>
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -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 { Logger } from "@utils/Logger";
|
||||||
|
|
||||||
|
import { GitHubRepo } from "./types";
|
||||||
|
|
||||||
const logger = new Logger("GitHubRepos");
|
const logger = new Logger("GitHubRepos");
|
||||||
|
|
||||||
export interface GitHubUserInfo {
|
export interface GitHubUserInfo {
|
||||||
|
@ -55,4 +62,4 @@ export async function fetchReposByUsername(username: string, perPage: number = 3
|
||||||
|
|
||||||
function sortReposByStars(repos: GitHubRepo[]): GitHubRepo[] {
|
function sortReposByStars(repos: GitHubRepo[]): GitHubRepo[] {
|
||||||
return repos.sort((a, b) => b.stargazers_count - a.stargazers_count);
|
return repos.sort((a, b) => b.stargazers_count - a.stargazers_count);
|
||||||
}
|
}
|
|
@ -6,16 +6,35 @@
|
||||||
|
|
||||||
import "./styles.css";
|
import "./styles.css";
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { EquicordDevs } from "@utils/constants";
|
import { EquicordDevs } from "@utils/constants";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy } from "@webpack";
|
import { findByCodeLazy } from "@webpack";
|
||||||
import { React } from "@webpack/common";
|
import { React } from "@webpack/common";
|
||||||
import { User } from "discord-types/general";
|
import { User } from "discord-types/general";
|
||||||
|
|
||||||
import { GitHubReposComponent } from "./components/GitHubReposComponent";
|
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:");
|
const getProfileThemeProps = findByCodeLazy(".getPreviewThemeColors", "primaryColor:");
|
||||||
|
|
||||||
|
@ -58,8 +77,8 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: "action:\"PRESS_APP_CONNECTION\"",
|
find: "action:\"PRESS_APP_CONNECTION\"",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?<=user:(\i).{0,15}displayProfile:(\i).*?#{intl::USER_PROFILE_MEMBER_SINCE}.{0,90}\}\)\}\))/,
|
match: /(?<=user:(\i).{0,15}displayProfile:(\i).*?CONNECTIONS.{0,100}\}\)\}\))/,
|
||||||
replace: "$&,$self.ProfilePopoutComponent({ user: $1, displayProfile: $2 }),"
|
replace: ",$self.ProfilePopoutComponent({ user: $1, displayProfile: $2 })"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -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 {
|
export interface GitHubRepo {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -19,4 +25,4 @@ export interface RepoCardProps {
|
||||||
theme: string;
|
theme: string;
|
||||||
showStars: boolean;
|
showStars: boolean;
|
||||||
showLanguage: boolean;
|
showLanguage: boolean;
|
||||||
}
|
}
|
|
@ -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
|
|
||||||
},
|
|
||||||
});
|
|
Loading…
Add table
Reference in a new issue