mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
feat: start of avatars
This commit is contained in:
1 parent
455679a981
commit
ea412086d4
7 files changed
+72
-15
No files matched your search
@@ -0,0 +1,19 @@
|
||||
.avatar-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.avatar-image {
|
||||
width: 100%;
|
||||
aspect-ratio: 7 / 8;
|
||||
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.avatar-label {
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { Avatar } from "../../protos/avatar";
|
||||
import { Text } from "../Text";
|
||||
import "./index.css";
|
||||
|
||||
interface Props {
|
||||
avatar: Avatar;
|
||||
}
|
||||
|
||||
export function AvatarCard({ avatar }: Props) {
|
||||
return (
|
||||
<div className="avatar-card">
|
||||
<div
|
||||
className="avatar-image"
|
||||
style={{ backgroundImage: `url(/api/avatars/${avatar.name}.webp)` }}
|
||||
/>
|
||||
<Text className="avatar-label">{avatar.name}</Text>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,19 +1,9 @@
|
||||
import { fetchPB } from "@blitzkit/core";
|
||||
import { Tank } from "../../protos/tank";
|
||||
import { TankList } from "../../protos/tank_list";
|
||||
import { Tanks } from "../../protos/tanks";
|
||||
import { Avatars } from "../../protos/avatars";
|
||||
import { AbstractAPI } from "./abstract";
|
||||
|
||||
export class ClientAPI extends AbstractAPI {
|
||||
tanks() {
|
||||
return fetchPB("/api/tanks/all.pb", Tanks);
|
||||
}
|
||||
|
||||
tankList() {
|
||||
return fetchPB("/api/tanks/list.pb", TankList);
|
||||
}
|
||||
|
||||
tank(id: string) {
|
||||
return fetchPB(`/api/tanks/${id}.pb`, Tank);
|
||||
protected _avatars() {
|
||||
return fetchPB("/api/avatars/all.pb", Avatars);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,19 @@
|
||||
import { AvatarCard } from "../../../components/AvatarCard";
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
import { useAwait } from "../../../hooks/useAwait";
|
||||
|
||||
interface Props {
|
||||
skeleton?: boolean;
|
||||
}
|
||||
|
||||
export function Page({ skeleton }: Props) {}
|
||||
export function Page({ skeleton }: Props) {
|
||||
const { avatars } = useAwait(() => api.avatars(), "avatars");
|
||||
|
||||
return (
|
||||
<div className="avatars">
|
||||
{avatars.map((avatar) => (
|
||||
<AvatarCard key={avatar.name} avatar={avatar} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -7,6 +7,14 @@ export { getStaticPaths } from "../index.astro";
|
||||
const { locale } = Astro.props;
|
||||
---
|
||||
|
||||
<style is:global>
|
||||
.avatars {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(var(--space-7), 1fr));
|
||||
gap: var(--space-4);
|
||||
}
|
||||
</style>
|
||||
|
||||
<BaseLayout {locale} accent="gold">
|
||||
<Page client:only="react">
|
||||
<Page skeleton slot="fallback" />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
|
||||
export async function GET() {
|
||||
const { avatars } = await api.avatars();
|
||||
const avatars = await api.avatars();
|
||||
return Response.json(avatars);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { api } from "../../../core/api/dynamic";
|
||||
import { Avatars } from "../../../protos/avatars";
|
||||
|
||||
export async function GET() {
|
||||
const avatars = await api.avatars();
|
||||
return new Response(Avatars.encode(avatars).finish());
|
||||
}
|
||||
Reference in new issue
Block a user