diff --git a/documentation/src/context/CommunityStats/index.tsx b/documentation/src/context/CommunityStats/index.tsx deleted file mode 100644 index 7beec1a..0000000 --- a/documentation/src/context/CommunityStats/index.tsx +++ /dev/null @@ -1,116 +0,0 @@ -import React, { - createContext, - FC, - useCallback, - useContext, - useEffect, - useMemo, - useState, -} from "react"; - -interface ICommunityStatsContext { - githubStarCount: number; - githubStarCountText: string; - githubCommitCount: number; - discordMemberCount: number; - discordMemberCountText: string; - loading: boolean; - refetch: () => Promise; -} - -export const CommunityStatsContext = createContext< - ICommunityStatsContext | undefined ->(undefined); - -export const CommunityStatsProvider: FC = ({ children }) => { - const [loading, setLoading] = useState(true); - const [githubStarCount, setGithubStarCount] = useState(0); - const [githubCommitCount, setGithubCommitCount] = useState(0); - const [discordMemberCount, setDiscordMemberCount] = useState(0); - - const fetchGithubCount = useCallback(async (signal: AbortSignal) => { - try { - setLoading(true); - - const response = await fetch( - `https://stargate.refine.dev/community-numbers`, - { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - signal, - }, - ); - - const json = await response.json(); - setGithubStarCount(json.githubStarCount); - setGithubCommitCount(json.githubCommitCount); - setDiscordMemberCount(json.discordMemberCount); - } catch (error) { - } finally { - setLoading(false); - } - }, []); - - useEffect(() => { - const abortController = new AbortController(); - fetchGithubCount(abortController.signal); - - return () => { - abortController.abort(); - }; - }, [fetchGithubCount]); - - const githubStarCountText = useMemo(() => { - return convertStatToText(githubStarCount); - }, [githubStarCount]); - - const discordMemberCountText = useMemo(() => { - return convertStatToText(discordMemberCount); - }, [discordMemberCount]); - - const value = { - githubStarCount, - githubStarCountText, - githubCommitCount, - discordMemberCount, - discordMemberCountText, - loading, - refetch: fetchGithubCount, - }; - - return ( - - {children} - - ); -}; - -export const useCommunityStatsContext = () => { - const context = useContext(CommunityStatsContext); - if (context === undefined) { - throw new Error( - "useGithubProvider must be used within a GithubProvider", - ); - } - return context; -}; - -export const convertStatToText = (num: number) => { - const hasIntlSupport = - typeof Intl == "object" && - Intl && - typeof Intl.NumberFormat == "function"; - - if (!hasIntlSupport) { - return `${(num / 1000).toFixed(1)}k`; - } - - const formatter = new Intl.NumberFormat("en-US", { - notation: "compact", - compactDisplay: "short", - maximumSignificantDigits: 3, - }); - return formatter.format(num); -}; diff --git a/documentation/src/refine-theme/landing-community.tsx b/documentation/src/refine-theme/landing-community.tsx deleted file mode 100644 index ea28351..0000000 --- a/documentation/src/refine-theme/landing-community.tsx +++ /dev/null @@ -1,190 +0,0 @@ -import clsx from "clsx"; -import React, { FC, useMemo } from "react"; -import { useColorMode } from "@docusaurus/theme-common"; -import { useCommunityStatsContext } from "../context/CommunityStats"; -import useIsBrowser from "@docusaurus/useIsBrowser"; - -type Props = { - className?: string; -}; - -export const LandingCommunity: FC = ({ className }) => { - const isBrowser = useIsBrowser(); - - const { colorMode } = useColorMode(); - - const { githubStarCountText } = useCommunityStatsContext(); - - const list = useMemo(() => { - return [ - { - stat: githubStarCountText, - description: "Active installations", - href: "https://github.com/stefanpejcic", - }, - { - stat: "8K+", - description: - "Resolved issues and forum topics", - }, - { - stat: "420K+", - description: "End users are hosting websites using OpenPanel", - }, - { - stat: "1M+", - description: "Websites are running on OpenAdmin servers", - }, - ]; - }, [githubStarCountText]); - - return ( -
-
-

- Feel the power of a{" "} - - great community - - . -

-
- -
-
- {list.map((item, index) => { - return ( - -
- {item.stat} -
-
- {item.description} -
-
- ); - })} -
- -
- {isBrowser && ( - investors - )} -
- Built by{" "} - - MI - {" "} - and{" "} - - JA - - . -
-
-
-
- ); -}; diff --git a/documentation/src/theme/Root.tsx b/documentation/src/theme/Root.tsx deleted file mode 100644 index c219456..0000000 --- a/documentation/src/theme/Root.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import React, { FC } from "react"; - -import { CommunityStatsProvider } from "../context/CommunityStats"; - -const Root: FC = ({ children }) => { - return {children}; -}; - -export default Root;