Skip to content

Commit 25fef62

Browse files
feat: replace buttons and links with radix components
1 parent 609b6b3 commit 25fef62

13 files changed

+48
-45
lines changed

src/controllers/get-rom.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export async function getRom({ fileName, id, platform }: { fileName: string; id:
2626
}
2727

2828
if (romId) {
29-
const [r] = await getRoms({ id: romId })
30-
return r
29+
const {
30+
roms: [rom],
31+
} = await getRoms({ id: romId })
32+
return rom
3133
}
3234
}

src/controllers/get-roms.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export type RomsPagination = GetRomsReturning['pagination']
4646
export async function getRoms({
4747
id,
4848
page = 1,
49-
pageSize = 100,
49+
pageSize = 50,
5050
platform,
5151
}: { id?: string; page?: number; pageSize?: number; platform?: string } = {}) {
5252
const { currentUser, db } = getContextData()

src/pages/library/components/app-layout.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function AppLayout({
2828
return (
2929
<ServerDataContextProvider value={value}>
3030
<div className='flex h-screen bg-[var(--theme)]'>
31-
<aside className='flex shrink-0 flex-col'>
31+
<aside className='flex w-64 shrink-0 flex-col'>
3232
<div className='flex items-center justify-center gap-2 pb-4 pt-2 font-bold text-white'>
3333
<img alt='logo' height='32' src='/assets/logo/logo-192x192.png' width='32' />
3434
RetroAssembly

src/pages/library/components/game-list-pagination.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export function GameListPagination({ pagination }: { pagination: RomsPagination
1111
}
1212

1313
return (
14-
<ul className='flex flex-wrap justify-center gap-2 px-10'>
15-
{range(1, pages).map((page) => (
14+
<ul className='mt-8 flex flex-wrap justify-center gap-2 px-10'>
15+
{range(1, pages + 1).map((page) => (
1616
<li key={page}>
1717
<Button asChild size='3' variant={current === page ? 'solid' : 'soft'}>
1818
{current === page ? (

src/pages/library/components/game-list.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function GameList({ pagination, roms: initialRoms }: { pagination: RomsPa
1717

1818
return (
1919
<div>
20-
<div className='grid gap-x-4 gap-y-8 [grid-template-columns:repeat(auto-fill,minmax(calc(var(--spacing)*40),1fr))]'>
20+
<div className='grid gap-x-4 gap-y-2 [grid-template-columns:repeat(auto-fill,minmax(calc(var(--spacing)*40),1fr))]'>
2121
{renderedRoms.map((rom) => (
2222
<GameEntry key={rom.id} rom={rom} />
2323
))}
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1+
'use client'
2+
import { Button } from '@radix-ui/themes'
13
import { clsx } from 'clsx'
24
import { Link } from 'waku/router/client'
35

46
export function SidebarLink({ active = false, children, href }) {
57
return (
6-
<div className='relative'>
8+
<Button asChild size='3' variant={active ? 'ghost' : 'solid'}>
79
<Link
8-
className={clsx(
9-
'mx-2 flex items-center gap-2 rounded px-4 py-2.5 font-semibold transition-colors hover:text-white',
10-
active ? 'cursor-default bg-rose-900 font-semibold text-white' : 'text-white/80 ',
11-
)}
10+
className={clsx('!mx-2 !my-0 !h-auto !px-4 !py-2.5', { '!bg-white': active })}
1211
scroll
1312
to={href}
14-
unstable_pending={<div className='z-1 absolute top-0 size-full' />}
13+
unstable_pending={<div className='z-1 absolute top-0 size-full bg-white' />}
1514
>
16-
{children}
15+
<div className='flex h-auto w-full justify-start gap-2 font-semibold'>{children}</div>
1716
</Link>
18-
</div>
17+
</Button>
1918
)
2019
}

src/pages/library/components/sidebar-links.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export function SidebarLinks({ platform }: { platform?: string }) {
3131
<div className='mt-4'>
3232
<h3 className='px-4 text-white/60'>Platforms</h3>
3333

34-
<div className='mt-2 flex flex-col gap-y-1'>
34+
<div className='mt-2 flex flex-col gap-y-2'>
3535
{platformLinks.map(({ href, icon, name, text }) => (
3636
<SidebarLink active={platform === name} href={href} key={text}>
37-
{icon ? <img alt='icon' height='20' src={icon} width='20' /> : null}
37+
{icon ? <img alt='icon' className='shrink-0' height='20' src={icon} width='20' /> : null}
3838
{text}
3939
</SidebarLink>
4040
))}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Button } from '@radix-ui/themes'
12
import { noop } from 'es-toolkit'
23
import type { ReactNode } from 'react'
34

@@ -7,13 +8,16 @@ export function GameOverlayButton({
78
onClick = noop,
89
}: { children: ReactNode; isLoading?: boolean; onClick?: any }) {
910
return (
10-
<button
11-
className='backdrop-blur-xs flex items-center justify-center gap-2 rounded px-6 py-3 font-semibold text-white shadow-lg hover:bg-rose-700'
11+
<Button
12+
className='[--accent-a11:white] [--accent-a3:rgba(255,255,255,.3)] [--accent-a4:rgba(255,255,255,.3)] [--accent-a5:rgba(255,255,255,.2)]'
1213
disabled={isLoading}
1314
onClick={onClick}
15+
radius='full'
16+
size='4'
1417
type='button'
18+
variant='soft'
1519
>
1620
{children}
17-
</button>
21+
</Button>
1822
)
1923
}

src/pages/library/platform/rom/components/game-overlay/game-overlay-buttons.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,28 @@ export function GameOverlayButtons() {
4747
return (
4848
<>
4949
<GameOverlayButton onClick={handleClickResume}>
50-
<span className='icon-[material-symbols--resume] size-7' />
50+
<span className='icon-[material-symbols--resume] size-5' />
5151
Resume
5252
</GameOverlayButton>
5353

5454
<GameOverlayButton onClick={handleClickSaveState}>
55-
<span className='icon-[mdi--content-save] size-7' />
55+
<span className='icon-[mdi--content-save] size-5' />
5656
Save State
5757
</GameOverlayButton>
5858

5959
<div className='flex-1' />
6060
<GameOverlayButton onClick={handleClickRestart}>
61-
<span className='icon-[mdi--restart] size-7' />
61+
<span className='icon-[mdi--restart] size-5' />
6262
Restart
6363
</GameOverlayButton>
6464

6565
<GameOverlayButton onClick={handleClickExit}>
66-
<span className='icon-[mdi--exit-to-app] size-7' />
66+
<span className='icon-[mdi--exit-to-app] size-5' />
6767
Exit
6868
</GameOverlayButton>
6969

7070
<GameOverlayButton onClick={handleClickSaveExit}>
71-
<span className='icon-[mdi--location-exit] size-7' />
71+
<span className='icon-[mdi--location-exit] size-5' />
7272
Save & Exit
7373
</GameOverlayButton>
7474
</>

src/pages/library/platform/rom/components/game-overlay/game-overlay.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useGameStates } from '../../hooks/use-game-states.ts'
77
import { GameOverlayButtons } from './game-overlay-buttons.tsx'
88
import { GameStates } from './game-states.tsx'
99

10-
export function GameOverlay() {
10+
export function GameOverlay({ rom }) {
1111
const { show, toggle } = useGameOverlay()
1212
const { emulator } = useEmulator()
1313
const { reloadStates } = useGameStates()
@@ -41,6 +41,7 @@ export function GameOverlay() {
4141
>
4242
<div className='bg-linear-to-b to-text-transparent h-32 w-full from-black' />
4343
<div className='w-6xl mx-auto flex flex-1 flex-col gap-8'>
44+
<div className='text-5xl'>{rom.file_name}</div>
4445
<div className='flex gap-8'>
4546
<GameOverlayButtons />
4647
</div>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use client'
2+
import { Button } from '@radix-ui/themes'
23
import { useKeyboardEvent } from '@react-hookz/web'
34
import { clsx } from 'clsx'
45
import { useEmulator } from '../hooks/use-emulator.ts'
@@ -21,23 +22,19 @@ export function LaunchButton() {
2122
})
2223

2324
return (
24-
<button
25-
className={clsx(
26-
'inline-flex h-16 w-72 items-center justify-center gap-3 rounded bg-[var(--theme)] text-xl font-bold text-white',
27-
{ 'opacity-50': isPreparing },
28-
)}
29-
disabled={isPreparing}
30-
onClick={launch}
31-
type='button'
32-
>
33-
<span
34-
className={
35-
isPreparing
36-
? 'icon-[mdi--loading] animate-spin'
37-
: 'icon-[mdi--play] motion-preset-pulse-lg motion-duration-1000'
38-
}
39-
/>
40-
{isPreparing ? 'Loading...' : 'Press any key to start'}
25+
<button className={clsx({ 'opacity-50': isPreparing })} disabled={isPreparing} onClick={launch} type='button'>
26+
<Button asChild className='!h-16' radius='small' size='4' type='button'>
27+
<div>
28+
<span
29+
className={
30+
isPreparing
31+
? 'icon-[mdi--loading] animate-spin'
32+
: 'icon-[mdi--play] motion-preset-pulse-lg motion-duration-1500'
33+
}
34+
/>
35+
<span className='w-[228px] text-2xl'>{isPreparing ? 'Loading...' : 'Press any key to start'}</span>
36+
</div>
37+
</Button>
4138
</button>
4239
)
4340
}

src/pages/library/platform/rom/hooks/use-game-states.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function useGameStates() {
2222
if (thumbnail) {
2323
formData.append('thumbnail', thumbnail)
2424
}
25-
formData.append('rom_id', rom.id)
25+
formData.append('rom', rom.id)
2626
formData.append('core', core)
2727
formData.append('type', 'manual')
2828
await ky.put(url, { body: formData })

src/pages/library/platform/rom/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export async function RomPage({ fileName, id, platform }) {
7070

7171
<Portal>
7272
<Theme accentColor='red'>
73-
<GameOverlay />
73+
<GameOverlay rom={rom} />
7474
</Theme>
7575
</Portal>
7676
</AppLayout>

0 commit comments

Comments
 (0)