53 lines
2.2 KiB
TypeScript
53 lines
2.2 KiB
TypeScript
import type { IndexSummary } from '@nalssigak/shared/api/client/types.gen';
|
|
import { Pressable, View } from 'react-native';
|
|
import { Text } from '@/components/text';
|
|
|
|
import { Ic, Skel } from '@/components/ui';
|
|
import { useSheet } from '@/lib/sheet';
|
|
|
|
const CELL = 'w-[32%] items-center rounded-[22px] border-b-[5px] border-shade bg-card px-1.5 pt-3 pb-2.5';
|
|
const SKELS = Array.from({ length: 9 }, (_, i) => i);
|
|
|
|
export function GridSkel() {
|
|
return (
|
|
<View className="flex-row flex-wrap justify-between gap-y-2 p-3">
|
|
{SKELS.map((i) => (
|
|
<View key={i} className={`${CELL} gap-1.5`}>
|
|
<View className="size-[50px] rounded-full bg-skel" />
|
|
<Skel className="w-14" />
|
|
<Skel className="h-5 w-8" />
|
|
</View>
|
|
))}
|
|
</View>
|
|
);
|
|
}
|
|
|
|
/** 3칸 바둑판. 지금 시간대가 아니거나 제철이 아닌 각은 흐리게 */
|
|
export function GakGrid({ items, dim }: { items: IndexSummary[]; dim: boolean }) {
|
|
const { open } = useSheet();
|
|
return (
|
|
<View className="flex-row flex-wrap gap-y-2 p-3" style={{ columnGap: '2%', opacity: dim ? 0.6 : 1 }}>
|
|
{items.map((g) => (
|
|
<Pressable
|
|
key={g.index_id}
|
|
onPress={() => open({ type: 'gak', indexId: g.index_id })}
|
|
accessibilityLabel={g.active ? `${g.rank}위 ${g.name} ${g.score}점` : `${g.name}, ${g.in_season === false ? '제철 아님' : '지금 시간대 아님'}`}
|
|
className={`${CELL} ${g.active ? '' : 'opacity-55'}`}
|
|
>
|
|
{g.active && <Text className="absolute top-[7px] left-[9px] font-jua text-[13px] text-ink3">{g.rank}</Text>}
|
|
{!!g.season && <Text className="absolute top-2 right-2 text-[10.5px] font-extrabold text-[#1f9d62]">{g.season}</Text>}
|
|
<Ic name={g.icon} size={50} />
|
|
<Text numberOfLines={1} className="mt-1 font-jua text-[15px] text-ink">
|
|
{g.name}
|
|
</Text>
|
|
{g.active ? (
|
|
<Text className={`font-bagel text-[22px] leading-[24px] ${g.score < 50 ? 'text-ink3' : 'text-orange'}`}>{g.score}</Text>
|
|
) : (
|
|
<Text className="py-1 text-[12px] leading-[14px] font-extrabold text-ink3">{g.in_season === false ? '제철 아님' : '지금 아님'}</Text>
|
|
)}
|
|
</Pressable>
|
|
))}
|
|
</View>
|
|
);
|
|
}
|