Skip to content

Build your personal knowledge base with Trilium Notes

client/options: fix line lengths

Adorian Dorancb438e715276
diff --git a/apps/client/src/widgets/dialogs/OptionsDialog.tsx b/apps/client/src/widgets/dialogs/OptionsDialog.tsx
index 78501d7630..06873706f0 100644
--- a/apps/client/src/widgets/dialogs/OptionsDialog.tsx
+++ b/apps/client/src/widgets/dialogs/OptionsDialog.tsx
@@ -197,7 +197,9 @@ export function isOptionPageVisibleOnPlatform(page: FNote) {
* resets both scroll containers in use: the `.modal-body` on the desktop sidebar layout and the
* `.note-detail` pane in the mobile master-detail flow.
*/
-function SettingsScrollReset({ modalRef, searching }: { modalRef: RefObject<HTMLDivElement>, searching: boolean }) {
+function SettingsScrollReset(
+ { modalRef, searching }: { modalRef: RefObject<HTMLDivElement>, searching: boolean }
+) {
const { noteId } = useNoteContext();
useLayoutEffect(() => {
const modal = modalRef.current;
@@ -210,7 +212,7 @@ function SettingsScrollReset({ modalRef, searching }: { modalRef: RefObject<HTML
interface SettingsSidebarProps {
searchQuery: string;
- /** Whether the search is what the dialog is showing, in which case no page is the active one. */
+ /** Whether the search is showing, in which case no page in the list is the active one. */
searching: boolean;
onSearchChange(query: string): void;
onSearchFocus(): void;
@@ -223,7 +225,9 @@ interface SettingsSidebarProps {
* context via the surrounding provider) so the highlighted entry tracks navigation. The link clicks
* themselves are handled by the dialog's {@link useContainedLinkNavigation} interceptor.
*/
-function SettingsSidebar({ searchQuery, searching, onSearchChange, onSearchFocus }: SettingsSidebarProps) {
+function SettingsSidebar({
+ searchQuery, searching, onSearchChange, onSearchFocus
+}: SettingsSidebarProps) {
const { noteId } = useNoteContext();
return (
diff --git a/apps/client/src/widgets/react/Card.css b/apps/client/src/widgets/react/Card.css
index fbe19fa3b5..5993b45096 100644
--- a/apps/client/src/widgets/react/Card.css
+++ b/apps/client/src/widgets/react/Card.css
@@ -174,8 +174,8 @@ body.mobile .tn-card-option:has(> .btn, > .slider) {
}
}
-/* A card the filter did not ask for by name is left with the settings that matched: whatever else it
- holds belongs to the card as a whole, and the card goes once no setting is left in it. Hidden
+/* A card the filter did not ask for by name is left with the settings that matched: whatever else
+ it holds belongs to the card as a whole, and the card goes once no setting is left in it. Hidden
rather than dropped, so that what is filtered out keeps its state and comes back untouched. */
.tn-card-filter-unmatched {
> .tn-card-body > :not(.tn-card-option, .tn-card-section-nested) {
diff --git a/apps/client/src/widgets/react/Card.spec.tsx b/apps/client/src/widgets/react/Card.spec.tsx
index 96b9551d02..d998cd0ee4 100644
--- a/apps/client/src/widgets/react/Card.spec.tsx
+++ b/apps/client/src/widgets/react/Card.spec.tsx
@@ -147,7 +147,11 @@ describe("a segment that leads somewhere", () => {
describe("under a filter", () => {
const settings = (
<>
- <OptionCardSection className="wrapping" label="Word wrapping" description="Wraps long lines." />
+ <OptionCardSection
+ className="wrapping"
+ label="Word wrapping"
+ description="Wraps long lines."
+ />
<OptionCardSection className="theme" label="Theme" />
</>
);
@@ -160,7 +164,9 @@ describe("under a filter", () => {
expect(byLabel.querySelector(".wrapping")).toBeNull();
expect(byLabel.querySelector(".theme")).not.toBeNull();
- const bySentence = renderInto(<FilterProvider query="long lines">{settings}</FilterProvider>);
+ const bySentence = renderInto(
+ <FilterProvider query="long lines">{settings}</FilterProvider>
+ );
expect(bySentence.querySelector(".wrapping")).not.toBeNull();
expect(bySentence.querySelector(".theme")).toBeNull();
});
@@ -175,7 +181,7 @@ describe("under a filter", () => {
</FilterProvider>
);
- expect(container.querySelector(".tn-card")?.className).not.toContain("tn-card-filter-unmatched");
+ expect(classesOf(container, ".tn-card")).not.toContain("tn-card-filter-unmatched");
expect(container.querySelectorAll(".tn-card-option")).toHaveLength(2);
expect(container.querySelector(".picture")).not.toBeNull();
});
@@ -190,7 +196,7 @@ describe("under a filter", () => {
</FilterProvider>
);
- expect(container.querySelector(".tn-card")?.className).toContain("tn-card-filter-unmatched");
+ expect(classesOf(container, ".tn-card")).toContain("tn-card-filter-unmatched");
expect(container.querySelector(".wrapping")).toBeNull();
expect(container.querySelector(".theme")).not.toBeNull();
// Still rendered: hiding it is the CSS rule's job, which happy-dom does not apply.
@@ -200,7 +206,7 @@ describe("under a filter", () => {
it("leaves a card unmarked while nothing is being filtered", () => {
const container = renderInto(<Card heading="Appearance">{settings}</Card>);
- expect(container.querySelector(".tn-card")?.className).not.toContain("tn-card-filter-unmatched");
+ expect(classesOf(container, ".tn-card")).not.toContain("tn-card-filter-unmatched");
});
it("brings a setting's sub-sections along when the setting itself matched", () => {
@@ -212,31 +218,33 @@ describe("under a filter", () => {
expect(container.querySelector(".tn-card-option-filter-unmatched")).toBeNull();
});
- it("keeps a setting whose sub-section matched, so the detail is read under what it belongs to", () => {
+ it("keeps a setting whose sub-section matched, so the detail is read under it", () => {
const container = fontsCard("font size");
expect(container.querySelector(".size")).not.toBeNull();
// Kept for the sub-section's sake rather than its own, which is what the mark says: CSS
// takes it down again once nothing is left beside it, and happy-dom applies no CSS.
- expect(container.querySelector(".fonts")?.className).toContain("tn-card-option-filter-unmatched");
+ expect(classesOf(container, ".fonts")).toContain("tn-card-option-filter-unmatched");
});
it("leaves a setting nothing to stand on once none of its sub-sections matched", () => {
const container = fontsCard("nothing at all");
expect(container.querySelector(".size")).toBeNull();
- expect(container.querySelector(".fonts")?.className).toContain("tn-card-option-filter-unmatched");
+ expect(classesOf(container, ".fonts")).toContain("tn-card-option-filter-unmatched");
});
/** A setting with a single detail under it, the pairing the filter has to tell apart. */
function fontsCard(query: string) {
+ const fontSize = <OptionCardSection key="size" className="size" label="Font size" />;
+
return renderInto(
<FilterProvider query={query}>
<Card heading="Appearance">
<OptionCardSection
className="fonts"
label="Custom fonts"
- subSections={[ <OptionCardSection key="size" className="size" label="Font size" /> ]}
+ subSections={[ fontSize ]}
subSectionsVisible
/>
</Card>
@@ -244,3 +252,7 @@ describe("under a filter", () => {
);
}
});
+
+function classesOf(container: HTMLElement, selector: string) {
+ return container.querySelector(selector)?.className;
+}
diff --git a/apps/client/src/widgets/react/Card.tsx b/apps/client/src/widgets/react/Card.tsx
index bbe02784eb..3778564431 100644
--- a/apps/client/src/widgets/react/Card.tsx
+++ b/apps/client/src/widgets/react/Card.tsx
@@ -48,10 +48,10 @@ export interface CardProps {
/**
* A titled group of sections.
*
- * Under a `FilterProvider`, a card matching by its heading or description shows everything it holds,
- * since asking for the group is asking for its contents. One that does not match keeps only the
- * sections that matched on their own, and disappears when none did (both through CSS, so nothing is
- * torn down and rebuilt as the query changes).
+ * Under a `FilterProvider`, a card matching by its heading or description shows everything it
+ * holds, since asking for the group is asking for its contents. One that does not match keeps only
+ * the sections that matched on their own, and disappears when none did (both through CSS, so
+ * nothing is torn down and rebuilt as the query changes).
*/
export function Card(props: {children: ComponentChildren} & CardProps) {
const matched = useFilterMatch(props.heading, props.description);
@@ -182,7 +182,9 @@ export function OptionCardSection(props: OptionCardSectionProps) {
"tn-card-option-stacked": stacked,
"tn-card-option-filter-unmatched": !matched
})}
- subSections={subSections && <FilterPassthrough when={matched}>{subSections}</FilterPassthrough>}
+ subSections={subSections && (
+ <FilterPassthrough when={matched}>{subSections}</FilterPassthrough>
+ )}
{...rest}>
<label className="tn-card-option-label" for={bound ? id : undefined}>
{/* Held together as one thing, because the label stacks the sentence under the name and
diff --git a/apps/client/src/widgets/react/filter.spec.tsx b/apps/client/src/widgets/react/filter.spec.tsx
index b62cca1f58..933dbb2ea8 100644
--- a/apps/client/src/widgets/react/filter.spec.tsx
+++ b/apps/client/src/widgets/react/filter.spec.tsx
@@ -191,7 +191,7 @@ function Group({ heading, children }: { heading: string, children: ComponentChil
let mounts = 0;
-/** Sits inside the group without filtering itself, so its mounts tell whether the group remounted. */
+/** Sits in the group without filtering itself, so its mounts tell whether the group remounted. */
function Persistent() {
useEffect(() => {
mounts++;
diff --git a/apps/client/src/widgets/react/filter.tsx b/apps/client/src/widgets/react/filter.tsx
index 2617158888..e82f9951c7 100644
--- a/apps/client/src/widgets/react/filter.tsx
+++ b/apps/client/src/widgets/react/filter.tsx
@@ -31,9 +31,9 @@ interface FilterProviderProps {
* Filters everything rendered below it by `query`, without those components needing to know where
* the query came from or that a filter exists at all.
*
- * Each participating component asks {@link useFilterMatch} whether its own text matches, and returns
- * `null` when it does not. Components that do not ask are left alone, so a filter can be added over
- * an existing tree and only the parts opted in respond to it.
+ * Each participating component asks {@link useFilterMatch} whether its own text matches, and
+ * returns `null` when it does not. Components that do not ask are left alone, so a filter can be
+ * added over an existing tree and only the parts opted in respond to it.
*
* Nothing here is debounced: pass a value already settled with `useDebouncedValue` when the filter
* covers enough content that filtering on every keystroke would be felt.
@@ -109,8 +109,8 @@ export function useFilterState(): FilterState | null {
}
/**
- * Whether anything is being filtered here. Useful for styling a component differently while a filter
- * is running, for example to hide a group left empty by it through CSS rather than in code.
+ * Whether anything is being filtered here. Useful for styling a component differently while a
+ * filter is running, for example to hide a group left empty by it through CSS rather than in code.
*/
export function useIsFiltering(): boolean {
return useContext(FilterContext) !== null;
diff --git a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.tsx b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.tsx
index ea10317300..3655b63776 100644
--- a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.tsx
+++ b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.tsx
@@ -38,7 +38,9 @@ interface OptionsPageHeaderProps {
* for options pages. The sticky-bar styling differs per context (see the CSS), but each page owns its
* header the same way in all of them.
*/
-export default function OptionsPageHeader({ actions, below, helpUrl, title, icon }: OptionsPageHeaderProps) {
+export default function OptionsPageHeader({
+ actions, below, helpUrl, title, icon
+}: OptionsPageHeaderProps) {
const { note } = useNoteContext();
const shownTitle = title ?? note?.title;
const shownIcon = icon ?? note?.getIcon();
diff --git a/apps/client/src/widgets/type_widgets/options/components/SettingsSearch.spec.tsx b/apps/client/src/widgets/type_widgets/options/components/SettingsSearch.spec.tsx
index d2535f0bb1..d61a3300c0 100644
--- a/apps/client/src/widgets/type_widgets/options/components/SettingsSearch.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/components/SettingsSearch.spec.tsx
@@ -11,14 +11,16 @@ import { renderInto } from "../../../../test/render";
import SettingsSearch from "./SettingsSearch";
describe("SettingsSearch", () => {
- it("carries what is being looked for, and offers to clear it only once there is something to clear", () => {
+ it("carries what is being looked for, and offers to clear it only once there is text", () => {
const onChange = vi.fn();
const empty = renderInto(<SettingsSearch query="" onChange={onChange} onFocus={vi.fn()} />);
expect(empty.querySelector("input")?.value).toBe("");
expect(empty.querySelector(".settings-search-clear")).toBeNull();
- const filled = renderInto(<SettingsSearch query="backup" onChange={onChange} onFocus={vi.fn()} />);
+ const filled = renderInto(
+ <SettingsSearch query="backup" onChange={onChange} onFocus={vi.fn()} />
+ );
expect(filled.querySelector("input")?.value).toBe("backup");
filled.querySelector<HTMLButtonElement>(".settings-search-clear")?.click();
diff --git a/apps/client/src/widgets/type_widgets/options/search_page.css b/apps/client/src/widgets/type_widgets/options/search_page.css
index e460bdc14f..fe69e63e01 100644
--- a/apps/client/src/widgets/type_widgets/options/search_page.css
+++ b/apps/client/src/widgets/type_widgets/options/search_page.css
@@ -31,14 +31,14 @@
}
/*
- * A page brings its whole self along, of which the search wants only the cards: its header names the
- * page it thinks it is showing, and its tables and listings are not settings anyone can search for.
- * A page is free to keep its cards inside a block of its own (the shortcuts page does), so what is
- * kept is anything with a card still left in it rather than the cards alone.
+ * A page brings its whole self along, of which the search wants only the cards: its header names
+ * the page it thinks it is showing, and its tables and listings are not settings anyone can search
+ * for. A page is free to keep its cards inside a block of its own (the shortcuts page does), so
+ * what is kept is anything with a card still left in it rather than the cards alone.
*
- * Something is left when a card matched by name, or when a single setting inside one did — the same
- * test decides whether a block is worth keeping, whether a page is worth naming, and whether the
- * search came back with anything at all. A setting kept only for the details under it does not
+ * Something is left when a card matched by name, or when a single setting inside one did — the
+ * same test decides whether a block is worth keeping, whether a page is worth naming, and whether
+ * the search came back with anything at all. A setting kept only for the details under it does not
* count, since it is shown for their sake and goes with them (see `Card.css`).
*/
.options-search-page > :not(.tn-card, .options-search-page-title):not(:has(.tn-card:not(.tn-card-filter-unmatched), .tn-card-option:not(.tn-card-option-filter-unmatched))),
diff --git a/apps/client/src/widgets/type_widgets/options/search_page.spec.tsx b/apps/client/src/widgets/type_widgets/options/search_page.spec.tsx
index 92416fe02c..c4479cfbb8 100644
--- a/apps/client/src/widgets/type_widgets/options/search_page.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/search_page.spec.tsx
@@ -110,7 +110,8 @@ describe("OptionsSearchPage", () => {
it("names the page each result belongs to", async () => {
const container = await renderSearch("theme");
- const titles = [ ...container.querySelectorAll(".options-search-page-title") ].map((el) => el.textContent);
+ const titles = [ ...container.querySelectorAll(".options-search-page-title") ]
+ .map((el) => el.textContent);
expect(titles).toContain("Appearance");
});
diff --git a/apps/client/src/widgets/type_widgets/options/search_page.tsx b/apps/client/src/widgets/type_widgets/options/search_page.tsx
index 8d297d401a..252f8270f5 100644
--- a/apps/client/src/widgets/type_widgets/options/search_page.tsx
+++ b/apps/client/src/widgets/type_widgets/options/search_page.tsx
@@ -27,8 +27,8 @@ const PAGES_LEFT_OUT = new Set([ "_optionsContentManager" ]);
/**
* The settings search: every options page at once, cut down to the settings matching what is being
- * looked for. Reached by focusing the field in the sidebar rather than from the list of pages, since
- * it is a way of finding a setting rather than a page of its own.
+ * looked for. Reached by focusing the field in the sidebar rather than from the list of pages,
+ * since it is a way of finding a setting rather than a page of its own.
*
* The pages are mounted as they are, and each takes care of hiding what does not match through
* {@link FilterProvider}. Mounting them costs a moment, which is what the spinner covers; from then
@@ -53,8 +53,8 @@ export default function OptionsSearchPage({ query }: { query: string }) {
<p className="options-search-hint">{t("options.search_hint")}</p>
)}
- {/* Kept mounted while there is nothing to look for, so that the first search is as quick
- as every one after it. */}
+ {/* Kept mounted while there is nothing to look for, so that the first search is as
+ quick as every one after it. */}
<FilterProvider query={filter}>
<div className="options-search-results" hidden={!filter}>
<SearchedPages />
@@ -84,7 +84,9 @@ function SearchedPages() {
const { noteContext, parentComponent, ntxId, viewScope } = useNoteContext();
const pageProps = { noteContext, parentComponent, ntxId, viewScope, isVisible: true };
- return <>{pages.map((page) => <SearchedPage key={page.noteId} page={page} {...pageProps} />)}</>;
+ return <>
+ {pages.map((page) => <SearchedPage key={page.noteId} page={page} {...pageProps} />)}
+ </>;
}
/** One page's cards, under the name of the page they belong to, so a result says where it lives. */
@@ -105,8 +107,8 @@ function SearchedPage({ page, ...pageProps }: { page: FNote } & Omit<TypeWidgetP
}
/**
- * False for the first render and true from the next one, which gives the spinner a chance to be seen
- * before the pages are built and the browser is busy with them.
+ * False for the first render and true from the next one, which gives the spinner a chance to be
+ * seen before the pages are built and the browser is busy with them.
*/
function useDeferredMount() {
const [ ready, setReady ] = useState(false);