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:
+77
@@ -0,0 +1,77 @@
|
||||
import React from "react";
|
||||
|
||||
import {
|
||||
Collapsible,
|
||||
CollapsibleHeaderContent,
|
||||
} from "@dndbeyond/character-components/es";
|
||||
import {
|
||||
FormatUtils,
|
||||
SpellSlotContract,
|
||||
} from "@dndbeyond/character-rules-engine/es";
|
||||
|
||||
import SpellSlotManagerLevel from "../SpellSlotManagerLevel";
|
||||
|
||||
interface Props {
|
||||
heading: string;
|
||||
slots: Array<SpellSlotContract>;
|
||||
onSlotSet?: (level: number, used: number) => void;
|
||||
isReadonly: boolean;
|
||||
}
|
||||
export default class SpellSlotManagerGroup extends React.PureComponent<Props> {
|
||||
renderCallout = (): React.ReactNode => {
|
||||
const { slots } = this.props;
|
||||
|
||||
return (
|
||||
<div className="ct-spell-slot-manager__group-summary">
|
||||
{slots.map((levelSlots) => (
|
||||
<div
|
||||
className="ct-spell-slot-manager__group-level"
|
||||
key={levelSlots.level}
|
||||
>
|
||||
<div className="ct-spell-slot-manager__group-level-name">
|
||||
{FormatUtils.ordinalize(levelSlots.level)}
|
||||
</div>
|
||||
<div className="ct-spell-slot-manager__group-level-available">
|
||||
{levelSlots.available === 0 ? "-" : levelSlots.available}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { slots, onSlotSet, heading, isReadonly } = this.props;
|
||||
|
||||
let headerNode: React.ReactNode = (
|
||||
<CollapsibleHeaderContent
|
||||
heading={heading}
|
||||
callout={this.renderCallout()}
|
||||
/>
|
||||
);
|
||||
|
||||
if (!slots.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Collapsible header={headerNode} className="ct-spell-slot-manager__group">
|
||||
<div className="ct-spell-slot-manager__levels">
|
||||
{slots.map((levelSlots) => {
|
||||
if (levelSlots.available === 0) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<SpellSlotManagerLevel
|
||||
key={levelSlots.level}
|
||||
{...levelSlots}
|
||||
onSlotSet={onSlotSet}
|
||||
isInteractive={!isReadonly}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Collapsible>
|
||||
);
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import SpellSlotManagerGroup from "./SpellSlotManagerGroup";
|
||||
|
||||
export default SpellSlotManagerGroup;
|
||||
export { SpellSlotManagerGroup };
|
||||
Reference in New Issue
Block a user