mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-17 10:53:57 +01:00
1 parent
ee1ecb83b7
commit
7b650bf39b
5 files changed
+62
-36
No files matched your search
@@ -1,12 +1,12 @@
|
||||
@keyframes skeleton-animation {
|
||||
0% {
|
||||
background-color: var(--black-a8);
|
||||
background-color: var(--black-a6);
|
||||
}
|
||||
50% {
|
||||
background-color: var(--black-a5);
|
||||
}
|
||||
100% {
|
||||
background-color: var(--black-a8);
|
||||
background-color: var(--black-a6);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,19 +31,17 @@
|
||||
|
||||
background-size: 140%;
|
||||
background-position: 40% center;
|
||||
|
||||
.cover {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(transparent 75%, var(--gray-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.name {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
.skeleton {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,10 @@ import { api } from "../../core/api/dynamic";
|
||||
import { useAwait } from "../../hooks/useAwait";
|
||||
import { useGameStrings } from "../../hooks/useGameStrings";
|
||||
import { useLocale } from "../../hooks/useLocale";
|
||||
import type { PropsWithSkeleton } from "../../types/propsWithSkeleton";
|
||||
import { InlineSkeleton } from "../InlineSkeleton";
|
||||
import { LinkI18n } from "../LinkI18n";
|
||||
import { Skeleton } from "../Skeleton";
|
||||
import { Text } from "../Text";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
@@ -11,37 +14,46 @@ interface TankCardProps {
|
||||
subtitle?: string;
|
||||
}
|
||||
|
||||
export function TankCard({ id }: TankCardProps) {
|
||||
const tank = useAwait(() => api.tank(id), `tank-${id}`);
|
||||
const gameStrings = useGameStrings("TankEntity");
|
||||
export function TankCard(props: PropsWithSkeleton<TankCardProps>) {
|
||||
const tank = props.skeleton
|
||||
? undefined
|
||||
: useAwait(() => api.tank(props.id), `tank-${props.id}`);
|
||||
const gameStrings = props.skeleton ? undefined : useGameStrings("TankEntity");
|
||||
const locale = useLocale();
|
||||
|
||||
return (
|
||||
<LinkI18n
|
||||
href={`/tanks/${tank.slug}`}
|
||||
href={props.skeleton ? undefined : `/tanks/${tank!.slug}`}
|
||||
underline="never"
|
||||
locale={locale}
|
||||
className={styles["tank-card"]}
|
||||
>
|
||||
<div className={styles["icon-wrapper"]}>
|
||||
<div
|
||||
className={styles.flag}
|
||||
style={{
|
||||
backgroundImage: `url(/api/nations/${tank.tank!.nation}/card.webp)`,
|
||||
}}
|
||||
/>
|
||||
{!props.skeleton && (
|
||||
<div
|
||||
className={styles.flag}
|
||||
style={{
|
||||
backgroundImage: `url(/api/nations/${tank!.tank!.nation}/card.webp)`,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div
|
||||
className={styles.icon}
|
||||
style={{
|
||||
backgroundImage: `url(/api/tanks/${id}.webp)`,
|
||||
}}
|
||||
>
|
||||
<div className={styles.cover} />
|
||||
</div>
|
||||
{!props.skeleton && (
|
||||
<div
|
||||
className={styles.icon}
|
||||
style={{
|
||||
backgroundImage: `url(/api/tanks/${props.id}.webp)`,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{props.skeleton && <Skeleton className={styles.icon} />}
|
||||
</div>
|
||||
|
||||
<Text className={styles.name}>{gameStrings[tank.tank!.name!.value]}</Text>
|
||||
<Text className={styles.name}>
|
||||
{props.skeleton && <InlineSkeleton className={styles.skeleton} />}
|
||||
{!props.skeleton && gameStrings![tank!.tank!.name!.value]}
|
||||
</Text>
|
||||
</LinkI18n>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user