mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: tooltips
This commit is contained in:
1 parent
c73eb0d951
commit
14fccf3f6e
4 files changed
+21
-2
No files matched your search
@@ -1,6 +1,8 @@
|
|||||||
import { ClockIcon, ReloadIcon } from '@radix-ui/react-icons';
|
import { ClockIcon, ReloadIcon } from '@radix-ui/react-icons';
|
||||||
import { Flex, Text } from '@radix-ui/themes';
|
import { Flex, Text } from '@radix-ui/themes';
|
||||||
|
import { use } from 'react';
|
||||||
import { asset } from '../../core/blitzkit/asset';
|
import { asset } from '../../core/blitzkit/asset';
|
||||||
|
import { consumableDefinitions } from '../../core/blitzkit/consumableDefinitions';
|
||||||
import { useDelta } from '../../hooks/useDelta';
|
import { useDelta } from '../../hooks/useDelta';
|
||||||
import { GenericTankComponentButton } from './GenericTankComponentButton';
|
import { GenericTankComponentButton } from './GenericTankComponentButton';
|
||||||
import { TankComponentButtonProps } from './TankComponentButton';
|
import { TankComponentButtonProps } from './TankComponentButton';
|
||||||
@@ -17,11 +19,13 @@ export function ConsumableButton({
|
|||||||
duration,
|
duration,
|
||||||
...props
|
...props
|
||||||
}: ConsumableButtonProps) {
|
}: ConsumableButtonProps) {
|
||||||
|
const awaitedConsumableDefinitions = use(consumableDefinitions);
|
||||||
const cooldownDelta = useDelta(cooldown ?? 0);
|
const cooldownDelta = useDelta(cooldown ?? 0);
|
||||||
const durationDelta = useDelta(duration ?? 0);
|
const durationDelta = useDelta(duration ?? 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GenericTankComponentButton
|
<GenericTankComponentButton
|
||||||
|
tooltip={awaitedConsumableDefinitions[consumable].name}
|
||||||
icon={asset(`icons/consumables/${consumable}.webp`)}
|
icon={asset(`icons/consumables/${consumable}.webp`)}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import { use } from 'react';
|
||||||
import { asset } from '../../core/blitzkit/asset';
|
import { asset } from '../../core/blitzkit/asset';
|
||||||
|
import { equipmentDefinitions } from '../../core/blitzkit/equipmentDefinitions';
|
||||||
import { GenericTankComponentButton } from './GenericTankComponentButton';
|
import { GenericTankComponentButton } from './GenericTankComponentButton';
|
||||||
import { TankComponentButtonProps } from './TankComponentButton';
|
import { TankComponentButtonProps } from './TankComponentButton';
|
||||||
|
|
||||||
@@ -7,8 +9,11 @@ interface EquipmentButtonProps extends TankComponentButtonProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function EquipmentButton({ equipment, ...props }: EquipmentButtonProps) {
|
export function EquipmentButton({ equipment, ...props }: EquipmentButtonProps) {
|
||||||
|
const awaitedEquipmentDefinitions = use(equipmentDefinitions);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GenericTankComponentButton
|
<GenericTankComponentButton
|
||||||
|
tooltip={awaitedEquipmentDefinitions.equipments[equipment].name}
|
||||||
icon={asset(`icons/equipment/${equipment}.webp`)}
|
icon={asset(`icons/equipment/${equipment}.webp`)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import { use } from 'react';
|
||||||
import { asset } from '../../core/blitzkit/asset';
|
import { asset } from '../../core/blitzkit/asset';
|
||||||
|
import { provisionDefinitions } from '../../core/blitzkit/provisionDefinitions';
|
||||||
import { GenericTankComponentButton } from './GenericTankComponentButton';
|
import { GenericTankComponentButton } from './GenericTankComponentButton';
|
||||||
import { TankComponentButtonProps } from './TankComponentButton';
|
import { TankComponentButtonProps } from './TankComponentButton';
|
||||||
|
|
||||||
@@ -7,8 +9,11 @@ interface ProvisionButtonProps extends TankComponentButtonProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function ProvisionButton({ provision, ...props }: ProvisionButtonProps) {
|
export function ProvisionButton({ provision, ...props }: ProvisionButtonProps) {
|
||||||
|
const awaitedProvisionDefinitions = use(provisionDefinitions);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GenericTankComponentButton
|
<GenericTankComponentButton
|
||||||
|
tooltip={awaitedProvisionDefinitions[provision].name}
|
||||||
icon={asset(`icons/provisions/${provision}.webp`)}
|
icon={asset(`icons/provisions/${provision}.webp`)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Button, Text } from '@radix-ui/themes';
|
import { Button, Text, Tooltip } from '@radix-ui/themes';
|
||||||
import { ComponentProps, ReactNode } from 'react';
|
import { ComponentProps, ReactNode } from 'react';
|
||||||
|
|
||||||
export interface TankComponentButtonProps
|
export interface TankComponentButtonProps
|
||||||
@@ -9,6 +9,7 @@ export interface TankComponentButtonProps
|
|||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
banner?: string;
|
banner?: string;
|
||||||
special?: boolean;
|
special?: boolean;
|
||||||
|
tooltip?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TankComponentButton({
|
export function TankComponentButton({
|
||||||
@@ -20,9 +21,10 @@ export function TankComponentButton({
|
|||||||
banner,
|
banner,
|
||||||
disabled,
|
disabled,
|
||||||
style,
|
style,
|
||||||
|
tooltip,
|
||||||
...props
|
...props
|
||||||
}: TankComponentButtonProps) {
|
}: TankComponentButtonProps) {
|
||||||
return (
|
const button = (
|
||||||
<Button
|
<Button
|
||||||
radius="medium"
|
radius="medium"
|
||||||
color={selected ? (special ? 'amber' : undefined) : 'gray'}
|
color={selected ? (special ? 'amber' : undefined) : 'gray'}
|
||||||
@@ -73,4 +75,7 @@ export function TankComponentButton({
|
|||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (tooltip) return <Tooltip content={tooltip}>{button}</Tooltip>;
|
||||||
|
return button;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user