mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: more home page
This commit is contained in:
1 parent
44203223fd
commit
c5f5f69fd6
11 files changed
+60
-10
No files matched your search
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"common": {
|
"common": {
|
||||||
"name": "BlitzKit",
|
"name": "BlitzKit"
|
||||||
"credit": "by TrèsAbhi"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"units": {
|
"units": {
|
||||||
@@ -28,6 +27,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"home": {
|
"home": {
|
||||||
"search": "Search tanks, players, tools..."
|
"search": "Search tanks, players, tools...",
|
||||||
|
"credit": "by TrèsAbhi"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { ComponentProps } from "react";
|
import type { ComponentProps } from "react";
|
||||||
import { classNames } from "../../core/react/classNames";
|
import { classNames } from "../../core/ui/classNames";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
export interface CodeProps extends ComponentProps<"code"> {}
|
export interface CodeProps extends ComponentProps<"code"> {}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
import * as colors from "@radix-ui/colors";
|
import * as colors from "@radix-ui/colors";
|
||||||
import type { Color } from "../pages/styles/colors/[accent].css";
|
import type { Color } from "../core/ui/color";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
color: Color;
|
color: Color;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { MagnifyingGlassIcon } from "@radix-ui/react-icons";
|
|||||||
import { api } from "../core/api/dynamic";
|
import { api } from "../core/api/dynamic";
|
||||||
import { BlitzKitIcon } from "../icons/BlitzKit";
|
import { BlitzKitIcon } from "../icons/BlitzKit";
|
||||||
import { Code } from "./Code";
|
import { Code } from "./Code";
|
||||||
|
import { Text } from "./Text";
|
||||||
import { TextField } from "./TextField";
|
import { TextField } from "./TextField";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -82,6 +83,7 @@ const strings = await api.strings(locale);
|
|||||||
|
|
||||||
.text-field {
|
.text-field {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
max-width: 25rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -96,6 +98,10 @@ const strings = await api.strings(locale);
|
|||||||
<BlitzKitIcon className="icon" />
|
<BlitzKitIcon className="icon" />
|
||||||
<Code className="version">2.0</Code>
|
<Code className="version">2.0</Code>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Text lowContrast>
|
||||||
|
{strings.home.credit}
|
||||||
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<TextField placeholder={strings.home.search}>
|
<TextField placeholder={strings.home.search}>
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
.text {
|
||||||
|
font-size: var(--font-size-regular);
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import type { ComponentProps } from "react";
|
||||||
|
import type { Color } from "../../core/ui/color";
|
||||||
|
import "./index.css";
|
||||||
|
|
||||||
|
export interface TextProps extends ComponentProps<"span"> {
|
||||||
|
color?: Color;
|
||||||
|
lowContrast?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Text({ color = "gray", lowContrast, ...props }: TextProps) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className="text"
|
||||||
|
style={{ color: `var(--${color}-${lowContrast ? 11 : 12})` }}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -32,9 +32,8 @@ export abstract class AbstractAPI {
|
|||||||
return await this._strings(locale);
|
return await this._strings(locale);
|
||||||
}
|
}
|
||||||
async gameStrings(locale: string, prefix: string) {
|
async gameStrings(locale: string, prefix: string) {
|
||||||
const supported = this.assertLocale(locale);
|
this.assertLocale(locale);
|
||||||
const blitz = supported.blitz ?? supported.locale;
|
return await this._gameStrings(locale, prefix);
|
||||||
return await this._gameStrings(blitz, prefix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract tank(id: string): Promise<Tank>;
|
abstract tank(id: string): Promise<Tank>;
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ if (typeof window !== "undefined") {
|
|||||||
throw new Error("ServerAPI is being evaluated in the browser");
|
throw new Error("ServerAPI is being evaluated in the browser");
|
||||||
}
|
}
|
||||||
|
|
||||||
const globbedStrings = import.meta.glob("../../../../i18n/strings/*.json");
|
const globbedStrings = import.meta.glob("../../../../i18n/strings/*.json", {
|
||||||
|
import: "default",
|
||||||
|
});
|
||||||
|
|
||||||
interface LocalizationConfig {
|
interface LocalizationConfig {
|
||||||
namespaces: string[];
|
namespaces: string[];
|
||||||
@@ -72,7 +74,7 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
Object.assign(
|
Object.assign(
|
||||||
strings,
|
strings,
|
||||||
await fetch(
|
await fetch(
|
||||||
`${remoteStorage.url}/${remoteStorage.relative_path}/${namespace}/${locale}.yaml`
|
`${remoteStorage.url}${remoteStorage.relative_path}/${namespace}/${locale}.yaml`
|
||||||
)
|
)
|
||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((text) => {
|
.then((text) => {
|
||||||
|
|||||||
File renamed without changes.
@@ -0,0 +1,7 @@
|
|||||||
|
import type * as colors from "@radix-ui/colors";
|
||||||
|
|
||||||
|
const ignoreEndings = ["A", "P3", "Dark", "DarkA", "DarkP3"] as const;
|
||||||
|
export type Color = Exclude<
|
||||||
|
keyof typeof colors,
|
||||||
|
`${string}${(typeof ignoreEndings)[number]}` | "__esModule"
|
||||||
|
>;
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import locales from "@blitzkit/i18n/locales.json";
|
||||||
|
import type { APIContext, GetStaticPaths } from "astro";
|
||||||
|
import { api } from "../../../core/api/dynamic";
|
||||||
|
|
||||||
|
export const getStaticPaths = (() => {
|
||||||
|
return locales.supported.map(({ locale }) => ({ params: { locale } }));
|
||||||
|
}) satisfies GetStaticPaths;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BlitzKit strings.
|
||||||
|
*/
|
||||||
|
export async function GET({ params }: APIContext<never, { locale: string }>) {
|
||||||
|
const strings = await api.strings(params.locale);
|
||||||
|
return Response.json(strings);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user