Skip to content

Build your personal knowledge base with Trilium Notes

feat(mobile): different search bar in new tab on mobile

Elian Doran0e853c901a11
diff --git a/apps/client/src/widgets/type_widgets/Empty.css b/apps/client/src/widgets/type_widgets/Empty.css
index d48ed2b9e1..5efed63b62 100644
--- a/apps/client/src/widgets/type_widgets/Empty.css
+++ b/apps/client/src/widgets/type_widgets/Empty.css
@@ -58,6 +58,10 @@ body.desktop {
.empty-tab-search label {
margin-bottom: 8px;
color: var(--muted-text-color);
+
+ body.mobile & {
+ display: none;
+ }
}
.empty-tab-search .note-autocomplete-input {
@@ -67,3 +71,28 @@ body.desktop {
.empty-tab-search .input-clearer-button {
border-bottom-right-radius: 0;
}
+
+.empty-tab-search-mobile {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 10px 12px;
+ margin-inline: 16px;
+ border: 1px solid var(--bs-border-color);
+ border-radius: 8px;
+ background: var(--input-background-color);
+ cursor: pointer;
+
+ &:active {
+ background: var(--icon-button-hover-background);
+ }
+}
+
+.empty-tab-search-mobile-icon {
+ font-size: 1.2em;
+ color: var(--muted-text-color);
+}
+
+.empty-tab-search-mobile-placeholder {
+ color: var(--muted-text-color);
+}
diff --git a/apps/client/src/widgets/type_widgets/Empty.tsx b/apps/client/src/widgets/type_widgets/Empty.tsx
index 83a4074937..e020342c42 100644
--- a/apps/client/src/widgets/type_widgets/Empty.tsx
+++ b/apps/client/src/widgets/type_widgets/Empty.tsx
@@ -1,13 +1,16 @@
+import "./Empty.css";
+
import { useContext, useEffect, useRef, useState } from "preact/hooks";
+
+import appContext from "../../components/app_context";
+import FNote from "../../entities/fnote";
import { t } from "../../services/i18n";
+import note_autocomplete from "../../services/note_autocomplete";
+import search from "../../services/search";
+import { isMobile } from "../../services/utils";
import FormGroup from "../react/FormGroup";
import NoteAutocomplete from "../react/NoteAutocomplete";
-import "./Empty.css";
import { ParentComponent, refToJQuerySelector } from "../react/react_utils";
-import note_autocomplete from "../../services/note_autocomplete";
-import appContext from "../../components/app_context";
-import FNote from "../../entities/fnote";
-import search from "../../services/search";
import { TypeWidgetProps } from "./type_widget";
export default function Empty({ ntxId }: TypeWidgetProps) {
@@ -16,10 +19,30 @@ export default function Empty({ ntxId }: TypeWidgetProps) {
<WorkspaceSwitcher />
<NoteSearch ntxId={ntxId ?? null} />
</>
- )
+ );
}
function NoteSearch({ ntxId }: { ntxId: string | null }) {
+ if (isMobile()) {
+ return <MobileNoteSearch />;
+ }
+
+ return <DesktopNoteSearch ntxId={ntxId} />;
+}
+
+function MobileNoteSearch() {
+ return (
+ <div
+ className="empty-tab-search-mobile"
+ onClick={() => appContext.triggerCommand("jumpToNote")}
+ >
+ <span className="bx bx-search empty-tab-search-mobile-icon" />
+ <span className="empty-tab-search-mobile-placeholder">{t("empty.search_placeholder")}</span>
+ </div>
+ );
+}
+
+function DesktopNoteSearch({ ntxId }: { ntxId: string | null }) {
const resultsContainerRef = useRef<HTMLDivElement>(null);
const autocompleteRef = useRef<HTMLInputElement>(null);