mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
* incorporating configuration panes from #1078 * standardizing player hero subcomponents & removing `owner` var from `useProfileField` 🚪 * switching box type, ambiguating overly-specific names, & massaging heights 📱 * reordering profile details sections, updating deployment environment, & conditionally wrapping the hero elements 🎬 * fixing render of color disposition selector 🕍 * self code review changes: removed some `;`s 🎋 * getting yarn typecheck && yarn lint to pass post rebase 🏇🏾 * handling "missing <div> in <button>" error with mounted check & setting HTTP return codes for OpenSea API endpoint 🕺 * `ProfileWizard` extends `Wizard`, roles display better on mobile, & pronouns use `ProfileWizardPane` 🍊 * properly encapsulating ETH address regex 🚲 * adding some tasks 🏥 * fixed skills layou * handling default values? ❔ * corrections for revision comments from @dan13ram (UI bugs to follow) 🌋 * cleaning up memberships & explorer type 🧫 * refactoring player roles configuration and display to use `WizardPane` 🔮 * bunches of mobile fixes & repairing the display of deserialized skills 📟 * removing redirect in static props & formatting memberships display for responsiveness 🪆 * improving comprehensability of `/me` & more mobile tweaking 🍦 * various spacing fixes & a “try again” button for connecting 🫕 * maybe fixed issue with saving images for fields with default values 🇩🇿 * switched roles selection to a bounded `SimpleGrid` to fix sizing weirdness 🧰 * fix: removed verify on brightId button * fix: clean up username page * formatting & fixing skills issues 🥩 * reformatting NFT display 🚂 * adding `/join` 🚉 * style: peth's suggestions * added mainnet required message * style: slight tweak of megamenu item positions * chore(release): 0.2.0 Co-authored-by: tenfinney <scott@1box.onmicrosoft.com> Co-authored-by: dan13ram <dan13ram@gmail.com> Co-authored-by: vidvidvid <weetopol@gmail.com>
203 lines
6.2 KiB
TypeScript
203 lines
6.2 KiB
TypeScript
import {
|
|
Button,
|
|
Flex,
|
|
FlexProps,
|
|
Input,
|
|
MetaTheme,
|
|
Modal,
|
|
ModalBody,
|
|
ModalCloseButton,
|
|
ModalContent,
|
|
ModalFooter,
|
|
ModalHeader,
|
|
ModalOverlay,
|
|
Select,
|
|
useDisclosure,
|
|
VStack,
|
|
} from '@metafam/ds';
|
|
import { Maybe } from '@metafam/utils';
|
|
import BackgroundImage from 'assets/main-background.jpg';
|
|
import { PlayerSection } from 'components/Profile/PlayerSection';
|
|
import { Player } from 'graphql/autogen/types';
|
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
import { BoxMetadata, BoxType, BoxTypes } from 'utils/boxTypes';
|
|
|
|
type Props = FlexProps & {
|
|
player: Player;
|
|
boxes: Array<BoxType>;
|
|
onAddBox: (arg0: BoxType, arg1: BoxMetadata) => void;
|
|
};
|
|
|
|
export const PlayerAddSection = React.forwardRef<HTMLDivElement, Props>(
|
|
({ player, boxes = [], onAddBox, ...props }, ref) => {
|
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
|
const [type, setType] = useState<Maybe<BoxType>>(null);
|
|
const [metadata, setMetadata] = useState<BoxMetadata>({});
|
|
const selectBoxType = useCallback(
|
|
({ target: { value: boxId } }) => setType(boxId),
|
|
[],
|
|
);
|
|
|
|
const addSection = useCallback(() => {
|
|
if (!type) return;
|
|
onAddBox(type, metadata);
|
|
onClose();
|
|
}, [type, metadata, onAddBox, onClose]);
|
|
|
|
useEffect(() => {
|
|
setMetadata({});
|
|
setType(null);
|
|
}, [isOpen]);
|
|
|
|
return (
|
|
<Flex
|
|
w="full"
|
|
h="full"
|
|
direction="column"
|
|
boxShadow="md"
|
|
pos="relative"
|
|
{...{ ref }}
|
|
>
|
|
<Flex
|
|
bg="whiteAlpha.200"
|
|
border="dashed 1px rgba(255, 255, 255, 0.3)"
|
|
borderRadius="lg"
|
|
boxShadow="md"
|
|
w="100%"
|
|
h="100%"
|
|
css={{ backdropFilter: 'blur(8px)' }}
|
|
{...props}
|
|
>
|
|
<Button
|
|
onClick={onOpen}
|
|
w="100%"
|
|
h="100%"
|
|
m={0}
|
|
bg="blue20"
|
|
color="offwhite"
|
|
textTransform="uppercase"
|
|
opacity={0.4}
|
|
size="lg"
|
|
_hover={{ bg: 'purpleBoxLight', opacity: '0.8' }}
|
|
>
|
|
Add New Block
|
|
</Button>
|
|
<Modal {...{ isOpen, onClose }}>
|
|
<ModalOverlay />
|
|
<ModalContent
|
|
maxW="50rem"
|
|
bgImage={`url(${BackgroundImage})`}
|
|
bgSize="cover"
|
|
bgAttachment="fixed"
|
|
px={[4, 8, 12]}
|
|
py={8}
|
|
>
|
|
<VStack spacing={0} align="center">
|
|
<ModalCloseButton
|
|
color="pinkShadeOne"
|
|
size="xl"
|
|
p={4}
|
|
top={0}
|
|
right={0}
|
|
_focus={{ boxShadow: 'none' }}
|
|
/>
|
|
<ModalHeader color="white" fontSize="4xl" fontWeight="normal">
|
|
Add New Block
|
|
</ModalHeader>
|
|
<ModalBody>
|
|
<VStack
|
|
spacing={6}
|
|
color="white"
|
|
w={{ base: '100%', sm: '30rem' }}
|
|
maxW="30rem"
|
|
>
|
|
<Select
|
|
placeholder="Select a Type to Add…"
|
|
borderColor={MetaTheme.colors.whiteAlpha[800]}
|
|
onChange={selectBoxType}
|
|
sx={{
|
|
textTransform: 'capitalize',
|
|
'& > option': {
|
|
backgroundColor: MetaTheme.colors.purpleBoxLight,
|
|
},
|
|
'& > option[value=""]': {
|
|
fontStyle: 'italic',
|
|
opacity: 0.75,
|
|
},
|
|
}}
|
|
>
|
|
{boxes.length === 0 ? (
|
|
<option value="nothing" disabled>
|
|
No choice :/
|
|
</option>
|
|
) : (
|
|
boxes.map((box) => (
|
|
<option key={box} value={box}>
|
|
{box.replace(/-/g, ' ')}
|
|
</option>
|
|
))
|
|
)}
|
|
</Select>
|
|
{type === BoxTypes.EMBEDDED_URL && (
|
|
<Input
|
|
bg="dark"
|
|
w="100%"
|
|
placeholder="Provide the URL of the content"
|
|
_placeholder={{ color: 'whiteAlpha.500' }}
|
|
onChange={({ target: { value: url } }) =>
|
|
setMetadata({ url })
|
|
}
|
|
size="lg"
|
|
borderRadius={0}
|
|
borderColor="borderPurple"
|
|
fontSize="md"
|
|
borderWidth="2px"
|
|
/>
|
|
)}
|
|
{type && (
|
|
<Flex
|
|
w={{ base: '100%', sm: '30rem' }}
|
|
maxW="30rem"
|
|
bg="blueProfileSection"
|
|
borderRadius="lg"
|
|
>
|
|
<PlayerSection
|
|
isOwnProfile={false}
|
|
editing={false}
|
|
{...{
|
|
type,
|
|
metadata,
|
|
player,
|
|
}}
|
|
/>
|
|
</Flex>
|
|
)}
|
|
</VStack>
|
|
</ModalBody>
|
|
<ModalFooter>
|
|
<Button
|
|
colorScheme="blue"
|
|
mr={3}
|
|
onClick={addSection}
|
|
isDisabled={!type}
|
|
>
|
|
Save Block
|
|
</Button>
|
|
<Button
|
|
variant="ghost"
|
|
onClick={onClose}
|
|
color="white"
|
|
_hover={{ bg: 'none' }}
|
|
>
|
|
Close
|
|
</Button>
|
|
</ModalFooter>
|
|
</VStack>
|
|
</ModalContent>
|
|
</Modal>
|
|
</Flex>
|
|
</Flex>
|
|
);
|
|
},
|
|
);
|