Repository navigation
Expand file tree
/
Copy pathOps.tsx
More file actions
37 lines (35 loc) · 1.5 KB
/
Copy pathOps.tsx
File metadata and controls
37 lines (35 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from "react";
import { Pre, Tooltip } from "@blueprintjs/core";
import { HasId } from "./Data";
import { backgroundColor } from "./common";
export type Op =
// TODO associated BreakTag id if conditional
{ type: 'break', conditional: boolean, fillMode: 'UNIFIED' | 'INDEPENDENT' | 'FORCED', toString: string } & HasId
| { type: 'token', beforeText: string, afterText: string, text: string } & HasId
| { type: 'openOp', toString: string } & HasId
| { type: 'closeOp' }
export const Ops: React.FC<{ ops: Array<Op> }> = ({ops}) => {
const renderOps = ops.map(op => {
switch (op.type) {
case "break":
const classes = ["break", `FillMode-${op.fillMode}`];
if (op.conditional) {
classes.push('conditional')
}
return <Tooltip content={op.toString}><span className={classes.join(" ")}/></Tooltip>;
case "token":
return <span className={"token"} style={backgroundColor(op)}>
{op.beforeText}
<span className={"tokenBody"}>{op.text}</span>
{op.afterText}
</span>;
case "openOp":
return <Tooltip content={op.toString}>
<span className={"open-op"} key={op.id}/>
</Tooltip>;
case "closeOp":
return <span className={"close-op"}/>;
}
});
return <Pre className={"Ops"}>{renderOps}</Pre>;
};