Skip to content

Commit 2979f66

Browse files
committed
feat: enhance CalDAV settings section with collapsible UI and state management
1 parent aa3b1fa commit 2979f66

1 file changed

Lines changed: 76 additions & 18 deletions

File tree

src/client/src/pages/SettingsPage/components/CalDAVSettingsSection.tsx

Lines changed: 76 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Checkbox, STYLE_TYPE } from "baseui/checkbox";
44
import { FormControl } from "baseui/form-control";
55
import { Input } from "baseui/input";
66
import { Select } from "baseui/select";
7+
import { useEffect, useState } from "react";
78
import type {
89
ApiCalDAVCalendar,
910
ApiCalDAVQueueSnapshot,
@@ -73,6 +74,7 @@ export default function CalDAVSettingsSection({
7374
surface = "card",
7475
}: Props) {
7576
const [css] = useStyletron();
77+
const [isOpen, setIsOpen] = useState(enabled);
7678
const isList = surface === "list";
7779
const backgroundSyncMinutes = Math.max(
7880
1,
@@ -84,6 +86,12 @@ export default function CalDAVSettingsSection({
8486
}));
8587
const queueItems = queue.items.slice(0, 8);
8688

89+
useEffect(() => {
90+
if (!enabled) {
91+
setIsOpen(false);
92+
}
93+
}, [enabled]);
94+
8795
return (
8896
<div
8997
className={css({
@@ -93,27 +101,75 @@ export default function CalDAVSettingsSection({
93101
border: "1px solid var(--color-bg-quaternary)",
94102
})}
95103
>
96-
<h2
97-
className={css({
98-
fontSize: "18px",
99-
fontWeight: 700,
100-
color: "var(--color-text-primary)",
101-
marginBottom: "12px",
102-
})}
103-
>
104-
{t("settings.caldav")}
105-
</h2>
106-
<div
104+
<button
105+
type="button"
106+
onClick={() => setIsOpen((prev) => !prev)}
107107
className={css({
108-
fontSize: "13px",
109-
color: "var(--color-text-secondary)",
110-
marginBottom: "14px",
108+
display: "flex",
109+
justifyContent: "space-between",
110+
alignItems: "center",
111+
gap: "12px",
112+
width: "100%",
113+
background: "transparent",
114+
border: "none",
115+
padding: 0,
116+
cursor: "pointer",
117+
marginBottom: isOpen ? "12px" : "0",
118+
textAlign: "left",
111119
})}
112120
>
113-
{t("settings.caldavDescription")}
114-
</div>
121+
<div
122+
className={css({
123+
display: "grid",
124+
gap: "4px",
125+
minWidth: 0,
126+
})}
127+
>
128+
<h2
129+
className={css({
130+
fontSize: "18px",
131+
fontWeight: 700,
132+
color: "var(--color-text-primary)",
133+
margin: 0,
134+
})}
135+
>
136+
{t("settings.caldav")}
137+
</h2>
138+
<div
139+
className={css({
140+
fontSize: "13px",
141+
color: "var(--color-text-secondary)",
142+
})}
143+
>
144+
{enabled
145+
? t("settings.caldavEnabled")
146+
: t("settings.caldavDisabled")}
147+
</div>
148+
</div>
149+
<span
150+
className={css({
151+
color: "var(--color-text-secondary)",
152+
fontSize: "18px",
153+
flexShrink: 0,
154+
})}
155+
>
156+
{isOpen ? "-" : "+"}
157+
</span>
158+
</button>
159+
160+
{isOpen ? (
161+
<>
162+
<div
163+
className={css({
164+
fontSize: "13px",
165+
color: "var(--color-text-secondary)",
166+
marginBottom: "14px",
167+
})}
168+
>
169+
{t("settings.caldavDescription")}
170+
</div>
115171

116-
<form onSubmit={onSubmit}>
172+
<form onSubmit={onSubmit}>
117173
<div
118174
className={css({
119175
display: "grid",
@@ -478,7 +534,9 @@ export default function CalDAVSettingsSection({
478534
</div>
479535
) : null}
480536
</div>
481-
</form>
537+
</form>
538+
</>
539+
) : null}
482540
</div>
483541
);
484542
}

0 commit comments

Comments
 (0)