Grabbed dndbeyond's source code
``` ~/go/bin/sourcemapper -output ddb -jsurl https://media.dndbeyond.com/character-app/static/js/main.90aa78c5.js ```
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { Tooltip } from "@dndbeyond/character-common-components/es";
|
||||
import {
|
||||
CharacterTheme,
|
||||
Creature,
|
||||
CreatureUtils,
|
||||
} from "@dndbeyond/character-rules-engine/es";
|
||||
|
||||
interface Props {
|
||||
creature: Creature;
|
||||
onClick?: (creature: Creature) => void;
|
||||
className: string;
|
||||
theme?: CharacterTheme;
|
||||
}
|
||||
export default class CreatureName extends React.PureComponent<Props> {
|
||||
static defaultProps = {
|
||||
className: "",
|
||||
};
|
||||
|
||||
handleClick = (evt: React.MouseEvent): void => {
|
||||
const { onClick, creature } = this.props;
|
||||
|
||||
if (onClick) {
|
||||
evt.stopPropagation();
|
||||
evt.nativeEvent.stopImmediatePropagation();
|
||||
|
||||
onClick(creature);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { creature, className, theme } = this.props;
|
||||
|
||||
let isCustomized = CreatureUtils.isCustomized(creature);
|
||||
let classNames: Array<string> = [className, "ddbc-creature-name"];
|
||||
|
||||
return (
|
||||
<span className={classNames.join(" ")} onClick={this.handleClick}>
|
||||
{CreatureUtils.getName(creature)}
|
||||
{isCustomized && (
|
||||
<Tooltip
|
||||
title="Creature is Customized"
|
||||
className="ddbc-creature-name__customized"
|
||||
isDarkMode={theme?.isDarkMode}
|
||||
>
|
||||
*
|
||||
</Tooltip>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user