Improve Settings modal

This commit is contained in:
2024-10-27 21:34:59 +01:00
parent ba4a0dadca
commit 239b441aa6
6 changed files with 87 additions and 41 deletions

View File

@@ -6,7 +6,7 @@ import {
Group, Group,
Title, Title,
Stack, Stack,
Divider, Accordion,
} from '@mantine/core'; } from '@mantine/core';
import { notifications } from '@mantine/notifications'; import { notifications } from '@mantine/notifications';
import { useWorkspace } from '../contexts/WorkspaceContext'; import { useWorkspace } from '../contexts/WorkspaceContext';
@@ -53,6 +53,12 @@ function settingsReducer(state, action) {
} }
} }
const AccordionControl = ({ children }) => (
<Accordion.Control>
<Title order={4}>{children}</Title>
</Accordion.Control>
);
const Settings = () => { const Settings = () => {
const { currentWorkspace, updateSettings } = useWorkspace(); const { currentWorkspace, updateSettings } = useWorkspace();
const { settingsModalVisible, setSettingsModalVisible } = useModalContext(); const { settingsModalVisible, setSettingsModalVisible } = useModalContext();
@@ -126,35 +132,90 @@ const Settings = () => {
</Badge> </Badge>
)} )}
<GeneralSettings <Accordion
name={state.localSettings.name} defaultValue={['general', 'appearance', 'editor', 'git', 'danger']}
onInputChange={handleInputChange} multiple
/> styles={(theme) => ({
<Divider /> control: {
paddingTop: theme.spacing.md,
paddingBottom: theme.spacing.md,
},
item: {
borderBottom: `1px solid ${
theme.colorScheme === 'dark'
? theme.colors.dark[4]
: theme.colors.gray[3]
}`,
'&[data-active]': {
backgroundColor:
theme.colorScheme === 'dark'
? theme.colors.dark[7]
: theme.colors.gray[0],
},
},
chevron: {
'&[data-rotate]': {
transform: 'rotate(180deg)',
},
},
})}
>
<Accordion.Item value="general">
<AccordionControl>General</AccordionControl>
<Accordion.Panel>
<GeneralSettings
name={state.localSettings.name}
onInputChange={handleInputChange}
/>
</Accordion.Panel>
</Accordion.Item>
<AppearanceSettings <Accordion.Item value="appearance">
themeSettings={state.localSettings.theme} <AccordionControl>Appearance</AccordionControl>
onThemeChange={(newTheme) => handleInputChange('theme', newTheme)} <Accordion.Panel>
/> <AppearanceSettings
<Divider /> themeSettings={state.localSettings.theme}
onThemeChange={(newTheme) =>
handleInputChange('theme', newTheme)
}
/>
</Accordion.Panel>
</Accordion.Item>
<EditorSettings <Accordion.Item value="editor">
autoSave={state.localSettings.autoSave} <AccordionControl>Editor</AccordionControl>
onAutoSaveChange={(value) => handleInputChange('autoSave', value)} <Accordion.Panel>
/> <EditorSettings
<Divider /> autoSave={state.localSettings.autoSave}
onAutoSaveChange={(value) =>
handleInputChange('autoSave', value)
}
/>
</Accordion.Panel>
</Accordion.Item>
<GitSettings <Accordion.Item value="git">
gitEnabled={state.localSettings.gitEnabled} <AccordionControl>Git Integration</AccordionControl>
gitUrl={state.localSettings.gitUrl} <Accordion.Panel>
gitUser={state.localSettings.gitUser} <GitSettings
gitToken={state.localSettings.gitToken} gitEnabled={state.localSettings.gitEnabled}
gitAutoCommit={state.localSettings.gitAutoCommit} gitUrl={state.localSettings.gitUrl}
gitCommitMsgTemplate={state.localSettings.gitCommitMsgTemplate} gitUser={state.localSettings.gitUser}
onInputChange={handleInputChange} gitToken={state.localSettings.gitToken}
/> gitAutoCommit={state.localSettings.gitAutoCommit}
gitCommitMsgTemplate={state.localSettings.gitCommitMsgTemplate}
onInputChange={handleInputChange}
/>
</Accordion.Panel>
</Accordion.Item>
<DangerZoneSettings /> <Accordion.Item value="danger">
<AccordionControl>Danger Zone</AccordionControl>
<Accordion.Panel>
<DangerZoneSettings />
</Accordion.Panel>
</Accordion.Item>
</Accordion>
<Group justify="flex-end"> <Group justify="flex-end">
<Button variant="default" onClick={handleClose}> <Button variant="default" onClick={handleClose}>

View File

@@ -13,9 +13,6 @@ const AppearanceSettings = ({ themeSettings, onThemeChange }) => {
return ( return (
<Box mb="md"> <Box mb="md">
<Title order={3} mb="md">
Appearance
</Title>
<Group justify="space-between" align="center"> <Group justify="space-between" align="center">
<Text size="sm">Dark Mode</Text> <Text size="sm">Dark Mode</Text>
<Switch checked={colorScheme === 'dark'} onChange={handleThemeChange} /> <Switch checked={colorScheme === 'dark'} onChange={handleThemeChange} />

View File

@@ -18,10 +18,6 @@ const DangerZoneSettings = () => {
return ( return (
<Box mb="md"> <Box mb="md">
<Title order={3} mb="md">
Danger Zone
</Title>
<Button <Button
color="red" color="red"
variant="light" variant="light"

View File

@@ -4,9 +4,6 @@ import { Text, Switch, Tooltip, Group, Box, Title } from '@mantine/core';
const EditorSettings = ({ autoSave, onAutoSaveChange }) => { const EditorSettings = ({ autoSave, onAutoSaveChange }) => {
return ( return (
<Box mb="md"> <Box mb="md">
<Title order={3} mb="md">
Editor
</Title>
<Tooltip label="Auto Save feature is coming soon!" position="left"> <Tooltip label="Auto Save feature is coming soon!" position="left">
<Group justify="space-between" align="center"> <Group justify="space-between" align="center">
<Text size="sm">Auto Save</Text> <Text size="sm">Auto Save</Text>

View File

@@ -4,10 +4,6 @@ import { Title, Box, TextInput, Text, Grid } from '@mantine/core';
const GeneralSettings = ({ name, onInputChange }) => { const GeneralSettings = ({ name, onInputChange }) => {
return ( return (
<Box mb="md"> <Box mb="md">
<Title order={3} mb="md">
General
</Title>
<Grid gutter="md" align="center"> <Grid gutter="md" align="center">
<Grid.Col span={6}> <Grid.Col span={6}>
<Text size="sm">Workspace Name</Text> <Text size="sm">Workspace Name</Text>

View File

@@ -21,7 +21,6 @@ const GitSettings = ({
}) => { }) => {
return ( return (
<Stack spacing="md"> <Stack spacing="md">
<Title order={3}>Git Integration</Title>
<Grid gutter="md" align="center"> <Grid gutter="md" align="center">
<Grid.Col span={6}> <Grid.Col span={6}>
<Text size="sm">Enable Git</Text> <Text size="sm">Enable Git</Text>