Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(search): make the split button look like one button
Elian Doran1c8e138d89c3
diff --git a/apps/client/src/widgets/react/Button.css b/apps/client/src/widgets/react/Button.cssindex cd8b38bde9..547c5f98a7 100644--- a/apps/client/src/widgets/react/Button.css+++ b/apps/client/src/widgets/react/Button.css@@ -3,3 +3,33 @@.tn-disabled-reason {display: inline-flex;}++/*+ * A split button is one button cut in two: both halves share the surface and the shadow the theme+ * gives a button, and a hairline marks the cut. The theme's button group instead lays its buttons+ * out as separate chips on a recessed surface.+ */+:root .btn-group.tn-split-button {+ gap: 0;+ padding: 0;+ border-radius: var(--button-border-radius, 6px);+ background: var(--cmd-button-background-color);+ box-shadow: 1px 1px 1px var(--cmd-button-shadow-color);++ button.btn {+ border-radius: 0;+ box-shadow: none;+ }++ > .btn:first-child {+ border-start-start-radius: inherit;+ border-end-start-radius: inherit;+ }++ > .dropdown > .btn.dropdown-toggle-split {+ border-start-end-radius: inherit;+ border-end-end-radius: inherit;+ border-inline-start: 1px solid var(--main-border-color);+ padding-inline: 0.45em;+ }+}diff --git a/apps/client/src/widgets/react/Button.spec.tsx b/apps/client/src/widgets/react/Button.spec.tsxindex aab5d2ee1d..9093b271d0 100644--- a/apps/client/src/widgets/react/Button.spec.tsx+++ b/apps/client/src/widgets/react/Button.spec.tsx@@ -64,4 +64,16 @@ describe("SplitButton", () => {.toEqual([ [ true, true ], [ true, true ] ]);expect(halves[0]?.classList.contains("btn-secondary")).toBe(false);});++ it("joins its halves, and takes a micro look on both", () => {+ render((+ <SplitButton text="Add" size="micro">+ <FormListItem onClick={() => {}}>Add another</FormListItem>+ </SplitButton>+ ), host);++ expect(host.querySelector(".btn-group")?.classList.contains("tn-split-button")).toBe(true);+ expect([ ...host.querySelectorAll<HTMLButtonElement>(".btn-group button") ]+ .every((button) => button.classList.contains("btn-micro"))).toBe(true);+ });});diff --git a/apps/client/src/widgets/react/Button.tsx b/apps/client/src/widgets/react/Button.tsxindex 6d72051466..3e2933728f 100644--- a/apps/client/src/widgets/react/Button.tsx+++ b/apps/client/src/widgets/react/Button.tsx@@ -135,16 +135,16 @@ export function SplitButton({ text, icon, kind = "secondary", size = "normal", c/** The icon's full class, as `"bx bx-search"`. */icon?: string;kind?: "primary" | "secondary";- size?: "normal" | "small";+ size?: "normal" | "small" | "micro";title?: string;/** Click handler for the main button component (not the split). */onClick?: () => void;/** The menu's rows: `FormListItem`s and the other `FormList` rows. */children: ComponentChildren;}) {- const look = `btn-${kind}${size === "small" ? " btn-sm" : ""}`;+ const look = `btn-${kind}${size === "small" ? " btn-sm" : size === "micro" ? " btn-micro" : ""}`;return (- <ButtonGroup size={size === "small" ? "sm" : undefined}>+ <ButtonGroup className="tn-split-button" size={size === "small" ? "sm" : undefined}><button type="button" class={`btn ${look}`} {...restProps}>{icon && <Icon icon={icon} />}{text}diff --git a/apps/client/src/widgets/search/SearchDefinition.tsx b/apps/client/src/widgets/search/SearchDefinition.tsxindex c6f4d0c702..f28ba9f6df 100644--- a/apps/client/src/widgets/search/SearchDefinition.tsx+++ b/apps/client/src/widgets/search/SearchDefinition.tsx@@ -143,6 +143,7 @@ function SearchButtonBar({ note, refreshResults, savePendingOptions }: {<CardSection className="search-definition-actions"><SplitButtontext={t("search_definition.search_button")} icon="bx bx-search"+ size="micro"onClick={refreshResults}><FormListItem icon="bx bxs-zap" onClick={searchAndExecuteActions}>{t("search_definition.search_execute")}</FormListItem>