import * as React from "react"; import { Tooltip } from "@dndbeyond/character-common-components/es"; import { CharacterTheme, DiceContract, DiceUtils, FormatUtils, } from "@dndbeyond/character-rules-engine/es"; import { DamageTypeIcon } from "../Icons"; import { DamageTypePropType } from "../Icons/IconConstants"; export interface Props { className: string; damage: DiceContract | string | number | null; type: string | null; info?: string; isVersatile: boolean; showInfoTooltip: boolean; showInfoInline: boolean; theme?: CharacterTheme; } export default class Damage extends React.PureComponent { static defaultProps = { className: "", type: null, isVersatile: false, showInfoTooltip: true, showInfoInline: false, }; render() { const { className, damage, type, isVersatile, info, showInfoInline, showInfoTooltip, theme, } = this.props; let displayDamage: React.ReactNode; if (damage !== null) { if (typeof damage === "string" || typeof damage === "number") { displayDamage = damage; } else { displayDamage = DiceUtils.renderDice(damage); } } let classNames: Array = [className, "ddbc-damage"]; if (isVersatile) { classNames.push("ddbc-damage--versatile"); } if (theme?.isDarkMode) { classNames.push("ddbc-damage--dark-mode"); } let tooltipContent: string | null = null; if (showInfoTooltip && (info || type)) { tooltipContent = info ? info : type; } return ( {displayDamage} {!isVersatile && !!type && ( )} {showInfoInline && {info}} ); } }