Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions web/src/styles/study-settings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
.study-settings {
min-width: 0;
font-size: 13px;
line-height: 1.45;
}
.study-settings form {
display: flex;
flex-direction: column;
gap: 12px;
}
.study-settings-help {
margin: 0;
color: var(--t3);
font-size: 12px;
}
.study-settings-row {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
gap: 16px;
min-height: 52px;
padding: 8px 0;
border-top: 1px solid var(--line);
}
.study-settings-row > label,
.study-settings-row > div,
.study-settings-row > span:first-child {
min-width: 0;
flex: 1;
}
.study-settings-row b {
display: block;
font-size: 13px;
font-weight: 500;
color: var(--t1);
}
.study-settings-row small {
display: block;
color: var(--t3);
font-size: 12px;
overflow-wrap: anywhere;
}
.study-settings-row small.error {
color: var(--red);
}
.study-settings-row > input[type="text"],
.study-settings-row > select {
width: 100px;
height: 32px;
flex: none;
padding: 0 10px;
border: 1px solid var(--line2);
border-radius: 8px;
background: var(--main);
color: var(--t1);
font-size: 12.5px;
}
.study-settings-row > input[type="checkbox"] {
appearance: none;
width: 30px;
height: 18px;
flex: none;
padding: 0;
margin: 0;
border: 0;
border-radius: 999px;
background: radial-gradient(circle, var(--main) 7px, transparent 7px) 2px
2px / 14px 14px no-repeat var(--line2);
cursor: pointer;
}
.study-settings-row > input[type="checkbox"]:checked {
background-position: 14px 2px;
background-color: var(--t1);
}
.study-settings-footer {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 6px;
padding-top: 12px;
}
.study-settings-footer > span {
flex: 1;
color: var(--t3);
font-size: 12px;
}
.study-settings-notice {
margin: 0;
color: var(--t2);
}
.study-settings-planned {
margin-top: 20px;
}
.study-planned-label {
flex: none;
color: var(--t3);
font-size: 11px;
}
.study-settings-confirm-actions {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.settings-study-pane .settings-content {
padding-top: 8px;
}
.settings-study-pane .settings-heading h3 {
font-size: 22px;
letter-spacing: -0.015em;
}
@media (max-width: 600px) {
.study-settings-row {
flex-wrap: wrap;
}
.study-settings-row > label {
flex-basis: calc(100% - 116px);
}
.study-settings-footer > span {
flex-basis: 100%;
}
}
176 changes: 168 additions & 8 deletions web/src/ui/SettingsView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { useState } from "react";
import { Download, Settings } from "lucide-react";
import { useRef, useState } from "react";
import { Download, Layers, Settings, Type } from "lucide-react";
import { StudySettingsPanel } from "./StudySettingsPanel";
import type {
StudySettingsOwner,
SettingsLeaveGuard,
} from "./studySettingsTypes";
import type { Theme, usePreferences } from "./primitives";
import { useEditorPreferences } from "./editorPreferences";

export function SettingsView({
email,
Expand All @@ -9,37 +15,85 @@ export function SettingsView({
onExport,
onErase,
onDone,
onSetup,
setupUnavailable = false,
studyOwner = { status: "unavailable" },
onStudyGuardReady,
}: {
studyOwner?: StudySettingsOwner;
onStudyGuardReady?: (guard: SettingsLeaveGuard | null) => void;
onSetup?: () => void;
setupUnavailable?: boolean;
email: string;
preferences: ReturnType<typeof usePreferences>;
onSignOut: () => void;
onExport: () => void;
onErase: () => void;
onDone: () => void;
}) {
const [section, setSection] = useState<"general" | "data">("general");
const [section, setSection] = useState<
"general" | "editor" | "study" | "data"
>("general");
const editor = useEditorPreferences();
const studyGuard = useRef<SettingsLeaveGuard | null>(null);
function leave(action: () => void) {
if (studyGuard.current) studyGuard.current.requestLeave(action);
else action();
}
function registerGuard(guard: SettingsLeaveGuard | null) {
studyGuard.current = guard;
onStudyGuardReady?.(guard);
}
return (
<div className="settings-layout">
<nav className="settings-nav" aria-label="Settings sections">
<button
aria-current={section === "general" ? "page" : undefined}
onClick={() => setSection("general")}
onClick={() => leave(() => setSection("general"))}
>
<Settings size={15} />
General
</button>
<button
aria-current={section === "editor" ? "page" : undefined}
onClick={() => leave(() => setSection("editor"))}
>
<Type size={15} />
Editor
</button>
<button
aria-current={section === "study" ? "page" : undefined}
onClick={() => leave(() => setSection("study"))}
>
<Layers size={15} />
Study
</button>
<button
aria-current={section === "data" ? "page" : undefined}
onClick={() => setSection("data")}
onClick={() => leave(() => setSection("data"))}
>
<Download size={15} />
Data and export
</button>
</nav>
<div className="settings-pane">
<div
className={
section === "study"
? "settings-pane settings-study-pane"
: "settings-pane"
}
>
<header className="settings-heading">
<h3>{section === "general" ? "General" : "Data and export"}</h3>
<button onClick={onDone}>Done</button>
<h3>
{section === "general"
? "General"
: section === "editor"
? "Editor"
: section === "study"
? "Study"
: "Data and export"}
</h3>
<button onClick={() => leave(onDone)}>Done</button>
</header>
<div className="settings-content">
{section === "general" ? (
Expand All @@ -51,6 +105,21 @@ export function SettingsView({
</div>
<button onClick={onSignOut}>Sign out</button>
</div>
{onSetup && (
<div className="settings-row">
<div>
<b>Set up Notes</b>
<small>
{setupUnavailable
? "Finish the current note-link request first."
: "Optional import and local storage setup."}
</small>
</div>
<button disabled={setupUnavailable} onClick={onSetup}>
Set up Notes
</button>
</div>
)}
<div className="settings-row">
<div>
<b>Appearance</b>
Expand Down Expand Up @@ -96,6 +165,97 @@ export function SettingsView({
</div>
</div>
</>
) : section === "editor" ? (
<>
<div className="settings-row">
<b>Font</b>
<span>Geist</span>
</div>
<div className="settings-row">
<b>Text size</b>
<div
className="settings-segments"
role="group"
aria-label="Text size"
>
{(["small", "medium", "large"] as const).map((size) => (
<button
key={size}
aria-pressed={editor.preferences.textSize === size}
onClick={() => editor.setPreferences({ textSize: size })}
>
{size.charAt(0).toUpperCase() + size.slice(1)}
</button>
))}
</div>
</div>
<div className="settings-row">
<b>Line width</b>
<div
className="settings-segments"
role="group"
aria-label="Line width"
>
{(["narrow", "wide"] as const).map((width) => (
<button
key={width}
aria-pressed={editor.preferences.lineWidth === width}
onClick={() =>
editor.setPreferences({ lineWidth: width })
}
>
{width.charAt(0).toUpperCase() + width.slice(1)}
</button>
))}
</div>
</div>
<label className="settings-row settings-toggle">
<span>
<b>Turn Markdown into formatting while typing</b>
<small>Type ## and a space to make a heading</small>
</span>
<input
type="checkbox"
checked={editor.preferences.markdown}
onChange={(event) =>
editor.setPreferences({ markdown: event.target.checked })
}
/>
</label>
<label className="settings-row settings-toggle">
<b>Check spelling</b>
<input
type="checkbox"
checked={editor.preferences.spellcheck}
onChange={(event) =>
editor.setPreferences({ spellcheck: event.target.checked })
}
/>
</label>
<div className="settings-row">
<div>
<b>Show “Linked from” beside notes</b>
<small>
Planned · Opening backlinks by default isn’t available yet.
Use Links and backlinks in a note.
</small>
</div>
<input
type="checkbox"
aria-label="Show Linked from beside notes"
disabled
/>
</div>
<div className="settings-row">
<b>Open task and event chips in</b>
<span>Orbyn Planner · Planned</span>
</div>
</>
) : section === "study" ? (
<StudySettingsPanel
owner={studyOwner}
onGuardReady={registerGuard}
/>
) : (
<>
<div className="settings-row">
Expand Down
Loading
Loading