-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sidebar, add small animations, some bug fixing and improvem…
…ents
- Loading branch information
1 parent
2aef13d
commit 27e0de3
Showing
16 changed files
with
385 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use client'; | ||
|
||
import { Dialog as ArkDrawer } from '@ark-ui/react/dialog'; | ||
import { ark } from '@ark-ui/react/factory'; | ||
import { styled } from '@style/jsx'; | ||
import { drawer } from '@style/recipes'; | ||
import { createStyleContext } from 'lib/create-style-context'; | ||
import type { ComponentProps } from 'react'; | ||
|
||
const { withProvider, withContext } = createStyleContext(drawer); | ||
|
||
export const Root = withProvider(ArkDrawer.Root); | ||
export const Backdrop = withContext(styled(ArkDrawer.Backdrop), 'backdrop'); | ||
export const Body = withContext(styled(ark.div), 'body'); | ||
export const CloseTrigger = withContext( | ||
styled(ArkDrawer.CloseTrigger), | ||
'closeTrigger', | ||
); | ||
export const Content = withContext(styled(ArkDrawer.Content), 'content'); | ||
export const Description = withContext( | ||
styled(ArkDrawer.Description), | ||
'description', | ||
); | ||
export const Footer = withContext(styled(ark.div), 'footer'); | ||
export const Header = withContext(styled(ark.div), 'header'); | ||
export const Positioner = withContext( | ||
styled(ArkDrawer.Positioner), | ||
'positioner', | ||
); | ||
export const Title = withContext(styled(ArkDrawer.Title), 'title'); | ||
export const Trigger = withContext(styled(ArkDrawer.Trigger), 'trigger'); | ||
|
||
export type RootProps = ComponentProps<typeof Root>; | ||
export type BackdropProps = ComponentProps<typeof Backdrop>; | ||
export type BodyProps = ComponentProps<typeof Body>; | ||
export type CloseTriggerProps = ComponentProps<typeof CloseTrigger>; | ||
export type ContentProps = ComponentProps<typeof Content>; | ||
export type DescriptionProps = ComponentProps<typeof Description>; | ||
export type FooterProps = ComponentProps<typeof Footer>; | ||
export type HeaderProps = ComponentProps<typeof Header>; | ||
export type PositionerProps = ComponentProps<typeof Positioner>; | ||
export type TitleProps = ComponentProps<typeof Title>; | ||
export type TriggerProps = ComponentProps<typeof Trigger>; |
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 was deleted.
Oops, something went wrong.
102 changes: 102 additions & 0 deletions
102
src/components/@scenario/InitiativeList/InitiativeList.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,102 @@ | ||
'use client'; | ||
|
||
import { Box, Stack } from '@style/jsx'; | ||
import { Icon } from 'icons'; | ||
import { ArrowLeftFromLineIcon } from 'lucide-react'; | ||
import { useLayoutEffect, useState } from 'react'; | ||
|
||
import { useInitiative } from 'hooks/useInitiative'; | ||
import { useStore } from 'services/stores'; | ||
import { CharacterNames } from 'types/character.types'; | ||
import { EnemyNames } from 'types/enemies.types'; | ||
|
||
import { Drawer, IconButton } from 'components/@common'; | ||
|
||
import Item from './Item'; | ||
import Widget from './Widget'; | ||
|
||
const InitiativeList = () => { | ||
const [drawerOpen, setDrawerOpen] = useState(false); | ||
const { initiatives, activeTurn, hasPlayed, roundEnded } = useInitiative(); | ||
const { toggleInitiativePlayed } = useStore((state) => state.actions); | ||
|
||
const handleToggleInitiativePlayed = (name: CharacterNames | EnemyNames) => { | ||
if (name === activeTurn || hasPlayed(name)) { | ||
toggleInitiativePlayed(name); | ||
} | ||
}; | ||
|
||
useLayoutEffect(() => { | ||
if (roundEnded) setDrawerOpen(false); | ||
}, [roundEnded]); | ||
|
||
return ( | ||
<Box | ||
width={75} | ||
borderLeft="1px" | ||
borderColor="border.subtle" | ||
borderStyle="solid" | ||
my="8" | ||
px="4" | ||
alignItems="center" | ||
flexDirection="column" | ||
justifyContent="space-between" | ||
display={{ smDown: 'none', base: 'flex' }} | ||
> | ||
<Stack gap={6} flexDirection="column" alignItems="center" mb={6}> | ||
{initiatives.map((initiative) => ( | ||
<Widget | ||
key={initiative.name} | ||
activeTurn={initiative.name === activeTurn} | ||
initiative={initiative} | ||
onClick={handleToggleInitiativePlayed} | ||
/> | ||
))} | ||
</Stack> | ||
|
||
{!!initiatives.length && ( | ||
<Drawer.Root | ||
open={drawerOpen} | ||
onOpenChange={(e) => setDrawerOpen(e.open)} | ||
> | ||
<Drawer.Trigger asChild> | ||
<ArrowLeftFromLineIcon size={24} /> | ||
</Drawer.Trigger> | ||
<Drawer.Backdrop /> | ||
<Drawer.Positioner> | ||
<Drawer.Content gridTemplateRows="auto 1fr 0"> | ||
<Drawer.Header | ||
flexDirection="row" | ||
alignItems="center" | ||
display="flex" | ||
justifyContent="space-between" | ||
> | ||
<Drawer.Title fontSize="2xl" fontWeight="normal"> | ||
Initiative overview | ||
</Drawer.Title> | ||
<Drawer.CloseTrigger asChild> | ||
<IconButton variant="ghost"> | ||
<Icon name="close" /> | ||
</IconButton> | ||
</Drawer.CloseTrigger> | ||
</Drawer.Header> | ||
<Drawer.Body> | ||
<Stack gap={4} flexDirection="column"> | ||
{initiatives.map((initiative) => ( | ||
<Item | ||
key={initiative.name} | ||
initiative={initiative} | ||
onClick={handleToggleInitiativePlayed} | ||
/> | ||
))} | ||
</Stack> | ||
</Drawer.Body> | ||
</Drawer.Content> | ||
</Drawer.Positioner> | ||
</Drawer.Root> | ||
)} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default InitiativeList; |
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,47 @@ | ||
import { Box } from '@style/jsx'; | ||
import { CHARACTERS } from 'data/characters'; | ||
|
||
import { CharacterNames } from 'types/character.types'; | ||
import { EnemyNames } from 'types/enemies.types'; | ||
import { Initiative } from 'types/initiative.types'; | ||
|
||
import { Text } from 'components/@common'; | ||
|
||
import Thumbnail from './Thumbnail'; | ||
import { isCharacterName } from './utils'; | ||
|
||
interface Props { | ||
initiative: Initiative; | ||
onClick: (name: CharacterNames | EnemyNames) => void; | ||
} | ||
|
||
const Item = ({ initiative, onClick }: Props) => { | ||
return ( | ||
<Box | ||
key={initiative.name} | ||
cursor="pointer" | ||
onClick={() => onClick(initiative.name)} | ||
display="flex" | ||
alignItems="center" | ||
justifyContent="space-between" | ||
gap={4} | ||
> | ||
<Box display="flex" alignItems="center" gap={4}> | ||
<Thumbnail initiative={initiative} size={45} /> | ||
<Text | ||
fontSize="2xl" | ||
color={initiative.played ? 'sand.5' : 'fg.default'} | ||
> | ||
{isCharacterName(initiative.name) | ||
? CHARACTERS[initiative.name].spoilerName | ||
: initiative.name} | ||
</Text> | ||
</Box> | ||
<Text fontSize="xl" color={initiative.played ? 'sand.5' : 'sand.10'}> | ||
{initiative.initiative} | ||
</Text> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default Item; |
Oops, something went wrong.