diff options
Diffstat (limited to 'src/client/views/PropertiesView.tsx')
-rw-r--r-- | src/client/views/PropertiesView.tsx | 90 |
1 files changed, 62 insertions, 28 deletions
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx index a61a14536..ae6f6afe2 100644 --- a/src/client/views/PropertiesView.tsx +++ b/src/client/views/PropertiesView.tsx @@ -7,7 +7,7 @@ import { concat, intersection } from 'lodash'; import { Lambda, action, computed, observable } from 'mobx'; import { observer } from 'mobx-react'; import { ColorState, SketchPicker } from 'react-color'; -import { emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue, setupMoveUpEvents } from '../../Utils'; +import { Utils, emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue, setupMoveUpEvents } from '../../Utils'; import { Doc, Field, FieldResult, HierarchyMapping, NumListCast, Opt, ReverseHierarchyMap, StrListCast } from '../../fields/Doc'; import { AclAdmin, DocAcl, DocData, Height, Width } from '../../fields/DocSymbols'; import { Id } from '../../fields/FieldSymbols'; @@ -32,7 +32,7 @@ import { PropertiesDocBacklinksSelector } from './PropertiesDocBacklinksSelector import { PropertiesDocContextSelector } from './PropertiesDocContextSelector'; import './PropertiesView.scss'; import { DefaultStyleProvider } from './StyleProvider'; -import { Button, Colors, EditableText, NumberDropdown, Size, Slider, Type } from 'browndash-components'; +import { Button, Colors, EditableText, NumberDropdown, Size, Slider, Type, NumberInput } from 'browndash-components'; import { PropertiesSection } from './PropertiesSection'; import { DocumentView, OpenWhere, StyleProviderFunc } from './nodes/DocumentView'; import { PresBox, PresEffect, PresEffectDirection } from './nodes/trails'; @@ -548,11 +548,12 @@ export class PropertiesView extends React.Component<PropertiesViewProps> { } @computed get type() { - const type = StrCast(this.selectedDoc?.type); + const type = Utils.cleanDocumentType(StrCast(this.selectedDoc?.type) as DocumentType); return ( <Button formLabel={"Type"} text={type} + type={Type.SEC} color={this.color} align='flex-start' fillWidth @@ -992,35 +993,68 @@ export class PropertiesView extends React.Component<PropertiesViewProps> { ); } + getNumber = (label: string, unit: string, min: number, max: number, number: number, setNumber: any) => { + return <div> + <NumberInput + formLabel={label} + formLabelPlacement={'left'} + type={Type.SEC} + unit={unit} + fillWidth + color={this.color} + number={number} + setNumber={setNumber} + /> + <Slider + multithumb={false} + color={this.color} + size={Size.XSMALL} + min={min} + max={max} + unit={unit} + number={number} + setNumber={setNumber} + fillWidth + /> + </div> + } + @computed get transformEditor() { return ( <div className="transform-editor"> {this.isInk ? this.controlPointsButton : null} - <Slider - formLabel={'Height'} - multithumb={false} - color={this.color} - size={Size.XSMALL} - min={0} - max={1000} - number={Number(this.shapeHgt)} - setNumber={undoable((val: string) => !isNaN(Number(val)) && (this.shapeHgt = val), 'set height')} - fillWidth - /> - <Slider - formLabel={'Width'} - multithumb={false} - color={this.color} - size={Size.XSMALL} - min={0} - max={1000} - number={Number(this.shapeWid)} - setNumber={undoable((val: string) => !isNaN(Number(val)) && (this.shapeWid = val), 'set width')} - fillWidth - /> - - {this.hgtInput} - {this.XpsInput} + {this.getNumber( + "Height", + " px", + 0, + 1000, + Number(this.shapeHgt), + undoable((val: string) => !isNaN(Number(val)) && (this.shapeHgt = val), 'set height') + )} + {this.getNumber( + "Width", + " px", + 0, + 1000, + Number(this.shapeWid), + undoable((val: string) => !isNaN(Number(val)) && (this.shapeWid = val), 'set width') + )} + {this.getNumber( + "X Coordinate", + " px", + -2000, + 2000, + Number(this.shapeXps), + undoable((val: string) => !isNaN(Number(val)) && (this.shapeXps = val), 'set x coord') + )} + {this.getNumber( + "Y Coordinate", + " px", + -2000, + 2000, + Number(this.shapeYps), + undoable((val: string) => !isNaN(Number(val)) && (this.shapeYps = val), 'set y coord') + )} </div> ); } |