Move Rename into outfit menu
More stuff will be there later, mostly I'm just creating the new home, and making room for the new save UI
This commit is contained in:
parent
9f5b8a7e6e
commit
7a7c166148
1 changed files with 56 additions and 49 deletions
|
@ -10,13 +10,18 @@ import {
|
||||||
Skeleton,
|
Skeleton,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
VisuallyHidden,
|
VisuallyHidden,
|
||||||
|
Menu,
|
||||||
|
MenuButton,
|
||||||
|
MenuList,
|
||||||
|
MenuItem,
|
||||||
|
Portal,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { EditIcon, QuestionIcon } from "@chakra-ui/icons";
|
import { EditIcon, QuestionIcon } from "@chakra-ui/icons";
|
||||||
import { CSSTransition, TransitionGroup } from "react-transition-group";
|
import { CSSTransition, TransitionGroup } from "react-transition-group";
|
||||||
|
|
||||||
import { Delay, Heading1, Heading2 } from "../util";
|
import { Delay, Heading1, Heading2 } from "../util";
|
||||||
import Item, { ItemListContainer, ItemListSkeleton } from "./Item";
|
import Item, { ItemListContainer, ItemListSkeleton } from "./Item";
|
||||||
import WIPCallout from "../components/WIPCallout";
|
import { MdMoreVert } from "react-icons/md";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ItemsPanel shows the items in the current outfit, and lets the user toggle
|
* ItemsPanel shows the items in the current outfit, and lets the user toggle
|
||||||
|
@ -239,13 +244,12 @@ function ItemZoneGroupSkeleton({ itemCount }) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OutfitHeading is an editable outfit name, as a big pretty page heading!
|
* OutfitHeading is an editable outfit name, as a big pretty page heading!
|
||||||
|
* It also contains the outfit menu, for saving etc.
|
||||||
*/
|
*/
|
||||||
function OutfitHeading({ outfitState, dispatchToOutfit }) {
|
function OutfitHeading({ outfitState, dispatchToOutfit }) {
|
||||||
return (
|
return (
|
||||||
<Flex align="flex-start" justify="space-between">
|
// The Editable wraps everything, including the menu, because the menu has
|
||||||
<Box marginRight="4">
|
// a Rename option.
|
||||||
<Box role="group" d="inline-block" position="relative" width="100%">
|
|
||||||
<Heading1 mb="6">
|
|
||||||
<Editable
|
<Editable
|
||||||
// Make sure not to ever pass `undefined` into here, or else the
|
// Make sure not to ever pass `undefined` into here, or else the
|
||||||
// component enters uncontrolled mode, and changing the value
|
// component enters uncontrolled mode, and changing the value
|
||||||
|
@ -256,41 +260,44 @@ function OutfitHeading({ outfitState, dispatchToOutfit }) {
|
||||||
dispatchToOutfit({ type: "rename", outfitName: value })
|
dispatchToOutfit({ type: "rename", outfitName: value })
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{({ isEditing, onEdit }) => (
|
{({ onEdit }) => (
|
||||||
<Flex align="flex-top">
|
<Flex align="center" justify="space-between" marginBottom="6">
|
||||||
<EditablePreview />
|
<Box marginRight="4">
|
||||||
<EditableInput />
|
<Box role="group" d="inline-block" position="relative" width="100%">
|
||||||
{!isEditing && (
|
<Heading1>
|
||||||
<Box
|
<EditablePreview lineHeight="48px" />
|
||||||
opacity="0"
|
<EditableInput lineHeight="48px" />
|
||||||
transition="opacity 0.5s"
|
|
||||||
_groupHover={{ opacity: "1" }}
|
|
||||||
onClick={onEdit}
|
|
||||||
>
|
|
||||||
<IconButton
|
|
||||||
icon={<EditIcon />}
|
|
||||||
variant="link"
|
|
||||||
aria-label="Edit outfit name"
|
|
||||||
title="Edit outfit name"
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Flex>
|
|
||||||
)}
|
|
||||||
</Editable>
|
|
||||||
</Heading1>
|
</Heading1>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
{outfitState.id && (
|
<Menu placement="bottom-end">
|
||||||
<WIPCallout
|
<MenuButton
|
||||||
details={`To save a new version of this outfit, use Classic DTI. But you can still play around in here for now!`}
|
as={IconButton}
|
||||||
marginTop="1"
|
variant="ghost"
|
||||||
placement="bottom-end"
|
icon={<MdMoreVert />}
|
||||||
|
aria-label="Outfit menu"
|
||||||
|
borderRadius="full"
|
||||||
|
fontSize="24px"
|
||||||
|
opacity="0.8"
|
||||||
|
/>
|
||||||
|
<Portal>
|
||||||
|
<MenuList>
|
||||||
|
<MenuItem
|
||||||
|
icon={<EditIcon />}
|
||||||
|
onClick={() => {
|
||||||
|
// Start the rename after a tick, so finishing up the click
|
||||||
|
// won't just immediately remove focus from the Editable.
|
||||||
|
setTimeout(onEdit, 0);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Saved outfits are WIP!
|
Rename
|
||||||
</WIPCallout>
|
</MenuItem>
|
||||||
)}
|
</MenuList>
|
||||||
|
</Portal>
|
||||||
|
</Menu>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
)}
|
||||||
|
</Editable>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue