diff --git a/frontend-react/src/components/common/Flag.tsx b/frontend-react/src/components/common/Flag.tsx index 093fef419..8a1ee357f 100644 --- a/frontend-react/src/components/common/Flag.tsx +++ b/frontend-react/src/components/common/Flag.tsx @@ -1,5 +1,6 @@ import React from "react" import { CountryCode } from "../../types" +import { countries } from "../../utils/lists" interface FlagProps { code: CountryCode @@ -9,8 +10,14 @@ const Flag: React.FC = ({ code }) => { return ( {`Flag obj.code === code)?.name} /> ) } diff --git a/frontend-react/src/components/elements/Button.tsx b/frontend-react/src/components/elements/Button.tsx index babe749c8..d72c05da8 100644 --- a/frontend-react/src/components/elements/Button.tsx +++ b/frontend-react/src/components/elements/Button.tsx @@ -1,5 +1,8 @@ import React from "react" -import { Button as ChakraButton } from "@chakra-ui/core" +import { + Button as ChakraButton, + ButtonProps as ChakraButtonProps, +} from "@chakra-ui/core" import { useContext } from "react" import MyThemeContext from "../../themeContext" import { IconType } from "react-icons/lib/cjs" @@ -15,7 +18,7 @@ interface ButtonProps { loading?: boolean } -const Button: React.FC = ({ +const Button: React.FC = ({ children, onClick, icon, @@ -24,6 +27,7 @@ const Button: React.FC = ({ loading, width, outlined = false, + ...props }) => { const { themeColor } = useContext(MyThemeContext) return ( @@ -36,6 +40,7 @@ const Button: React.FC = ({ isDisabled={disabled} isLoading={loading} width={width ?? undefined} + {...props} > {children} diff --git a/frontend-react/src/components/elements/Markdown.tsx b/frontend-react/src/components/elements/Markdown.tsx index 109a8524a..fc62cc371 100644 --- a/frontend-react/src/components/elements/Markdown.tsx +++ b/frontend-react/src/components/elements/Markdown.tsx @@ -80,7 +80,7 @@ const Markdown: React.FC = ({ value }) => { text: (props: any) => { const { children } = props return ( - + {reactStringReplace(children, /(:\S+:)/g, (match, i) => ( ))} diff --git a/frontend-react/src/components/user/AvatarWithInfo.tsx b/frontend-react/src/components/user/AvatarWithInfo.tsx index 5b62226a2..9387d9a84 100644 --- a/frontend-react/src/components/user/AvatarWithInfo.tsx +++ b/frontend-react/src/components/user/AvatarWithInfo.tsx @@ -1,18 +1,12 @@ -import React, { useState } from "react" -import { Flex, List, ListItem, ListIcon } from "@chakra-ui/core" -import { - FaUserAlt, - FaTwitter, - FaTwitch, - FaGamepad, - FaEdit, -} from "react-icons/fa" - -import UserAvatar from "../common/UserAvatar" +import { Box, Flex, Heading } from "@chakra-ui/core" +import React, { useContext, useState } from "react" +import { FaEdit, FaGamepad, FaTwitch, FaTwitter } from "react-icons/fa" +import MyThemeContext from "../../themeContext" import { User } from "../../types" import Flag from "../common/Flag" -import { countries } from "../../utils/lists" -import IconButton from "../elements/IconButton" +import UserAvatar from "../common/UserAvatar" +import WeaponImage from "../common/WeaponImage" +import Button from "../elements/Button" import ProfileModal from "./ProfileModal" function getSensString(motion: number | undefined, stick: number): string { @@ -29,6 +23,7 @@ interface AvatarWithInfoProps { } const AvatarWithInfo: React.FC = ({ user, canEdit }) => { + const { grayWithShade } = useContext(MyThemeContext) const [showModal, setShowModal] = useState(false) return ( <> @@ -42,62 +37,78 @@ const AvatarWithInfo: React.FC = ({ user, canEdit }) => { }} /> )} - - - - {canEdit && ( - - setShowModal(true)} - /> - - )} - - - {user.username}#{user.discriminator} - - {user.country && ( - - - {countries.find((obj) => obj.code === user.country)?.name} - - )} - {user.twitter_name && ( - - - - {user.twitter_name} - - - )} - {user.twitch_name && ( - - - - {user.twitch_name} - - - )} - {user.sens && (!!user.sens.stick || user.sens.stick === 0) && ( - - - {getSensString(user.sens.motion, user.sens.stick)} - - )} - + + + + + + {user.username}#{user.discriminator} + + {user.country && } + + + + {user.twitter_name && ( + + + + {user.twitter_name} + + + )} + {user.twitch_name && ( + + + + {user.twitch_name} + + + )} + {user.sens && (!!user.sens.stick || user.sens.stick === 0) && ( + + + {getSensString(user.sens.motion, user.sens.stick)} + + )} + {user.weapons && user.weapons.length > 0 && ( + + {user.weapons.map((wpn) => ( + + + + ))} + + )} + + + + {canEdit && ( + + )} ) diff --git a/frontend-react/src/components/user/UserPage.tsx b/frontend-react/src/components/user/UserPage.tsx index a2e480ad2..1e6e79261 100644 --- a/frontend-react/src/components/user/UserPage.tsx +++ b/frontend-react/src/components/user/UserPage.tsx @@ -1,45 +1,42 @@ -import React, { useContext } from "react" -import { RouteComponentProps, Redirect } from "@reach/router" import { useQuery } from "@apollo/react-hooks" - import { - SEARCH_FOR_USER, + Badge, + Box, + Tab, + TabList, + TabPanel, + TabPanels, + Tabs, +} from "@chakra-ui/core" +import { Redirect, RouteComponentProps } from "@reach/router" +import React, { useContext } from "react" +import { Helmet } from "react-helmet-async" +import { FaTrophy, FaTshirt } from "react-icons/fa" +import { IconType } from "react-icons/lib/cjs" +import { PLAYER_INFO } from "../../graphql/queries/playerInfo" +import { SEARCH_FOR_BUILDS } from "../../graphql/queries/searchForBuilds" +import { SearchForUserData, SearchForUserVars, + SEARCH_FOR_USER, } from "../../graphql/queries/searchForUser" import { USER } from "../../graphql/queries/user" -import Loading from "../common/Loading" -import Error from "../common/Error" +import MyThemeContext from "../../themeContext" import { - UserData, - SearchForBuildsData, - SearchForBuildsVars, PlayerInfoData, PlayerInfoVars, + SearchForBuildsData, + SearchForBuildsVars, + UserData, } from "../../types" -import { FaTshirt, FaTrophy } from "react-icons/fa" -import { IconType } from "react-icons/lib/cjs" -import AvatarWithInfo from "./AvatarWithInfo" -import WeaponPool from "./WeaponPool" -import { - Box, - Tabs, - TabList, - Tab, - TabPanels, - TabPanel, - Badge, -} from "@chakra-ui/core" -import { Helmet } from "react-helmet-async" -import { SEARCH_FOR_BUILDS } from "../../graphql/queries/searchForBuilds" -import BuildTab from "./BuildTab" -import MyThemeContext from "../../themeContext" -import { PLAYER_INFO } from "../../graphql/queries/playerInfo" -import XRankTab from "./XRankTab" import { weapons } from "../../utils/lists" +import Error from "../common/Error" +import Loading from "../common/Loading" import Alert from "../elements/Alert" import Markdown from "../elements/Markdown" -import SubHeader from "../common/SubHeader" +import AvatarWithInfo from "./AvatarWithInfo" +import BuildTab from "./BuildTab" +import XRankTab from "./XRankTab" interface Tab { id: number @@ -172,14 +169,8 @@ const UserPage: React.FC = ({ id }) => { user={user} canEdit={userLean?.discord_id === user.discord_id} /> - {user.weapons && user.weapons.length > 0 && ( - - - - )} {user.bio && ( - - Bio + )} diff --git a/frontend-react/src/components/user/WeaponPool.tsx b/frontend-react/src/components/user/WeaponPool.tsx deleted file mode 100644 index 8a2fc4b58..000000000 --- a/frontend-react/src/components/user/WeaponPool.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from "react" -import { Weapon } from "../../types" -import { Box, Flex } from "@chakra-ui/core" -import WeaponImage from "../common/WeaponImage" -import FieldsetWithLegend from "../common/FieldsetWithLegend" - -interface WeaponPoolProps { - weapons: Weapon[] -} - -const WeaponPool: React.FC = ({ weapons }) => { - return ( - - - {weapons.map(wpn => ( - - - - ))} - - - ) -} - -export default WeaponPool