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
feat(search): align the parameter rows as a grid
Elian Doranda2e7054c0db
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 3c30592619..9fdec2310e 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1540,7 +1540,7 @@"desc": "Descending"},"search_script": {- "title": "Search script:",+ "title": "Search script","placeholder": "search for note by its name","description1": "Search script allows to define search results by running a script. This provides maximal flexibility when standard search doesn't suffice.","description2": "Search script must be of type \"code\" and subtype \"JavaScript backend\". The script needs to return an array of noteIds or notes.",@@ -1549,7 +1549,7 @@"note": "Note that search script and search string can't be combined with each other."},"search_string": {- "title_column": "Search string:",+ "title_column": "Search string","placeholder": "Ctrl+Space for suggestions, @ for a note, Shift+Enter for a new line, Enter to search","search_syntax": "Search syntax","also_see": "also see",diff --git a/apps/client/src/widgets/search/SearchDefinition.css b/apps/client/src/widgets/search/SearchDefinition.cssindex f12b62a107..22617141ed 100644--- a/apps/client/src/widgets/search/SearchDefinition.css+++ b/apps/client/src/widgets/search/SearchDefinition.css@@ -7,19 +7,32 @@gap: 8px;}- /* 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-option.tn-card-option > .search-option-fields {- display: flex;- flex: 1 1 auto;- flex-wrap: wrap;+ /* An option row lines up like the bulk actions below it: a title column, the controls, and the+ row's buttons at the trailing edge. */+ .search-option.tn-card-option {+ display: grid;+ grid-template-columns: 12em minmax(0, 1fr) auto;align-items: center;- justify-content: flex-end;- gap: 8px;- min-width: 0;+ column-gap: 12px;+ row-gap: 4px;++ > .tn-card-option-label {+ grid-column: 1;+ min-width: 0;+ }++ > .search-option-fields {+ grid-column: 2;+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ gap: 8px;+ min-width: 0;+ }++ > .search-option-actions {+ grid-column: 3;+ }}.search-option-fields > * {@@ -30,6 +43,12 @@flex: 1 1 16rem;}+ /* The bulk action rows share the option rows' title column. */+ .bulk-existing-action-list .title-column {+ width: calc(12em + 12px);+ white-space: normal;+ }+.search-option-row {display: flex;align-items: center;@@ -76,6 +95,31 @@ body.mobile .search-definition-widget {contain: none;}+@container (width < 560px) {+ .search-option.tn-card-option {+ grid-template-columns: minmax(0, 1fr) auto;++ > .tn-card-option-label {+ grid-column: 1;+ grid-row: 1;+ }++ > .search-option-actions {+ grid-column: 2;+ grid-row: 1;+ }++ > .search-option-fields {+ grid-column: 1 / -1;+ grid-row: 2;+ }+ }++ .search-definition-widget .bulk-existing-action-list .title-column {+ width: auto;+ }+}+@media (max-width: 720px) {.search-result-widget,diff --git a/apps/client/src/widgets/search/SearchDefinitionOptions.tsx b/apps/client/src/widgets/search/SearchDefinitionOptions.tsxindex 0a6c0bf8a1..d4ca6157f6 100644--- a/apps/client/src/widgets/search/SearchDefinitionOptions.tsx+++ b/apps/client/src/widgets/search/SearchDefinitionOptions.tsx@@ -130,20 +130,20 @@ function SearchOption({ note, className, title, titleIcon, children, help, attri><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);- }- }- }}- /></div>+ <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);+ }+ }+ }}+ /></OptionCardSection>);}@@ -194,6 +194,7 @@ function SearchStringOption({ note, refreshResults, flushRef, error, ...restPropreturn <><SearchOption+ titleIcon="bx bx-text"title={t("search_string.title_column")}className={clsx({ "has-error": !!error })}help={<>@@ -244,6 +245,7 @@ function SearchScriptOption({ note, ...restProps }: SearchOptionProps) {const [ searchScript, setSearchScript ] = useNoteRelation(note, "searchScript");return <SearchOption+ titleIcon="bx bx-code"title={t("search_script.title")}help={<><p>{t("search_script.description1")}</p>@@ -280,6 +282,7 @@ function AncestorOption({ note, ...restProps}: SearchOptionProps) {}, []);return <SearchOption+ titleIcon="bx bx-filter-alt"title={t("ancestor.label")}note={note} {...restProps}>@@ -290,7 +293,7 @@ function AncestorOption({ note, ...restProps}: SearchOptionProps) {placeholder={t("ancestor.placeholder")}/>- <span className="search-option-row-label">{t("ancestor.depth_label")}:</span>+ <span className="search-option-row-label">{t("ancestor.depth_label")}</span><FormSelectvalues={options}keyProperty="value" titleProperty="label"