Skip to content

Build your personal knowledge base with Trilium Notes

feat(search): group the search parameters into cards

Elian Doran9ac072f1f9e0
diff --git a/apps/client/src/stylesheets/theme-next/pages.css b/apps/client/src/stylesheets/theme-next/pages.css
index be0ea5c2c1..1e631bca7a 100644
--- a/apps/client/src/stylesheets/theme-next/pages.css
+++ b/apps/client/src/stylesheets/theme-next/pages.css
@@ -37,7 +37,7 @@
*/
/* Button bar */
- .search-definition-widget .search-setting-table .search-actions-container {
+ .search-definition-widget .search-actions-container {
justify-content: flex-end;
gap: 8px;
}
diff --git a/apps/client/src/widgets/bulk_actions/BulkAction.css b/apps/client/src/widgets/bulk_actions/BulkAction.css
index 266494c377..3d44c89e5c 100644
--- a/apps/client/src/widgets/bulk_actions/BulkAction.css
+++ b/apps/client/src/widgets/bulk_actions/BulkAction.css
@@ -95,3 +95,62 @@
body[dir=rtl] .bulk-action-arrow {
transform: scaleX(-1);
}
+
+/* A list of actions, shown whole in the bulk-actions dialog and in the search parameters. */
+.bulk-existing-action-list {
+ width: 100%;
+
+ tr:not(:last-child) {
+ border-bottom: 1px solid var(--main-border-color);
+ }
+
+ td {
+ padding: 8px 12px;
+ }
+
+ .title-column {
+ width: 1%;
+ white-space: nowrap;
+ }
+
+ .bulk-action-fields :is(.form-control, .form-select, .input-group-text) {
+ padding-block: 0.25rem;
+ }
+
+ .button-column {
+ width: 1%;
+ padding-inline-start: 0;
+ }
+}
+
+@container (width < 560px) {
+ .bulk-existing-action-list {
+ tr {
+ display: grid;
+ grid-template-columns: 1fr auto;
+ }
+
+ .title-column {
+ width: auto;
+ white-space: normal;
+ }
+
+ .bulk-action-fields-column {
+ grid-column: 1 / -1;
+ grid-row: 2;
+ padding-top: 0;
+ }
+
+ .button-column {
+ width: auto;
+ }
+
+ .bulk-action-fields {
+ flex-wrap: wrap;
+
+ > :not(.bulk-action-name, .bulk-action-arrow) {
+ flex-basis: 14ch;
+ }
+ }
+ }
+}
diff --git a/apps/client/src/widgets/bulk_actions/BulkAction.tsx b/apps/client/src/widgets/bulk_actions/BulkAction.tsx
index 4c2ad6bb3b..5cb925cf6e 100644
--- a/apps/client/src/widgets/bulk_actions/BulkAction.tsx
+++ b/apps/client/src/widgets/bulk_actions/BulkAction.tsx
@@ -31,10 +31,12 @@ const BulkAction = memo(({ children, bulkAction }: BulkActionProps) => {
{children ?? <span className="bulk-action-description">{actionDescription}</span>}
</div>
</td>
- <HelpRemoveButtons
- removeText={t("bulk_actions.remove_action")}
- onRemove={() => bulkAction?.deleteAction()}
- />
+ <td className="button-column">
+ <HelpRemoveButtons
+ removeText={t("bulk_actions.remove_action")}
+ onRemove={() => bulkAction?.deleteAction()}
+ />
+ </td>
</tr>
);
});
diff --git a/apps/client/src/widgets/dialogs/bulk_actions.css b/apps/client/src/widgets/dialogs/bulk_actions.css
index 4d82d908c2..3c742eb3f1 100644
--- a/apps/client/src/widgets/dialogs/bulk_actions.css
+++ b/apps/client/src/widgets/dialogs/bulk_actions.css
@@ -11,66 +11,4 @@
display: flex;
justify-content: flex-end;
}
-
- .bulk-existing-action-list {
- width: 100%;
-
- tr:not(:last-child) {
- border-bottom: 1px solid var(--main-border-color);
- }
-
- td {
- padding: 8px 12px;
- }
-
- .title-column {
- width: 1%;
- white-space: nowrap;
- }
-
- .bulk-action-fields :is(.form-control, .form-select, .input-group-text) {
- padding-block: 0.25rem;
- }
-
- .button-column {
- width: 1%;
- padding-inline-start: 0;
- }
- }
-
- .bulk-actions-chosen-actions {
- container-type: inline-size;
- }
-
- @container (width < 560px) {
- .bulk-existing-action-list {
- tr {
- display: grid;
- grid-template-columns: 1fr auto;
- }
-
- .title-column {
- width: auto;
- white-space: normal;
- }
-
- .bulk-action-fields-column {
- grid-column: 1 / -1;
- grid-row: 2;
- padding-top: 0;
- }
-
- .button-column {
- width: auto;
- }
-
- .bulk-action-fields {
- flex-wrap: wrap;
-
- > :not(.bulk-action-name, .bulk-action-arrow) {
- flex-basis: 14ch;
- }
- }
- }
- }
}
diff --git a/apps/client/src/widgets/layout/NoteTitleActions.tsx b/apps/client/src/widgets/layout/NoteTitleActions.tsx
index 438d7c96b2..c8555bf625 100644
--- a/apps/client/src/widgets/layout/NoteTitleActions.tsx
+++ b/apps/client/src/widgets/layout/NoteTitleActions.tsx
@@ -37,7 +37,6 @@ function SearchProperties({ note, ntxId }: { note: FNote | null | undefined, ntx
return (note &&
<Collapsible
title={t("search_definition.search_parameters")}
- card
initiallyExpanded={note.isInHiddenSubtree()} // not saved searches
>
<SearchDefinition note={note} ntxId={ntxId} />
diff --git a/apps/client/src/widgets/react/HelpRemoveButtons.css b/apps/client/src/widgets/react/HelpRemoveButtons.css
new file mode 100644
index 0000000000..a336e29afb
--- /dev/null
+++ b/apps/client/src/widgets/react/HelpRemoveButtons.css
@@ -0,0 +1,5 @@
+.help-remove-buttons {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+}
diff --git a/apps/client/src/widgets/react/HelpRemoveButtons.tsx b/apps/client/src/widgets/react/HelpRemoveButtons.tsx
index 4ae6a15c80..b84cff4692 100644
--- a/apps/client/src/widgets/react/HelpRemoveButtons.tsx
+++ b/apps/client/src/widgets/react/HelpRemoveButtons.tsx
@@ -1,4 +1,8 @@
+import "./HelpRemoveButtons.css";
+
+import clsx from "clsx";
import type { ComponentChildren } from "preact";
+
import ActionButton from "./ActionButton";
import { DropdownPanel } from "./Dropdown";
@@ -6,19 +10,19 @@ interface HelpRemoveButtonsProps {
help?: ComponentChildren;
removeText?: string;
onRemove?: () => void;
+ className?: string;
}
-export default function HelpRemoveButtons({ help, removeText, onRemove }: HelpRemoveButtonsProps) {
+export default function HelpRemoveButtons({ help, removeText, onRemove, className }: HelpRemoveButtonsProps) {
return (
- <td className="button-column">
- {help && <>
+ <div className={clsx("help-remove-buttons", className)}>
+ {help && (
<DropdownPanel
className="help-dropdown"
buttonClassName="bx bx-help-circle icon-action"
hideToggleArrow
>{help}</DropdownPanel>
- {" "}
- </>}
+ )}
<ActionButton
icon="bx bx-x"
className="search-option-del"
@@ -28,6 +32,6 @@ export default function HelpRemoveButtons({ help, removeText, onRemove }: HelpRe
onRemove?.();
}}
/>
- </td>
+ </div>
);
}
diff --git a/apps/client/src/widgets/search/SearchDefinition.css b/apps/client/src/widgets/search/SearchDefinition.css
index 722222b2d3..e7d1ac26e6 100644
--- a/apps/client/src/widgets/search/SearchDefinition.css
+++ b/apps/client/src/widgets/search/SearchDefinition.css
@@ -1,167 +1,99 @@
-.search-setting-table {
- margin-top: 0;
- margin-bottom: 7px;
- width: 100%;
- border-collapse: separate;
- border-spacing: 10px;
-
- .admonition {
- margin-top: 0.25em;
- margin-bottom: 1em;
- text-wrap: wrap;
- }
-}
-
-.search-setting-table div {
- white-space: nowrap;
-}
-
-.search-setting-table .title-column {
- /* minimal width so that table remains static sized and most space remains for middle column with settings */
- width: 50px;
- white-space: nowrap;
-}
-
-.search-setting-table .button-column {
- /* minimal width so that table remains static sized and most space remains for middle column with settings */
- width: 50px;
- white-space: nowrap;
- text-align: end;
- vertical-align: middle;
-}
-
-.search-setting-table .button-column .dropdown {
- display: inline-block !important;
-}
-
-.search-setting-table .button-column > * {
- vertical-align: middle;
-}
-
-.attribute-list hr {
- height: 1px;
- border-color: var(--main-border-color);
- position: relative;
- top: 4px;
- margin-top: 5px;
- margin-bottom: 0;
-}
-
-.search-definition-widget input:user-invalid {
- border: 3px solid red;
-}
-
-.add-search-option button {
- margin: 3px;
-}
-
-.search-actions-container {
- display: flex;
- justify-content: space-evenly;
-}
-
-body.mobile .search-definition-widget {
- contain: none;
-}
-
-@media (max-width: 720px) {
-
- .search-setting-table {
- display: block;
- font-size: 0.9em;
+.search-definition-widget {
+ .search-definition-add {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 8px;
}
- .search-setting-table tr {
- padding: 0.5em 0;
- border-bottom: 1px solid var(--main-border-color);
+ .search-definition-add-label {
+ font-weight: 500;
}
- .search-setting-table tr,
- .search-setting-table td {
- display: block;
+ .search-definition-add-buttons {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 6px;
+ margin-inline-start: auto;
}
- .search-setting-table tbody {
- display: block;
- padding: 0 1em;
+ /* An option's controls take the room its label leaves, with the help and remove buttons last. */
+ .search-option.tn-card-option > .tn-card-option-label {
+ flex: 0 1 auto;
}
- .search-setting-table tbody:first-of-type {
- display: block;
- overflow: auto;
+ .search-option.tn-card-option > .search-option-fields {
+ display: flex;
+ flex: 1 1 auto;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: flex-end;
+ gap: 8px;
+ min-width: 0;
}
- .search-setting-table .add-search-option {
- display: flex;
+ .search-option-fields > * {
+ min-width: 0;
}
- .search-setting-table .add-search-option button {
- font-size: 0.75em;
+ .search-option-fields > :is(.search-string, .input-group, .search-option-row) {
+ flex: 1 1 16rem;
}
- .search-options tr,
- .action-options tr {
+ .search-option-row {
display: flex;
align-items: center;
+ gap: 8px;
+ min-width: 0;
}
- .action-options tr > td > div {
- flex-wrap: wrap;
- gap: 0.5em 0;
- }
-
- .action-options input {
- max-width: 75vw;
+ .search-option-row .input-group {
+ flex: 1 1 auto;
}
- .search-setting-table .title-column {
- width: unset;
- margin-right: 0.5em;
- min-width: 30%;
- flex-shrink: 0;
+ .search-option-row-label {
+ white-space: nowrap;
}
- .search-setting-table .button-column {
- flex-grow: 1;
- justify-content: end;
- overflow: hidden;
- flex-shrink: 0;
+ .search-definition-error .admonition {
+ margin: 0;
}
- .search-setting-table .button-column .bx-help-circle {
- display: none;
+ .search-actions {
+ display: flex;
}
- .search-setting-table tr.orderBy td:nth-of-type(2) {
+ .search-actions-container {
display: flex;
- flex-direction: column;
- overflow: hidden;
- gap: 0.5em;
+ flex: 1 1 auto;
+ justify-content: space-evenly;
+ gap: 8px;
+ min-width: 0;
}
+}
- .search-setting-table tr.searchString {
- td:nth-of-type(2) {
- flex-grow: 1;
- }
+.search-definition-widget input:user-invalid {
+ border: 3px solid red;
+}
- .button-column {
- flex-grow: 0;
- flex-shrink: 0;
- width: 64px;
- }
+.attribute-list hr {
+ height: 1px;
+ border-color: var(--main-border-color);
+ position: relative;
+ top: 4px;
+ margin-top: 5px;
+ margin-bottom: 0;
+}
- &.has-error {
- border-bottom: 0;
- }
- }
+body.mobile .search-definition-widget {
+ contain: none;
+}
- .search-setting-table tr.ancestor > td > div {
- flex-direction: column;
- align-items: flex-start !important;
- }
+@media (max-width: 720px) {
- .search-actions tr {
- border-bottom: 0;
+ .search-definition-add-buttons {
+ margin-inline-start: 0;
}
.search-actions-container {
diff --git a/apps/client/src/widgets/search/SearchDefinition.spec.tsx b/apps/client/src/widgets/search/SearchDefinition.spec.tsx
index ed656321d4..a098df8fb7 100644
--- a/apps/client/src/widgets/search/SearchDefinition.spec.tsx
+++ b/apps/client/src/widgets/search/SearchDefinition.spec.tsx
@@ -44,6 +44,16 @@ afterEach(() => {
});
describe("the search definition", () => {
+ it("lays the parameters out as segments of a card, as the bulk actions dialog does", () => {
+ const container = renderDefinition();
+ const card = container.querySelector(".search-definition-widget > .tn-card");
+
+ expect(card).not.toBeNull();
+ expect(card?.querySelector(".tn-card-section.search-definition-add")).not.toBeNull();
+ expect(card?.querySelector(".tn-card-section.tn-card-option.searchString")).not.toBeNull();
+ expect(card?.querySelector(".tn-card-section.search-definition-actions")).not.toBeNull();
+ });
+
it.each([
[ "search", "search_definition.search_button", () => search.runSearchNote ],
[ "search & execute", "search_definition.search_execute", () => server.post ]
diff --git a/apps/client/src/widgets/search/SearchDefinition.tsx b/apps/client/src/widgets/search/SearchDefinition.tsx
index 6d57971c37..b24185ca49 100644
--- a/apps/client/src/widgets/search/SearchDefinition.tsx
+++ b/apps/client/src/widgets/search/SearchDefinition.tsx
@@ -1,6 +1,7 @@
import "./SearchDefinition.css";
import { SaveSearchNoteResponse } from "@triliumnext/commons";
+import { Fragment } from "preact";
import { useContext, useEffect, useRef, useState } from "preact/hooks";
import appContext from "../../components/app_context";
@@ -16,6 +17,7 @@ import ws from "../../services/ws";
import AddBulkActionButton from "../bulk_actions/AddBulkActionButton";
import RenameNoteBulkAction from "../bulk_actions/note/rename_note";
import Button, { SplitButton } from "../react/Button";
+import { Card, CardSection } from "../react/Card";
import Dropdown from "../react/Dropdown";
import { FormListItem } from "../react/FormList";
import { useTriliumEvent } from "../react/hooks";
@@ -80,72 +82,69 @@ export default function SearchDefinition({ note, ntxId }: {
return (
<div className="search-definition-widget">
- <div className="search-settings">
- {note && (
- <table className="search-setting-table">
- <tbody>
- <tr>
- <td className="title-column">{t("search_definition.add_search_option")}</td>
- <td colSpan={2} className="add-search-option">
- <ResponsiveContainer
- desktop={searchOptions?.availableOptions.map(({ icon, label, tooltip, attributeName, attributeType, defaultValue }) => (
- <Button
+ {note && (
+ <Card className="search-definition-card">
+ <CardSection className="search-definition-add">
+ <span className="search-definition-add-label">{t("search_definition.add_search_option")}</span>
+ <div className="search-definition-add-buttons">
+ <ResponsiveContainer
+ desktop={searchOptions?.availableOptions.map(({ icon, label, tooltip, attributeName, attributeType, defaultValue }) => (
+ <Button
+ key={`${attributeType}-${attributeName}`}
+ size="small" icon={icon} text={label} title={tooltip}
+ onClick={() => attributes.setAttribute(note, attributeType, attributeName, defaultValue ?? "")}
+ />
+ ))}
+ mobile={
+ <Dropdown
+ buttonClassName="action-add-toggle btn btn-sm"
+ text={<><Icon icon="bx bx-plus" />{" "}{t("search_definition.option")}</>}
+ mobileBottomSheet
+ noSelectButtonStyle
+ >
+ {searchOptions?.availableOptions.map(({ icon, label, tooltip, attributeName, attributeType, defaultValue }) => (
+ <FormListItem
key={`${attributeType}-${attributeName}`}
- size="small" icon={icon} text={label} title={tooltip}
+ icon={icon}
+ description={tooltip}
onClick={() => attributes.setAttribute(note, attributeType, attributeName, defaultValue ?? "")}
- />
+ >{label}</FormListItem>
))}
- mobile={
- <Dropdown
- buttonClassName="action-add-toggle btn btn-sm"
- text={<><Icon icon="bx bx-plus" />{" "}{t("search_definition.option")}</>}
- mobileBottomSheet
- noSelectButtonStyle
- >
- {searchOptions?.availableOptions.map(({ icon, label, tooltip, attributeName, attributeType, defaultValue }) => (
- <FormListItem
- key={`${attributeType}-${attributeName}`}
- icon={icon}
- description={tooltip}
- onClick={() => attributes.setAttribute(note, attributeType, attributeName, defaultValue ?? "")}
- >{label}</FormListItem>
- ))}
- </Dropdown>
- }
- />
-
- <AddBulkActionButton
- noteId={note.noteId}
- buttonClassName="action-add-toggle btn btn-sm"
- text={<><Icon icon="bx bxs-zap" />{" "}{t("search_definition.action")}</>}
- />
- </td>
- </tr>
- </tbody>
- <tbody className="search-options">
- {searchOptions?.activeOptions.map(({ attributeType, attributeName, component, additionalAttributesToDelete, defaultValue }) => {
- const Component = component;
- return <Component
- attributeName={attributeName}
- attributeType={attributeType}
- note={note}
- refreshResults={refreshResults}
- flushRef={flushRef}
- error={error}
- additionalAttributesToDelete={additionalAttributesToDelete}
- defaultValue={defaultValue}
- />;
- })}
- </tbody>
- <BulkActionsList note={note} />
- <SearchButtonBar
+ </Dropdown>
+ }
+ />
+
+ <AddBulkActionButton
+ noteId={note.noteId}
+ buttonClassName="action-add-toggle btn btn-sm"
+ text={<><Icon icon="bx bxs-zap" />{" "}{t("search_definition.action")}</>}
+ />
+ </div>
+ </CardSection>
+
+ {searchOptions?.activeOptions.map(({ attributeType, attributeName, component, additionalAttributesToDelete, defaultValue }) => {
+ const Component = component;
+ return <Component
+ attributeName={attributeName}
+ attributeType={attributeType}
note={note}
refreshResults={refreshResults}
- savePendingOptions={savePendingOptions}
- />
- </table>
- )}
- </div>
+ flushRef={flushRef}
+ error={error}
+ additionalAttributesToDelete={additionalAttributesToDelete}
+ defaultValue={defaultValue}
+ />;
+ })}
+
+ <BulkActionsList note={note} />
+
+ <SearchButtonBar
+ note={note}
+ refreshResults={refreshResults}
+ savePendingOptions={savePendingOptions}
+ />
+ </Card>
+ )}
</div>
);
}
@@ -175,30 +174,26 @@ function SearchButtonBar({ note, refreshResults, savePendingOptions }: {
}
return (
- <tbody className="search-actions">
- <tr>
- <td colSpan={3}>
- <ResponsiveContainer
- desktop={
- <div className="search-actions-container">
- <Button icon="bx bx-search" text={t("search_definition.search_button")} keyboardShortcut="Enter" onClick={refreshResults} />
- <Button icon="bx bxs-zap" text={t("search_definition.search_execute")} onClick={searchAndExecuteActions} />
- {note.isHiddenCompletely() && <Button icon="bx bx-save" text={t("search_definition.save_to_note")} onClick={saveSearchNote} />}
- </div>
- }
- mobile={
- <SplitButton
- text={t("search_definition.search_button")} icon="bx bx-search"
- onClick={refreshResults}
- >
- <FormListItem icon="bx bxs-zap" onClick={searchAndExecuteActions}>{t("search_definition.search_execute")}</FormListItem>
- {note.isHiddenCompletely() && <FormListItem icon="bx bx-save" onClick={saveSearchNote}>{t("search_definition.save_to_note")}</FormListItem>}
- </SplitButton>
- }
- />
- </td>
- </tr>
- </tbody>
+ <CardSection className="search-definition-actions">
+ <ResponsiveContainer
+ desktop={
+ <div className="search-actions-container">
+ <Button icon="bx bx-search" text={t("search_definition.search_button")} keyboardShortcut="Enter" onClick={refreshResults} />
+ <Button icon="bx bxs-zap" text={t("search_definition.search_execute")} onClick={searchAndExecuteActions} />
+ {note.isHiddenCompletely() && <Button icon="bx bx-save" text={t("search_definition.save_to_note")} onClick={saveSearchNote} />}
+ </div>
+ }
+ mobile={
+ <SplitButton
+ text={t("search_definition.search_button")} icon="bx bx-search"
+ onClick={refreshResults}
+ >
+ <FormListItem icon="bx bxs-zap" onClick={searchAndExecuteActions}>{t("search_definition.search_execute")}</FormListItem>
+ {note.isHiddenCompletely() && <FormListItem icon="bx bx-save" onClick={saveSearchNote}>{t("search_definition.save_to_note")}</FormListItem>}
+ </SplitButton>
+ }
+ />
+ </CardSection>
);
}
@@ -219,11 +214,19 @@ function BulkActionsList({ note }: { note: FNote }) {
}
});
+ if (!bulkActions?.length) {
+ return null;
+ }
+
return (
- <tbody className="action-options">
- {bulkActions?.map(bulkAction => (
- bulkAction.doRender()
- ))}
- </tbody>
+ <CardSection noPadding className="search-definition-bulk-actions">
+ <table className="bulk-existing-action-list">
+ <tbody>
+ {bulkActions.map((bulkAction) => (
+ <Fragment key={bulkAction.attribute.attributeId}>{bulkAction.doRender()}</Fragment>
+ ))}
+ </tbody>
+ </table>
+ </CardSection>
);
}
diff --git a/apps/client/src/widgets/search/SearchDefinitionOptions.spec.tsx b/apps/client/src/widgets/search/SearchDefinitionOptions.spec.tsx
index 83f0e2d487..3937a8312d 100644
--- a/apps/client/src/widgets/search/SearchDefinitionOptions.spec.tsx
+++ b/apps/client/src/widgets/search/SearchDefinitionOptions.spec.tsx
@@ -5,6 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import FNote from "../../entities/fnote";
import attributes from "../../services/attributes";
import { renderInto } from "../../test/render";
+import { Card } from "../react/Card";
import { SEARCH_OPTIONS } from "./SearchDefinitionOptions";
// Echoes the key, so a spec can tell which string a title shows.
@@ -94,7 +95,7 @@ function renderOption(note: FNote, container?: HTMLDivElement, error?: { message
const Component = option.component;
const vnode = (
- <table><tbody>
+ <Card>
<Component
note={note}
refreshResults={() => {}}
@@ -103,7 +104,7 @@ function renderOption(note: FNote, container?: HTMLDivElement, error?: { message
attributeName="searchString"
attributeType="label"
/>
- </tbody></table>
+ </Card>
);
if (container) {
diff --git a/apps/client/src/widgets/search/SearchDefinitionOptions.tsx b/apps/client/src/widgets/search/SearchDefinitionOptions.tsx
index 9e19657715..0a6c0bf8a1 100644
--- a/apps/client/src/widgets/search/SearchDefinitionOptions.tsx
+++ b/apps/client/src/widgets/search/SearchDefinitionOptions.tsx
@@ -11,6 +11,7 @@ import server from "../../services/server";
import SpacedUpdate from "../../services/spaced_update";
import { openInAppHelpFromUrl } from "../../services/utils";
import { ExtendedAdmonition } from "../react/Admonition";
+import { CardSection, OptionCardSection } from "../react/Card";
import FormSelect from "../react/FormSelect";
import FormTextBox from "../react/FormTextBox";
import HelpRemoveButtons from "../react/HelpRemoveButtons";
@@ -123,25 +124,27 @@ function SearchOption({ note, className, title, titleIcon, children, help, attri
additionalAttributesToDelete?: { type: "label" | "relation", name: string }[]
}) {
return (
- <tr className={clsx(attributeName, className)}>
- <td className="title-column">
- {titleIcon && <><Icon icon={titleIcon} />{" "}</>}
- {title}
- </td>
- <td>{children}</td>
- <HelpRemoveButtons
- help={help}
- removeText={t("abstract_search_option.remove_this_search_option")}
- onRemove={() => {
- removeOwnedAttributesByNameOrType(note, attributeType, attributeName);
- if (additionalAttributesToDelete) {
- for (const { type, name } of additionalAttributesToDelete) {
- removeOwnedAttributesByNameOrType(note, type, name);
+ <OptionCardSection
+ className={clsx("search-option", attributeName, className)}
+ label={titleIcon ? <><Icon icon={titleIcon} />{" "}{title}</> : title}
+ >
+ <div className="search-option-fields">
+ {children}
+ <HelpRemoveButtons
+ className="search-option-actions"
+ help={help}
+ removeText={t("abstract_search_option.remove_this_search_option")}
+ onRemove={() => {
+ removeOwnedAttributesByNameOrType(note, attributeType, attributeName);
+ if (additionalAttributesToDelete) {
+ for (const { type, name } of additionalAttributesToDelete) {
+ removeOwnedAttributesByNameOrType(note, type, name);
+ }
}
- }
- }}
- />
- </tr>
+ }}
+ />
+ </div>
+ </OptionCardSection>
);
}
@@ -224,17 +227,15 @@ function SearchStringOption({ note, refreshResults, flushRef, error, ...restProp
/>
</SearchOption>
{error?.message && (
- <tr>
- <td colspan={3}>
- <ExtendedAdmonition
- type="caution"
- icon="bx bx-error-circle"
- title={t("search_string.error_title")}
- >
- {error.message}
- </ExtendedAdmonition>
- </td>
- </tr>
+ <CardSection className="search-definition-error">
+ <ExtendedAdmonition
+ type="caution"
+ icon="bx bx-error-circle"
+ title={t("search_string.error_title")}
+ >
+ {error.message}
+ </ExtendedAdmonition>
+ </CardSection>
)}
</>;
}
@@ -282,19 +283,18 @@ function AncestorOption({ note, ...restProps}: SearchOptionProps) {
title={t("ancestor.label")}
note={note} {...restProps}
>
- <div style={{display: "flex", alignItems: "center"}}>
+ <div className="search-option-row">
<NoteAutocomplete
noteId={ancestor !== "root" ? ancestor ?? undefined : undefined}
noteIdChanged={noteId => setAncestor(noteId ?? "root")}
placeholder={t("ancestor.placeholder")}
/>
- <div style="margin-inline-start: 10px; margin-inline-end: 10px">{t("ancestor.depth_label")}:</div>
+ <span className="search-option-row-label">{t("ancestor.depth_label")}:</span>
<FormSelect
values={options}
keyProperty="value" titleProperty="label"
currentValue={depth ?? ""} onChange={(value) => setDepth(value ? value : null)}
- style={{ flexShrink: 3 }}
/>
</div>
</SearchOption>;