-
Notifications
You must be signed in to change notification settings - Fork 1
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 #6 from JollyGrin/feat/aura
Feat/aura
- Loading branch information
Showing
18 changed files
with
992 additions
and
87 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,29 @@ | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "@/components/ui/dialog"; | ||
import { DialogProps } from "@radix-ui/react-dialog"; | ||
import { ReactNode } from "react"; | ||
|
||
export const Modal = (props: { | ||
wrapperProps: DialogProps; | ||
trigger?: ReactNode; | ||
title?: string; | ||
content?: ReactNode; | ||
}) => { | ||
return ( | ||
<Dialog {...props.wrapperProps}> | ||
<DialogTrigger>{props.trigger}</DialogTrigger> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>{props.title}</DialogTitle> | ||
<DialogDescription>{props.content}</DialogDescription> | ||
</DialogHeader> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; |
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,33 @@ | ||
import { Box } from "styled-system/jsx"; | ||
|
||
export const FullCardAtlas = ({ | ||
img = "atlas_rift_valley.webp", | ||
}: { | ||
img?: string; | ||
}) => { | ||
return ( | ||
<Box | ||
position="relative" | ||
m="0.5rem auto" | ||
w="inherit" | ||
h="inherit" | ||
borderRadius="1rem" | ||
isolation="isolate" | ||
> | ||
<Box | ||
style={{ backgroundImage: `url(/mock-cards/${img})` }} // bgImage has caching issues | ||
isolation="isolate" | ||
w="100%" | ||
h="100%" | ||
// position="absolute" | ||
backgroundPosition="right" | ||
backgroundSize="cover" | ||
backgroundRepeat="no-repeat" | ||
transform="rotate(90deg)" | ||
bg="gray.400" | ||
borderRadius="1rem" | ||
transition="all 0.25s ease" | ||
/> | ||
</Box> | ||
); | ||
}; |
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,37 @@ | ||
import { Box } from "styled-system/jsx"; | ||
|
||
export const CardImage = ({ | ||
img = "headless_haunt.webp", | ||
position = "top", | ||
}: { | ||
img?: string; | ||
position?: "top" | "bottom"; | ||
}) => { | ||
return ( | ||
<Box | ||
w="inherit" | ||
h="inherit" | ||
position="relative" | ||
m="0.5rem auto" | ||
borderRadius="1rem" | ||
mb={position === "top" ? "unset" : "unset"} | ||
mt={position === "bottom" ? "-0.25rem" : "unset"} | ||
isolation="isolate" | ||
transform="unset" | ||
opacity="1" | ||
transition="all 0.25s ease" | ||
> | ||
<Box | ||
style={{ backgroundImage: `url(/mock-cards/${img})` }} | ||
w="100%" | ||
h="100%" | ||
minH="300px" | ||
backgroundPosition="top" | ||
backgroundSize="contain" | ||
backgroundRepeat="no-repeat" | ||
transition="all 0.25s ease" | ||
// bg="gray.400" | ||
/>{" "} | ||
</Box> | ||
); | ||
}; |
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
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
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,16 @@ | ||
import { DroppableGridItem } from "@/components/molecules/DropGridItem"; | ||
import { ReactNode } from "react"; | ||
|
||
export const AuraDrop = ({ | ||
gridIndex, | ||
children, | ||
}: { | ||
gridIndex: number; | ||
children: ReactNode; | ||
}) => { | ||
return ( | ||
<DroppableGridItem id={gridIndex.toString()} gridIndex={gridIndex}> | ||
{children} | ||
</DroppableGridItem> | ||
); | ||
}; |
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,111 @@ | ||
import { Box } from "styled-system/jsx"; | ||
import { AuraDrop } from "./AuraDrop"; | ||
import { GameStateActions } from ".."; | ||
import { DragItem } from "@/components/molecules/DragItem"; | ||
import { GameCard } from "@/pages/game"; | ||
import { useState } from "react"; | ||
import { Modal } from "@/components/atoms/Modal"; | ||
import { FullCardAtlas } from "@/components/atoms/card-view/atlas"; | ||
import { CardImage as FullCard } from "@/components/atoms/card-view/card"; | ||
|
||
export const Auras = (props: GameStateActions) => { | ||
return ( | ||
<Box position="absolute" w="100%" h="100%"> | ||
{Array.from({ length: 12 }).map((_, index) => ( | ||
<Aura | ||
key={"aura" + index} | ||
card={props.gridItems?.[21 + index]?.[0]} | ||
gridIndex={21 + index} | ||
index={0} | ||
/> | ||
))} | ||
</Box> | ||
); | ||
}; | ||
|
||
const Aura = (props: { card: GameCard; gridIndex: number; index: number }) => { | ||
const auraCard = props.card; | ||
|
||
const auraIndex = props.gridIndex - 21; // normalize to zero | ||
const topIndex = Math.floor(auraIndex / 4) + 1; // increments every 4 | ||
const top = `${topIndex * 25}%`; // in percent | ||
const leftIndex = 1 + (auraIndex % 4); // every 4, resets | ||
const left = `${leftIndex * 20}%`; // in percent | ||
|
||
return ( | ||
<Box | ||
style={{ | ||
top, | ||
left, | ||
}} | ||
position="absolute" | ||
w="75px" | ||
h="75px" | ||
transform="translate(-50%, -50%)" /* Center the box */ | ||
_hover={{ | ||
border: "solid 5px rgba(0,100,200,0.5)", | ||
borderRadius: "1rem", | ||
}} | ||
> | ||
{!auraCard?.id && ( | ||
<AuraDrop gridIndex={props.gridIndex}> | ||
<Box | ||
w="100%" | ||
h="100%" | ||
backgroundSize="cover" | ||
transform="rotate(90deg)" | ||
borderRadius="0.5rem" | ||
/> | ||
</AuraDrop> | ||
)} | ||
{auraCard?.id && ( | ||
<DragWrapper gridIndex={props.gridIndex} index={0} card={auraCard} /> | ||
)} | ||
</Box> | ||
); | ||
}; | ||
|
||
const DragWrapper = ({ | ||
card, | ||
...props | ||
}: { | ||
gridIndex: number; | ||
index: number; | ||
card: GameCard; | ||
}) => { | ||
const [preview, setPreview] = useState(false); | ||
return ( | ||
<div style={{ width: "100%", height: "100%" }}> | ||
<DragItem | ||
gridIndex={props.gridIndex} | ||
index={props.index} | ||
style={{ width: "100%", height: "100%", zIndex: 1000 }} | ||
> | ||
<Box | ||
w="100%" | ||
h="100%" | ||
backgroundSize="200%" | ||
backgroundPosition="10% 20%" | ||
transform={card?.type === "site" ? "rotate(90deg)" : ""} | ||
borderRadius="0.5rem" | ||
style={{ | ||
backgroundImage: `url(/mock-cards/${card?.img})`, | ||
}} | ||
onContextMenu={(e) => { | ||
e.preventDefault(); | ||
setPreview(true); | ||
}} | ||
/> | ||
</DragItem> | ||
<Modal | ||
wrapperProps={{ open: preview, onOpenChange: setPreview }} | ||
content={ | ||
<Box h="600px"> | ||
{card?.type === "site" && <FullCardAtlas img={card?.img} />} | ||
{card?.type !== "site" && <FullCard img={card?.img} />} | ||
</Box> | ||
} | ||
/> | ||
</div> | ||
); | ||
}; |
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.