Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework game page header #71

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 85 additions & 57 deletions app/routes/game.$id.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,25 @@ import {
useDisclosure,
IconButton,
Tag,
useColorModeValue,
Link as ChakraLink,
List,
ListItem,
chakra,
Flex,
Menu,
MenuButton,
MenuList,
MenuItem,
MenuDivider,
useColorModeValue,
} from '@chakra-ui/react';
import {
AddIcon,
DeleteIcon,
EditIcon,
ExternalLinkIcon,
HamburgerIcon,
TimeIcon,
} from '@chakra-ui/icons';
import { json } from '@remix-run/node';
import { Form, Link, useFetcher, useLoaderData } from '@remix-run/react';
Expand Down Expand Up @@ -186,39 +193,66 @@ const Game = () => {

return (
<>
<Box mb={5} pl={5} pr={5} mt={5}>
<Box m={5}>
<Flex direction="row" align="center">
<Heading as="h2" noOfLines={1} title={name} size="2xl">
<Heading
as="h2"
size="2xl"
fontWeight="300"
noOfLines={1}
flex="auto"
title={name}
>
{name}
</Heading>

{site && (
<IconButton
as={ChakraLink}
icon={<ExternalLinkIcon />}
href={site}
isExternal
/>
)}

{currentUser && (
<>
<ChakraLink to={`/game/${id}/changes`} as={Link} ml="auto">
Changes History
</ChakraLink>
<Button
as={Link}
to={`/game/${id}/edit`}
leftIcon={<EditIcon />}
colorScheme="teal"
ml={3}
>
Edit
</Button>
</>
<Menu>
<MenuButton
as={IconButton}
aria-label="Options"
icon={<HamburgerIcon />}
variant="outline"
ml={2}
/>
<MenuList>
<MenuItem
as={ChakraLink}
icon={<EditIcon />}
href={`/game/${id}/edit`}
>
Edit
</MenuItem>
<MenuItem
as={ChakraLink}
icon={<TimeIcon />}
href={`/game/${id}/changes`}
>
History
</MenuItem>
<MenuDivider />
<MenuItem
icon={<DeleteIcon />}
onClick={deleteModal.onOpen}
>
Delete
</MenuItem>
</MenuList>
</Menu>
)}
</Flex>
{site && (
<Text fontSize="lg">
<ChakraLink href={site} isExternal>
{site.replace(/https?:\/\//, '')}
<ExternalLinkIcon mx="2px" />
</ChakraLink>
</Text>
)}

{about && (
<Box mt={3}>
<Box my={5} maxWidth="37em">
<Markdown value={about} />
</Box>
)}
Expand Down Expand Up @@ -459,37 +493,31 @@ const Game = () => {
)}

{currentUser && (
<Box mb={5} pl={5} pr={5}>
<Button variant="link" colorScheme="red" onClick={deleteModal.onOpen}>
Delete game
</Button>

<Modal isOpen={deleteModal.isOpen} onClose={deleteModal.onClose}>
<ModalOverlay />
<ModalContent as={Form} action={`/game/${id}/delete`} method="post">
<ModalHeader>Delete Game</ModalHeader>
<ModalCloseButton />
<ModalBody>
<Text>Do you really want to delete {name}?</Text>
</ModalBody>

<ModalFooter>
<Button
type="submit"
isLoading={false}
loadingText="Deleting"
colorScheme="red"
mr={3}
>
Delete
</Button>
<Button variant="ghost" onClick={deleteModal.onClose}>
Cancel
</Button>
</ModalFooter>
</ModalContent>
</Modal>
</Box>
<Modal isOpen={deleteModal.isOpen} onClose={deleteModal.onClose}>
<ModalOverlay />
<ModalContent as={Form} action={`/game/${id}/delete`} method="post">
<ModalHeader>Delete Game</ModalHeader>
<ModalCloseButton />
<ModalBody>
<Text>Do you really want to delete {name}?</Text>
</ModalBody>

<ModalFooter>
<Button
type="submit"
isLoading={false}
loadingText="Deleting"
colorScheme="red"
mr={3}
>
Delete
</Button>
<Button variant="ghost" onClick={deleteModal.onClose}>
Cancel
</Button>
</ModalFooter>
</ModalContent>
</Modal>
)}
</>
);
Expand Down