aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/PropertiesView.tsx
diff options
context:
space:
mode:
authorGeireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>2023-07-18 01:00:46 -0400
committerGeireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>2023-07-18 01:00:46 -0400
commit75a7c44f9615c4ac024403011a968f8b3038c500 (patch)
treedc38e44423d1080b7681f46741d27cc6e02bbc3c /src/client/views/PropertiesView.tsx
parent71fb3eca3d5ebb90d2ab2cfe09a864a4fab9d625 (diff)
added number inputs to right hand side
Diffstat (limited to 'src/client/views/PropertiesView.tsx')
-rw-r--r--src/client/views/PropertiesView.tsx90
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>
);
}