Factor out AttachmentIndicesWidget.
rodzic
b444787c04
commit
31bc73a7b1
|
@ -265,6 +265,29 @@ export const CREATURE_DESIGN_DEFAULTS: CreatureDesign = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const AttachmentIndicesWidget: React.FC<{
|
||||||
|
type: AttachmentPointType;
|
||||||
|
creature: CreatureSymbol;
|
||||||
|
attachment: AttachedCreatureSymbol;
|
||||||
|
onChange: (attachments: AttachedCreatureSymbol) => void;
|
||||||
|
idPrefix: string;
|
||||||
|
}> = (props) => {
|
||||||
|
const id = `${props.idPrefix}_indices`;
|
||||||
|
const typeCap = capitalize(props.type);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex-widget">
|
||||||
|
<label htmlFor={id}>{typeCap} attachment point indices:</label>
|
||||||
|
<input
|
||||||
|
id={id}
|
||||||
|
type="text"
|
||||||
|
disabled
|
||||||
|
value={props.attachment.indices.join(", ")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const CreaturePartEditor: React.FC<{
|
const CreaturePartEditor: React.FC<{
|
||||||
creature: CreatureSymbol;
|
creature: CreatureSymbol;
|
||||||
onChange: (symbol: CreatureSymbol) => void;
|
onChange: (symbol: CreatureSymbol) => void;
|
||||||
|
@ -351,6 +374,7 @@ const CreaturePartEditor: React.FC<{
|
||||||
</div>
|
</div>
|
||||||
{creatureAttachments.map((attach, i) => {
|
{creatureAttachments.map((attach, i) => {
|
||||||
const atIdPrefix = `${idPrefix}_${type}_${i}_`;
|
const atIdPrefix = `${idPrefix}_${type}_${i}_`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={i}
|
key={i}
|
||||||
|
@ -359,17 +383,15 @@ const CreaturePartEditor: React.FC<{
|
||||||
paddingLeft: "4px",
|
paddingLeft: "4px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="flex-widget">
|
<AttachmentIndicesWidget
|
||||||
<label htmlFor={`${atIdPrefix}_indices`}>
|
type={type}
|
||||||
{typeCap} attachment point indices:
|
creature={creature}
|
||||||
</label>
|
attachment={attach}
|
||||||
<input
|
idPrefix={atIdPrefix}
|
||||||
id={`${atIdPrefix}_indices`}
|
onChange={(attachments) =>
|
||||||
type="text"
|
onChange({ ...creature, ...attachments })
|
||||||
disabled
|
}
|
||||||
value={attach.indices.join(", ")}
|
/>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="thingy">
|
<div className="thingy">
|
||||||
<button onClick={deleteAttachment.bind(null, attach)}>
|
<button onClick={deleteAttachment.bind(null, attach)}>
|
||||||
Remove this attachment
|
Remove this attachment
|
||||||
|
|
Ładowanie…
Reference in New Issue