-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made data sheet the dominant object on the page
- Loading branch information
1 parent
32f142b
commit 29a90c2
Showing
13 changed files
with
285 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./panels"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.width-adjustable-panel | ||
transition: max-width 0.1s ease-in-out | ||
height: 100% | ||
display: flex | ||
flex-direction: row | ||
position: relative | ||
|
||
.width-adjustable-panel-content | ||
overflow: scroll | ||
height: 100% | ||
flex-grow: 1 | ||
padding: 1em | ||
|
||
.width-adjuster | ||
cursor: col-resize | ||
width: 6px | ||
height: 100% | ||
// Not sure why this defaults to shrinking | ||
flex-shrink: 0 | ||
background-color: #efefef | ||
&:hover | ||
background-color: #ddd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { ReactNode, useEffect } from "react"; | ||
import { useRef } from "react"; | ||
import { useStoredState } from "@macrostrat/ui-components"; | ||
import hyper from "@macrostrat/hyper"; | ||
import styles from "./main.module.sass"; | ||
import { on } from "events"; | ||
export const h = hyper.styled(styles); | ||
|
||
export enum AdjustSide { | ||
LEFT = "left", | ||
RIGHT = "right", | ||
} | ||
|
||
export function WidthAdjustablePanel({ | ||
children, | ||
adjustSide = AdjustSide.RIGHT, | ||
expand, | ||
className, | ||
storageID = null, | ||
}: { | ||
children: ReactNode; | ||
adjustSide?: AdjustSide; | ||
expand?: boolean; | ||
className?: string; | ||
storageID?: string; | ||
}) { | ||
const [maxWidth, setMaxWidth] = useStoredState( | ||
storageID, | ||
0, | ||
(v) => typeof v === "number" | ||
); | ||
|
||
useEffect(() => { | ||
if (typeof window === "undefined") return; | ||
setMaxWidth(window.innerWidth / 2); | ||
}, []); | ||
|
||
if (expand) { | ||
return h("div.width-adjustable-panel", { className }, [ | ||
h("div.width-adjustable-panel-content", {}, children), | ||
]); | ||
} | ||
return h( | ||
"div.width-adjustable-panel", | ||
{ style: { maxWidth: maxWidth + "px" }, className }, | ||
[ | ||
h.if(adjustSide == AdjustSide.LEFT)(WidthAdjuster, { | ||
onAdjust: (dx) => { | ||
const newMaxWidth = maxWidth - dx; | ||
setMaxWidth(newMaxWidth); | ||
}, | ||
}), | ||
h("div.width-adjustable-panel-content", {}, children), | ||
h.if(adjustSide == AdjustSide.RIGHT)(WidthAdjuster, { | ||
onAdjust: (dx) => { | ||
const newMaxWidth = maxWidth + dx; | ||
setMaxWidth(newMaxWidth); | ||
}, | ||
}), | ||
] | ||
); | ||
} | ||
|
||
function WidthAdjuster({ onAdjust }: { onAdjust: (dx: number) => void }) { | ||
const startPosition = useRef(0); | ||
return h( | ||
"div.width-adjuster", | ||
{ | ||
onDragStart: (e) => { | ||
startPosition.current = e.clientX; | ||
}, | ||
onDragEnd: (e) => { | ||
const dx = e.clientX - startPosition.current; | ||
onAdjust(dx); | ||
}, | ||
draggable: true, | ||
}, | ||
[] | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.