diff options
| author | kimdahey <claire_kim1@brown.edu> | 2019-11-23 14:30:06 -0500 |
|---|---|---|
| committer | kimdahey <claire_kim1@brown.edu> | 2019-11-23 14:30:06 -0500 |
| commit | 66424255021c7563df93aa9de9c1535bef1d9b50 (patch) | |
| tree | 1149b7d16ab9680660aee470a34f456dae960639 /src/client/views/collections/CollectionStaffView.tsx | |
| parent | b4a23b21bbe0a44df1328419c7d94b97a772e54f (diff) | |
| parent | 3b37cc31bb09b11238868c34a38a8e99f508479f (diff) | |
pulled from master
Diffstat (limited to 'src/client/views/collections/CollectionStaffView.tsx')
| -rw-r--r-- | src/client/views/collections/CollectionStaffView.tsx | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/client/views/collections/CollectionStaffView.tsx b/src/client/views/collections/CollectionStaffView.tsx new file mode 100644 index 000000000..40e860b12 --- /dev/null +++ b/src/client/views/collections/CollectionStaffView.tsx @@ -0,0 +1,59 @@ +import { CollectionSubView } from "./CollectionSubView"; +import { Transform } from "../../util/Transform"; +import React = require("react"); +import { computed, action, IReactionDisposer, reaction, runInAction, observable } from "mobx"; +import { Doc, HeightSym } from "../../../new_fields/Doc"; +import { NumCast } from "../../../new_fields/Types"; +import "./CollectionStaffView.scss"; +import { observer } from "mobx-react"; + +@observer +export class CollectionStaffView extends CollectionSubView(doc => doc) { + private getTransform = (): Transform => this.props.ScreenToLocalTransform().translate(0, -this._mainCont.current!.scrollTop); + private _mainCont = React.createRef<HTMLDivElement>(); + private _reactionDisposer: IReactionDisposer | undefined; + @observable private _staves = NumCast(this.props.Document.staves); + + componentDidMount = () => { + this._reactionDisposer = reaction( + () => NumCast(this.props.Document.staves), + (staves) => runInAction(() => this._staves = staves) + ); + + this.props.Document.staves = 5; + } + + @computed get fieldExtensionDoc() { + return Doc.fieldExtensionDoc(this.props.DataDoc || this.props.Document, this.props.fieldKey); + } + + @computed get addStaffButton() { + return <div onPointerDown={this.addStaff}>+</div>; + } + + @computed get staves() { + let staves = []; + for (let i = 0; i < this._staves; i++) { + let rows = []; + for (let j = 0; j < 5; j++) { + rows.push(<div key={`staff-${i}-${j}`} className="collectionStaffView-line"></div>); + } + staves.push(<div key={`staff-${i}`} className="collectionStaffView-staff"> + {rows} + </div>); + } + return staves; + } + + @action + addStaff = (e: React.PointerEvent) => { + this.props.Document.staves = this._staves + 1; + } + + render() { + return <div className="collectionStaffView" ref={this._mainCont}> + {this.staves} + {this.addStaffButton} + </div>; + } +}
\ No newline at end of file |
