Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/components/TreeReactFlow/Flavor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const commonHoverClasses = "hover:ring hover:ring-4 hover:ring-offset-4";

export const flavorClasses = (flavor: NodeFlavor): string =>
classNames(
typeOrTermClasses(isTypeLevel(flavor)),
sortClasses(flavorSort(flavor)),
(() => {
switch (flavor) {
case "Hole":
Expand Down Expand Up @@ -209,7 +209,7 @@ export const flavorContentClasses = (
flavor: NodeFlavorTextBody | NodeFlavorPrimBody | NodeFlavorNoBody
): string =>
classNames(
typeOrTermContentClasses(isTypeLevel(flavor)),
sortContentClasses(flavorSort(flavor)),
(() => {
switch (flavor) {
case "Hole":
Expand Down Expand Up @@ -531,10 +531,10 @@ export const boxFlavorBackground = (flavor: NodeFlavorBoxBody): string => {
};

/** What sort of node does this flavor correspond to?
* Note that the backend could in principal tell us this independently of flavors,
* Note that the backend could in principle tell us this independently of flavors,
* since it comes down to whether the node ultimately comes from an `Expr`, `Type` or `Kind`.
*/
export const isTypeLevel = (flavor: NodeFlavor): "term" | "type" | "kind" => {
export const flavorSort = (flavor: NodeFlavor): "term" | "type" | "kind" => {
switch (flavor) {
case "Con":
case "Lam":
Expand Down Expand Up @@ -574,8 +574,8 @@ export const isTypeLevel = (flavor: NodeFlavor): "term" | "type" | "kind" => {
}
};

export const typeOrTermClasses = (x: "term" | "type" | "kind"): string => {
switch (x) {
export const sortClasses = (s: "term" | "type" | "kind"): string => {
switch (s) {
case "term":
return "rounded-3xl";
case "type":
Expand All @@ -585,10 +585,8 @@ export const typeOrTermClasses = (x: "term" | "type" | "kind"): string => {
}
};

export const typeOrTermContentClasses = (
x: "term" | "type" | "kind"
): string => {
switch (x) {
export const sortContentClasses = (s: "term" | "type" | "kind"): string => {
switch (s) {
case "term":
return "";
case "type":
Expand Down
10 changes: 5 additions & 5 deletions src/components/TreeReactFlow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import {
flavorLabel,
flavorLabelClasses,
noBodyFlavorContents,
typeOrTermClasses,
sortClasses,
} from "./Flavor";
import { ZoomBar, ZoomBarProps } from "./ZoomBar";
import { WasmLayoutType } from "@zxch3n/tidy/wasm_dist";
Expand Down Expand Up @@ -274,7 +274,7 @@ const nodeTypes = {
<div
title={data.def.baseName}
className={classNames(
typeOrTermClasses("term"),
sortClasses("term"),
"flex items-center justify-center",
"bg-white-primary",
"border-4 border-grey-secondary ring-grey-secondary",
Expand Down Expand Up @@ -304,7 +304,7 @@ const nodeTypes = {
<div
title={data.name.baseName}
className={classNames(
typeOrTermClasses("type"),
sortClasses("type"),
"flex items-center justify-center",
"bg-white-primary",
"border-4 border-grey-secondary ring-grey-secondary",
Expand Down Expand Up @@ -336,7 +336,7 @@ const nodeTypes = {
<div
title={data.name}
className={classNames(
typeOrTermClasses("type"),
sortClasses("type"),
"flex items-center justify-center",
"border-4",
data.selected && "ring-4 ring-offset-4",
Expand Down Expand Up @@ -373,7 +373,7 @@ const nodeTypes = {
<div
title={data.name.baseName}
className={classNames(
typeOrTermClasses("term"),
sortClasses("term"),
"flex items-center justify-center",
"border-4",
data.selected && "ring-4 ring-offset-4",
Expand Down