From 50bb17efa7d8dad53eefaeb4b327a6930e441d70 Mon Sep 17 00:00:00 2001 From: Hammad Jutt Date: Sat, 19 Dec 2020 21:32:37 -0700 Subject: [PATCH] Consolidate contact UI with PlayerTile and Player page --- packages/design-system/src/index.ts | 1 + packages/web/components/LoginButton.tsx | 3 +- .../web/components/Player/PlayerContacts.tsx | 22 +++++-- .../Player/Section/PlayerContactButtons.tsx | 65 ------------------- .../components/Player/Section/PlayerHero.tsx | 58 +++++++++-------- packages/web/pages/player/[username].tsx | 11 +--- packages/web/utils/playerHelpers.ts | 3 + 7 files changed, 55 insertions(+), 108 deletions(-) delete mode 100644 packages/web/components/Player/Section/PlayerContactButtons.tsx diff --git a/packages/design-system/src/index.ts b/packages/design-system/src/index.ts index f831622f..d7ba80af 100644 --- a/packages/design-system/src/index.ts +++ b/packages/design-system/src/index.ts @@ -4,6 +4,7 @@ export { Box, FlexProps, Button, + ButtonProps, ButtonGroup, CSSReset, ChakraProvider, diff --git a/packages/web/components/LoginButton.tsx b/packages/web/components/LoginButton.tsx index 0f44849e..f66d6215 100644 --- a/packages/web/components/LoginButton.tsx +++ b/packages/web/components/LoginButton.tsx @@ -3,8 +3,7 @@ import { MetaLink } from 'components/Link'; import { Web3Context } from 'contexts/Web3Context'; import React, { useCallback, useContext } from 'react'; -const formatAddress = (address = '') => - `${address.slice(0, 6)}...${address.slice(-4)}`; +import { formatAddress } from '../utils/playerHelpers'; export const LoginButton: React.FC = () => { const { connectWeb3, disconnect, isConnected, address } = useContext( diff --git a/packages/web/components/Player/PlayerContacts.tsx b/packages/web/components/Player/PlayerContacts.tsx index fd3493b6..0346afc8 100644 --- a/packages/web/components/Player/PlayerContacts.tsx +++ b/packages/web/components/Player/PlayerContacts.tsx @@ -1,7 +1,9 @@ -import { Button } from '@metafam/ds'; +import { Button, Wrap } from '@metafam/ds'; import { PlayerFragmentFragment } from 'graphql/autogen/types'; import React from 'react'; -import { FaGithub, FaTwitter } from 'react-icons/fa'; +import { FaEthereum, FaGithub, FaTwitter } from 'react-icons/fa'; + +import { formatAddress } from '../../utils/playerHelpers'; type Props = { player: PlayerFragmentFragment; @@ -9,7 +11,7 @@ type Props = { export const PlayerContacts: React.FC = ({ player }) => { return ( - <> + {player.Accounts.map((acc) => { if (acc.type === 'TWITTER') { const link = `https://twitter.com/${acc.identifier}`; @@ -46,6 +48,18 @@ export const PlayerContacts: React.FC = ({ player }) => { } return null; })} - + {player.ethereum_address ? ( + + ) : null} + ); }; diff --git a/packages/web/components/Player/Section/PlayerContactButtons.tsx b/packages/web/components/Player/Section/PlayerContactButtons.tsx deleted file mode 100644 index 6b7dd710..00000000 --- a/packages/web/components/Player/Section/PlayerContactButtons.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import { Button, HStack } from '@metafam/ds'; -import { PlayerFragmentFragment } from 'graphql/autogen/types'; -import React from 'react'; -import { FaGithub, FaTwitter } from 'react-icons/fa'; - -import { PlayerSection } from './PlayerSection'; - -// TODO Maybe add more social platform -type Props = { player: PlayerFragmentFragment; onRemoveClick: () => void }; -export const PlayerContactButtons: React.FC = ({ - player, - onRemoveClick, -}) => { - return ( - - - {player.Accounts.map((acc) => { - if (acc.type === 'TWITTER') { - const link = `https://twitter.com/${acc.identifier}`; - return ( - - ); - } - if (acc.type === 'GITHUB') { - const link = `https://github.com/${acc.identifier}`; - return ( - - ); - } - return null; - })} - - - ); -}; diff --git a/packages/web/components/Player/Section/PlayerHero.tsx b/packages/web/components/Player/Section/PlayerHero.tsx index d31b5b3e..05a4d7e2 100644 --- a/packages/web/components/Player/Section/PlayerHero.tsx +++ b/packages/web/components/Player/Section/PlayerHero.tsx @@ -1,4 +1,4 @@ -import { Avatar, Box, HStack, Image, MetaTag, Text, VStack } from '@metafam/ds'; +import { Avatar, Box, HStack, Image, Text, VStack } from '@metafam/ds'; import { PlayerFragmentFragment } from 'graphql/autogen/types'; import React from 'react'; import { @@ -9,6 +9,7 @@ import { import { PersonalityTypes } from '../../../graphql/types'; import { FlexContainer } from '../../Container'; +import { PlayerContacts } from '../PlayerContacts'; import { PlayerCollab } from './PlayerCollab'; import { PlayerSection } from './PlayerSection'; @@ -33,11 +34,10 @@ export const PlayerHero: React.FC = ({ player }) => { {getPlayerName(player)} - {player.playerType?.title ? ( - - {player.playerType?.title.toUpperCase()} - - ) : null} + + + + @@ -63,27 +63,31 @@ export const PlayerHero: React.FC = ({ player }) => { - - {player.EnneagramType && ( - - {player.EnneagramType.name} - - - {player.EnneagramType.name} - - - {player.EnneagramType.description} - - - - )} - + {player.EnneagramType && ( + + {player.EnneagramType.name} + + + {player.EnneagramType.name} + + {player.EnneagramType.description} + + + )} + {player.playerType?.title ? ( + + + {player.playerType.title.toUpperCase()} + + {player.playerType.description} + + ) : null} ); diff --git a/packages/web/pages/player/[username].tsx b/packages/web/pages/player/[username].tsx index ab3c73a7..e5c91497 100644 --- a/packages/web/pages/player/[username].tsx +++ b/packages/web/pages/player/[username].tsx @@ -14,7 +14,6 @@ import React from 'react'; import { PageContainer } from '../../components/Container'; import { PlayerAchievements } from '../../components/Player/Section/PlayerAchievements'; import { PlayerAddSection } from '../../components/Player/Section/PlayerAddSection'; -import { PlayerContactButtons } from '../../components/Player/Section/PlayerContactButtons'; import { PlayerGallery } from '../../components/Player/Section/PlayerGallery'; import { PlayerMemberships } from '../../components/Player/Section/PlayerMemberships'; import { PlayerSkills } from '../../components/Player/Section/PlayerSkills'; @@ -27,7 +26,6 @@ const PlayerPage: React.FC = ({ player }) => { // TODO Fake data should be saved in back-end const BOX_TYPE = { PLAYER_SKILLS: 'Skills', - PLAYER_CONTACT_BUTTONS: 'Contact', PLAYER_GALLERY: 'Gallery', PLAYER_MEMBERSHIPS: 'Memberships', PLAYER_ACHIEVEMENTS: 'Achievements', @@ -36,7 +34,7 @@ const PlayerPage: React.FC = ({ player }) => { const [canEdit] = React.useState(false); const [fakeData, setFakeData] = React.useState([ - [BOX_TYPE.PLAYER_CONTACT_BUTTONS], + [], [BOX_TYPE.PLAYER_MEMBERSHIPS, BOX_TYPE.PLAYER_SKILLS], [BOX_TYPE.PLAYER_GALLERY], ]); @@ -74,13 +72,6 @@ const PlayerPage: React.FC = ({ player }) => { onRemoveClick={() => removeBox(column, name)} /> ); - case BOX_TYPE.PLAYER_CONTACT_BUTTONS: - return ( - removeBox(column, name)} - /> - ); case BOX_TYPE.PLAYER_GALLERY: return ( export const getPlayerDescription = (player: PlayerFragmentFragment): string => player.box_profile?.description || ''; + +export const formatAddress = (address = '') => + `${address.slice(0, 6)}...${address.slice(-4)}`;