Skip to content

Build your personal knowledge base with Trilium Notes

feat(options/appearance): switch between layouts

Elian Dorand623b2ffa0e3
diff --git a/apps/client/src/services/experimental_features.ts b/apps/client/src/services/experimental_features.ts
index 3984674102..23477eae9d 100644
--- a/apps/client/src/services/experimental_features.ts
+++ b/apps/client/src/services/experimental_features.ts
@@ -20,6 +20,10 @@ export type ExperimentalFeatureId = typeof experimentalFeatures[number]["id"];
let enabledFeatures: Set<ExperimentalFeatureId> | null = null;
export function isExperimentalFeatureEnabled(featureId: ExperimentalFeatureId): boolean {
+ if (featureId === "new-layout") {
+ return options.is("newLayout");
+ }
+
return getEnabledFeatures().has(featureId);
}
diff --git a/apps/client/src/widgets/type_widgets/options/appearance.tsx b/apps/client/src/widgets/type_widgets/options/appearance.tsx
index fe6c547464..5bc1b3854e 100644
--- a/apps/client/src/widgets/type_widgets/options/appearance.tsx
+++ b/apps/client/src/widgets/type_widgets/options/appearance.tsx
@@ -112,9 +112,16 @@ export default function AppearanceSettings() {
}
function LayoutSwitcher() {
+ const [ newLayout, setNewLayout ] = useTriliumOptionBool("newLayout");
+
return (
- <OptionsSection title="Layout">
+ <OptionsSection title="User interface">
<RadioWithIllustration
+ currentValue={newLayout ? "new-layout" : "old-layout"}
+ onChange={async newValue => {
+ await setNewLayout(newValue === "new-layout");
+ reloadFrontendApp();
+ }}
values={[
{ key: "old-layout", text: "Old layout", illustration: <LayoutIllustration /> },
{ key: "new-layout", text: "New layout", illustration: <LayoutIllustration isNewLayout /> }
@@ -124,7 +131,7 @@ function LayoutSwitcher() {
);
}
-function LayoutIllustration({ isNewLayout }: { isNewLayout: boolean }) {
+function LayoutIllustration({ isNewLayout }: { isNewLayout?: boolean }) {
return (
<div className="old-layout-illustration">
<div className="launcher-pane">
diff --git a/apps/client/src/widgets/type_widgets/options/components/RadioWithIllustration.css b/apps/client/src/widgets/type_widgets/options/components/RadioWithIllustration.css
index a8550fde9c..a8286805e9 100644
--- a/apps/client/src/widgets/type_widgets/options/components/RadioWithIllustration.css
+++ b/apps/client/src/widgets/type_widgets/options/components/RadioWithIllustration.css
@@ -13,5 +13,16 @@
}
margin-bottom: 0;
+
+ &> .illustration {
+ border-radius: 6px;
+ padding: 3px;
+ cursor: pointer;
+ }
}
+
+ &> .selected figure > .illustration {
+ outline: 3px solid var(--input-focus-outline-color);
+ }
+
}
diff --git a/apps/client/src/widgets/type_widgets/options/components/RadioWithIllustration.tsx b/apps/client/src/widgets/type_widgets/options/components/RadioWithIllustration.tsx
index b5bdfa4b22..f41d3701ba 100644
--- a/apps/client/src/widgets/type_widgets/options/components/RadioWithIllustration.tsx
+++ b/apps/client/src/widgets/type_widgets/options/components/RadioWithIllustration.tsx
@@ -1,5 +1,6 @@
import "./RadioWithIllustration.css";
+import clsx from "clsx";
import { ComponentChild } from "preact";
interface RadioWithIllustrationProps {
@@ -12,13 +13,22 @@ interface RadioWithIllustrationProps {
onChange(newValue: string);
}
-export default function RadioWithIllustration({ values }: RadioWithIllustrationProps) {
+export default function RadioWithIllustration({ currentValue, onChange, values }: RadioWithIllustrationProps) {
return (
<ul className="radio-with-illustration">
{values.map(value => (
- <li key={value.key}>
+ <li
+ key={value.key}
+ className={clsx(value.key === currentValue && "selected")}
+ >
<figure>
- {value.illustration}
+ <div
+ className="illustration"
+ role="button"
+ onClick={() => onChange(value.key)}
+ >
+ {value.illustration}
+ </div>
<figcaption>{value.text}</figcaption>
</figure>
</li>