mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
Improve mobile settings design
This commit is contained in:
4 files changed
+91
-49
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { ChevronRight } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface SettingsItemMobileProps {
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
title: string;
|
||||
onClick: () => void;
|
||||
isFirst?: boolean;
|
||||
isLast?: boolean;
|
||||
}
|
||||
|
||||
export function SettingsItemMobile({
|
||||
icon: Icon,
|
||||
title,
|
||||
onClick,
|
||||
isFirst = false,
|
||||
isLast = false,
|
||||
}: SettingsItemMobileProps) {
|
||||
return (
|
||||
<button
|
||||
onClick={onClick}
|
||||
className={cn(
|
||||
'w-full text-left px-4 py-3.5 bg-background transition-colors active:bg-muted/50',
|
||||
'flex items-center gap-3',
|
||||
'border-b border-border last:border-b-0',
|
||||
{
|
||||
'rounded-t-xl': isFirst,
|
||||
'rounded-b-xl': isLast,
|
||||
}
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center justify-center w-7 h-7 rounded-lg bg-primary/10">
|
||||
<Icon className="h-4 w-4 text-primary flex-shrink-0" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="text-base text-foreground">
|
||||
{title}
|
||||
</div>
|
||||
</div>
|
||||
<ChevronRight className="h-5 w-5 text-muted-foreground/50 flex-shrink-0" />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import { ProjectSidebar } from '@/components/ProjectSidebar';
|
||||
import { useProjectsManager } from '@/hooks/useProjectsManager';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { type Project } from '@/lib/ProjectsManager';
|
||||
import { settingsCategories } from '@/lib/settingsItems';
|
||||
import { getSettingsCategories } from '@/lib/settingsItems';
|
||||
import { SettingsItem } from '@/components/SettingsItem';
|
||||
|
||||
export function SettingsLayout() {
|
||||
@@ -60,6 +60,7 @@ export function SettingsLayout() {
|
||||
};
|
||||
|
||||
// Get current settings page
|
||||
const settingsCategories = getSettingsCategories(t);
|
||||
const currentPath = location.pathname;
|
||||
const currentSettingsId = settingsCategories
|
||||
.flatMap(category => category.items)
|
||||
@@ -151,7 +152,7 @@ export function SettingsLayout() {
|
||||
{settingsCategories.map((category) => (
|
||||
<div key={category.id}>
|
||||
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2 px-2">
|
||||
{t(category.titleKey)}
|
||||
{category.title}
|
||||
</h3>
|
||||
<div className="space-y-1">
|
||||
{category.items.map((item) => {
|
||||
@@ -161,7 +162,7 @@ export function SettingsLayout() {
|
||||
<SettingsItem
|
||||
key={item.id}
|
||||
icon={item.icon}
|
||||
title={t(item.titleKey)}
|
||||
title={item.title}
|
||||
onClick={() => navigate(item.href)}
|
||||
isActive={isActive}
|
||||
/>
|
||||
|
||||
+20
-18
@@ -1,84 +1,86 @@
|
||||
import { Bot, GitBranch, Database, Wifi, Settings2, Info, Settings, Rocket } from 'lucide-react';
|
||||
|
||||
export interface SettingsItemConfig {
|
||||
export interface SettingsItem {
|
||||
id: string;
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
titleKey: string;
|
||||
title: string;
|
||||
href: string;
|
||||
}
|
||||
|
||||
export interface SettingsCategoryConfig {
|
||||
export interface SettingsCategory {
|
||||
id: string;
|
||||
titleKey: string;
|
||||
items: SettingsItemConfig[];
|
||||
title: string;
|
||||
items: SettingsItem[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings structure organized by category
|
||||
* Get the categorized list of settings items with translations
|
||||
* @param t - Translation function from useTranslation hook
|
||||
* @returns Array of settings categories with translated items
|
||||
*/
|
||||
export const settingsCategories: SettingsCategoryConfig[] = [
|
||||
export const getSettingsCategories = (t: (key: string) => string): SettingsCategory[] => [
|
||||
{
|
||||
id: 'general',
|
||||
titleKey: 'general',
|
||||
title: t('general'),
|
||||
items: [
|
||||
{
|
||||
id: 'preferences',
|
||||
icon: Settings2,
|
||||
titleKey: 'preferences',
|
||||
title: t('preferences'),
|
||||
href: '/settings/preferences',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'integrations',
|
||||
titleKey: 'integrations',
|
||||
title: t('integrations'),
|
||||
items: [
|
||||
{
|
||||
id: 'ai',
|
||||
icon: Bot,
|
||||
titleKey: 'aiSettings',
|
||||
title: t('aiSettings'),
|
||||
href: '/settings/ai',
|
||||
},
|
||||
{
|
||||
id: 'git',
|
||||
icon: GitBranch,
|
||||
titleKey: 'gitSettings',
|
||||
title: t('gitSettings'),
|
||||
href: '/settings/git',
|
||||
},
|
||||
{
|
||||
id: 'nostr',
|
||||
icon: Wifi,
|
||||
titleKey: 'nostrSettings',
|
||||
title: t('nostrSettings'),
|
||||
href: '/settings/nostr',
|
||||
},
|
||||
{
|
||||
id: 'deploy',
|
||||
icon: Rocket,
|
||||
titleKey: 'deploySettings',
|
||||
title: t('deploySettings'),
|
||||
href: '/settings/deploy',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'advanced',
|
||||
titleKey: 'advanced',
|
||||
title: t('advanced'),
|
||||
items: [
|
||||
{
|
||||
id: 'storage',
|
||||
icon: Database,
|
||||
titleKey: 'storageSettings',
|
||||
title: t('storageSettings'),
|
||||
href: '/settings/storage',
|
||||
},
|
||||
{
|
||||
id: 'system',
|
||||
icon: Settings,
|
||||
titleKey: 'systemSettings',
|
||||
title: t('systemSettings'),
|
||||
href: '/settings/system',
|
||||
},
|
||||
{
|
||||
id: 'about',
|
||||
icon: Info,
|
||||
titleKey: 'aboutShakespeare',
|
||||
title: t('aboutShakespeare'),
|
||||
href: '/settings/about',
|
||||
},
|
||||
],
|
||||
|
||||
+24
-28
@@ -1,42 +1,38 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { getSettingsItems } from '@/lib/settingsItems';
|
||||
import { getSettingsCategories } from '@/lib/settingsItems';
|
||||
import { SettingsItemMobile } from '@/components/SettingsItemMobile';
|
||||
|
||||
export function Settings() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
const settingsItems = getSettingsItems(t);
|
||||
const settingsCategories = getSettingsCategories(t);
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
<div className="p-6 space-y-4">
|
||||
<div className="space-y-2">
|
||||
<h2 className="text-xl font-bold">{t('settings')}</h2>
|
||||
<p className="text-muted-foreground">
|
||||
{t('settingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
{settingsItems.map((item) => {
|
||||
const Icon = item.icon;
|
||||
return (
|
||||
<div
|
||||
key={item.id}
|
||||
className="flex items-center gap-3 p-4 rounded-lg border hover:border-primary/20 hover:bg-primary/5 cursor-pointer transition-colors"
|
||||
onClick={() => navigate(item.href)}
|
||||
>
|
||||
<Icon className="h-5 w-5 text-primary flex-shrink-0" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="font-medium">{item.title}</div>
|
||||
<div className="text-sm text-muted-foreground">{item.description}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div className="p-4 space-y-8">
|
||||
{settingsCategories.map((category) => (
|
||||
<div key={category.id}>
|
||||
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2 px-2">
|
||||
{category.title}
|
||||
</h3>
|
||||
<div className="overflow-hidden rounded-xl border border-border shadow-sm">
|
||||
{category.items.map((item, index) => (
|
||||
<SettingsItemMobile
|
||||
key={item.id}
|
||||
icon={item.icon}
|
||||
title={item.title}
|
||||
onClick={() => navigate(item.href)}
|
||||
isFirst={index === 0}
|
||||
isLast={index === category.items.length - 1}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{import.meta.env.VERSION && (
|
||||
<div className="text-center text-xs text-muted-foreground/60 pt-4">
|
||||
v{import.meta.env.VERSION}
|
||||
@@ -47,4 +43,4 @@ export function Settings() {
|
||||
}
|
||||
}
|
||||
|
||||
export default Settings;
|
||||
export default Settings;
|
||||
Reference in new issue
Block a user