11import { useAsync , useKeyPress } from '@siberiacancode/reactuse' ;
2- import { ChevronLeftIcon , ChevronRightIcon , Loader2Icon } from 'lucide-react' ;
2+ import { HeartIcon , Loader2Icon , XIcon } from 'lucide-react' ;
33import { useState } from 'react' ;
44
55interface Pokemon {
@@ -27,7 +27,6 @@ const fetchPokemon = async (id: number) => {
2727
2828const Demo = ( ) => {
2929 const [ id , setId ] = useState ( randomId ) ;
30-
3130 const pokemonAsync = useAsync ( ( ) => fetchPokemon ( id ) , [ id ] ) ;
3231
3332 const onNext = ( ) => setId ( randomId ( ) ) ;
@@ -43,8 +42,8 @@ const Demo = () => {
4342 const loading = ! pokemonAsync . data ;
4443
4544 return (
46- < section className = 'flex w-full max-w-xs flex-col items-center gap-3 p-4' >
47- < div className = 'border-border bg-card relative h-[370px ] w-full overflow-hidden rounded-2xl border shadow-lg' >
45+ < section className = 'flex w-full max-w-[280px] flex-col items-center gap-3 p-4' >
46+ < div className = 'border-border bg-card relative aspect-[3/4 ] w-full overflow-hidden rounded-2xl border shadow-lg' >
4847 < div className = 'absolute inset-0 flex items-center justify-center' >
4948 { loading && < Loader2Icon className = 'text-muted-foreground size-8 animate-spin' /> }
5049 { ! loading && pokemonAsync . data && (
@@ -88,32 +87,30 @@ const Demo = () => {
8887 ) ) }
8988 </ div >
9089 </ div >
90+
91+ < button
92+ aria-label = 'Pass'
93+ className = 'absolute bottom-4 left-4 flex size-11 items-center justify-center rounded-full bg-white text-neutral-900 shadow-lg transition-transform hover:scale-110'
94+ data-variant = 'unstyled'
95+ type = 'button'
96+ onClick = { onNext }
97+ >
98+ < XIcon className = 'size-5' strokeWidth = { 2.5 } />
99+ </ button >
100+
101+ < button
102+ aria-label = 'Like'
103+ className = 'text-destructive absolute right-4 bottom-4 flex size-11 items-center justify-center rounded-full bg-white shadow-lg transition-transform hover:scale-110'
104+ data-variant = 'unstyled'
105+ type = 'button'
106+ onClick = { onNext }
107+ >
108+ < HeartIcon className = 'size-5' fill = 'currentColor' />
109+ </ button >
91110 </ >
92111 ) }
93112 </ div >
94113
95- < div className = 'flex w-full items-stretch gap-2' >
96- < button
97- aria-label = 'Pass'
98- className = 'flex-1'
99- data-variant = 'secondary'
100- type = 'button'
101- onClick = { onNext }
102- >
103- < ChevronLeftIcon className = 'size-5' />
104- </ button >
105-
106- < button
107- aria-label = 'Like'
108- className = 'flex-1'
109- data-variant = 'secondary'
110- type = 'button'
111- onClick = { onNext }
112- >
113- < ChevronRightIcon className = 'size-5' />
114- </ button >
115- </ div >
116-
117114 < span className = 'text-muted-foreground text-[10px]' > Use β β keys to swipe</ span >
118115 </ section >
119116 ) ;
0 commit comments