-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #315 from scottbenton/feat/redesign-moves-and-oracles
Feat/redesign moves and oracles
- Loading branch information
Showing
29 changed files
with
473 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/components/features/charactersAndCampaigns/CollapsibleSectionHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
Box, | ||
ListItemButton, | ||
ListItemIcon, | ||
ListSubheader, | ||
} from "@mui/material"; | ||
import OpenIcon from "@mui/icons-material/ChevronRight"; | ||
|
||
export interface CollapsibleSectionHeaderProps { | ||
text: string; | ||
open: boolean; | ||
toggleOpen: () => void; | ||
} | ||
|
||
export function CollapsibleSectionHeader(props: CollapsibleSectionHeaderProps) { | ||
const { text, open, toggleOpen } = props; | ||
|
||
return ( | ||
<ListSubheader | ||
disableGutters | ||
sx={(theme) => ({ | ||
mt: open ? 0.5 : 0, | ||
backgroundColor: theme.palette.background.paperInlayDarker, | ||
color: theme.palette.grey[theme.palette.mode === "light" ? 700 : 200], | ||
...theme.typography.body1, | ||
fontFamily: theme.fontFamilyTitle, | ||
display: "flex", | ||
justifyContent: "space-between", | ||
alignItems: "center", | ||
transition: theme.transitions.create(["margin"], { | ||
duration: theme.transitions.duration.shorter, | ||
}), | ||
})} | ||
> | ||
<ListItemButton onClick={toggleOpen}> | ||
<Box sx={{ flexGrow: 1 }}>{text}</Box> | ||
<ListItemIcon sx={{ minWidth: "unset" }}> | ||
<OpenIcon | ||
sx={(theme) => ({ | ||
transform: `rotate(${open ? "-" : ""}90deg)`, | ||
transition: theme.transitions.create(["transform"], { | ||
duration: theme.transitions.duration.shorter, | ||
}), | ||
})} | ||
/> | ||
</ListItemIcon> | ||
</ListItemButton> | ||
</ListSubheader> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 71 additions & 41 deletions
112
src/components/features/charactersAndCampaigns/MovesSection/MoveCategory.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,99 @@ | ||
import { | ||
Box, | ||
Collapse, | ||
ListItem, | ||
ListItemButton, | ||
ListItemIcon, | ||
ListSubheader, | ||
} from "@mui/material"; | ||
import { Move, MoveCategory as IMoveCategory } from "dataforged"; | ||
import OpenIcon from "@mui/icons-material/ChevronRight"; | ||
import { useEffect, useState } from "react"; | ||
import { useNewMoveOracleView } from "hooks/featureFlags/useNewMoveOracleView"; | ||
import { CollapsibleSectionHeader } from "../CollapsibleSectionHeader"; | ||
|
||
export interface MoveCategoryProps { | ||
category: IMoveCategory; | ||
openMove: (move: Move) => void; | ||
forceOpen?: boolean; | ||
} | ||
|
||
export function MoveCategory(props: MoveCategoryProps) { | ||
const { category, openMove } = props; | ||
const { category, openMove, forceOpen } = props; | ||
|
||
const showNewView = useNewMoveOracleView(); | ||
const [isExpanded, setIsExpanded] = useState(showNewView ? false : true); | ||
|
||
useEffect(() => { | ||
setIsExpanded(showNewView ? false : true); | ||
}, [showNewView]); | ||
|
||
const isExpandedOrForced = isExpanded || forceOpen; | ||
|
||
return ( | ||
<> | ||
<ListSubheader | ||
sx={(theme) => ({ | ||
backgroundColor: | ||
theme.palette.darkGrey[ | ||
theme.palette.mode === "light" ? "light" : "dark" | ||
], | ||
color: theme.palette.darkGrey.contrastText, | ||
...theme.typography.body1, | ||
fontFamily: theme.fontFamilyTitle, | ||
})} | ||
> | ||
{category.Title.Standard} | ||
</ListSubheader> | ||
{Object.values(category.Moves).map((move, index) => ( | ||
<ListItem | ||
id={move.$id} | ||
key={index} | ||
{showNewView ? ( | ||
<CollapsibleSectionHeader | ||
open={isExpandedOrForced ?? false} | ||
toggleOpen={() => !forceOpen && setIsExpanded((prev) => !prev)} | ||
text={category.Title.Standard} | ||
/> | ||
) : ( | ||
<ListSubheader | ||
sx={(theme) => ({ | ||
"&:nth-of-type(odd)": { | ||
backgroundColor: theme.palette.action.hover, | ||
}, | ||
backgroundColor: | ||
theme.palette.darkGrey[ | ||
theme.palette.mode === "light" ? "light" : "dark" | ||
], | ||
color: theme.palette.darkGrey.contrastText, | ||
...theme.typography.body1, | ||
fontFamily: theme.fontFamilyTitle, | ||
})} | ||
disablePadding | ||
> | ||
<ListItemButton | ||
onClick={() => openMove(move)} | ||
sx={{ | ||
display: "flex", | ||
justifyContent: "space-between", | ||
alignItems: "center", | ||
}} | ||
> | ||
<Box | ||
{category.Title.Standard} | ||
</ListSubheader> | ||
)} | ||
<Collapse in={isExpandedOrForced}> | ||
<Box | ||
sx={{ | ||
mb: showNewView && isExpandedOrForced ? 0.5 : 0, | ||
}} | ||
> | ||
{Object.values(category.Moves).map((move, index) => ( | ||
<ListItem | ||
id={move.$id} | ||
key={index} | ||
sx={(theme) => ({ | ||
...theme.typography.body2, | ||
color: theme.palette.text.primary, | ||
"&:nth-of-type(even)": { | ||
backgroundColor: theme.palette.background.paperInlay, | ||
}, | ||
})} | ||
disablePadding | ||
> | ||
{move.Title.Standard} | ||
</Box> | ||
<ListItemIcon sx={{ minWidth: "unset" }}> | ||
<OpenIcon /> | ||
</ListItemIcon> | ||
</ListItemButton> | ||
</ListItem> | ||
))} | ||
<ListItemButton | ||
onClick={() => openMove(move)} | ||
sx={{ | ||
display: "flex", | ||
justifyContent: "space-between", | ||
alignItems: "center", | ||
}} | ||
> | ||
<Box | ||
sx={(theme) => ({ | ||
...theme.typography.body2, | ||
color: theme.palette.text.primary, | ||
})} | ||
> | ||
{move.Title.Standard} | ||
</Box> | ||
<ListItemIcon sx={{ minWidth: "unset" }}> | ||
<OpenIcon /> | ||
</ListItemIcon> | ||
</ListItemButton> | ||
</ListItem> | ||
))} | ||
</Box> | ||
</Collapse> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.