diff --git a/packages/i18n/strings/en.json b/packages/i18n/strings/en.json index daaadace0..22b4087e0 100644 --- a/packages/i18n/strings/en.json +++ b/packages/i18n/strings/en.json @@ -1445,18 +1445,6 @@ "button": "Get started", "description": "Get started with BlitzKit", "seo_description": "Get started with BlitzKit" - }, - "blitz_analysis": { - "name": "BlitzAnalysis[]", - "button": "Analyze now", - "description": "Rich historic average stats", - "seo_description": "Rich historic average stats in World of Tanks Blitz" - }, - "blitz_insider": { - "name": "Blitz Insider", - "button": "Discover today", - "description": "In-game session stats", - "seo_description": "In-game session stats in World of Tanks Blitz" } }, diff --git a/packages/website/src/components/Navbar.astro b/packages/website/src/components/Navbar.astro index 90d0b9a3b..3942cf0e9 100644 --- a/packages/website/src/components/Navbar.astro +++ b/packages/website/src/components/Navbar.astro @@ -1,24 +1,24 @@ --- -import { assertSecret } from '@blitzkit/core'; +import { assertSecret } from "@blitzkit/core"; import { Cross1Icon, DiscordLogoIcon, GearIcon, HamburgerMenuIcon, -} from '@radix-ui/react-icons'; -import { Box, Code, Flex, IconButton, Link } from '@radix-ui/themes'; -import { TOOLS } from '../constants/tools'; -import { resolveBranchName } from '../core/blitzkit/branches'; -import { getStrings } from '../core/i18n/getStrings'; -import { Var } from '../core/radix/var'; -import { LinkI18n } from './LinkI18n'; +} from "@radix-ui/react-icons"; +import { Box, Code, Flex, IconButton, Link } from "@radix-ui/themes"; +import { TOOLS } from "../constants/tools"; +import { resolveBranchName } from "../core/blitzkit/branches"; +import { getStrings } from "../core/i18n/getStrings"; +import { Var } from "../core/radix/var"; +import { LinkI18n } from "./LinkI18n"; export interface Props { integrated?: boolean; } const { integrated = false } = Astro.props; -const toolsFiltered = TOOLS.filter((tool) => !('href' in tool)); +const toolsFiltered = TOOLS.filter((tool) => !tool.href && !tool.disabled); const { locale } = Astro.params; const branchName = resolveBranchName(locale); const isBranchNamed = branchName !== undefined; @@ -39,47 +39,47 @@ const strings = getStrings(locale); height: 0; } - .navbar[data-expanded='false'] *[data-expanded] { + .navbar[data-expanded="false"] *[data-expanded] { display: none; } - .navbar[data-expanded='true'] { + .navbar[data-expanded="true"] { height: 100%; } - .navbar[data-expanded='false'][data-integrated='false'] .content { + .navbar[data-expanded="false"][data-integrated="false"] .content { background-color: var(--black-a8); backdrop-filter: blur(4rem); box-shadow: var(--shadow-3); } - .navbar[data-expanded='true'] .content { + .navbar[data-expanded="true"] .content { background-color: var(--gray-1); } - .navbar[data-expanded='true'] *[data-closed] { + .navbar[data-expanded="true"] *[data-closed] { display: none; } { !integrated && ( - + ) } @@ -94,16 +94,16 @@ const strings = getStrings(locale); position="fixed" style={{ zIndex: 1, - backdropFilter: 'blur(4rem)', + backdropFilter: "blur(4rem)", }} > @@ -131,30 +131,26 @@ const strings = getStrings(locale); { toolsFiltered.map((tool) => { - const unavailableOnBranch = tool.branches?.every( - (branch) => - branch !== assertSecret(import.meta.env.PUBLIC_BRANCH), - ); const selected = Astro.url.pathname.includes(`/${tool.id}`); const toolStrings = strings.website.tools[ - (tool.stringsId ?? + (tool.strings ?? tool.id) as keyof typeof strings.website.tools ]; - if (unavailableOnBranch) return null; + if (toolStrings === undefined) console.log(tool.id); return ( --> - + @@ -206,36 +202,28 @@ const strings = getStrings(locale); direction="column" data-expanded gap="3" - display={{ initial: 'flex', sm: 'none' }} + display={{ initial: "flex", sm: "none" }} > { toolsFiltered.map((tool) => { - const unavailableOnBranch = tool.branches?.every( - (branch) => - branch !== assertSecret(import.meta.env.PUBLIC_BRANCH), - ); - - if (unavailableOnBranch) return null; - const toolStrings = strings.website.tools[ - (tool.stringsId ?? - tool.id) as keyof typeof strings.website.tools + (tool.strings ?? tool.id) as keyof typeof strings.website.tools ]; return ( {toolStrings.name} @@ -261,11 +249,11 @@ const strings = getStrings(locale); data-expanded flexGrow="1" width="100%" - display={{ initial: 'block', sm: 'none' }} + display={{ initial: "block", sm: "none" }} style={{ - backgroundColor: Var('black-a7'), - backdropFilter: 'blur(0.5rem)', - WebkitBackdropFilter: 'blur(0.5rem)', + backgroundColor: Var("black-a7"), + backdropFilter: "blur(0.5rem)", + WebkitBackdropFilter: "blur(0.5rem)", }} /> diff --git a/packages/website/src/components/ToolCard.astro b/packages/website/src/components/ToolCard.astro index 863e75b03..e8e8455fd 100644 --- a/packages/website/src/components/ToolCard.astro +++ b/packages/website/src/components/ToolCard.astro @@ -1,24 +1,20 @@ --- -import { assertSecret } from '@blitzkit/core'; -import { CaretRightIcon } from '@radix-ui/react-icons'; -import { Box, Button, Code, Flex, Heading, Text } from '@radix-ui/themes'; -import type { Tool } from '../constants/tools'; -import { getStrings } from '../core/i18n/getStrings'; -import { LinkI18n } from './LinkI18n'; +import { CaretRightIcon } from "@radix-ui/react-icons"; +import { Box, Button, Flex, Heading, Text } from "@radix-ui/themes"; +import type { Tool } from "../constants/tools"; +import { getStrings } from "../core/i18n/getStrings"; +import { LinkI18n } from "./LinkI18n"; interface Props { tool: Tool; } const { tool } = Astro.props; -const disabled = tool.branches?.every( - (branch) => branch !== assertSecret(import.meta.env.PUBLIC_BRANCH), -); const { locale } = Astro.params; const strings = getStrings(locale); const toolStrings = strings.website.tools[ - (tool.stringsId ?? tool.id) as keyof typeof strings.website.tools + (tool.strings ?? tool.id) as keyof typeof strings.website.tools ]; --- @@ -29,11 +25,12 @@ const toolStrings = background-position: center; height: 16rem; - &[data-disabled='true'] { + &[data-disabled="true"] { opacity: 0.25; } - &[data-significant='true'] { + &[data-significant="true"] { + width: 100%; height: min(20rem, 50vh); } } @@ -49,90 +46,76 @@ const toolStrings = {toolStrings.name} - { - disabled ? ( - <> - Unavailable on{' '} - {assertSecret(import.meta.env.PUBLIC_BRANCH)} - - ) : ( - toolStrings.description - ) - } + {toolStrings.description} - { - !disabled && ( - - ) - } + diff --git a/packages/website/src/constants/tools.json b/packages/website/src/constants/tools.json new file mode 100644 index 000000000..5f11169b5 --- /dev/null +++ b/packages/website/src/constants/tools.json @@ -0,0 +1,24 @@ +[ + { + "id": "tanks", + "strings": "tankopedia", + "button": { "color": "purple" }, + "significant": true + }, + + { + "id": "compare", + "button": { "color": "crimson" } + }, + + { + "id": "session", + "button": { "color": "blue" } + }, + + { + "id": "discord", + "href": "https://discord.com/application-directory/1097673957865443370", + "button": { "color": "indigo" } + } +] diff --git a/packages/website/src/constants/tools.ts b/packages/website/src/constants/tools.ts index 19716a0b5..171a56031 100644 --- a/packages/website/src/constants/tools.ts +++ b/packages/website/src/constants/tools.ts @@ -1,148 +1,82 @@ -import { Button } from '@radix-ui/themes'; -import type { ComponentProps } from 'react'; +import { Button } from "@radix-ui/themes"; +import type { ComponentProps } from "react"; export interface Tool { id: string; - stringsId?: string; + strings?: string; disabled?: boolean; href?: string; button: { highContrast?: boolean; - color: ComponentProps['color']; + color: ComponentProps["color"]; }; significant?: boolean; - branches?: string[]; } -export const tankopediaTool: Tool = { - id: 'tanks', - stringsId: 'tankopedia', - button: { - color: 'purple', - }, - significant: true, - branches: ['main', 'dev', 'opentest', 'preview'], -}; - -// export const ratingTool: Tool = { -// id: 'rating', -// image: 'WEyMZH3', -// button: { -// color: 'orange', -// }, -// branches: ['main', 'dev'], -// }; - -export const compareTool: Tool = { - id: 'compare', - button: { - color: 'crimson', - }, - branches: ['main', 'dev', 'opentest', 'preview'], -}; - -export const sessionTool: Tool = { - // TODO: rename to tracker - id: 'session', - button: { - color: 'blue', - }, - branches: ['main', 'dev'], -}; - -export const discordTool: Tool = { - id: 'discord', - href: 'https://discord.com/application-directory/1097673957865443370', - button: { - color: 'indigo', - }, -}; - -export const moreTool: Tool = { - id: 'more', - href: 'https://discord.gg/nDt7AjGJQH', - button: { - color: 'plum', - }, -}; - -export const playersTool: Tool = { - id: 'players', - button: { - color: 'blue', - }, - href: '_', // TODO: remove this to re-enable link - branches: ['main', 'dev'], -}; - -export const performanceTool: Tool = { - id: 'performance', - button: { - color: 'jade', - }, - branches: ['main', 'dev'], -}; - -export const embedTool: Tool = { - id: 'embed', - button: { - color: 'red', - }, - branches: ['main', 'dev'], -}; - -export const homeTool: Tool = { - id: 'home', - button: { color: 'blue' }, -}; - -export const galleryTool: Tool = { - id: 'gallery', - button: { - color: 'gold', - }, - branches: ['main', 'dev'], -}; - -export const tierListTool: Tool = { - id: 'tier-list', - stringsId: 'tier_list', - button: { - color: 'orange', - }, - branches: ['main', 'dev', 'opentest', 'preview'], -}; - -export const chartsTool: Tool = { - id: 'charts', - button: { - color: 'bronze', - }, - branches: ['main', 'dev'], -}; - -export const guessTool: Tool = { - id: 'guess', - button: { color: 'cyan' }, - branches: ['main', 'dev', 'opentest', 'preview'], -}; - -export const mixerTool: Tool = { - id: 'mixer', - button: { color: 'red' }, - branches: ['main', 'dev', 'opentest', 'preview'], -}; - export const TOOLS: Tool[] = [ - tankopediaTool, - compareTool, - performanceTool, - guessTool, - // mixerTool, - // chartsTool, - galleryTool, - sessionTool, - tierListTool, - embedTool, - // ratingTool, + { + id: "tanks", + strings: "tankopedia", + button: { color: "purple" }, + significant: true, + }, + { + id: "players", + disabled: true, + button: { color: "blue" }, + }, + { + id: "compare", + button: { color: "crimson" }, + }, + { + id: "performance", + button: { color: "jade" }, + }, + { + id: "charts", + disabled: true, + button: { color: "bronze" }, + }, + { + id: "guess", + button: { color: "cyan" }, + }, + { + id: "mixer", + disabled: true, + button: { color: "red" }, + }, + { + id: "charts", + disabled: true, + button: { color: "red" }, + }, + { + id: "gallery", + button: { color: "gold" }, + }, + { + id: "session", + button: { color: "blue" }, + }, + { + id: "discord", + href: "https://discord.com/application-directory/1097673957865443370", + button: { color: "indigo" }, + }, + { + id: "tier-list", + strings: "tier_list", + button: { color: "orange" }, + }, + { + id: "embed", + button: { color: "red" }, + }, + { + id: "more", + href: "https://discord.gg/nDt7AjGJQH", + button: { color: "plum" }, + }, ]; diff --git a/packages/website/src/layouts/ToolLayout.astro b/packages/website/src/layouts/ToolLayout.astro index 6dd87967e..f3ad98a80 100644 --- a/packages/website/src/layouts/ToolLayout.astro +++ b/packages/website/src/layouts/ToolLayout.astro @@ -1,9 +1,9 @@ --- -import { Box, Flex, Heading, Text } from '@radix-ui/themes'; -import ToolOpenGraph from '../components/ToolOpenGraph.astro'; -import { type Tool } from '../constants/tools'; -import { getStrings } from '../core/i18n/getStrings'; -import BaseLayout from './BaseLayout.astro'; +import { Box, Flex, Heading, Text } from "@radix-ui/themes"; +import ToolOpenGraph from "../components/ToolOpenGraph.astro"; +import { type Tool } from "../constants/tools"; +import { getStrings } from "../core/i18n/getStrings"; +import BaseLayout from "./BaseLayout.astro"; interface Props { tool: Tool; @@ -14,7 +14,7 @@ const { locale } = Astro.params; const strings = getStrings(locale); const toolStrings = strings.website.tools[ - (tool.stringsId ?? tool.id) as keyof typeof strings.website.tools + (tool.strings ?? tool.id) as keyof typeof strings.website.tools ]; --- @@ -24,7 +24,7 @@ const toolStrings = {toolStrings.name} diff --git a/packages/website/src/pages/[...locale]/index.astro b/packages/website/src/pages/[...locale]/index.astro index 833ec1687..34437d8da 100644 --- a/packages/website/src/pages/[...locale]/index.astro +++ b/packages/website/src/pages/[...locale]/index.astro @@ -1,37 +1,43 @@ --- -import { AstroSeo } from '@astrolib/seo'; -import { assertSecret } from '@blitzkit/core'; -import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from '@blitzkit/i18n'; -import { literals } from '@blitzkit/i18n/src/literals'; -import { Box, Flex, Heading, Link } from '@radix-ui/themes'; -import type { GetStaticPaths } from 'astro'; -import { AesonPlug } from '../../components/AesonPlug'; -import HomeHero from '../../components/HomeHero.astro'; -import { Plugs } from '../../components/Plugs'; -import ToolCard from '../../components/ToolCard.astro'; -import { - compareTool, - discordTool, - embedTool, - galleryTool, - guessTool, - moreTool, - performanceTool, - sessionTool, - tankopediaTool, - tierListTool, -} from '../../constants/tools'; -import { getStrings } from '../../core/i18n/getStrings'; -import BaseLayout from '../../layouts/BaseLayout.astro'; +import { AstroSeo } from "@astrolib/seo"; +import { assertSecret } from "@blitzkit/core"; +import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from "@blitzkit/i18n"; +import { literals } from "@blitzkit/i18n/src/literals"; +import { Box, Flex, Link } from "@radix-ui/themes"; +import type { GetStaticPaths } from "astro"; +import { AesonPlug } from "../../components/AesonPlug"; +import HomeHero from "../../components/HomeHero.astro"; +import { Plugs } from "../../components/Plugs"; +import ToolCard from "../../components/ToolCard.astro"; +import { TOOLS, type Tool } from "../../constants/tools"; +import { getStrings } from "../../core/i18n/getStrings"; +import BaseLayout from "../../layouts/BaseLayout.astro"; + +const MAX_TOOLS_PER_ROW = 2; const PUBLIC_ASSET_BRANCH = assertSecret(import.meta.env.PUBLIC_BRANCH); const locale = Astro.params.locale ?? DEFAULT_LOCALE; const strings = getStrings(Astro.params.locale); +const rows: Tool[][] = []; + +for (const tool of TOOLS) { + if (tool.disabled) continue; + + const compatibleRow = rows.find( + (row) => row.length < MAX_TOOLS_PER_ROW && !row[0].significant + ); + + if (compatibleRow) { + compatibleRow.push(tool); + } else { + rows.push([tool]); + } +} export const getStaticPaths = (() => { return [ ...SUPPORTED_LOCALES.filter((locale) => locale !== DEFAULT_LOCALE).map( - (locale) => ({ params: { locale } }), + (locale) => ({ params: { locale } }) ), { params: { locale: undefined } }, ]; @@ -44,11 +50,11 @@ export const getStaticPaths = (() => { canonical={Astro.url.href} openGraph={{ url: Astro.url.href, - title: 'BlitzKit', + title: "BlitzKit", description: strings.website.home.seo_description, - site_name: 'BlitzKit', + site_name: "BlitzKit", }} - twitter={{ cardType: 'summary_large_image' }} + twitter={{ cardType: "summary_large_image" }} /> @@ -79,7 +85,7 @@ export const getStaticPaths = (() => { underline="always" > {literals(strings.website.home.help_translate, [ - 'BlitzKit', + "BlitzKit", strings.common.locales[locale], ])} @@ -90,7 +96,7 @@ export const getStaticPaths = (() => { { - PUBLIC_ASSET_BRANCH === 'preview' && ( + PUBLIC_ASSET_BRANCH === "preview" && ( @@ -99,57 +105,18 @@ export const getStaticPaths = (() => { - - - - {/* */} - - - - - - - - - - - - - - - - - - - - - - - - - - {strings.website.home.other_projects.title} - - - - - + { + rows.map((row) => ( + + {row.map((tool) => ( + + ))} + {row.length < MAX_TOOLS_PER_ROW && !row[0].significant && ( + + )} + + )) + }