Compare commits

...
3 Commits
Author SHA1 Message Date
TrèsAbhi 35275d4aa8 fix: use animation 2026-01-17 13:54:19 -06:00
TrèsAbhi dda63830ec feat: glow 2026-01-17 13:50:53 -06:00
TrèsAbhi 79b4f05809 feat: start of popup 2026-01-17 13:36:17 -06:00
13 changed files with 339 additions and 69 deletions

No files matched your search

+10 -1
View File
@@ -49,6 +49,15 @@
},
"avatars": {
"search": "Search avatars..."
"search": "Search avatars...",
"no_description": "Avatar has no description."
},
"grades": {
"0": "Unspecified",
"1": "Common",
"2": "Rare",
"3": "Epic",
"4": "Legendary"
}
}
@@ -1,47 +0,0 @@
.avatar-card {
display: flex;
flex-direction: column;
align-items: center;
gap: var(--space-4);
.avatar-series {
position: relative;
width: 100%;
aspect-ratio: 7 / 8;
.avatar-entry {
position: absolute;
border-radius: var(--space-3);
box-shadow: var(--shadow-interactive), var(--shadow-aggressive);
background-size: cover;
background-position: center;
&.skeleton {
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
.count {
position: absolute;
bottom: var(--space-3);
right: var(--space-3);
}
}
.avatar-label {
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 100%;
.skeleton {
width: 100%;
}
}
}
@@ -0,0 +1,102 @@
.card {
display: flex;
flex-direction: column;
align-items: center;
gap: var(--space-4);
.series {
position: relative;
width: 100%;
aspect-ratio: 7 / 8;
.entry {
position: absolute;
border-radius: var(--space-3);
box-shadow: var(--shadow-interactive), var(--shadow-aggressive);
background-size: cover;
background-position: center;
&.skeleton {
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
.count {
position: absolute;
bottom: var(--space-3);
right: var(--space-3);
box-shadow: var(--shadow-aggressive);
}
}
.label {
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 100%;
.skeleton {
width: 100%;
}
}
}
.details {
display: flex;
gap: var(--space-4);
align-items: center;
.preview {
display: flex;
flex-direction: column;
align-items: center;
padding: var(--space-2);
&[data-grade="1"] .image {
outline: var(--space-2) solid var(--gray-9);
}
&[data-grade="2"] .image {
outline: var(--space-2) solid var(--blue-9);
box-shadow: 0 0 var(--space-3) var(--blue-9);
}
&[data-grade="3"] .image {
outline: var(--space-2) solid var(--purple-9);
box-shadow: 0 0 var(--space-4) var(--purple-9);
}
&[data-grade="4"] .image {
outline: var(--space-2) solid var(--amber-9);
box-shadow: 0 0 var(--space-5) var(--amber-9);
}
.image {
aspect-ratio: 7 / 8;
width: 8rem;
border-radius: var(--space-3);
background-size: cover;
background-position: center;
}
.grade {
margin-top: calc(var(--space-3) * -1);
}
}
.description {
display: flex;
flex-direction: column;
max-width: 20rem;
}
}
@@ -1,12 +1,17 @@
import { literals } from "@blitzkit/i18n";
import { Grade } from "@protos/auto_items";
import { StarFilledIcon } from "@radix-ui/react-icons";
import type { Color } from "../../core/ui/color";
import { useGameStrings } from "../../hooks/useGameStrings";
import { useStrings } from "../../hooks/useStrings";
import type { Avatar } from "../../protos/avatar";
import type { PropsWithSkeleton } from "../../types/propsWithSkeleton";
import { Badge } from "../Badge";
import { Dialog } from "../Dialog";
import { InlineSkeleton } from "../InlineSkeleton";
import { Skeleton } from "../Skeleton";
import { Text } from "../Text";
import "./index.css";
import styles from "./index.module.css";
interface Props {
name: string;
@@ -17,15 +22,85 @@ const MAX_CARDS = 3;
const CARD_TRIM = "var(--space-3)";
export function AvatarCard(props: PropsWithSkeleton<Props>) {
return (
<div className="avatar-card">
const card = (
<div className={styles.card}>
<Series skeleton={props.skeleton} {...props} />
<Text align="center" className="avatar-label">
<Text align="center" className={styles.label}>
{props.skeleton ? <InlineSkeleton /> : props.name}
</Text>
</div>
);
if (props.skeleton) return card;
return (
<Dialog.Root>
<Dialog.Trigger>{card}</Dialog.Trigger>
<Dialog.Content>
<Text size="major" weight="bold">
{props.name}
</Text>
<Details avatars={props.avatars} />
</Dialog.Content>
</Dialog.Root>
);
}
interface DetailsProps {
avatars: Avatar[];
}
const gradeColors: Record<Grade, Color> = {
[Grade.GRADE_GRADE_UNSPECIFIED]: "gray",
[Grade.GRADE_GRADE_COMMON]: "gray",
[Grade.GRADE_GRADE_RARE]: "blue",
[Grade.GRADE_GRADE_EPIC]: "purple",
[Grade.GRADE_GRADE_LEGENDARY]: "amber",
};
function Details({ avatars }: DetailsProps) {
const gameStrings = useGameStrings("ProfileAvatarEntity");
const strings = useStrings();
return [...avatars].reverse().map((avatar) => {
const description = gameStrings[avatar.stuff_ui!.description];
const obtaining = gameStrings[avatar.stuff_ui!.obtaining_methods];
const hasDescription = description || obtaining;
return (
<div className={styles.details}>
<div className={styles.preview} data-grade={avatar.stuff_ui!.grade}>
<div
className={styles.image}
style={{
backgroundImage: `url(/api/avatars/${avatar.name}.webp)`,
}}
/>
<Badge
color={gradeColors[avatar.stuff_ui!.grade]}
className={styles.grade}
>
<StarFilledIcon />
{strings.grades[avatar.stuff_ui!.grade]}
</Badge>
</div>
<div className={styles.description}>
<Text>
{hasDescription ? (
<>
{description} {obtaining}
</>
) : (
strings.avatars.no_description
)}
</Text>
</div>
</div>
);
});
}
interface SeriesProps {
@@ -37,12 +112,12 @@ function Series(props: PropsWithSkeleton<SeriesProps>) {
const strings = useStrings();
return (
<div className="avatar-series">
<div className={styles.series}>
{!props.skeleton &&
props.avatars.slice(-MAX_CARDS).map((avatar, index) => (
<div
key={avatar.name}
className="avatar-entry"
className={styles.entry}
style={{
filter: `brightness(${(index + 1) / count})`,
top: `calc(${index} * ${CARD_TRIM})`,
@@ -55,12 +130,12 @@ function Series(props: PropsWithSkeleton<SeriesProps>) {
))}
{!props.skeleton && props.avatars.length > 1 && (
<Badge color="gray" highContrast className="count">
<Badge color="gray" highContrast className={styles.count}>
{literals(strings.units.x, { value: props.avatars.length })}
</Badge>
)}
{props.skeleton && <Skeleton className="avatar-entry" />}
{props.skeleton && <Skeleton className={styles.entry} />}
</div>
);
}
@@ -1,5 +1,9 @@
.avatars-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr));
gap: var(--space-5) var(--space-4);
grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr));
@media (min-width: 32rem) {
grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
}
}
@@ -18,13 +18,13 @@ export function AvatarsList() {
const locale = useLocale();
const search = Avatars.use((state) => state.search);
const { avatars } = useAwait(() => api.avatars(), "avatars");
const profileAvatarEntityStrings = useGameStrings("ProfileAvatarEntity");
const gameStrings = useGameStrings("ProfileAvatarEntity");
const groups = useMemo(() => {
const groups = new Map<string, Avatar[]>();
for (const avatar of avatars) {
const name =
profileAvatarEntityStrings[avatar.stuff_ui!.display_name] ??
gameStrings[avatar.stuff_ui!.display_name] ??
avatar.stuff_ui!.display_name;
if (groups.has(name)) {
@@ -75,8 +75,8 @@ export function AvatarsList() {
return (
<div className="avatars-list">
<IncrementalLoader
initial={9 * 5}
intermediate={9 * 3}
initial={7 * 5}
intermediate={7 * 3}
data={filtered}
Component={AvatarCard}
/>
@@ -1,9 +1,17 @@
.badge {
border-radius: var(--max-size);
box-shadow: var(--shadow-aggressive);
padding: var(--space-2) var(--space-3);
font-size: var(--font-size-minor);
font-weight: var(--weight-medium);
display: flex;
align-items: center;
gap: var(--space-2);
.svg {
width: 1em;
height: 1em;
}
}
@@ -1,7 +1,8 @@
import type { ComponentProps } from "react";
import { classNames } from "../../core/ui/classNames";
import type { Color } from "../../core/ui/color";
import "./index.css";
import { LIGHT_TEXT_COLORS } from "../Button";
import styles from "./index.module.css";
export interface BadgeProps extends ComponentProps<"div"> {
color?: Color | "accent";
@@ -15,13 +16,14 @@ export function Badge({
highContrast,
...props
}: BadgeProps) {
const lightText = LIGHT_TEXT_COLORS.has(color as Color);
return (
<div
className={classNames("badge", className)}
className={classNames(styles.badge, className)}
style={{
backgroundColor: `var(--${color}-${highContrast ? 12 : 9})`,
color: `var(--gray-${highContrast ? 1 : 12})`,
color: `var(--gray-${highContrast || lightText ? 1 : 12})`,
...style,
}}
{...props}
@@ -8,12 +8,12 @@ export interface ButtonProps extends ComponentProps<"button"> {
variant?: "solid";
}
const LIGHT_TEXT_COLORS = new Set<Color>([
"purple",
export const LIGHT_TEXT_COLORS = new Set<Color>([
"gold",
"bronze",
"teal",
"grass",
"amber",
]);
export function Button({
@@ -0,0 +1,33 @@
.trigger {
display: contents;
cursor: pointer;
}
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100dvh;
background-color: var(--black-a9);
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
padding: var(--space-4);
.content {
display: flex;
flex-direction: column;
gap: var(--space-4);
min-width: 25rem;
background-color: var(--gray-3);
padding: var(--space-4);
box-shadow: var(--shadow-interactive), var(--shadow-aggressive);
border-radius: var(--space-3);
}
}
@@ -0,0 +1,80 @@
import { createContext, useContext, useState, type ReactNode } from "react";
import styles from "./index.module.css";
const DialogContext = createContext<{
open: boolean;
setOpen: (open: boolean) => void;
} | null>(null);
function useDialog() {
const context = useContext(DialogContext);
if (context === null) {
throw new Error("Dialog components must be used within a Dialog.Root");
}
return context;
}
interface RootProps {
children: ReactNode;
}
function Root({ children }: RootProps) {
const [open, setOpen] = useState(false);
return (
<DialogContext.Provider value={{ open, setOpen }}>
{children}
</DialogContext.Provider>
);
}
interface TriggerProps {
children: ReactNode;
}
function Trigger({ children }: TriggerProps) {
const { setOpen } = useDialog();
return (
<div
className={styles.trigger}
onClick={() => {
setOpen(true);
}}
>
{children}
</div>
);
}
interface ContentProps {
children: ReactNode;
}
function Content({ children }: ContentProps) {
const { open, setOpen } = useDialog();
if (!open) return null;
return (
<div
className={styles.overlay}
onClick={() => {
setOpen(false);
}}
>
<div
className={styles.content}
onClick={(event) => {
event.stopPropagation();
}}
>
{children}
</div>
</div>
);
}
export const Dialog = { Root, Trigger, Content };
@@ -15,7 +15,7 @@ export async function imageProxy(url: string) {
}
const buffer = await response.arrayBuffer();
const image = sharp(buffer);
const image = sharp(buffer, { animated: true });
const webp = await image.webp().toBuffer();
const array = new Uint8Array(webp);
@@ -1,4 +1,5 @@
---
import ColorScale from "../../../components/ColorScale.astro";
import ToolBanner from "../../../components/ToolBanner.astro";
import { tools } from "../../../core/tools/tools";
import BaseLayout from "../../../layouts/BaseLayout.astro";
@@ -10,6 +11,9 @@ const { locale } = Astro.props;
---
<BaseLayout {locale} accent="gold">
<ColorScale color="purple" />
<ColorScale color="blue" />
<ToolBanner {locale} tool={tools.avatars} slot="pre-app" />
<Page {locale} client:load />
</BaseLayout>