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,62 @@
|
||||
import { orderBy } from "lodash";
|
||||
import React from "react";
|
||||
|
||||
import {
|
||||
BasicActionContract,
|
||||
CharacterTheme,
|
||||
} from "@dndbeyond/character-rules-engine/es";
|
||||
|
||||
interface Props {
|
||||
basicActions: Array<BasicActionContract>;
|
||||
onActionClick?: (basicAction: BasicActionContract) => void;
|
||||
theme: CharacterTheme;
|
||||
}
|
||||
export default class BasicActions extends React.PureComponent<Props> {
|
||||
handleActionClick = (
|
||||
basicAction: BasicActionContract,
|
||||
evt: React.MouseEvent
|
||||
): void => {
|
||||
const { onActionClick } = this.props;
|
||||
|
||||
if (onActionClick) {
|
||||
evt.stopPropagation();
|
||||
evt.nativeEvent.stopImmediatePropagation();
|
||||
onActionClick(basicAction);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { basicActions, theme } = this.props;
|
||||
|
||||
if (!basicActions.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let orderedActions = orderBy(
|
||||
basicActions,
|
||||
[(basicAction) => basicAction.name],
|
||||
["asc"]
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`ct-basic-actions ${
|
||||
theme.isDarkMode ? "ct-basic-actions--dark-mode" : ""
|
||||
}`}
|
||||
>
|
||||
{orderedActions.map((basicAction, idx) => (
|
||||
<span
|
||||
className="ct-basic-actions__action"
|
||||
key={basicAction.id}
|
||||
onClick={this.handleActionClick.bind(this, basicAction)}
|
||||
>
|
||||
{basicAction.name}
|
||||
{idx + 1 < orderedActions.length && (
|
||||
<span className="ct-basic-actions__action-sep">,</span>
|
||||
)}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import BasicActions from "./BasicActions";
|
||||
|
||||
export default BasicActions;
|
||||
export { BasicActions };
|
||||
Reference in New Issue
Block a user