-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c7180e
commit bfff3ca
Showing
14 changed files
with
105 additions
and
53 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { atom } from 'jotai' | ||
|
||
export const showMenuOverlayAtom = atom(false) | ||
export const shouldFocusStatesListAtom = atom(false) | ||
export const previousFocusedElementAtom = atom<HTMLElement | null>(null) |
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
15 changes: 11 additions & 4 deletions
15
src/views/components/home-screen/game-menus/menu-entry-button.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
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
28 changes: 22 additions & 6 deletions
28
src/views/components/home-screen/virtual-controller/virtual-button.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,42 +1,58 @@ | ||
import { clsx } from 'clsx' | ||
import { motion } from 'framer-motion' | ||
import { type UIEvent, useState } from 'react' | ||
import { pressController } from '../../../../core' | ||
|
||
interface VirtualButtonProps { | ||
name: string | ||
name?: string | ||
onTap?: () => void | ||
} | ||
|
||
export function VirtualButton({ name }: VirtualButtonProps) { | ||
export function VirtualButton({ name, onTap }: VirtualButtonProps) { | ||
const [pressing, setPressing] = useState(false) | ||
|
||
function onPress(event: UIEvent<HTMLDivElement>) { | ||
event.stopPropagation() | ||
setPressing(true) | ||
pressController(name, 'down') | ||
if (name) { | ||
for (const n of name.split(',')) { | ||
pressController(n, 'down') | ||
} | ||
} | ||
|
||
onTap?.() | ||
} | ||
|
||
function onRelease(event: UIEvent<HTMLDivElement>) { | ||
event.stopPropagation() | ||
if (pressing) { | ||
setPressing(false) | ||
pressController(name, 'up') | ||
if (name) { | ||
for (const n of name.split(',')) { | ||
pressController(n, 'up') | ||
} | ||
} | ||
} | ||
} | ||
|
||
return ( | ||
<div | ||
<motion.div | ||
animate={{ opacity: 1 }} | ||
aria-hidden | ||
className={clsx( | ||
'flex h-full w-full select-none items-center justify-center text-transparent', | ||
pressing ? 'bg-white' : 'bg-transparent', | ||
)} | ||
exit={{ opacity: 0 }} | ||
initial={{ opacity: 0 }} | ||
onMouseDown={onPress} | ||
onMouseLeave={onRelease} | ||
onMouseUp={onRelease} | ||
onTouchEnd={onRelease} | ||
onTouchStart={onPress} | ||
transition={{ duration: 0.2 }} | ||
> | ||
{name} | ||
</div> | ||
</motion.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
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