mirror of
https://github.com/zadam/trilium.git
synced 2025-12-20 22:34:23 +01:00
feat(options/appearance): switch between layouts
This commit is contained in:
parent
3ed613cf1d
commit
d623b2ffa0
@ -20,6 +20,10 @@ export type ExperimentalFeatureId = typeof experimentalFeatures[number]["id"];
|
|||||||
let enabledFeatures: Set<ExperimentalFeatureId> | null = null;
|
let enabledFeatures: Set<ExperimentalFeatureId> | null = null;
|
||||||
|
|
||||||
export function isExperimentalFeatureEnabled(featureId: ExperimentalFeatureId): boolean {
|
export function isExperimentalFeatureEnabled(featureId: ExperimentalFeatureId): boolean {
|
||||||
|
if (featureId === "new-layout") {
|
||||||
|
return options.is("newLayout");
|
||||||
|
}
|
||||||
|
|
||||||
return getEnabledFeatures().has(featureId);
|
return getEnabledFeatures().has(featureId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -112,9 +112,16 @@ export default function AppearanceSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function LayoutSwitcher() {
|
function LayoutSwitcher() {
|
||||||
|
const [ newLayout, setNewLayout ] = useTriliumOptionBool("newLayout");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OptionsSection title="Layout">
|
<OptionsSection title="User interface">
|
||||||
<RadioWithIllustration
|
<RadioWithIllustration
|
||||||
|
currentValue={newLayout ? "new-layout" : "old-layout"}
|
||||||
|
onChange={async newValue => {
|
||||||
|
await setNewLayout(newValue === "new-layout");
|
||||||
|
reloadFrontendApp();
|
||||||
|
}}
|
||||||
values={[
|
values={[
|
||||||
{ key: "old-layout", text: "Old layout", illustration: <LayoutIllustration /> },
|
{ key: "old-layout", text: "Old layout", illustration: <LayoutIllustration /> },
|
||||||
{ key: "new-layout", text: "New layout", illustration: <LayoutIllustration isNewLayout /> }
|
{ 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 (
|
return (
|
||||||
<div className="old-layout-illustration">
|
<div className="old-layout-illustration">
|
||||||
<div className="launcher-pane">
|
<div className="launcher-pane">
|
||||||
|
|||||||
@ -13,5 +13,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
|
||||||
|
&> .illustration {
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 3px;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&> .selected figure > .illustration {
|
||||||
|
outline: 3px solid var(--input-focus-outline-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import "./RadioWithIllustration.css";
|
import "./RadioWithIllustration.css";
|
||||||
|
|
||||||
|
import clsx from "clsx";
|
||||||
import { ComponentChild } from "preact";
|
import { ComponentChild } from "preact";
|
||||||
|
|
||||||
interface RadioWithIllustrationProps {
|
interface RadioWithIllustrationProps {
|
||||||
@ -12,13 +13,22 @@ interface RadioWithIllustrationProps {
|
|||||||
onChange(newValue: string);
|
onChange(newValue: string);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function RadioWithIllustration({ values }: RadioWithIllustrationProps) {
|
export default function RadioWithIllustration({ currentValue, onChange, values }: RadioWithIllustrationProps) {
|
||||||
return (
|
return (
|
||||||
<ul className="radio-with-illustration">
|
<ul className="radio-with-illustration">
|
||||||
{values.map(value => (
|
{values.map(value => (
|
||||||
<li key={value.key}>
|
<li
|
||||||
|
key={value.key}
|
||||||
|
className={clsx(value.key === currentValue && "selected")}
|
||||||
|
>
|
||||||
<figure>
|
<figure>
|
||||||
|
<div
|
||||||
|
className="illustration"
|
||||||
|
role="button"
|
||||||
|
onClick={() => onChange(value.key)}
|
||||||
|
>
|
||||||
{value.illustration}
|
{value.illustration}
|
||||||
|
</div>
|
||||||
<figcaption>{value.text}</figcaption>
|
<figcaption>{value.text}</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user