mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-06 08:13:09 +01:00
Compare commits
3
Commits
f5f3f70e35
...
4a6f5845f9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a6f5845f9 | ||
|
|
e9684ce033 | ||
|
|
27abf1b0de |
No files matched your search
@@ -12,13 +12,13 @@
|
|||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
|
|
||||||
outline: var(--outline-interactive);
|
box-shadow: var(--shadow-interactive), var(--shadow-subtle);
|
||||||
box-shadow: var(--shadow-subtle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar-label {
|
.avatar-label {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import { api } from "../../core/api/dynamic";
|
import { useGameStrings } from "../../hooks/useGameStrings";
|
||||||
import { useAwait } from "../../hooks/useAwait";
|
|
||||||
import type { Avatar } from "../../protos/avatar";
|
import type { Avatar } from "../../protos/avatar";
|
||||||
import { Text } from "../Text";
|
import { Text } from "../Text";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
@@ -9,12 +8,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function AvatarCard({ avatar }: Props) {
|
export function AvatarCard({ avatar }: Props) {
|
||||||
// const { locale } = useLocale();
|
const profileAvatarEntityStrings = useGameStrings("ProfileAvatarEntity");
|
||||||
const { locale } = { locale: "en" };
|
|
||||||
const profileAvatarEntityStrings = useAwait(
|
|
||||||
() => api.groupedGameStrings(locale, "ProfileAvatarEntity"),
|
|
||||||
"profile-avatar-entity-strings"
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="avatar-card">
|
<div className="avatar-card">
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import "@fontsource-variable/roboto-flex";
|
|||||||
--space-8: 16rem;
|
--space-8: 16rem;
|
||||||
--space-9: 32rem;
|
--space-9: 32rem;
|
||||||
|
|
||||||
|
--page-width: 52rem;
|
||||||
|
|
||||||
--max-size: max(100vw, 100vh);
|
--max-size: max(100vw, 100vh);
|
||||||
|
|
||||||
--font-size-regular: 1rem;
|
--font-size-regular: 1rem;
|
||||||
@@ -34,7 +36,6 @@ import "@fontsource-variable/roboto-flex";
|
|||||||
--weight-bold: 700;
|
--weight-bold: 700;
|
||||||
--weight-black: 900;
|
--weight-black: 900;
|
||||||
|
|
||||||
--outline-interactive: solid var(--space-1) var(--gray-5);
|
|
||||||
--outline-focus: var(--space-1) solid var(--accent-6);
|
--outline-focus: var(--space-1) solid var(--accent-6);
|
||||||
|
|
||||||
--shadow-cavity:
|
--shadow-cavity:
|
||||||
@@ -42,11 +43,27 @@ import "@fontsource-variable/roboto-flex";
|
|||||||
var(--space-1) var(--black-a3),
|
var(--space-1) var(--black-a3),
|
||||||
inset calc(var(--space-1) * sin(45deg) * -1)
|
inset calc(var(--space-1) * sin(45deg) * -1)
|
||||||
calc(var(--space-1) * sin(45deg) * -1) var(--space-1) var(--white-a1);
|
calc(var(--space-1) * sin(45deg) * -1) var(--space-1) var(--white-a1);
|
||||||
|
|
||||||
--shadow-bump:
|
--shadow-bump:
|
||||||
inset calc(var(--space-1) * sin(45deg)) calc(var(--space-1) * sin(45deg))
|
inset calc(var(--space-1) * sin(45deg)) calc(var(--space-1) * sin(45deg))
|
||||||
var(--space-1) var(--white-a3),
|
var(--space-1) var(--white-a3),
|
||||||
inset calc(var(--space-1) * sin(45deg) * -1)
|
inset calc(var(--space-1) * sin(45deg) * -1)
|
||||||
calc(var(--space-1) * sin(45deg) * -1) var(--space-1) var(--black-a3);
|
calc(var(--space-1) * sin(45deg) * -1) var(--space-1) var(--black-a3);
|
||||||
|
|
||||||
|
--shadow-outline-width: 1.5px;
|
||||||
|
--shadow-outline-width-negative: calc(var(--shadow-outline-width) * -1);
|
||||||
|
|
||||||
|
--shadow-interactive-background: 0 0 0 var(--shadow-outline-width)
|
||||||
|
var(--gray-6);
|
||||||
|
--shadow-interactive-shine: var(--shadow-outline-width-negative)
|
||||||
|
var(--shadow-outline-width-negative) var(--shadow-outline-width)
|
||||||
|
var(--white-a1);
|
||||||
|
--shadow-interactive-shadow: var(--shadow-outline-width)
|
||||||
|
var(--shadow-outline-width) var(--shadow-outline-width) var(--black-a4);
|
||||||
|
--shadow-interactive:
|
||||||
|
var(--shadow-interactive-shine), var(--shadow-interactive-shadow),
|
||||||
|
var(--shadow-interactive-background);
|
||||||
|
|
||||||
--shadow-subtle: var(--space-1) var(--space-1) var(--space-4)
|
--shadow-subtle: var(--space-1) var(--space-1) var(--space-4)
|
||||||
var(--black-a11);
|
var(--black-a11);
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const strings = await api.strings(locale);
|
|||||||
|
|
||||||
.content {
|
.content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
max-width: 52rem;
|
max-width: var(--page-width);
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -1,36 +1,54 @@
|
|||||||
---
|
---
|
||||||
import { HamburgerMenuIcon, MagnifyingGlassIcon } from "@radix-ui/react-icons";
|
import { HamburgerMenuIcon, MagnifyingGlassIcon } from "@radix-ui/react-icons";
|
||||||
import { BlitzKitIcon } from "../icons/BlitzKit";
|
import { BlitzKitIcon } from "../icons/BlitzKit";
|
||||||
|
import { LinkI18n } from "./LinkI18n";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
locale: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { locale } = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.navbar {
|
.navbar {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 100%;
|
left: 0;
|
||||||
margin-bottom: calc(var(--space-4) * -1);
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: center;
|
||||||
|
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
backdrop-filter: var(--blur-glass);
|
backdrop-filter: var(--blur-glass);
|
||||||
background-color: var(--black-a11);
|
background-color: var(--black-a5);
|
||||||
|
|
||||||
|
.content {
|
||||||
|
flex: 1;
|
||||||
|
max-width: calc(var(--page-width) + 2 * var(--space-4));
|
||||||
|
|
||||||
.side {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
.action {
|
.side {
|
||||||
width: calc(var(--space-5) + var(--space-4));
|
|
||||||
height: calc(var(--space-5) + var(--space-4));
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
.icon {
|
.action {
|
||||||
width: 1.25em;
|
padding: var(--space-4);
|
||||||
height: 1.25em;
|
|
||||||
|
cursor: pointer;
|
||||||
|
color: var(--color-regular);
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: var(--outline-focus);
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
width: 1.25em;
|
||||||
|
height: 1.25em;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,19 +56,21 @@ import { BlitzKitIcon } from "../icons/BlitzKit";
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="side">
|
<div class="content">
|
||||||
<div class="action">
|
<div class="side">
|
||||||
<BlitzKitIcon className="icon" />
|
<LinkI18n {locale} href="/" className="action" tabIndex={0}>
|
||||||
</div>
|
<BlitzKitIcon className="icon" />
|
||||||
</div>
|
</LinkI18n>
|
||||||
|
|
||||||
<div class="side">
|
|
||||||
<div class="action">
|
|
||||||
<MagnifyingGlassIcon className="icon" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="action">
|
<div class="side">
|
||||||
<HamburgerMenuIcon className="icon" />
|
<div class="action" tabindex="0">
|
||||||
|
<MagnifyingGlassIcon className="icon" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="action" tabindex="0">
|
||||||
|
<HamburgerMenuIcon className="icon" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
.content {
|
.content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
max-width: 52rem;
|
max-width: var(--page-width);
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -9,8 +9,7 @@
|
|||||||
border-radius: var(--max-size);
|
border-radius: var(--max-size);
|
||||||
|
|
||||||
background-color: var(--gray-1);
|
background-color: var(--gray-1);
|
||||||
outline: var(--outline-interactive);
|
box-shadow: var(--shadow-interactive), var(--shadow-cavity);
|
||||||
box-shadow: var(--shadow-cavity);
|
|
||||||
|
|
||||||
font-size: var(--font-size-regular);
|
font-size: var(--font-size-regular);
|
||||||
color: var(--gray-11);
|
color: var(--gray-11);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { fetchPB } from "@blitzkit/core";
|
import { fetchPB } from "@blitzkit/core";
|
||||||
|
import type { Strings } from "@blitzkit/i18n";
|
||||||
import { Avatars } from "../../protos/avatars";
|
import { Avatars } from "../../protos/avatars";
|
||||||
import { AbstractAPI } from "./abstract";
|
import { AbstractAPI } from "./abstract";
|
||||||
|
|
||||||
@@ -29,4 +30,11 @@ export class ClientAPI extends AbstractAPI {
|
|||||||
|
|
||||||
return strings;
|
return strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async _strings(locale: string) {
|
||||||
|
const response = await fetch(`/api/strings/${locale}.json`);
|
||||||
|
const json = (await response.json()) as Strings;
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { api } from "../core/api/dynamic";
|
||||||
|
import { useAwait } from "./useAwait";
|
||||||
|
import { useLocale } from "./useLocale";
|
||||||
|
|
||||||
|
export function useGameStrings(group: string) {
|
||||||
|
const { locale } = useLocale();
|
||||||
|
const strings = useAwait(
|
||||||
|
() => api.groupedGameStrings(locale, group),
|
||||||
|
`game-strings-${locale}-${group}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import locales from "@blitzkit/i18n/locales.json";
|
||||||
|
import { createContext, useContext, type ReactNode } from "react";
|
||||||
|
import { api } from "../core/api/dynamic";
|
||||||
|
import { useAwait } from "./useAwait";
|
||||||
|
|
||||||
|
const LocaleContext = createContext<{
|
||||||
|
locale: string;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
|
interface LocaleProviderProps extends LocaleAcceptorProps {
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function LocaleProvider({ locale, children }: LocaleProviderProps) {
|
||||||
|
return (
|
||||||
|
<LocaleContext.Provider value={{ locale: locale ?? locales.default }}>
|
||||||
|
{children}
|
||||||
|
</LocaleContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useLocale() {
|
||||||
|
const context = useContext(LocaleContext);
|
||||||
|
|
||||||
|
if (!context) {
|
||||||
|
throw new Error("useLocale must be used within a LocaleProvider");
|
||||||
|
}
|
||||||
|
|
||||||
|
const strings = useAwait(
|
||||||
|
() => api.strings(context.locale),
|
||||||
|
`strings-${context.locale}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return { locale: context.locale, strings };
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LocaleAcceptorProps {
|
||||||
|
locale: string | undefined;
|
||||||
|
}
|
||||||
@@ -48,7 +48,7 @@ const { accent, noNavbar, locale } = Astro.props;
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="dark">
|
<body class="dark">
|
||||||
{!noNavbar && <Navbar />}
|
{!noNavbar && <Navbar {locale} />}
|
||||||
|
|
||||||
<slot />
|
<slot />
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,30 @@
|
|||||||
import { AvatarCard } from "../../../components/AvatarCard";
|
import { AvatarCard } from "../../../components/AvatarCard";
|
||||||
import { api } from "../../../core/api/dynamic";
|
import { api } from "../../../core/api/dynamic";
|
||||||
import { useAwait } from "../../../hooks/useAwait";
|
import { useAwait } from "../../../hooks/useAwait";
|
||||||
|
import { LocaleProvider } from "../../../hooks/useLocale";
|
||||||
|
|
||||||
interface Props {
|
interface PageProps extends ContentProps {
|
||||||
|
locale: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Page({ locale, ...props }: PageProps) {
|
||||||
|
return (
|
||||||
|
<LocaleProvider locale={locale}>
|
||||||
|
<Content {...props} />
|
||||||
|
</LocaleProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ContentProps {
|
||||||
skeleton?: boolean;
|
skeleton?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Page({ skeleton }: Props) {
|
function Content({ skeleton }: ContentProps) {
|
||||||
const { avatars } = useAwait(() => api.avatars(), "avatars");
|
const { avatars } = useAwait(() => api.avatars(), "avatars");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="avatars">
|
<div className="avatars">
|
||||||
{avatars.map((avatar) => (
|
{avatars.slice(0, 12).map((avatar) => (
|
||||||
<AvatarCard key={avatar.name} avatar={avatar} />
|
<AvatarCard key={avatar.name} avatar={avatar} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ const { locale } = Astro.props;
|
|||||||
|
|
||||||
<BaseLayout {locale} accent="gold">
|
<BaseLayout {locale} accent="gold">
|
||||||
<Section>
|
<Section>
|
||||||
<Page client:only="react">
|
<Page {locale} client:only="react">
|
||||||
<Page skeleton slot="fallback" />
|
<Page {locale} skeleton slot="fallback" />
|
||||||
</Page>
|
</Page>
|
||||||
</Section>
|
</Section>
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
Reference in new issue
Block a user