Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): extract mobile layout CSS to dedicated file

Elian Doran70523574b0b6
diff --git a/apps/client/src/layouts/mobile_layout.css b/apps/client/src/layouts/mobile_layout.css
new file mode 100644
index 0000000000..95b9dd8afb
--- /dev/null
+++ b/apps/client/src/layouts/mobile_layout.css
@@ -0,0 +1,72 @@
+span.keyboard-shortcut,
+kbd {
+ display: none;
+}
+
+.dropdown-menu {
+ font-size: larger;
+}
+
+.action-button {
+ background: none;
+ border: none;
+ cursor: pointer;
+ font-size: 1.25em;
+ padding-inline-start: 0.5em;
+ padding-inline-end: 0.5em;
+ color: var(--main-text-color);
+}
+.quick-search {
+ margin: 0;
+}
+.quick-search .dropdown-menu {
+ max-width: 350px;
+}
+
+/* #region Tree */
+.tree-wrapper {
+ max-height: 100%;
+ margin-top: 0px;
+ overflow-y: auto;
+ contain: content;
+ padding-inline-start: 10px;
+}
+
+.fancytree-title {
+ margin-inline-start: 0.6em !important;
+}
+
+.fancytree-node {
+ padding: 5px;
+}
+
+span.fancytree-expander {
+ width: 24px !important;
+ margin-inline-end: 5px;
+}
+
+.fancytree-loading span.fancytree-expander {
+ width: 24px;
+ height: 32px;
+}
+
+.fancytree-loading span.fancytree-expander:after {
+ width: 20px;
+ height: 20px;
+ margin-top: 4px;
+ border-width: 2px;
+ border-style: solid;
+}
+
+.tree-wrapper .collapse-tree-button,
+.tree-wrapper .scroll-to-active-note-button,
+.tree-wrapper .tree-settings-button {
+ position: fixed;
+ margin-inline-end: 16px;
+ display: none;
+}
+
+.tree-wrapper .unhoist-button {
+ font-size: 200%;
+}
+/* #endregion */
diff --git a/apps/client/src/layouts/mobile_layout.tsx b/apps/client/src/layouts/mobile_layout.tsx
index 5b30fc2c90..0f36f282c4 100644
--- a/apps/client/src/layouts/mobile_layout.tsx
+++ b/apps/client/src/layouts/mobile_layout.tsx
@@ -1,3 +1,5 @@
+import "./mobile_layout.css";
+
import type AppContext from "../components/app_context.js";
import GlobalMenuWidget from "../widgets/buttons/global_menu.js";
import CloseZenModeButton from "../widgets/close_zen_button.js";
@@ -29,89 +31,11 @@ import SearchResult from "../widgets/search_result.jsx";
import MobileEditorToolbar from "../widgets/type_widgets/text/mobile_editor_toolbar.jsx";
import { applyModals } from "./layout_commons.js";
-const MOBILE_CSS = `
-<style>
-span.keyboard-shortcut,
-kbd {
- display: none;
-}
-
-.dropdown-menu {
- font-size: larger;
-}
-
-.action-button {
- background: none;
- border: none;
- cursor: pointer;
- font-size: 1.25em;
- padding-inline-start: 0.5em;
- padding-inline-end: 0.5em;
- color: var(--main-text-color);
-}
-.quick-search {
- margin: 0;
-}
-.quick-search .dropdown-menu {
- max-width: 350px;
-}
-</style>`;
-
-const FANCYTREE_CSS = `
-<style>
-.tree-wrapper {
- max-height: 100%;
- margin-top: 0px;
- overflow-y: auto;
- contain: content;
- padding-inline-start: 10px;
-}
-
-.fancytree-title {
- margin-inline-start: 0.6em !important;
-}
-
-.fancytree-node {
- padding: 5px;
-}
-
-span.fancytree-expander {
- width: 24px !important;
- margin-inline-end: 5px;
-}
-
-.fancytree-loading span.fancytree-expander {
- width: 24px;
- height: 32px;
-}
-
-.fancytree-loading span.fancytree-expander:after {
- width: 20px;
- height: 20px;
- margin-top: 4px;
- border-width: 2px;
- border-style: solid;
-}
-
-.tree-wrapper .collapse-tree-button,
-.tree-wrapper .scroll-to-active-note-button,
-.tree-wrapper .tree-settings-button {
- position: fixed;
- margin-inline-end: 16px;
- display: none;
-}
-
-.tree-wrapper .unhoist-button {
- font-size: 200%;
-}
-</style>`;
-
export default class MobileLayout {
getRootWidget(appContext: typeof AppContext) {
const rootContainer = new RootContainer(true)
.setParent(appContext)
.class("horizontal-layout")
- .cssBlock(MOBILE_CSS)
.child(new FlexContainer("column").id("mobile-sidebar-container"))
.child(
new FlexContainer("row")
@@ -125,7 +49,7 @@ export default class MobileLayout {
.css("padding-inline-start", "0")
.css("padding-inline-end", "0")
.css("contain", "content")
- .child(new FlexContainer("column").filling().id("mobile-sidebar-wrapper").child(new QuickSearchWidget()).child(new NoteTreeWidget().cssBlock(FANCYTREE_CSS)))
+ .child(new FlexContainer("column").filling().id("mobile-sidebar-wrapper").child(new QuickSearchWidget()).child(new NoteTreeWidget()))
)
.child(
new ScreenContainer("detail", "row")