mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
Merge pull request #244 from karelpak1/feat-tankopedia-modules-tooltips
feat: add localized tooltips to tankopedia modules tree
This commit is contained in:
1 file changed
+12
-2
+12
-2
@@ -18,6 +18,7 @@ import {
|
|||||||
Heading,
|
Heading,
|
||||||
IconButton,
|
IconButton,
|
||||||
Text,
|
Text,
|
||||||
|
Tooltip,
|
||||||
} from "@radix-ui/themes";
|
} from "@radix-ui/themes";
|
||||||
import { awaitableTankDefinitions } from "../../../../core/awaitables/tankDefinitions";
|
import { awaitableTankDefinitions } from "../../../../core/awaitables/tankDefinitions";
|
||||||
import { useLocale } from "../../../../hooks/useLocale";
|
import { useLocale } from "../../../../hooks/useLocale";
|
||||||
@@ -55,12 +56,14 @@ function ModuleButton({
|
|||||||
selected,
|
selected,
|
||||||
unlock,
|
unlock,
|
||||||
top,
|
top,
|
||||||
|
tooltip,
|
||||||
onClick,
|
onClick,
|
||||||
}: {
|
}: {
|
||||||
unlock: Unlock;
|
unlock: Unlock;
|
||||||
tier: number;
|
tier: number;
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
top: boolean;
|
top: boolean;
|
||||||
|
tooltip?: string;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
}) {
|
}) {
|
||||||
const isTank = unlock.type === ModuleType.MODULE_TYPE_VEHICLE;
|
const isTank = unlock.type === ModuleType.MODULE_TYPE_VEHICLE;
|
||||||
@@ -134,7 +137,7 @@ function ModuleButton({
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
|
|
||||||
return isTank ? (
|
const node = isTank ? (
|
||||||
<LinkI18n
|
<LinkI18n
|
||||||
locale={locale}
|
locale={locale}
|
||||||
href={`/tanks/${tankDefinitions.tanks[unlock.id].slug}`}
|
href={`/tanks/${tankDefinitions.tanks[unlock.id].slug}`}
|
||||||
@@ -144,6 +147,10 @@ function ModuleButton({
|
|||||||
) : (
|
) : (
|
||||||
button
|
button
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!tooltip) return node;
|
||||||
|
|
||||||
|
return <Tooltip content={tooltip}>{node}</Tooltip>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tankDefinitions = await awaitableTankDefinitions;
|
const tankDefinitions = await awaitableTankDefinitions;
|
||||||
@@ -167,7 +174,7 @@ export function Modules() {
|
|||||||
const topGun = topTurret.guns.at(-1)!;
|
const topGun = topTurret.guns.at(-1)!;
|
||||||
const topEngine = tank.engines.at(-1)!;
|
const topEngine = tank.engines.at(-1)!;
|
||||||
const topTrack = tank.tracks.at(-1)!;
|
const topTrack = tank.tracks.at(-1)!;
|
||||||
const { strings } = useLocale();
|
const { strings, unwrap } = useLocale();
|
||||||
|
|
||||||
function setByUnlock(unlock: Unlock) {
|
function setByUnlock(unlock: Unlock) {
|
||||||
Duel.mutate((draft) => {
|
Duel.mutate((draft) => {
|
||||||
@@ -249,6 +256,8 @@ export function Modules() {
|
|||||||
|
|
||||||
if (module === undefined) return null;
|
if (module === undefined) return null;
|
||||||
|
|
||||||
|
const tooltip = unwrap(module.name!);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
key={unlock.id}
|
key={unlock.id}
|
||||||
@@ -301,6 +310,7 @@ export function Modules() {
|
|||||||
<ModuleButton
|
<ModuleButton
|
||||||
unlock={unlock}
|
unlock={unlock}
|
||||||
tier={extractModule(module).tier}
|
tier={extractModule(module).tier}
|
||||||
|
tooltip={tooltip}
|
||||||
selected={
|
selected={
|
||||||
(unlock.type === ModuleType.MODULE_TYPE_TURRET
|
(unlock.type === ModuleType.MODULE_TYPE_TURRET
|
||||||
? turret.id
|
? turret.id
|
||||||
|
|||||||
Reference in new issue
Block a user