Skip to content

Commit

Permalink
make labels more explicit, and label styles per-node
Browse files Browse the repository at this point in the history
u
we finally see "match" instead of "m" in expert mode

can we remove "always show labels"?

Signed-off-by: George Thomas <[email protected]>
  • Loading branch information
georgefst authored and dhess committed Apr 9, 2024
1 parent f4a3ceb commit d1d9593
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 36 deletions.
11 changes: 0 additions & 11 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const App = (): JSX.Element => {
const devToolsMaxHeight = 500;
const [devOpts, setDevOpts] = useState<DevOptions>({
showIDs: false,
inlineLabels: false,
alwaysShowLabels: true,
});

Expand Down Expand Up @@ -134,16 +133,6 @@ const DevMenu = (p: { opts: DevOptions; set: (opts: DevOptions) => void }) => (
/>
<label htmlFor="alwaysShowLabels">always show labels</label>
</div>
<div>
<input
type="checkbox"
id="inlineLabels"
checked={p.opts.inlineLabels}
onChange={(e) => p.set({ ...p.opts, inlineLabels: e.target.checked })}
className="mr-1"
/>
<label htmlFor="inlineLabels">inline labels</label>
</div>
</div>
);

Expand Down
6 changes: 1 addition & 5 deletions src/components/Edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import {
} from "@/primer-api";
import {
defaultTreeReactFlowProps,
inlineTreeReactFlowProps,
ScrollToDef,
} from "@/components/TreeReactFlow";
import { Mode } from "../Toolbar";
Expand All @@ -58,7 +57,6 @@ const initialLevel: Level = "Expert";

export type DevOptions = {
showIDs: boolean;
inlineLabels: boolean;
alwaysShowLabels: boolean;
};

Expand Down Expand Up @@ -287,9 +285,7 @@ const AppNoError = ({
.sort((a, b) => cmpName(a.name, b.name))
.map((d) => d.name.baseName);

const treeProps = p.devOpts.inlineLabels
? inlineTreeReactFlowProps
: defaultTreeReactFlowProps;
const treeProps = defaultTreeReactFlowProps;

return (
<div className="grid h-[100dvh] grid-cols-[auto_20rem]">
Expand Down
18 changes: 0 additions & 18 deletions src/components/TreeReactFlow/TreeReactFlow.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ComponentStory, ComponentMeta } from "@storybook/react";
import {
defaultTreeReactFlowProps,
inlineTreeReactFlowProps,
TreeReactFlow,
TreeReactFlowProps,
} from "./";
Expand Down Expand Up @@ -361,20 +360,3 @@ export const OddAndEvenMiscStyles: ComponentStory<typeof TreeReactFlow> = (
contents: { def: def5.name, node: { nodeType: "BodyNode", meta: 5 } },
},
});
export const OddAndEvenInline: ComponentStory<typeof TreeReactFlow> = (
args: TreeReactFlowProps
) =>
treeSized({
...inlineTreeReactFlowProps,
...args,
defs: oddEvenTrees.map(([baseName, term]) => ({
name: { qualifiedModule: [], baseName },
term,
type_: emptyTypeTree(baseName),
})),
typeDefs: [],
selection: {
tag: "SelectionDef",
contents: { def: def5.name, node: { nodeType: "BodyNode", meta: 5 } },
},
});
2 changes: 0 additions & 2 deletions src/components/TreeReactFlow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ type ReactFlowParams = {
};

/** These properties are needed to construct nodes, but are invariant across all nodes. */
export type NodeStyle = "corner" | "inline";
type NodeParams = {
style: NodeStyle;
nodeWidth: number;
nodeHeight: number;
boxPadding: number;
Expand Down

0 comments on commit d1d9593

Please sign in to comment.