Browse Source

支持设置建筑高度

master
Cmen 3 years ago
parent
commit
07103edf74
  1. 19
      src/editor/Property/FineInput.tsx
  2. 24
      src/editor/Property/index.tsx

19
src/editor/Property/FineInput.tsx

@ -0,0 +1,19 @@
import { Input } from "antd";
import { useState } from "react";
export type FineInputProps = {
value: string | number;
onChange: (value: string) => void;
};
export const FineInput = (props: FineInputProps) => {
const [value, setValue] = useState(props.value);
return (
<Input
value={value}
onChange={(e) => setValue(e.target.value)}
onBlur={(e) => props.onChange(e.target.value)}
/>
);
};

24
src/editor/Property/index.tsx

@ -3,9 +3,12 @@ import { Form, Input, Select } from "antd";
import { selectedIdsSelector, mapOptionsSelector, StoreAction } from "@store";
import { OverlayCategory, IOverlay } from "@map";
import "./index.less";
import { OverlayTypes } from "@types";
import { FineInput } from "./FineInput";
import "./index.less";
type CategoryItem = {
title: string;
value: OverlayCategory;
@ -40,12 +43,12 @@ const Property = () => {
<div className="property-area">
<Form size="small">
<Form.Item label="名称">
<Input
<FineInput
value={overlay.name}
onChange={(e) =>
onChange={(value) =>
updateOverlayProps({
id: overlay.id,
name: e.target.value,
name: value,
})
}
/>
@ -67,6 +70,19 @@ const Property = () => {
))}
</Select>
</Form.Item>
{overlay.category === OverlayCategory.Building ? (
<Form.Item label="高度">
<FineInput
value={overlay.height || 0}
onChange={(value) =>
updateOverlayProps({
id: overlay.id,
height: +value,
})
}
/>
</Form.Item>
) : null}
</Form>
</div>
);

Loading…
Cancel
Save