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(split): use grouped buttons for view selectors
Elian Doran1b4400db03e3
diff --git a/apps/client/src/stylesheets/theme-next/forms.css b/apps/client/src/stylesheets/theme-next/forms.cssindex 6efe42a9d7..28f13361d9 100644--- a/apps/client/src/stylesheets/theme-next/forms.css+++ b/apps/client/src/stylesheets/theme-next/forms.css@@ -131,11 +131,16 @@ button.tn-low-profile:hover {color: var(--icon-button-color);}-:root .btn-group .icon-action:last-child {+:root .btn-group .icon-action:not(:first-child) {border-top-left-radius: unset !important;border-bottom-left-radius: unset !important;}+:root .btn-group .icon-action:not(:last-child) {+ border-top-right-radius: unset !important;+ border-bottom-right-radius: unset !important;+}+.btn-group .tn-tool-button + .tn-tool-button {margin-inline-start: 4px !important;}diff --git a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx b/apps/client/src/widgets/FloatingButtonsDefinitions.tsxindex 4eabe122aa..2e82c4a0b0 100644--- a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx+++ b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx@@ -20,6 +20,7 @@ import tree from "../services/tree";import { createImageSrcUrl, openInAppHelpFromUrl } from "../services/utils";import { ViewTypeOptions } from "./collections/interface";import ActionButton, { ActionButtonProps } from "./react/ActionButton";+import { ButtonGroup } from "./react/Button";import { useIsNoteReadOnly, useNoteLabel, useNoteLabelBoolean, useTriliumEvent, useTriliumOption, useWindowSize } from "./react/hooks";import NoteLink from "./react/NoteLink";import RawHtml from "./react/RawHtml";@@ -122,7 +123,7 @@ function DisplayModeSwitcher({ note, isDefaultViewMode }: FloatingButtonContext)];return (- <>+ <ButtonGroup size="sm">{buttons.map(({ value, icon, text }) => (<FloatingButtonkey={value}@@ -132,7 +133,7 @@ function DisplayModeSwitcher({ note, isDefaultViewMode }: FloatingButtonContext)onClick={() => setDisplayMode(value)}/>))}- </>+ </ButtonGroup>);}diff --git a/apps/client/src/widgets/react/Button.tsx b/apps/client/src/widgets/react/Button.tsxindex 3114b9dfe8..95601a9228 100644--- a/apps/client/src/widgets/react/Button.tsx+++ b/apps/client/src/widgets/react/Button.tsx@@ -84,9 +84,9 @@ function Button({ name, buttonRef, className, text, onClick, keyboardShortcut, i);}-export function ButtonGroup({ children }: { children: ComponentChildren }) {+export function ButtonGroup({ size, className, children }: { size?: "sm" | "lg"; className?: string; children: ComponentChildren }) {return (- <div className="btn-group" role="group">+ <div className={`btn-group ${size ? `btn-group-${size}` : ""} ${className ?? ""}`} role="group">{children}</div>);diff --git a/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx b/apps/client/src/widgets/ribbon/NoteActionsCustom.tsxindex e072dbb446..899c6f46fa 100644--- a/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx+++ b/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx@@ -14,6 +14,7 @@ import { createImageSrcUrl, isMobile, openInAppHelpFromUrl } from "../../serviceimport { ViewTypeOptions } from "../collections/interface";import { buildSaveSqlToNoteHandler } from "../FloatingButtonsDefinitions";import ActionButton, { ActionButtonProps } from "../react/ActionButton";+import { ButtonGroup } from "../react/Button";import { FormFileUploadActionButton, FormFileUploadFormListItem, FormFileUploadProps } from "../react/FormFileUpload";import { FormListItem } from "../react/FormList";import { useNoteLabel, useNoteLabelBoolean, useNoteProperty, useTriliumEvent, useTriliumEvents, useTriliumOption } from "../react/hooks";@@ -230,8 +231,22 @@ function DisplayModeSwitcher({ note, isDefaultViewMode }: NoteActionsCustomInner{ value: "preview", icon: "bx bx-show", text: t("display_mode.preview") }];+ if (cachedIsMobile) {+ return <>+ {buttons.map(({ value, icon, text }) => (+ <NoteAction+ key={value}+ icon={icon}+ text={text}+ active={mode === value}+ onClick={() => setDisplayMode(value)}+ />+ ))}+ </>;+ }+return (- <>+ <ButtonGroup size="sm">{buttons.map(({ value, icon, text }) => (<NoteActionkey={value}@@ -241,7 +256,7 @@ function DisplayModeSwitcher({ note, isDefaultViewMode }: NoteActionsCustomInneronClick={() => setDisplayMode(value)}/>))}- </>+ </ButtonGroup>);}