Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

fix(ui): Improve visual consistency in all settings page

Mohamed Basseme02a4c5e0f56
diff --git a/apps/web/app/settings/api-keys/page.tsx b/apps/web/app/settings/api-keys/page.tsx
index 494a0b5c..828548de 100644
--- a/apps/web/app/settings/api-keys/page.tsx
+++ b/apps/web/app/settings/api-keys/page.tsx
@@ -1,5 +1,7 @@
import type { Metadata } from "next";
+import AddApiKey from "@/components/settings/AddApiKey";
import ApiKeySettings from "@/components/settings/ApiKeySettings";
+import { SettingsPage } from "@/components/settings/SettingsPage";
import { useTranslation } from "@/lib/i18n/server";
export async function generateMetadata(): Promise<Metadata> {
@@ -11,9 +13,14 @@ export async function generateMetadata(): Promise<Metadata> {
}
export default async function ApiKeysPage() {
+ // oxlint-disable-next-line rules-of-hooks
+ const { t } = await useTranslation();
return (
- <div className="rounded-md border bg-background p-4">
+ <SettingsPage
+ title={t("settings.api_keys.api_keys")}
+ action={<AddApiKey />}
+ >
<ApiKeySettings />
- </div>
+ </SettingsPage>
);
}
diff --git a/apps/web/app/settings/assets/page.tsx b/apps/web/app/settings/assets/page.tsx
index 77b3d159..84c31416 100644
--- a/apps/web/app/settings/assets/page.tsx
+++ b/apps/web/app/settings/assets/page.tsx
@@ -1,6 +1,10 @@
"use client";
import Link from "next/link";
+import {
+ SettingsPage,
+ SettingsSection,
+} from "@/components/settings/SettingsPage";
import { ActionButton } from "@/components/ui/action-button";
import ActionConfirmingDialog from "@/components/ui/action-confirming-dialog";
import { Button } from "@/components/ui/button";
@@ -69,13 +73,10 @@ export default function AssetsSettingsPage() {
}
return (
- <div className="rounded-md border bg-background p-4">
- <div className="flex flex-col gap-2">
- <div className="mb-2 text-lg font-medium">
- {t("settings.manage_assets.manage_assets")}
- </div>
+ <SettingsPage title={t("settings.manage_assets.manage_assets")}>
+ <SettingsSection>
{assets.length === 0 && (
- <p className="rounded-md bg-muted p-2 text-sm text-muted-foreground">
+ <p className="rounded-md bg-muted p-3 text-center text-sm text-muted-foreground">
{t("settings.manage_assets.no_assets")}
</p>
)}
@@ -182,7 +183,7 @@ export default function AssetsSettingsPage() {
</ActionButton>
</div>
)}
- </div>
- </div>
+ </SettingsSection>
+ </SettingsPage>
);
}
diff --git a/apps/web/app/settings/backups/page.tsx b/apps/web/app/settings/backups/page.tsx
index fc263089..8d0cc6e1 100644
--- a/apps/web/app/settings/backups/page.tsx
+++ b/apps/web/app/settings/backups/page.tsx
@@ -1,17 +1,17 @@
"use client";
import BackupSettings from "@/components/settings/BackupSettings";
+import { SettingsPage } from "@/components/settings/SettingsPage";
import { useTranslation } from "@/lib/i18n/client";
export default function BackupsPage() {
const { t } = useTranslation();
return (
- <div className="flex flex-col gap-4">
- <h1 className="text-3xl font-bold">{t("settings.backups.page_title")}</h1>
- <p className="text-muted-foreground">
- {t("settings.backups.page_description")}
- </p>
+ <SettingsPage
+ title={t("settings.backups.page_title")}
+ description={t("settings.backups.page_description")}
+ >
<BackupSettings />
- </div>
+ </SettingsPage>
);
}
diff --git a/apps/web/app/settings/broken-links/page.tsx b/apps/web/app/settings/broken-links/page.tsx
index 4197d62e..35351918 100644
--- a/apps/web/app/settings/broken-links/page.tsx
+++ b/apps/web/app/settings/broken-links/page.tsx
@@ -1,5 +1,9 @@
"use client";
+import {
+ SettingsPage,
+ SettingsSection,
+} from "@/components/settings/SettingsPage";
import { ActionButton } from "@/components/ui/action-button";
import { FullPageSpinner } from "@/components/ui/full-page-spinner";
import { toast } from "@/components/ui/sonner";
@@ -64,16 +68,11 @@ export default function BrokenLinksPage() {
});
return (
- <div className="rounded-md border bg-background p-4">
- <div className="flex items-center justify-between">
- <div className="mb-2 text-lg font-medium">
- {t("settings.broken_links.broken_links")}
- </div>
- </div>
- <div className="mt-2">
+ <SettingsPage title={t("settings.broken_links.broken_links")}>
+ <SettingsSection>
{isPending && <FullPageSpinner />}
{!isPending && data && data.bookmarks.length == 0 && (
- <p className="rounded-md bg-muted p-2 text-sm text-muted-foreground">
+ <p className="rounded-md bg-muted p-3 text-center text-sm text-muted-foreground">
No broken links found
</p>
)}
@@ -131,7 +130,7 @@ export default function BrokenLinksPage() {
</TableBody>
</Table>
)}
- </div>
- </div>
+ </SettingsSection>
+ </SettingsPage>
);
}
diff --git a/apps/web/app/settings/info/page.tsx b/apps/web/app/settings/info/page.tsx
index da9b2e51..41b9c8c2 100644
--- a/apps/web/app/settings/info/page.tsx
+++ b/apps/web/app/settings/info/page.tsx
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { ChangePassword } from "@/components/settings/ChangePassword";
import { DeleteAccount } from "@/components/settings/DeleteAccount";
import ReaderSettings from "@/components/settings/ReaderSettings";
+import { SettingsPage } from "@/components/settings/SettingsPage";
import UserAvatar from "@/components/settings/UserAvatar";
import UserDetails from "@/components/settings/UserDetails";
import UserOptions from "@/components/settings/UserOptions";
@@ -16,14 +17,16 @@ export async function generateMetadata(): Promise<Metadata> {
}
export default async function InfoPage() {
+ // oxlint-disable-next-line rules-of-hooks
+ const { t } = await useTranslation();
return (
- <div className="flex flex-col gap-4">
+ <SettingsPage title={t("settings.info.user_info")}>
<UserAvatar />
<UserDetails />
<ChangePassword />
<UserOptions />
<ReaderSettings />
<DeleteAccount />
- </div>
+ </SettingsPage>
);
}
diff --git a/apps/web/app/settings/rules/page.tsx b/apps/web/app/settings/rules/page.tsx
index 2e739343..ca6a1b0f 100644
--- a/apps/web/app/settings/rules/page.tsx
+++ b/apps/web/app/settings/rules/page.tsx
@@ -3,6 +3,10 @@
import { useState } from "react";
import { RuleEditor } from "@/components/dashboard/rules/RuleEngineRuleEditor";
import RuleList from "@/components/dashboard/rules/RuleEngineRuleList";
+import {
+ SettingsPage,
+ SettingsSection,
+} from "@/components/settings/SettingsPage";
import { Button } from "@/components/ui/button";
import { FullPageSpinner } from "@/components/ui/full-page-spinner";
import { useTranslation } from "@/lib/i18n/client";
@@ -47,20 +51,17 @@ export default function RulesSettingsPage() {
};
return (
- <div className="rounded-md border bg-background p-4">
- <div className="flex flex-col gap-2">
- <div className="flex items-center justify-between">
- <span className="flex items-center gap-2 text-lg font-medium">
- {t("settings.rules.rules")}
- </span>
- <Button onClick={handleCreateRule} variant="default">
- <PlusCircle className="mr-2 h-4 w-4" />
- {t("settings.rules.ceate_rule")}
- </Button>
- </div>
- <p className="text-sm italic text-muted-foreground">
- {t("settings.rules.description")}
- </p>
+ <SettingsPage
+ title={t("settings.rules.rules")}
+ description={t("settings.rules.description")}
+ action={
+ <Button onClick={handleCreateRule} variant="default">
+ <PlusCircle className="mr-2 h-4 w-4" />
+ {t("settings.rules.ceate_rule")}
+ </Button>
+ }
+ >
+ <SettingsSection>
{!rules || isLoading ? (
<FullPageSpinner />
) : (
@@ -78,7 +79,7 @@ export default function RulesSettingsPage() {
/>
)}
</div>
- </div>
- </div>
+ </SettingsSection>
+ </SettingsPage>
);
}
diff --git a/apps/web/app/settings/stats/page.tsx b/apps/web/app/settings/stats/page.tsx
index a8896a03..9820e1ea 100644
--- a/apps/web/app/settings/stats/page.tsx
+++ b/apps/web/app/settings/stats/page.tsx
@@ -1,6 +1,7 @@
"use client";
import { useMemo } from "react";
+import { SettingsPage } from "@/components/settings/SettingsPage";
import { Badge } from "@/components/ui/badge";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Progress } from "@/components/ui/progress";
@@ -185,16 +186,10 @@ export default function StatsPage() {
if (isLoading) {
return (
- <div className="space-y-6">
- <div>
- <h1 className="text-3xl font-bold">
- {t("settings.stats.usage_statistics")}
- </h1>
- <p className="text-muted-foreground">
- {t("settings.stats.insights_description")}
- </p>
- </div>
-
+ <SettingsPage
+ title={t("settings.stats.usage_statistics")}
+ description={t("settings.stats.insights_description")}
+ >
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
{Array.from({ length: 8 }).map((_, i) => (
<Card key={i}>
@@ -208,7 +203,7 @@ export default function StatsPage() {
</Card>
))}
</div>
- </div>
+ </SettingsPage>
);
}
@@ -223,22 +218,10 @@ export default function StatsPage() {
}
return (
- <div className="space-y-6">
- <div className="flex items-start justify-between">
- <div>
- <h1 className="text-3xl font-bold">
- {t("settings.stats.usage_statistics")}
- </h1>
- <p className="text-muted-foreground">
- Insights into your bookmarking habits and collection
- {userSettings?.timezone && userSettings.timezone !== "UTC" && (
- <span className="block text-sm">
- Times shown in {userSettings.timezone} timezone
- </span>
- )}
- </p>
- </div>
- </div>
+ <SettingsPage
+ title={t("settings.stats.usage_statistics")}
+ description="Insights into your bookmarking habits and collection"
+ >
{/* Overview Stats */}
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
<StatCard
@@ -620,6 +603,6 @@ export default function StatsPage() {
</CardContent>
</Card>
)}
- </div>
+ </SettingsPage>
);
}
diff --git a/apps/web/app/settings/subscription/page.tsx b/apps/web/app/settings/subscription/page.tsx
index 5b06798e..ac2933cf 100644
--- a/apps/web/app/settings/subscription/page.tsx
+++ b/apps/web/app/settings/subscription/page.tsx
@@ -1,5 +1,6 @@
import type { Metadata } from "next";
import { redirect } from "next/navigation";
+import { SettingsPage } from "@/components/settings/SettingsPage";
import SubscriptionSettings from "@/components/settings/SubscriptionSettings";
import { QuotaProgress } from "@/components/subscription/QuotaProgress";
import { useTranslation } from "@/lib/i18n/server";
@@ -19,10 +20,13 @@ export default async function SubscriptionPage() {
redirect("/settings");
}
+ // oxlint-disable-next-line rules-of-hooks
+ const { t } = await useTranslation();
+
return (
- <div className="flex flex-col gap-4">
+ <SettingsPage title={t("settings.subscription.subscription")}>
<SubscriptionSettings />
<QuotaProgress />
- </div>
+ </SettingsPage>
);
}
diff --git a/apps/web/components/settings/AISettings.tsx b/apps/web/components/settings/AISettings.tsx
index 6d28f4f8..9606153f 100644
--- a/apps/web/components/settings/AISettings.tsx
+++ b/apps/web/components/settings/AISettings.tsx
@@ -4,13 +4,6 @@ import React from "react";
import { TagsEditor } from "@/components/dashboard/bookmarks/TagsEditor";
import { ActionButton } from "@/components/ui/action-button";
import { Badge } from "@/components/ui/badge";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
import {
Field,
FieldContent,
@@ -66,26 +59,7 @@ import {
} from "@karakeep/shared/types/prompts";
import { zUpdateUserSettingsSchema } from "@karakeep/shared/types/users";
-function SettingsSection({
- title,
- description,
- children,
-}: {
- title?: string;
- description?: string;
- children: React.ReactNode;
- className?: string;
-}) {
- return (
- <Card>
- <CardHeader>
- {title && <CardTitle>{title}</CardTitle>}
- {description && <CardDescription>{description}</CardDescription>}
- </CardHeader>
- <CardContent>{children}</CardContent>
- </Card>
- );
-}
+import { SettingsPage, SettingsSection } from "./SettingsPage";
export function AIPreferences() {
const { t } = useTranslation();
@@ -839,25 +813,12 @@ export function PromptDemo() {
export default function AISettings() {
const { t } = useTranslation();
return (
- <div className="space-y-6">
- <h2 className="text-3xl font-bold tracking-tight">
- {t("settings.ai.ai_settings")}
- </h2>
-
- {/* AI Preferences */}
+ <SettingsPage title={t("settings.ai.ai_settings")}>
<AIPreferences />
-
- {/* Tag Style */}
<TagStyleSelector />
-
- {/* Curated Tags */}
<CuratedTagsSelector />
-
- {/* Tagging Rules */}
<TaggingRules />
-
- {/* Prompt Preview */}
<PromptDemo />
- </div>
+ </SettingsPage>
);
}
diff --git a/apps/web/components/settings/ApiKeySettings.tsx b/apps/web/components/settings/ApiKeySettings.tsx
index fa8b4927..4e0f5dc3 100644
--- a/apps/web/components/settings/ApiKeySettings.tsx
+++ b/apps/web/components/settings/ApiKeySettings.tsx
@@ -10,60 +10,52 @@ import { useTranslation } from "@/lib/i18n/server";
import { api } from "@/server/api/client";
import { formatDistanceToNow } from "date-fns";
-import AddApiKey from "./AddApiKey";
import DeleteApiKey from "./DeleteApiKey";
import RegenerateApiKey from "./RegenerateApiKey";
+import { SettingsSection } from "./SettingsPage";
export default async function ApiKeys() {
// oxlint-disable-next-line rules-of-hooks
const { t } = await useTranslation();
const keys = await api.apiKeys.list();
return (
- <div>
- <div className="flex items-center justify-between">
- <div className="mb-2 text-lg font-medium">
- {t("settings.api_keys.api_keys")}
- </div>
- <AddApiKey />
- </div>
- <div className="mt-2">
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead>{t("common.name")}</TableHead>
- <TableHead>{t("common.key")}</TableHead>
- <TableHead>{t("common.created_at")}</TableHead>
- <TableHead>{t("common.last_used")}</TableHead>
- <TableHead>{t("common.action")}</TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {keys.keys.map((key) => {
- return (
- <TableRow key={key.id}>
- <TableCell>{key.name}</TableCell>
- <TableCell>**_{key.keyId}_**</TableCell>
- <TableCell>
- {formatDistanceToNow(key.createdAt, { addSuffix: true })}
- </TableCell>
- <TableCell>
- {key.lastUsedAt
- ? formatDistanceToNow(key.lastUsedAt, { addSuffix: true })
- : "—"}
- </TableCell>
- <TableCell>
- <div className="flex items-center gap-2">
- <RegenerateApiKey name={key.name} id={key.id} />
- <DeleteApiKey name={key.name} id={key.id} />
- </div>
- </TableCell>
- </TableRow>
- );
- })}
- <TableRow></TableRow>
- </TableBody>
- </Table>
- </div>
- </div>
+ <SettingsSection>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>{t("common.name")}</TableHead>
+ <TableHead>{t("common.key")}</TableHead>
+ <TableHead>{t("common.created_at")}</TableHead>
+ <TableHead>{t("common.last_used")}</TableHead>
+ <TableHead>{t("common.action")}</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {keys.keys.map((key) => {
+ return (
+ <TableRow key={key.id}>
+ <TableCell>{key.name}</TableCell>
+ <TableCell>**_{key.keyId}_**</TableCell>
+ <TableCell>
+ {formatDistanceToNow(key.createdAt, { addSuffix: true })}
+ </TableCell>
+ <TableCell>
+ {key.lastUsedAt
+ ? formatDistanceToNow(key.lastUsedAt, { addSuffix: true })
+ : "—"}
+ </TableCell>
+ <TableCell>
+ <div className="flex items-center gap-2">
+ <RegenerateApiKey name={key.name} id={key.id} />
+ <DeleteApiKey name={key.name} id={key.id} />
+ </div>
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ <TableRow></TableRow>
+ </TableBody>
+ </Table>
+ </SettingsSection>
);
}
diff --git a/apps/web/components/settings/BackupSettings.tsx b/apps/web/components/settings/BackupSettings.tsx
index 57672fb0..a4ad6a37 100644
--- a/apps/web/components/settings/BackupSettings.tsx
+++ b/apps/web/components/settings/BackupSettings.tsx
@@ -55,6 +55,7 @@ import {
TableRow,
} from "../ui/table";
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
+import { SettingsSection } from "./SettingsPage";
function BackupConfigurationForm() {
const { t } = useTranslation();
@@ -87,10 +88,7 @@ function BackupConfigurationForm() {
});
return (
- <div className="rounded-md border bg-background p-4">
- <h3 className="mb-4 text-lg font-medium">
- {t("settings.backups.configuration.title")}
- </h3>
+ <SettingsSection title={t("settings.backups.configuration.title")}>
<Form {...form}>
<form
className="space-y-4"
@@ -203,7 +201,7 @@ function BackupConfigurationForm() {
</ActionButton>
</form>
</Form>
- </div>
+ </SettingsSection>
);
}
@@ -366,65 +364,59 @@ function BackupsList() {
);
return (
- <div className="rounded-md border bg-background p-4">
- <div className="flex flex-col gap-2">
- <div className="flex items-center justify-between">
- <span className="text-lg font-medium">
- {t("settings.backups.list.title")}
- </span>
- <ActionButton
- onClick={() => triggerBackup()}
- loading={isTriggering}
- variant="default"
- className="items-center"
- >
- <Play className="mr-2 size-4" />
- {t("settings.backups.list.create_backup_now")}
- </ActionButton>
- </div>
-
- {isLoading && <FullPageSpinner />}
+ <SettingsSection
+ title={t("settings.backups.list.title")}
+ action={
+ <ActionButton
+ onClick={() => triggerBackup()}
+ loading={isTriggering}
+ variant="default"
+ className="items-center"
+ >
+ <Play className="mr-2 size-4" />
+ {t("settings.backups.list.create_backup_now")}
+ </ActionButton>
+ }
+ >
+ {isLoading && <FullPageSpinner />}
- {backups && backups.backups.length === 0 && (
- <p className="rounded-md bg-muted p-2 text-sm text-muted-foreground">
- {t("settings.backups.list.no_backups")}
- </p>
- )}
+ {backups && backups.backups.length === 0 && (
+ <p className="rounded-md bg-muted p-3 text-center text-sm text-muted-foreground">
+ {t("settings.backups.list.no_backups")}
+ </p>
+ )}
- {backups && backups.backups.length > 0 && (
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead>
- {t("settings.backups.list.table.created_at")}
- </TableHead>
- <TableHead>
- {t("settings.backups.list.table.bookmarks")}
- </TableHead>
- <TableHead>{t("settings.backups.list.table.size")}</TableHead>
- <TableHead>{t("settings.backups.list.table.status")}</TableHead>
- <TableHead>
- {t("settings.backups.list.table.actions")}
- </TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {backups.backups.map((backup) => (
- <BackupRow key={backup.id} backup={backup} />
- ))}
- </TableBody>
- </Table>
- )}
- </div>
- </div>
+ {backups && backups.backups.length > 0 && (
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>
+ {t("settings.backups.list.table.created_at")}
+ </TableHead>
+ <TableHead>
+ {t("settings.backups.list.table.bookmarks")}
+ </TableHead>
+ <TableHead>{t("settings.backups.list.table.size")}</TableHead>
+ <TableHead>{t("settings.backups.list.table.status")}</TableHead>
+ <TableHead>{t("settings.backups.list.table.actions")}</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {backups.backups.map((backup) => (
+ <BackupRow key={backup.id} backup={backup} />
+ ))}
+ </TableBody>
+ </Table>
+ )}
+ </SettingsSection>
);
}
export default function BackupSettings() {
return (
- <div className="space-y-6">
+ <>
<BackupConfigurationForm />
<BackupsList />
- </div>
+ </>
);
}
diff --git a/apps/web/components/settings/ChangePassword.tsx b/apps/web/components/settings/ChangePassword.tsx
index 481d4b95..5111295c 100644
--- a/apps/web/components/settings/ChangePassword.tsx
+++ b/apps/web/components/settings/ChangePassword.tsx
@@ -16,14 +16,14 @@ import { toast } from "@/components/ui/sonner";
import { useTranslation } from "@/lib/i18n/client";
import { zodResolver } from "@hookform/resolvers/zod";
import { useMutation } from "@tanstack/react-query";
-import { Eye, EyeOff, Lock } from "lucide-react";
+import { Eye, EyeOff } from "lucide-react";
import { useForm } from "react-hook-form";
import { useTRPC } from "@karakeep/shared-react/trpc";
import { zChangePasswordSchema } from "@karakeep/shared/types/users";
import { Button } from "../ui/button";
-import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
+import { SettingsSection } from "./SettingsPage";
export function ChangePassword() {
const api = useTRPC();
@@ -70,33 +70,67 @@ export function ChangePassword() {
}
return (
- <Card>
- <CardHeader>
- <CardTitle className="flex items-center gap-2 text-xl">
- <Lock className="h-5 w-5" />
- Security
- </CardTitle>
- </CardHeader>
- <CardContent className="space-y-6">
- <Form {...form}>
- <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
+ <SettingsSection title="Security">
+ <Form {...form}>
+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
+ <FormField
+ control={form.control}
+ name="currentPassword"
+ render={({ field }) => (
+ <FormItem className="space-y-2">
+ <FormLabel
+ htmlFor="current-password"
+ className="text-sm font-medium"
+ >
+ {t("settings.info.current_password")}
+ </FormLabel>
+ <div className="relative">
+ <FormControl>
+ <Input
+ id="current-password"
+ type={showCurrentPassword ? "text" : "password"}
+ placeholder={t("settings.info.current_password")}
+ className="h-11 pr-10"
+ {...field}
+ />
+ </FormControl>
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ className="absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent"
+ onClick={() => setShowCurrentPassword(!showCurrentPassword)}
+ >
+ {showCurrentPassword ? (
+ <EyeOff className="h-4 w-4" />
+ ) : (
+ <Eye className="h-4 w-4" />
+ )}
+ </Button>
+ </div>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ <div className="grid gap-4 md:grid-cols-2">
<FormField
control={form.control}
- name="currentPassword"
+ name="newPassword"
render={({ field }) => (
<FormItem className="space-y-2">
<FormLabel
- htmlFor="current-password"
+ htmlFor="new-password"
className="text-sm font-medium"
>
- {t("settings.info.current_password")}
+ {t("settings.info.new_password")}
</FormLabel>
<div className="relative">
<FormControl>
<Input
- id="current-password"
- type={showCurrentPassword ? "text" : "password"}
- placeholder={t("settings.info.current_password")}
+ id="new-password"
+ type={showNewPassword ? "text" : "password"}
+ placeholder={t("settings.info.new_password")}
className="h-11 pr-10"
{...field}
/>
@@ -106,11 +140,9 @@ export function ChangePassword() {
variant="ghost"
size="sm"
className="absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent"
- onClick={() =>
- setShowCurrentPassword(!showCurrentPassword)
- }
+ onClick={() => setShowNewPassword(!showNewPassword)}
>
- {showCurrentPassword ? (
+ {showNewPassword ? (
<EyeOff className="h-4 w-4" />
) : (
<Eye className="h-4 w-4" />
@@ -122,98 +154,56 @@ export function ChangePassword() {
)}
/>
- <div className="grid gap-4 md:grid-cols-2">
- <FormField
- control={form.control}
- name="newPassword"
- render={({ field }) => (
- <FormItem className="space-y-2">
- <FormLabel
- htmlFor="new-password"
- className="text-sm font-medium"
- >
- {t("settings.info.new_password")}
- </FormLabel>
- <div className="relative">
- <FormControl>
- <Input
- id="new-password"
- type={showNewPassword ? "text" : "password"}
- placeholder={t("settings.info.new_password")}
- className="h-11 pr-10"
- {...field}
- />
- </FormControl>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- className="absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent"
- onClick={() => setShowNewPassword(!showNewPassword)}
- >
- {showNewPassword ? (
- <EyeOff className="h-4 w-4" />
- ) : (
- <Eye className="h-4 w-4" />
- )}
- </Button>
- </div>
- <FormMessage />
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="newPasswordConfirm"
- render={({ field }) => (
- <FormItem className="space-y-2">
- <FormLabel
- htmlFor="confirm-password"
- className="text-sm font-medium"
+ <FormField
+ control={form.control}
+ name="newPasswordConfirm"
+ render={({ field }) => (
+ <FormItem className="space-y-2">
+ <FormLabel
+ htmlFor="confirm-password"
+ className="text-sm font-medium"
+ >
+ {t("settings.info.confirm_new_password")}
+ </FormLabel>
+ <div className="relative">
+ <FormControl>
+ <Input
+ id="confirm-password"
+ type={showConfirmPassword ? "text" : "password"}
+ placeholder={t("settings.info.confirm_new_password")}
+ className="h-11 pr-10"
+ {...field}
+ />
+ </FormControl>
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ className="absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent"
+ onClick={() =>
+ setShowConfirmPassword(!showConfirmPassword)
+ }
>
- {t("settings.info.confirm_new_password")}
- </FormLabel>
- <div className="relative">
- <FormControl>
- <Input
- id="confirm-password"
- type={showConfirmPassword ? "text" : "password"}
- placeholder={t("settings.info.confirm_new_password")}
- className="h-11 pr-10"
- {...field}
- />
- </FormControl>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- className="absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent"
- onClick={() =>
- setShowConfirmPassword(!showConfirmPassword)
- }
- >
- {showConfirmPassword ? (
- <EyeOff className="h-4 w-4" />
- ) : (
- <Eye className="h-4 w-4" />
- )}
- </Button>
- </div>
- <FormMessage />
- </FormItem>
- )}
- />
- </div>
+ {showConfirmPassword ? (
+ <EyeOff className="h-4 w-4" />
+ ) : (
+ <Eye className="h-4 w-4" />
+ )}
+ </Button>
+ </div>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
- <div className="flex justify-end">
- <ActionButton type="submit" loading={mutator.isPending}>
- {t("actions.save")}
- </ActionButton>
- </div>
- </form>
- </Form>
- </CardContent>
- </Card>
+ <div className="flex justify-end">
+ <ActionButton type="submit" loading={mutator.isPending}>
+ {t("actions.save")}
+ </ActionButton>
+ </div>
+ </form>
+ </Form>
+ </SettingsSection>
);
}
diff --git a/apps/web/components/settings/DeleteAccount.tsx b/apps/web/components/settings/DeleteAccount.tsx
index 5ccbfaf7..bbe61ca3 100644
--- a/apps/web/components/settings/DeleteAccount.tsx
+++ b/apps/web/components/settings/DeleteAccount.tsx
@@ -25,7 +25,7 @@ import {
} from "@karakeep/shared-react/hooks/users";
import { Button } from "../ui/button";
-import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
+import { SettingsSection } from "./SettingsPage";
const createDeleteAccountSchema = (isLocalUser: boolean) =>
z.object({
@@ -79,104 +79,96 @@ export function DeleteAccount() {
};
return (
- <Card className="border-destructive/20">
- <CardHeader>
- <CardTitle className="flex items-center gap-2 text-xl text-destructive">
- <AlertTriangle className="h-5 w-5" />
- Danger Zone
- </CardTitle>
- </CardHeader>
- <CardContent className="space-y-4">
- <div className="space-y-2">
- <h3 className="text-lg font-medium">Delete Account</h3>
- <p className="text-sm text-muted-foreground">
- Permanently delete your account and all associated data. This action
- cannot be undone.
- </p>
- </div>
+ <SettingsSection title="Danger Zone" variant="danger">
+ <div className="space-y-2">
+ <h3 className="text-lg font-medium">Delete Account</h3>
+ <p className="text-sm text-muted-foreground">
+ Permanently delete your account and all associated data. This action
+ cannot be undone.
+ </p>
+ </div>
- <ActionConfirmingDialog
- open={isDialogOpen}
- setOpen={setIsDialogOpen}
- title="Delete Account"
- description={
- <div className="space-y-4">
- <div className="flex items-start gap-3 rounded-lg border border-destructive/20 bg-destructive/5 p-4">
- <AlertTriangle className="mt-0.5 h-5 w-5 flex-shrink-0 text-destructive" />
- <div className="space-y-2">
- <p className="font-medium text-destructive">
- This action is irreversible
- </p>
- <p className="text-sm text-muted-foreground">
- All your bookmarks, lists, tags, highlights, and other data
- will be permanently deleted. This cannot be undone.
- </p>
- </div>
+ <ActionConfirmingDialog
+ open={isDialogOpen}
+ setOpen={setIsDialogOpen}
+ title="Delete Account"
+ description={
+ <div className="space-y-4">
+ <div className="flex items-start gap-3 rounded-lg border border-destructive/20 bg-destructive/5 p-4">
+ <AlertTriangle className="mt-0.5 h-5 w-5 flex-shrink-0 text-destructive" />
+ <div className="space-y-2">
+ <p className="font-medium text-destructive">
+ This action is irreversible
+ </p>
+ <p className="text-sm text-muted-foreground">
+ All your bookmarks, lists, tags, highlights, and other data
+ will be permanently deleted. This cannot be undone.
+ </p>
</div>
-
- <Form {...form}>
- <form
- onSubmit={form.handleSubmit(onSubmit)}
- className="space-y-4"
- >
- {isLocalUser && (
- <FormField
- control={form.control}
- name="password"
- render={({ field }) => (
- <FormItem>
- <FormLabel>
- Enter your password to confirm deletion
- </FormLabel>
- <div className="relative">
- <FormControl>
- <Input
- type={showPassword ? "text" : "password"}
- placeholder="Enter your password"
- className="pr-10"
- {...field}
- />
- </FormControl>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- className="absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent"
- onClick={() => setShowPassword(!showPassword)}
- >
- {showPassword ? (
- <EyeOff className="h-4 w-4" />
- ) : (
- <Eye className="h-4 w-4" />
- )}
- </Button>
- </div>
- <FormMessage />
- </FormItem>
- )}
- />
- )}
- </form>
- </Form>
</div>
- }
- actionButton={() => (
- <ActionButton
- variant="destructive"
- loading={deleteAccountMutation.isPending}
- onClick={form.handleSubmit(onSubmit)}
- >
- <Trash2 className="mr-2 h-4 w-4" />
- Delete Account
- </ActionButton>
- )}
- >
- <Button variant="destructive" className="w-full">
+
+ <Form {...form}>
+ <form
+ onSubmit={form.handleSubmit(onSubmit)}
+ className="space-y-4"
+ >
+ {isLocalUser && (
+ <FormField
+ control={form.control}
+ name="password"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>
+ Enter your password to confirm deletion
+ </FormLabel>
+ <div className="relative">
+ <FormControl>
+ <Input
+ type={showPassword ? "text" : "password"}
+ placeholder="Enter your password"
+ className="pr-10"
+ {...field}
+ />
+ </FormControl>
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ className="absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent"
+ onClick={() => setShowPassword(!showPassword)}
+ >
+ {showPassword ? (
+ <EyeOff className="h-4 w-4" />
+ ) : (
+ <Eye className="h-4 w-4" />
+ )}
+ </Button>
+ </div>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ )}
+ </form>
+ </Form>
+ </div>
+ }
+ actionButton={() => (
+ <ActionButton
+ variant="destructive"
+ loading={deleteAccountMutation.isPending}
+ onClick={form.handleSubmit(onSubmit)}
+ >
<Trash2 className="mr-2 h-4 w-4" />
Delete Account
- </Button>
- </ActionConfirmingDialog>
- </CardContent>
- </Card>
+ </ActionButton>
+ )}
+ >
+ <Button variant="destructive" className="w-full">
+ <Trash2 className="mr-2 h-4 w-4" />
+ Delete Account
+ </Button>
+ </ActionConfirmingDialog>
+ </SettingsSection>
);
}
diff --git a/apps/web/components/settings/FeedSettings.tsx b/apps/web/components/settings/FeedSettings.tsx
index ba1568a7..d8ba7f88 100644
--- a/apps/web/components/settings/FeedSettings.tsx
+++ b/apps/web/components/settings/FeedSettings.tsx
@@ -60,6 +60,7 @@ import {
TableRow,
} from "../ui/table";
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
+import { SettingsPage, SettingsSection } from "./SettingsPage";
export function FeedsEditorDialog() {
const api = useTRPC();
@@ -470,41 +471,36 @@ export default function FeedSettings() {
const { t } = useTranslation();
const { data: feeds, isLoading } = useQuery(api.feeds.list.queryOptions());
return (
- <>
- <div className="rounded-md border bg-background p-4">
- <div className="flex flex-col gap-2">
- <div className="flex items-center justify-between">
- <span className="flex items-center gap-2 text-lg font-medium">
- {t("settings.feeds.rss_subscriptions")}
- </span>
- <FeedsEditorDialog />
- </div>
- {isLoading && <FullPageSpinner />}
- {feeds && feeds.feeds.length == 0 && (
- <p className="rounded-md bg-muted p-2 text-sm text-muted-foreground">
- You don&apos;t have any RSS subscriptions yet.
- </p>
- )}
- {feeds && feeds.feeds.length > 0 && (
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead>{t("common.name")}</TableHead>
- <TableHead>{t("common.url")}</TableHead>
- <TableHead>Last Fetch</TableHead>
- <TableHead>Last Status</TableHead>
- <TableHead>{t("common.actions")}</TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {feeds.feeds.map((feed) => (
- <FeedRow key={feed.id} feed={feed} />
- ))}
- </TableBody>
- </Table>
- )}
- </div>
- </div>
- </>
+ <SettingsPage
+ title={t("settings.feeds.rss_subscriptions")}
+ action={<FeedsEditorDialog />}
+ >
+ <SettingsSection>
+ {isLoading && <FullPageSpinner />}
+ {feeds && feeds.feeds.length == 0 && (
+ <p className="rounded-md bg-muted p-3 text-center text-sm text-muted-foreground">
+ You don&apos;t have any RSS subscriptions yet.
+ </p>
+ )}
+ {feeds && feeds.feeds.length > 0 && (
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>{t("common.name")}</TableHead>
+ <TableHead>{t("common.url")}</TableHead>
+ <TableHead>Last Fetch</TableHead>
+ <TableHead>Last Status</TableHead>
+ <TableHead>{t("common.actions")}</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {feeds.feeds.map((feed) => (
+ <FeedRow key={feed.id} feed={feed} />
+ ))}
+ </TableBody>
+ </Table>
+ )}
+ </SettingsSection>
+ </SettingsPage>
);
}
diff --git a/apps/web/components/settings/ImportExport.tsx b/apps/web/components/settings/ImportExport.tsx
index e02297c9..59b10d82 100644
--- a/apps/web/components/settings/ImportExport.tsx
+++ b/apps/web/components/settings/ImportExport.tsx
@@ -21,6 +21,7 @@ import { AlertCircle, Download, Loader2, Upload } from "lucide-react";
import { Card, CardContent } from "../ui/card";
import { ImportSessionsSection } from "./ImportSessionsSection";
+import { SettingsPage, SettingsSection } from "./SettingsPage";
function ImportCard({
text,
@@ -329,21 +330,12 @@ export function ImportExportRow() {
export default function ImportExport() {
const { t } = useTranslation();
return (
- <div className="space-y-3">
- <div className="rounded-md border bg-background p-4">
- <div className="flex w-full flex-col gap-6">
- <div>
- <p className="mb-4 text-lg font-medium">
- {t("settings.import.import_export_bookmarks")}
- </p>
- <ImportExportRow />
- </div>
- </div>
- </div>
+ <SettingsPage title={t("settings.import.import_export")}>
+ <SettingsSection title={t("settings.import.import_export_bookmarks")}>
+ <ImportExportRow />
+ </SettingsSection>
- <div className="rounded-md border bg-background p-4">
- <ImportSessionsSection />
- </div>
- </div>
+ <ImportSessionsSection />
+ </SettingsPage>
);
}
diff --git a/apps/web/components/settings/ImportSessionsSection.tsx b/apps/web/components/settings/ImportSessionsSection.tsx
index 38f248d2..661b27d6 100644
--- a/apps/web/components/settings/ImportSessionsSection.tsx
+++ b/apps/web/components/settings/ImportSessionsSection.tsx
@@ -7,6 +7,7 @@ import { Package } from "lucide-react";
import { FullPageSpinner } from "../ui/full-page-spinner";
import { ImportSessionCard } from "./ImportSessionCard";
+import { SettingsSection } from "./SettingsPage";
export function ImportSessionsSection() {
const { t } = useTranslation();
@@ -14,25 +15,21 @@ export function ImportSessionsSection() {
if (isLoading) {
return (
- <div className="flex w-full flex-col gap-4">
- <div className="flex items-center justify-between">
- <h3 className="text-lg font-medium">
- {t("settings.import_sessions.title")}
- </h3>
- </div>
+ <SettingsSection
+ title={t("settings.import_sessions.title")}
+ description={t("settings.import_sessions.description")}
+ >
<FullPageSpinner />
- </div>
+ </SettingsSection>
);
}
if (error) {
return (
- <div className="flex w-full flex-col gap-4">
- <div className="flex items-center justify-between">
- <h3 className="text-lg font-medium">
- {t("settings.import_sessions.title")}
- </h3>
- </div>
+ <SettingsSection
+ title={t("settings.import_sessions.title")}
+ description={t("settings.import_sessions.description")}
+ >
<Card>
<CardContent className="flex items-center justify-center py-8">
<p className="text-gray-600">
@@ -40,21 +37,15 @@ export function ImportSessionsSection() {
</p>
</CardContent>
</Card>
- </div>
+ </SettingsSection>
);
}
return (
- <div className="flex w-full flex-col gap-4">
- <div>
- <h3 className="text-lg font-medium">
- {t("settings.import_sessions.title")}
- </h3>
- <p className="mt-1 text-sm text-accent-foreground">
- {t("settings.import_sessions.description")}
- </p>
- </div>
-
+ <SettingsSection
+ title={t("settings.import_sessions.title")}
+ description={t("settings.import_sessions.description")}
+ >
{sessions && sessions.length > 0 ? (
<div className="space-y-4">
{sessions.map((session) => (
@@ -74,6 +65,6 @@ export function ImportSessionsSection() {
</CardContent>
</Card>
)}
- </div>
+ </SettingsSection>
);
}
diff --git a/apps/web/components/settings/ReaderSettings.tsx b/apps/web/components/settings/ReaderSettings.tsx
index d694bf02..e36da2a4 100644
--- a/apps/web/components/settings/ReaderSettings.tsx
+++ b/apps/web/components/settings/ReaderSettings.tsx
@@ -5,13 +5,7 @@ import { toast } from "@/components/ui/sonner";
import { useClientConfig } from "@/lib/clientConfig";
import { useTranslation } from "@/lib/i18n/client";
import { useReaderSettings } from "@/lib/readerSettings";
-import {
- AlertTriangle,
- BookOpen,
- ChevronDown,
- Laptop,
- RotateCcw,
-} from "lucide-react";
+import { AlertTriangle, ChevronDown, Laptop, RotateCcw } from "lucide-react";
import {
formatFontSize,
@@ -111,8 +105,7 @@ export default function ReaderSettings() {
<CardHeader>
<CollapsibleTrigger className="flex w-full items-center justify-between [&[data-state=open]>svg]:rotate-180">
<div className="flex flex-col items-start gap-1 text-left">
- <CardTitle className="flex items-center gap-2 text-xl">
- <BookOpen className="h-5 w-5" />
+ <CardTitle className="text-lg">
{t("settings.info.reader_settings.title")}
</CardTitle>
<CardDescription>
diff --git a/apps/web/components/settings/SettingsPage.tsx b/apps/web/components/settings/SettingsPage.tsx
new file mode 100644
index 00000000..f34aeb46
--- /dev/null
+++ b/apps/web/components/settings/SettingsPage.tsx
@@ -0,0 +1,82 @@
+import { cn } from "@/lib/utils";
+
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+} from "../ui/card";
+
+export function SettingsPage({
+ title,
+ description,
+ action,
+ children,
+}: {
+ title: string;
+ description?: string;
+ action?: React.ReactNode;
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="space-y-5">
+ <div className="flex items-center justify-between gap-4">
+ <div>
+ <h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
+ {description && (
+ <p className="mt-1 text-sm text-muted-foreground">{description}</p>
+ )}
+ </div>
+ {action && <div className="shrink-0">{action}</div>}
+ </div>
+ {children}
+ </div>
+ );
+}
+
+export function SettingsSection({
+ title,
+ description,
+ action,
+ children,
+ variant = "default",
+}: {
+ title?: string;
+ description?: string;
+ action?: React.ReactNode;
+ children: React.ReactNode;
+ variant?: "default" | "danger";
+}) {
+ return (
+ <Card
+ className={variant === "danger" ? "border-destructive/20" : undefined}
+ >
+ {(title || description || action) && (
+ <CardHeader>
+ <div className="flex items-center justify-between gap-4">
+ <div className="space-y-1">
+ {title && (
+ <CardTitle
+ className={cn(
+ "text-lg",
+ variant === "danger" && "text-destructive",
+ )}
+ >
+ {title}
+ </CardTitle>
+ )}
+ {description && <CardDescription>{description}</CardDescription>}
+ </div>
+ {action && <div className="shrink-0">{action}</div>}
+ </div>
+ </CardHeader>
+ )}
+ <CardContent
+ className={cn("space-y-4", !(title || description || action) && "pt-6")}
+ >
+ {children}
+ </CardContent>
+ </Card>
+ );
+}
diff --git a/apps/web/components/settings/SubscriptionSettings.tsx b/apps/web/components/settings/SubscriptionSettings.tsx
index 12797aac..43c88208 100644
--- a/apps/web/components/settings/SubscriptionSettings.tsx
+++ b/apps/web/components/settings/SubscriptionSettings.tsx
@@ -4,21 +4,15 @@ import { useEffect } from "react";
import { toast } from "@/components/ui/sonner";
import { useTranslation } from "@/lib/i18n/client";
import { useMutation, useQuery } from "@tanstack/react-query";
-import { CreditCard, Loader2 } from "lucide-react";
+import { Loader2 } from "lucide-react";
import { useTRPC } from "@karakeep/shared-react/trpc";
import { Alert, AlertDescription } from "../ui/alert";
import { Badge } from "../ui/badge";
import { Button } from "../ui/button";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "../ui/card";
import { Skeleton } from "../ui/skeleton";
+import { SettingsSection } from "./SettingsPage";
export default function SubscriptionSettings() {
const api = useTRPC();
@@ -103,142 +97,134 @@ export default function SubscriptionSettings() {
};
return (
- <Card>
- <CardHeader>
- <CardTitle className="flex items-center gap-2">
- <CreditCard className="h-5 w-5" />
- {t("settings.subscription.subscription")}
- </CardTitle>
- <CardDescription>
- {t("settings.subscription.manage_subscription")}
- </CardDescription>
- </CardHeader>
- <CardContent className="space-y-6">
- {isQueryLoading ? (
- <div className="space-y-6">
- <div className="grid gap-4 md:grid-cols-2">
- <div className="space-y-2">
- <Skeleton className="h-4 w-24" />
- <div className="flex items-center gap-2">
- <Skeleton className="h-5 w-16" />
- <Skeleton className="h-5 w-12" />
- </div>
- </div>
- <div className="space-y-2">
- <Skeleton className="h-4 w-28" />
- <Skeleton className="h-4 w-40" />
+ <SettingsSection
+ title={t("settings.subscription.subscription")}
+ description={t("settings.subscription.manage_subscription")}
+ >
+ {isQueryLoading ? (
+ <div className="space-y-6">
+ <div className="grid gap-4 md:grid-cols-2">
+ <div className="space-y-2">
+ <Skeleton className="h-4 w-24" />
+ <div className="flex items-center gap-2">
+ <Skeleton className="h-5 w-16" />
+ <Skeleton className="h-5 w-12" />
</div>
</div>
- <div className="space-y-4">
- <div className="rounded-lg border p-4">
- <div className="flex items-center justify-between">
- <div className="space-y-2">
- <Skeleton className="h-6 w-24" />
- <Skeleton className="h-4 w-64" />
- <Skeleton className="h-6 w-20" />
- </div>
- <Skeleton className="h-10 w-32" />
+ <div className="space-y-2">
+ <Skeleton className="h-4 w-28" />
+ <Skeleton className="h-4 w-40" />
+ </div>
+ </div>
+ <div className="space-y-4">
+ <div className="rounded-lg border p-4">
+ <div className="flex items-center justify-between">
+ <div className="space-y-2">
+ <Skeleton className="h-6 w-24" />
+ <Skeleton className="h-4 w-64" />
+ <Skeleton className="h-6 w-20" />
</div>
+ <Skeleton className="h-10 w-32" />
</div>
</div>
</div>
- ) : (
- <>
- <div className="grid gap-4 md:grid-cols-2">
- <div className="space-y-2">
- <label className="text-sm font-medium">
- {t("settings.subscription.current_plan")}
- </label>
- <div className="flex items-center gap-2">
- {subscriptionStatus?.tier &&
- getStatusBadge(subscriptionStatus.tier)}
- </div>
+ </div>
+ ) : (
+ <>
+ <div className="grid gap-4 md:grid-cols-2">
+ <div className="space-y-2">
+ <label className="text-sm font-medium">
+ {t("settings.subscription.current_plan")}
+ </label>
+ <div className="flex items-center gap-2">
+ {subscriptionStatus?.tier &&
+ getStatusBadge(subscriptionStatus.tier)}
</div>
+ </div>
- {subscriptionStatus?.hasActiveSubscription && (
- <>
- <div className="space-y-2">
- <label className="text-sm font-medium">
- {t("settings.subscription.billing_period")}
- </label>
- <div className="text-sm text-muted-foreground">
- {formatDate(subscriptionStatus.startDate)} -{" "}
- {formatDate(subscriptionStatus.endDate)}
- </div>
+ {subscriptionStatus?.hasActiveSubscription && (
+ <>
+ <div className="space-y-2">
+ <label className="text-sm font-medium">
+ {t("settings.subscription.billing_period")}
+ </label>
+ <div className="text-sm text-muted-foreground">
+ {formatDate(subscriptionStatus.startDate)} -{" "}
+ {formatDate(subscriptionStatus.endDate)}
</div>
- </>
- )}
- </div>
+ </div>
+ </>
+ )}
+ </div>
- <div className="space-y-4">
- {!subscriptionStatus?.hasActiveSubscription ? (
- <div className="space-y-4">
- <div className="rounded-lg border p-4">
- <div className="flex items-center justify-between">
- <div>
- <h3 className="flex items-center gap-2 font-semibold">
- {t("settings.subscription.paid_plan")}
- </h3>
- <p className="text-sm text-muted-foreground">
- {t("settings.subscription.unlock_bigger_quota")}
- </p>
- {subscriptionPrice && subscriptionPrice.amount ? (
- <span className="flex items-baseline gap-2">
- <p className="mt-2 text-lg font-bold uppercase">
- {subscriptionPrice.amount / 100}{" "}
- {subscriptionPrice.currency}
- </p>
- <span className="text-xs italic text-muted-foreground">
- (excl. VAT)
- </span>
+ <div className="space-y-4">
+ {!subscriptionStatus?.hasActiveSubscription ? (
+ <div className="space-y-4">
+ <div className="rounded-lg border p-4">
+ <div className="flex items-center justify-between">
+ <div>
+ <h3 className="flex items-center gap-2 font-semibold">
+ {t("settings.subscription.paid_plan")}
+ </h3>
+ <p className="text-sm text-muted-foreground">
+ {t("settings.subscription.unlock_bigger_quota")}
+ </p>
+ {subscriptionPrice && subscriptionPrice.amount ? (
+ <span className="flex items-baseline gap-2">
+ <p className="mt-2 text-lg font-bold uppercase">
+ {subscriptionPrice.amount / 100}{" "}
+ {subscriptionPrice.currency}
+ </p>
+ <span className="text-xs italic text-muted-foreground">
+ (excl. VAT)
</span>
- ) : (
- <Skeleton className="h-4 w-24" />
- )}
- </div>
- <Button
- onClick={() => createCheckoutSession.mutate()}
- disabled={isLoading}
- className="bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700"
- >
- {isLoading && (
- <Loader2 className="mr-2 h-4 w-4 animate-spin" />
- )}
- {t("settings.subscription.subscribe_now")}
- </Button>
+ </span>
+ ) : (
+ <Skeleton className="h-4 w-24" />
+ )}
</div>
- </div>
- </div>
- ) : (
- <div className="space-y-4">
- <div className="flex gap-2">
<Button
- onClick={() => createPortalSession.mutate()}
+ onClick={() => createCheckoutSession.mutate()}
disabled={isLoading}
- variant="outline"
+ className="bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700"
>
{isLoading && (
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
)}
- {t("settings.subscription.manage_billing")}
+ {t("settings.subscription.subscribe_now")}
</Button>
</div>
-
- {subscriptionStatus.cancelAtPeriodEnd && (
- <Alert>
- <AlertDescription>
- {t("settings.subscription.subscription_canceled", {
- date: formatDate(subscriptionStatus.endDate),
- })}
- </AlertDescription>
- </Alert>
- )}
</div>
- )}
- </div>
- </>
- )}
- </CardContent>
- </Card>
+ </div>
+ ) : (
+ <div className="space-y-4">
+ <div className="flex gap-2">
+ <Button
+ onClick={() => createPortalSession.mutate()}
+ disabled={isLoading}
+ variant="outline"
+ >
+ {isLoading && (
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
+ )}
+ {t("settings.subscription.manage_billing")}
+ </Button>
+ </div>
+
+ {subscriptionStatus.cancelAtPeriodEnd && (
+ <Alert>
+ <AlertDescription>
+ {t("settings.subscription.subscription_canceled", {
+ date: formatDate(subscriptionStatus.endDate),
+ })}
+ </AlertDescription>
+ </Alert>
+ )}
+ </div>
+ )}
+ </div>
+ </>
+ )}
+ </SettingsSection>
);
}
diff --git a/apps/web/components/settings/UserAvatar.tsx b/apps/web/components/settings/UserAvatar.tsx
index 6baff7c2..410850fb 100644
--- a/apps/web/components/settings/UserAvatar.tsx
+++ b/apps/web/components/settings/UserAvatar.tsx
@@ -8,7 +8,7 @@ import { toast } from "@/components/ui/sonner";
import { UserAvatar as UserAvatarImage } from "@/components/ui/user-avatar";
import useUpload from "@/lib/hooks/upload-file";
import { useTranslation } from "@/lib/i18n/client";
-import { Image as ImageIcon, Upload, User, X } from "lucide-react";
+import { Upload, User, X } from "lucide-react";
import {
useUpdateUserAvatar,
@@ -16,7 +16,7 @@ import {
} from "@karakeep/shared-react/hooks/users";
import { Button } from "../ui/button";
-import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
+import { SettingsSection } from "./SettingsPage";
export default function UserAvatar() {
const { t } = useTranslation();
@@ -68,82 +68,74 @@ export default function UserAvatar() {
};
return (
- <Card>
- <CardHeader>
- <CardTitle className="flex items-center gap-2 text-xl">
- <ImageIcon className="h-5 w-5" />
- {t("settings.info.avatar.title")}
- </CardTitle>
- </CardHeader>
- <CardContent className="space-y-4">
- <p className="text-sm text-muted-foreground">
- {t("settings.info.avatar.description")}
- </p>
- <div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
- <div className="flex items-center gap-4">
- <div className="flex size-16 items-center justify-center overflow-hidden rounded-full border bg-muted">
- <UserAvatarImage
- image={image}
- name={t("settings.info.avatar.title")}
- fallback={<User className="h-7 w-7 text-muted-foreground" />}
- className="h-full w-full"
- />
- </div>
- <input
- ref={fileInputRef}
- type="file"
- accept="image/*"
- className="hidden"
- onChange={handleFileChange}
+ <SettingsSection
+ title={t("settings.info.avatar.title")}
+ description={t("settings.info.avatar.description")}
+ >
+ <div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
+ <div className="flex items-center gap-4">
+ <div className="flex size-16 items-center justify-center overflow-hidden rounded-full border bg-muted">
+ <UserAvatarImage
+ image={image}
+ name={t("settings.info.avatar.title")}
+ fallback={<User className="h-7 w-7 text-muted-foreground" />}
+ className="h-full w-full"
/>
+ </div>
+ <input
+ ref={fileInputRef}
+ type="file"
+ accept="image/*"
+ className="hidden"
+ onChange={handleFileChange}
+ />
+ <ActionButton
+ type="button"
+ variant="secondary"
+ onClick={handleSelectFile}
+ loading={upload.isPending}
+ disabled={isBusy}
+ >
+ <Upload className="mr-2 h-4 w-4" />
+ {image
+ ? t("settings.info.avatar.change")
+ : t("settings.info.avatar.upload")}
+ </ActionButton>
+ </div>
+ <ActionConfirmingDialog
+ title={t("settings.info.avatar.remove_confirm_title")}
+ description={
+ <p>{t("settings.info.avatar.remove_confirm_description")}</p>
+ }
+ actionButton={(setDialogOpen) => (
<ActionButton
type="button"
- variant="secondary"
- onClick={handleSelectFile}
- loading={upload.isPending}
- disabled={isBusy}
- >
- <Upload className="mr-2 h-4 w-4" />
- {image
- ? t("settings.info.avatar.change")
- : t("settings.info.avatar.upload")}
- </ActionButton>
- </div>
- <ActionConfirmingDialog
- title={t("settings.info.avatar.remove_confirm_title")}
- description={
- <p>{t("settings.info.avatar.remove_confirm_description")}</p>
- }
- actionButton={(setDialogOpen) => (
- <ActionButton
- type="button"
- variant="destructive"
- loading={updateAvatar.isPending}
- onClick={() =>
- updateAvatar.mutate(
- { assetId: null },
- {
- onSuccess: () => {
- toast({
- description: t("settings.info.avatar.removed"),
- });
- setDialogOpen(false);
- },
+ variant="destructive"
+ loading={updateAvatar.isPending}
+ onClick={() =>
+ updateAvatar.mutate(
+ { assetId: null },
+ {
+ onSuccess: () => {
+ toast({
+ description: t("settings.info.avatar.removed"),
+ });
+ setDialogOpen(false);
},
- )
- }
- >
- {t("settings.info.avatar.remove")}
- </ActionButton>
- )}
- >
- <Button type="button" variant="outline" disabled={!image || isBusy}>
- <X className="mr-2 h-4 w-4" />
+ },
+ )
+ }
+ >
{t("settings.info.avatar.remove")}
- </Button>
- </ActionConfirmingDialog>
- </div>
- </CardContent>
- </Card>
+ </ActionButton>
+ )}
+ >
+ <Button type="button" variant="outline" disabled={!image || isBusy}>
+ <X className="mr-2 h-4 w-4" />
+ {t("settings.info.avatar.remove")}
+ </Button>
+ </ActionConfirmingDialog>
+ </div>
+ </SettingsSection>
);
}
diff --git a/apps/web/components/settings/UserDetails.tsx b/apps/web/components/settings/UserDetails.tsx
index 5b99c0ea..42bb41e4 100644
--- a/apps/web/components/settings/UserDetails.tsx
+++ b/apps/web/components/settings/UserDetails.tsx
@@ -1,10 +1,10 @@
import { Input } from "@/components/ui/input";
import { useTranslation } from "@/lib/i18n/server";
import { api } from "@/server/api/client";
-import { Mail, User } from "lucide-react";
+import { Mail } from "lucide-react";
-import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
import { Label } from "../ui/label";
+import { SettingsSection } from "./SettingsPage";
export default async function UserDetails() {
// oxlint-disable-next-line rules-of-hooks
@@ -12,50 +12,38 @@ export default async function UserDetails() {
const whoami = await api.users.whoami();
return (
- <Card>
- <CardHeader>
- <div className="flex items-center space-x-4">
- <div className="space-y-1">
- <CardTitle className="flex items-center gap-2 text-xl">
- <User className="h-5 w-5" />
- {t("settings.info.basic_details")}
- </CardTitle>
- </div>
+ <SettingsSection title={t("settings.info.basic_details")}>
+ <div className="grid gap-6 md:grid-cols-2">
+ <div className="space-y-2">
+ <Label htmlFor="name" className="text-sm font-medium">
+ {t("common.name")}
+ </Label>
+ <Input
+ id="name"
+ defaultValue={whoami.name ?? ""}
+ className="h-11"
+ disabled
+ />
</div>
- </CardHeader>
- <CardContent className="space-y-6">
- <div className="grid gap-6 md:grid-cols-2">
- <div className="space-y-2">
- <Label htmlFor="name" className="text-sm font-medium">
- {t("common.name")}
- </Label>
+ <div className="space-y-2">
+ <Label
+ htmlFor="email"
+ className="flex items-center gap-2 text-sm font-medium"
+ >
+ <Mail className="h-4 w-4" />
+ {t("common.email")}
+ </Label>
+ <div className="relative">
<Input
- id="name"
- defaultValue={whoami.name ?? ""}
+ id="email"
+ type="email"
+ defaultValue={whoami.email ?? ""}
className="h-11"
disabled
/>
</div>
- <div className="space-y-2">
- <Label
- htmlFor="email"
- className="flex items-center gap-2 text-sm font-medium"
- >
- <Mail className="h-4 w-4" />
- {t("common.email")}
- </Label>
- <div className="relative">
- <Input
- id="email"
- type="email"
- defaultValue={whoami.email ?? ""}
- className="h-11"
- disabled
- />
- </div>
- </div>
</div>
- </CardContent>
- </Card>
+ </div>
+ </SettingsSection>
);
}
diff --git a/apps/web/components/settings/UserOptions.tsx b/apps/web/components/settings/UserOptions.tsx
index 763695c5..76ec0f3f 100644
--- a/apps/web/components/settings/UserOptions.tsx
+++ b/apps/web/components/settings/UserOptions.tsx
@@ -8,7 +8,7 @@ import { useInterfaceLang } from "@/lib/userLocalSettings/bookmarksLayout";
import { updateInterfaceLang } from "@/lib/userLocalSettings/userLocalSettings";
import { useUserSettings } from "@/lib/userSettings";
import { zodResolver } from "@hookform/resolvers/zod";
-import { Archive, Bookmark, Clock, Globe } from "lucide-react";
+import { Archive, Bookmark, Clock } from "lucide-react";
import { useForm } from "react-hook-form";
import { z } from "zod";
@@ -19,7 +19,6 @@ import {
zUserSettingsSchema,
} from "@karakeep/shared/types/users";
-import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
import { Form, FormField } from "../ui/form";
import { Label } from "../ui/label";
import {
@@ -29,6 +28,7 @@ import {
SelectTrigger,
SelectValue,
} from "../ui/select";
+import { SettingsSection } from "./SettingsPage";
const LanguageSelect = () => {
const lang = useInterfaceLang();
@@ -139,142 +139,132 @@ export default function UserOptions() {
return (
<Form {...form}>
- <Card>
- <CardHeader>
- <CardTitle className="flex items-center gap-2 text-xl">
- <Globe className="h-5 w-5" />
- {t("settings.info.options")}
- </CardTitle>
- </CardHeader>
- <CardContent className="space-y-6">
- <div className="space-y-2">
- <Label className="text-sm font-medium">
- {t("settings.info.interface_lang")}
- </Label>
- <LanguageSelect />
- </div>
+ <SettingsSection title={t("settings.info.options")}>
+ <div className="space-y-2">
+ <Label className="text-sm font-medium">
+ {t("settings.info.interface_lang")}
+ </Label>
+ <LanguageSelect />
+ </div>
+ <FormField
+ control={form.control}
+ name="timezone"
+ render={({ field }) => (
+ <div className="space-y-2">
+ <Label className="flex items-center gap-2 text-sm font-medium">
+ <Clock className="h-4 w-4" />
+ Timezone
+ </Label>
+ <Select
+ disabled={!!clientConfig.demoMode || timezones === null}
+ value={field.value}
+ onValueChange={(value) => {
+ mutate({
+ timezone: value,
+ });
+ }}
+ >
+ <SelectTrigger className="h-11">
+ <SelectValue>
+ {timezones?.find(
+ (tz: { value: string; label: string }) =>
+ tz.value === field.value,
+ )?.label || field.value}
+ </SelectValue>
+ </SelectTrigger>
+ <SelectContent>
+ {timezones?.map((tz: { value: string; label: string }) => (
+ <SelectItem key={tz.value} value={tz.value}>
+ {tz.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </div>
+ )}
+ />
+
+ <div className="grid grid-cols-2 gap-6">
<FormField
control={form.control}
- name="timezone"
+ name="bookmarkClickAction"
render={({ field }) => (
<div className="space-y-2">
<Label className="flex items-center gap-2 text-sm font-medium">
- <Clock className="h-4 w-4" />
- Timezone
+ <Bookmark className="h-4 w-4" />
+ {t("settings.info.user_settings.bookmark_click_action.title")}
</Label>
<Select
- disabled={!!clientConfig.demoMode || timezones === null}
+ disabled={!!clientConfig.demoMode}
value={field.value}
onValueChange={(value) => {
mutate({
- timezone: value,
+ bookmarkClickAction:
+ value as ZUserSettings["bookmarkClickAction"],
});
}}
>
<SelectTrigger className="h-11">
<SelectValue>
- {timezones?.find(
- (tz: { value: string; label: string }) =>
- tz.value === field.value,
- )?.label || field.value}
+ {bookmarkClickActionTranslation[field.value]}
</SelectValue>
</SelectTrigger>
<SelectContent>
- {timezones?.map((tz: { value: string; label: string }) => (
- <SelectItem key={tz.value} value={tz.value}>
- {tz.label}
- </SelectItem>
- ))}
+ {Object.entries(bookmarkClickActionTranslation).map(
+ ([value, label]) => (
+ <SelectItem key={value} value={value}>
+ {label}
+ </SelectItem>
+ ),
+ )}
</SelectContent>
</Select>
</div>
)}
/>
- <div className="grid grid-cols-2 gap-6">
- <FormField
- control={form.control}
- name="bookmarkClickAction"
- render={({ field }) => (
- <div className="space-y-2">
- <Label className="flex items-center gap-2 text-sm font-medium">
- <Bookmark className="h-4 w-4" />
- {t(
- "settings.info.user_settings.bookmark_click_action.title",
- )}
- </Label>
- <Select
- disabled={!!clientConfig.demoMode}
- value={field.value}
- onValueChange={(value) => {
- mutate({
- bookmarkClickAction:
- value as ZUserSettings["bookmarkClickAction"],
- });
- }}
- >
- <SelectTrigger className="h-11">
- <SelectValue>
- {bookmarkClickActionTranslation[field.value]}
- </SelectValue>
- </SelectTrigger>
- <SelectContent>
- {Object.entries(bookmarkClickActionTranslation).map(
- ([value, label]) => (
- <SelectItem key={value} value={value}>
- {label}
- </SelectItem>
- ),
- )}
- </SelectContent>
- </Select>
- </div>
- )}
- />
-
- <FormField
- control={form.control}
- name="archiveDisplayBehaviour"
- render={({ field }) => (
- <div className="space-y-2">
- <Label className="flex items-center gap-2 text-sm font-medium">
- <Archive className="h-4 w-4" />
- {t(
- "settings.info.user_settings.archive_display_behaviour.title",
+ <FormField
+ control={form.control}
+ name="archiveDisplayBehaviour"
+ render={({ field }) => (
+ <div className="space-y-2">
+ <Label className="flex items-center gap-2 text-sm font-medium">
+ <Archive className="h-4 w-4" />
+ {t(
+ "settings.info.user_settings.archive_display_behaviour.title",
+ )}
+ </Label>
+ <Select
+ disabled={!!clientConfig.demoMode}
+ value={field.value}
+ onValueChange={(value) => {
+ mutate({
+ archiveDisplayBehaviour:
+ value as ZUserSettings["archiveDisplayBehaviour"],
+ });
+ }}
+ >
+ <SelectTrigger className="h-11">
+ <SelectValue>
+ {archiveDisplayBehaviourTranslation[field.value]}
+ </SelectValue>
+ </SelectTrigger>
+ <SelectContent>
+ {Object.entries(archiveDisplayBehaviourTranslation).map(
+ ([value, label]) => (
+ <SelectItem key={value} value={value}>
+ {label}
+ </SelectItem>
+ ),
)}
- </Label>
- <Select
- disabled={!!clientConfig.demoMode}
- value={field.value}
- onValueChange={(value) => {
- mutate({
- archiveDisplayBehaviour:
- value as ZUserSettings["archiveDisplayBehaviour"],
- });
- }}
- >
- <SelectTrigger className="h-11">
- <SelectValue>
- {archiveDisplayBehaviourTranslation[field.value]}
- </SelectValue>
- </SelectTrigger>
- <SelectContent>
- {Object.entries(archiveDisplayBehaviourTranslation).map(
- ([value, label]) => (
- <SelectItem key={value} value={value}>
- {label}
- </SelectItem>
- ),
- )}
- </SelectContent>
- </Select>
- </div>
- )}
- />
- </div>
- </CardContent>
- </Card>
+ </SelectContent>
+ </Select>
+ </div>
+ )}
+ />
+ </div>
+ </SettingsSection>
</Form>
);
}
diff --git a/apps/web/components/settings/WebhookSettings.tsx b/apps/web/components/settings/WebhookSettings.tsx
index 7a05b9e6..dedf5104 100644
--- a/apps/web/components/settings/WebhookSettings.tsx
+++ b/apps/web/components/settings/WebhookSettings.tsx
@@ -54,6 +54,7 @@ import {
TableHeader,
TableRow,
} from "../ui/table";
+import { SettingsPage, SettingsSection } from "./SettingsPage";
import { WebhookEventSelector } from "./WebhookEventSelector";
export function WebhooksEditorDialog() {
@@ -494,20 +495,15 @@ export default function WebhookSettings() {
api.webhooks.list.queryOptions(),
);
return (
- <div className="rounded-md border bg-background p-4">
- <div className="flex flex-col gap-2">
- <div className="flex items-center justify-between">
- <span className="flex items-center gap-2 text-lg font-medium">
- {t("settings.webhooks.webhooks")}
- </span>
- <WebhooksEditorDialog />
- </div>
- <p className="text-sm italic text-muted-foreground">
- {t("settings.webhooks.description")}
- </p>
+ <SettingsPage
+ title={t("settings.webhooks.webhooks")}
+ description={t("settings.webhooks.description")}
+ action={<WebhooksEditorDialog />}
+ >
+ <SettingsSection>
{isLoading && <FullPageSpinner />}
{webhooks && webhooks.webhooks.length == 0 && (
- <p className="rounded-md bg-muted p-2 text-sm text-muted-foreground">
+ <p className="rounded-md bg-muted p-3 text-center text-sm text-muted-foreground">
You don&apos;t have any webhooks configured yet.
</p>
)}
@@ -528,7 +524,7 @@ export default function WebhookSettings() {
</TableBody>
</Table>
)}
- </div>
- </div>
+ </SettingsSection>
+ </SettingsPage>
);
}