Skip to content

Commit

Permalink
Add info panel
Browse files Browse the repository at this point in the history
Fixes #105
  • Loading branch information
haydn committed Apr 24, 2020
1 parent 1f355aa commit 97d4bad
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { set, or, not, and } from "set-fns";
import useStateSnapshots from "use-state-snapshots";
import { Draggable, Droppable, DragDropContext } from "react-beautiful-dnd";

import InfoPanel from "./components/InfoPanel";

import useCanvasConnection from "./editor/useCanvasConnection";
import exampleDoc from "./editor/exampleDoc";
import useKeys from "./useKeys";
Expand Down Expand Up @@ -937,6 +939,19 @@ const Editor = ({ config }) => {
/>
) : null}
</svg>
<div
style={{
pointerEvents: "none",
userSelect: "none",
position: "absolute",
bottom: 0,
left: 0,
width: "100%",
background: "#eee9"
}}
>
<InfoPanel mouse={mouse} viewport={viewport} keys={keys} />
</div>
</div>
<div style={{ background: "#eee" }}>
{selection.size === 0 ? (
Expand Down
38 changes: 38 additions & 0 deletions src/components/InfoPanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from "react";

const InfoPanel = ({ mouse, viewport, keys }) => (
<dl className="InfoPanel">
<style jsx>{`
.InfoPanel {
font-family: monospace;
padding: 0 0.8em;
}
* + dt {
margin-left: 0.8em;
}
* + dd {
margin-left: 0.4em;
}
dt,
dd {
display: inline;
}
dt {
font-weight: bold;
text-transform: uppercase;
}
`}</style>
<dt>mouse</dt>
<dd>{(mouse.x + "," + mouse.y).padEnd(10, " ")}</dd>
<dt>zoom</dt>
<dd>{(Math.round(viewport.scale * 100) + "%").padEnd(10, " ")}</dd>
<dt>viewport</dt>
<dd>{(viewport.x + "," + viewport.y).padEnd(10, " ")}</dd>
<dt>mode</dt>
<dd>{mouse.status.padEnd(10, " ")}</dd>
<dt>keys</dt>
<dd>{keys.size === 0 ? "-" : [...keys].join(", ")}</dd>
</dl>
);

export default InfoPanel;

0 comments on commit 97d4bad

Please sign in to comment.