Skip to content
Draft
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
16 changes: 8 additions & 8 deletions packages/anvil-react/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@
min-width: 0;
}

/* Separates host content at the start of the toolbar, such as a brand, from the title. */
.anvil-toolbar-start {
column-gap: 12px;
}

.anvil-toolbar-end {
margin-left: auto;
}
Expand All @@ -216,14 +221,6 @@
background: var(--anvil-border);
}

.anvil-brand {
display: flex;
align-items: center;
gap: 8px;
margin-right: 12px;
font-weight: 650;
}

.anvil-doc-title {
max-width: 260px;
overflow: hidden;
Expand Down Expand Up @@ -1248,6 +1245,9 @@ textarea.anvil-input {
}

.anvil-issue-where {
display: flex;
flex-wrap: wrap;
gap: 2px 8px;
font-size: 12px;
color: var(--anvil-muted);
overflow-wrap: anywhere;
Expand Down
8 changes: 4 additions & 4 deletions packages/anvil-react/src/ui/AnvilEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ const Toolbar = ({

return (
<header className="anvil-toolbar">
<div className="anvil-toolbar-group">
<div className="anvil-toolbar-group anvil-toolbar-start">
{start}
<span className="anvil-doc-title" title={title}>
{title === undefined || title === "" ? "Untitled" : title}
Expand Down Expand Up @@ -421,7 +421,7 @@ const Toolbar = ({
`${counts.warning} warning${counts.warning === 1 ? "" : "s"}`,
]
.filter(Boolean)
.join(" · ")
.join(", ")
}
</button>
</div>
Expand Down Expand Up @@ -598,10 +598,10 @@ const HistoryButton = ({
</ol>
<div className="anvil-history-hint">
{steps.length > HISTORY_SHOWN ?
`${steps.length - HISTORY_SHOWN} older not shown · `
`${steps.length - HISTORY_SHOWN} older steps not shown. `
: ""}
Click a step to {undo ? "undo" : "redo"} it and everything above
it
it.
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/anvil-react/src/ui/Outline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,8 @@ export const Outline = () => {
)}
</div>
<div className="anvil-outline-help">
↑↓ select · ⌥↑↓ move · ⌥←→ nest · ⌫ delete · drag to reorder ·
right-click for more
Use ↑↓ to select, ⌥↑↓ to move, ⌥←→ to nest, and ⌫ to delete. Drag to
reorder and right-click for more.
</div>
{menu && (
<ContextMenu
Expand Down
5 changes: 3 additions & 2 deletions packages/anvil-react/src/ui/SidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ const JsonPanel = () => {
</>
: <>
<span className="anvil-muted">
{(json.length / 1024).toFixed(1)} KB · edit to change
{(json.length / 1024).toFixed(1)} KB. Edit the JSON to change the
questionnaire.
</span>
<Button
size="sm"
Expand Down Expand Up @@ -358,7 +359,7 @@ const IssuesPanel = () => {
<span className="anvil-issue-body">
<span>{issue.message}</span>
<span className="anvil-issue-where">
<code>{where}</code> · {issue.code}
<code>{where}</code> <span>{issue.code}</span>
</span>
</span>
</button>
Expand Down
7 changes: 7 additions & 0 deletions packages/anvil-react/test/editorPanels.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,13 @@ describe("issues panel", () => {
).toContain("Questionnaire.item[1].text");
fireEvent.click(panel.getByRole("button", { name: /Check Mood/ }));
expect(store.getState().selection).toBe(uid(0));
// The location and the code stay separate words in the text.
expect(
query(
panel.getByRole("button", { name: /Check Mood/ }),
".anvil-issue-where",
).textContent,
).toBe("mood test.item");

act(() =>
store.updateRoot((d) => {
Expand Down
8 changes: 4 additions & 4 deletions packages/anvil-react/test/editorShell.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ describe("toolbar", () => {
},
);
const status = () => getByRole("button", { name: /Valid|error|warning/ });
expect(status().textContent).toBe("1 error · 1 warning");
expect(status().textContent).toBe("1 error, 1 warning");
expect(status().classList).toContain("anvil-sev-error");
const setName = (name: string) =>
act(() =>
Expand All @@ -253,7 +253,7 @@ describe("toolbar", () => {
}),
);
setName("e2w1");
expect(status().textContent).toBe("2 errors · 2 warnings");
expect(status().textContent).toBe("2 errors, 2 warnings");
setName("e0w0");
expect(status().textContent).toBe("1 warning");
expect(status().classList).toContain("anvil-sev-warning");
Expand Down Expand Up @@ -287,7 +287,7 @@ describe("history menus", () => {
const menu = utils.getByRole("menu", { name: "Undo history" });
const steps = within(menu).getAllByRole("menuitem");
expect(steps).toHaveLength(15);
expect(menu.textContent).toContain("2 older not shown");
expect(menu.textContent).toContain("2 older steps not shown");
expect(menu.textContent).toContain(
"Click a step to undo it and everything above",
);
Expand Down Expand Up @@ -326,7 +326,7 @@ describe("history menus", () => {
expect(redoMenu.textContent).toContain(
"Click a step to redo it and everything above",
);
expect(redoMenu.textContent).not.toContain("older not shown");
expect(redoMenu.textContent).not.toContain("not shown");
fireEvent.click(at(within(redoMenu).getAllByRole("menuitem"), 0));
expect(utils.doc().title).toBe("T16");
fireEvent.mouseLeave(redo);
Expand Down
8 changes: 7 additions & 1 deletion packages/anvil-react/test/host.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,13 @@ describe("toolbar", () => {
}}
/>,
);
expect(screen.getByText("Brand")).toBeTruthy();
// The brand and the title share the start group, which spaces them apart.
expect(screen.getByText("Brand").parentElement).toBe(
document.querySelector(".anvil-doc-title")?.parentElement,
);
expect(screen.getByText("Brand").parentElement?.classList).toContain(
"anvil-toolbar-start",
);
expect(screen.getByRole("button", { name: "Save" })).toBeTruthy();
});
});
Expand Down
8 changes: 6 additions & 2 deletions packages/anvil/src/FileActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,13 @@ const ChooseDialog = ({
>
<strong>{q.title ?? q.name ?? `Questionnaire ${i + 1}`}</strong>
<span className="anvil-muted">
{[q.url, q.version, `${q.item?.length ?? 0} items`]
{[
q.url,
q.version && `version ${q.version}`,
`${q.item?.length ?? 0} item${q.item?.length === 1 ? "" : "s"}`,
]
.filter(Boolean)
.join(" · ")}
.join(", ")}
</span>
</button>
</li>
Expand Down
12 changes: 9 additions & 3 deletions packages/anvil/test/fileActions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,13 @@ describe("importing", () => {
id: "ided",
},
},
{ resource: { resourceType: "Questionnaire", status: "draft" } },
{
resource: {
resourceType: "Questionnaire",
status: "draft",
item: [{ linkId: "only", type: "string" }],
},
},
],
};

Expand Down Expand Up @@ -341,9 +347,9 @@ describe("importing", () => {
};
expect(await choices()).toEqual([
"Titled2 items",
"namedhttp://example.org/q · 2 · 0 items",
"namedhttp://example.org/q, version 2, 0 items",
"Questionnaire 30 items",
"Questionnaire 40 items",
"Questionnaire 41 item",
]);
expect(document.querySelector("dialog")).toBeNull();
// Closing the choice keeps the current questionnaire.
Expand Down
Loading