Skip to content

Build your personal knowledge base with Trilium Notes

client/content manager: simplify the header

Adorian Doran8c2be7d39994
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 2631d8860d..e1f52233e2 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -2656,7 +2656,7 @@
"view_mode": "View:",
"view_by_category": "By category",
"view_by_location": "By location",
- "sort_order": "Sort by:",
+ "sort_order": "Sort by",
"sort_by_title": "Title",
"sort_by_date_created": "Creation date",
"no_items": "No active content found.",
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager.tsx b/apps/client/src/widgets/type_widgets/options/content_manager.tsx
index 9f68595e1f..6cb74f5c8b 100644
--- a/apps/client/src/widgets/type_widgets/options/content_manager.tsx
+++ b/apps/client/src/widgets/type_widgets/options/content_manager.tsx
@@ -22,10 +22,13 @@ import {
} from "../../../services/content_manager";
import debounce from "../../../services/debounce";
import { t } from "../../../services/i18n";
+import { isMobile } from "../../../services/utils";
import { ListView, type ListViewOptions } from "../../collections/legacy/ListOrGridView";
import ActionButton from "../../react/ActionButton";
import { Badge } from "../../react/Badge";
import Button, { ButtonGroup } from "../../react/Button";
+import Dropdown from "../../react/Dropdown";
+import { FormListItem } from "../../react/FormList";
import FormTextBox from "../../react/FormTextBox";
import FormToggle from "../../react/FormToggle";
import { useTriliumEvent, useTriliumOption } from "../../react/hooks";
@@ -219,12 +222,7 @@ export default function ContentManagerSettings({ note }: TypeWidgetProps) {
currentValue={viewMode}
onChange={(newValue) => void setViewMode(newValue)}
/>
- <span className="content-manager-toolbar-label">{t("content_manager.sort_order")}</span>
- <SegmentedChoice
- options={SORT_ORDERS}
- currentValue={sortOrder}
- onChange={(newValue) => void setSortOrder(newValue)}
- />
+ <SortOrderMenu currentValue={sortOrder} onChange={(newValue) => void setSortOrder(newValue)} />
</div>
} />
@@ -430,6 +428,24 @@ function SegmentedChoice({ options, currentValue, onChange }: {
);
}
+/** A single icon rather than a labelled pair of buttons, the order being set rarely. */
+function SortOrderMenu({ currentValue, onChange }: { currentValue: string, onChange: (newValue: string) => void }) {
+ return (
+ <Dropdown
+ buttonClassName="bx bx-sort"
+ hideToggleArrow noSelectButtonStyle noDropdownListStyle iconAction
+ title={t("content_manager.sort_order")}
+ dropdownContainerClassName={isMobile() ? "mobile-bottom-menu" : undefined}
+ >
+ {SORT_ORDERS.map(({ value, label }) => (
+ <FormListItem key={value} checked={currentValue === value} onClick={() => onChange(value)}>
+ {label}
+ </FormListItem>
+ ))}
+ </Dropdown>
+ );
+}
+
const SORT_ORDERS: { value: ContentSortOrder, label: string }[] = [
{ value: "title", label: t("content_manager.sort_by_title") },
{ value: "dateCreated", label: t("content_manager.sort_by_date_created") }