From d8a6895dc4347587244d1d220691431e1d7d638f Mon Sep 17 00:00:00 2001 From: ljungster Date: Tue, 26 Apr 2022 20:47:54 -0400 Subject: attempt with columnResizer. Not sure about how to handle resize events --- .../views/collections/CollectionNoteTakingView.tsx | 54 +++++++++++++++++----- .../CollectionNoteTakingViewDivider.tsx | 28 +++++++++++ .../CollectionNoteTakingViewFieldColumn.tsx | 8 ++-- 3 files changed, 74 insertions(+), 16 deletions(-) create mode 100644 src/client/views/collections/CollectionNoteTakingViewDivider.tsx (limited to 'src') diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx index 0cdf63939..5435650b4 100644 --- a/src/client/views/collections/CollectionNoteTakingView.tsx +++ b/src/client/views/collections/CollectionNoteTakingView.tsx @@ -302,9 +302,9 @@ export class CollectionNoteTakingView extends CollectionSubView { + //TODO: that isn't the proper width of columns const totalWidth = this.PanelWidth - const colWidth = totalWidth / n + const dividerWidth = 70 + const totaldividerWidth = (n - 1) * dividerWidth + const colWidth = (totalWidth - totaldividerWidth) / n const newColXCoords: number[] = [] let colStart = 0 for (let i = 0; i < n; i++) { newColXCoords.push(colStart) - colStart += colWidth + colStart += colWidth + dividerWidth } this.columnStartXCoords = newColXCoords console.log(newColXCoords) @@ -617,6 +620,29 @@ export class CollectionNoteTakingView extends CollectionSubView { + // const eles = HTMLElement[e.currentTarget.Elem] + // DragManager.StartDrag(e.target, {}, e.clientX, e.clientY) + // } + + @action + onDividerPointerOver = (e: React.PointerEvent, index: number) => { + if (DragManager.docsBeingDragged.length == 0) { + //convert client X to how we're doing stuff + const xPos = e.clientX + 2 * this.xMargin + // get difference (-25 is because that's the center of the divider) + const xDividerPos = this.columnStartXCoords[index + 1] - 25 + const diff = xDividerPos - xPos + // make a copy of the array + const colXCoords : number[] = [] + this.columnStartXCoords.forEach(val => colXCoords.push(val)) + colXCoords[index + 1] -= diff + this.columnStartXCoords = colXCoords + } + } + // @computed get renderedSections() { TraceMobx(); @@ -631,13 +657,19 @@ export class CollectionNoteTakingView extends CollectionSubView - // new div - // - // ) - // } + if (i < sections.length - 1) { + eles.push( +
this.onDividerPointerOver(e, i)} key={i} + style={{ + height: "100%", + width: 50, + padding: `0 10 10 0`, + margin: "auto", + backgroundColor: "black" + }} + /> + ) + } } return eles } diff --git a/src/client/views/collections/CollectionNoteTakingViewDivider.tsx b/src/client/views/collections/CollectionNoteTakingViewDivider.tsx new file mode 100644 index 000000000..11e1b5d62 --- /dev/null +++ b/src/client/views/collections/CollectionNoteTakingViewDivider.tsx @@ -0,0 +1,28 @@ +import { auto } from "async"; +import { action } from "mobx"; +import * as React from "react"; +import { DragManager } from "../../util/DragManager"; + +interface DividerProps { + index: number + columnStartXCoords: number[] + xMargin: number +} + +export default class Divider extends React.Component{ + + + + render() { + return ( +
+ ) + } +} \ No newline at end of file diff --git a/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx index b9bed7174..55cfa3348 100644 --- a/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx +++ b/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx @@ -59,7 +59,6 @@ interface CSVFieldColumnProps { export class CollectionNoteTakingViewFieldColumn extends React.Component { @observable private _background = "inherit"; - // It seems like this is being a little funky atm @computed get columnWidth() { // base cases if (!this.props.columnHeaders || !this.props.headingObject || this.props.columnHeaders.length == 1) { @@ -70,7 +69,8 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component headings.indexOf(i) === idx); return (