Skip to content

Commit 0cb1520

Browse files
committed
ENH: Tweak equation editor spacing
1 parent 10ee957 commit 0cb1520

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

packages/frontend/src/model/equation_cell_editor.module.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,32 @@
9494
display: flex;
9595
flex-direction: row;
9696
flex-wrap: wrap;
97-
align-items: center;
9897
justify-content: center;
9998
gap: 1ex;
10099
min-width: 0;
100+
min-height: 60px;
101101
box-sizing: border-box;
102102
/* Vertical room for morphism names above arrows; see arrow_styles.module.css. */
103103
--formal-judgment-font-size: 0.9em;
104104
line-height: 1.2;
105105
}
106106

107+
/* Per-side alignment of the diagrammatic path so the two sides of the
108+
equation hug the central `=` sign: LHS sits at the bottom of its row
109+
(against the equals sign above? — actually the equals is between
110+
them, so "hug" means LHS bottoms toward the equals, RHS tops toward
111+
the equals). Applied to the inner `.path` since that is the flex
112+
container holding the path items. */
113+
.lhs .path {
114+
align-items: center;
115+
align-content: center;
116+
}
117+
118+
.rhs .path {
119+
align-items: flex-start;
120+
align-content: flex-start;
121+
}
122+
107123
/* A single (arrow + cod object) segment, kept together as one wrappable unit
108124
so the arrow never lands on a different line than its codomain. */
109125
.segment {

packages/frontend/src/model/equation_cell_editor.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ export default function EquationCellEditor(props: EquationEditorProps) {
196196
mor={props.equation.lhs}
197197
setMor={setLhs}
198198
isActive={props.isActive && activeInput() === "lhs"}
199+
side="lhs"
199200
exitBackward={() => setActiveInput("name")}
200201
exitForward={() => setActiveInput("rhs")}
201202
exitUp={() => setActiveInput("name")}
@@ -216,6 +217,7 @@ export default function EquationCellEditor(props: EquationEditorProps) {
216217
mor={props.equation.rhs}
217218
setMor={setRhs}
218219
isActive={props.isActive && activeInput() === "rhs"}
220+
side="rhs"
219221
exitBackward={() => setActiveInput("lhs")}
220222
exitForward={props.actions.activateBelow}
221223
exitUp={() => setActiveInput("lhs")}
@@ -240,6 +242,10 @@ type PathPickerProps = {
240242
mor: Mor | null;
241243
setMor: (mor: Mor | null) => void;
242244
isActive: boolean;
245+
/** Which side of the equation this picker represents. Drives the
246+
per-side alignment of the diagrammatic display (LHS bottom-aligned,
247+
RHS top-aligned) so the two sides hug the centre `=` sign. */
248+
side: "lhs" | "rhs";
243249
exitBackward?: () => void;
244250
exitForward?: () => void;
245251
exitUp?: () => void;
@@ -334,7 +340,7 @@ function PathPicker(props: PathPickerProps) {
334340

335341
return (
336342
<div
337-
class={styles.pathPicker}
343+
class={`${styles.pathPicker} ${props.side === "lhs" ? styles.lhs : styles.rhs}`}
338344
onMouseDown={(evt) => {
339345
// Activate the picker when clicking anywhere inside the
340346
// border, but only when not already in editing mode (so

0 commit comments

Comments
 (0)