-
Notifications
You must be signed in to change notification settings - Fork 4
JTE/PKFE-20 #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
JTE/PKFE-20 #46
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { SettingsDialog } from './settingsDialog'; | ||
export { SettingSpacer } from './settingSpacer'; | ||
export { SettingsSelectField } from './settingsSelectField'; |
5 changes: 5 additions & 0 deletions
5
app/front-end/src/components/dialogs/settingsDialog/settingSpacer.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Box } from '@mui/material'; | ||
|
||
export const SettingSpacer = ({ size = 3 }) => { | ||
return <Box mb={size} />; | ||
}; |
63 changes: 63 additions & 0 deletions
63
app/front-end/src/components/dialogs/settingsDialog/settingsDialog.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { SettingSpacer } from '@/components/dialogs/settingsDialog'; | ||
import { ColorModeSetting, LanguageSetting, TimeZoneSetting } from '@/components/dialogs/settingsDialog/settingsFields'; | ||
import { Close as CloseIcon } from '@mui/icons-material'; | ||
import { alpha, Box, Dialog, DialogContent, DialogTitle, Grid, IconButton, styled, useTheme } from '@mui/material'; | ||
|
||
const BootstrapDialog = styled(Dialog)(({ theme }) => ({ | ||
backdropFilter: 'blur(5px)', | ||
'& .MuiDialogContent-root': { | ||
padding: '1.5rem', | ||
}, | ||
'& .MuiDialogActions-root': { | ||
padding: '1.5rem', | ||
}, | ||
'& .MuiDialog-paper': { | ||
borderRadius: '1.5rem', | ||
minWidth: '25%', | ||
backgroundColor: theme.palette.background.paper, | ||
backgroundImage: 'none', | ||
}, | ||
})); | ||
|
||
interface SettingsDialogProps { | ||
open: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
export const SettingsDialog: React.FC<SettingsDialogProps> = ({ open, onClose }) => { | ||
const Theme = useTheme(); | ||
|
||
return ( | ||
<BootstrapDialog onClose={onClose} open={open}> | ||
<Grid container spacing={2} justifyContent='center' alignItems='center'> | ||
<Grid item xs={8}> | ||
<DialogTitle sx={{ color: Theme.palette.primary.main, pl: '1.5rem', pt: '1.5rem', fontWeight: '700' }}> | ||
Settings | ||
</DialogTitle> | ||
</Grid> | ||
<Grid item xs={4}> | ||
<Box display='flex' justifyContent='flex-end'> | ||
<IconButton | ||
aria-label='close' | ||
onClick={onClose} | ||
sx={{ | ||
color: Theme.palette.primary.main, | ||
mt: '0.5rem', | ||
mr: '1.5rem', | ||
}} | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
</Box> | ||
</Grid> | ||
</Grid> | ||
<DialogContent sx={{ borderTop: `1px solid ${alpha(Theme.palette.text.secondary, 0.3)}` }}> | ||
<ColorModeSetting /> | ||
<SettingSpacer /> | ||
<LanguageSetting /> | ||
<SettingSpacer /> | ||
<TimeZoneSetting /> | ||
</DialogContent> | ||
</BootstrapDialog> | ||
); | ||
}; |
23 changes: 23 additions & 0 deletions
23
app/front-end/src/components/dialogs/settingsDialog/settingsFields/colorModeSetting.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { SettingsSelectField } from '@/components/dialogs/settingsDialog'; | ||
import { useThemeContext } from '@/hooks'; | ||
|
||
export const ColorModeSetting = () => { | ||
const ThemeContext = useThemeContext(); | ||
|
||
const handleThemeChange = () => { | ||
ThemeContext.update(); | ||
}; | ||
|
||
return ( | ||
<SettingsSelectField | ||
title='Color mode' | ||
description='Toggle between light and dark modes' | ||
settings={[ | ||
{ value: 'light', label: 'Light' }, | ||
{ value: 'dark', label: 'Dark' }, | ||
]} | ||
value={ThemeContext.mode} | ||
onChange={handleThemeChange} | ||
/> | ||
); | ||
}; |
3 changes: 3 additions & 0 deletions
3
app/front-end/src/components/dialogs/settingsDialog/settingsFields/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { ColorModeSetting } from './colorModeSetting'; | ||
export { LanguageSetting } from './languageSetting'; | ||
export { TimeZoneSetting } from './timeZoneSetting'; |
28 changes: 28 additions & 0 deletions
28
app/front-end/src/components/dialogs/settingsDialog/settingsFields/languageSetting.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { SettingsSelectField } from '@/components/dialogs/settingsDialog'; | ||
import { SelectChangeEvent } from '@mui/material'; | ||
import { useState } from 'react'; | ||
|
||
export const LanguageSetting = () => { | ||
// TODO: Implement language switching functionality and replace with correct values | ||
|
||
const [switchLanguage, setSwitchLanguage] = useState('en'); | ||
|
||
const handleLanguageChange = (event: SelectChangeEvent<string>) => { | ||
const selectedLanguage = event.target.value; | ||
setSwitchLanguage(selectedLanguage); | ||
}; | ||
|
||
return ( | ||
<SettingsSelectField | ||
title='Language' | ||
description='Change the language of the application' | ||
settings={[ | ||
{ value: 'en', label: 'English' }, | ||
{ value: 'lt', label: 'Lithuanian' }, | ||
{ value: 'it', label: 'Italian' }, | ||
]} | ||
value={switchLanguage} | ||
onChange={handleLanguageChange} | ||
/> | ||
); | ||
}; |
24 changes: 24 additions & 0 deletions
24
app/front-end/src/components/dialogs/settingsDialog/settingsFields/timeZoneSetting.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { SettingsSelectField } from '@/components/dialogs/settingsDialog'; | ||
import { SelectChangeEvent } from '@mui/material'; | ||
import { useState } from 'react'; | ||
|
||
export const TimeZoneSetting = () => { | ||
// TODO: Implement time zone switching functionality and replace with correct values | ||
|
||
const [switchTimeZone, setSwitchTimeZone] = useState('GMT+3'); | ||
|
||
const handleTimeZoneChange = (event: SelectChangeEvent<string>) => { | ||
const selectedValue = event.target.value; | ||
setSwitchTimeZone(selectedValue); | ||
}; | ||
|
||
return ( | ||
<SettingsSelectField | ||
title='Time zone' | ||
description='Change the time zone of the application' | ||
settings={[{ value: 'GMT+3', label: 'GMT+3' }]} | ||
value={switchTimeZone} | ||
onChange={handleTimeZoneChange} | ||
/> | ||
); | ||
}; |
53 changes: 53 additions & 0 deletions
53
app/front-end/src/components/dialogs/settingsDialog/settingsSelectField.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Box, FormControl, Grid, MenuItem, Select, SelectChangeEvent, Typography, useTheme } from '@mui/material'; | ||
import React from 'react'; | ||
|
||
interface Setting { | ||
value: string | undefined; | ||
label: string; | ||
} | ||
|
||
interface SettingsSelectFieldProps { | ||
title: string; | ||
description: string; | ||
settings: Setting[]; | ||
value: string | undefined; | ||
onChange: (event: SelectChangeEvent) => void; | ||
} | ||
|
||
export const SettingsSelectField: React.FC<SettingsSelectFieldProps> = ({ | ||
title, | ||
description, | ||
settings, | ||
value, | ||
onChange, | ||
}) => { | ||
const Theme = useTheme(); | ||
|
||
return ( | ||
<Grid container spacing={2} justifyContent='center' alignItems='center'> | ||
<Grid item xs={8}> | ||
<Typography sx={{ fontSize: '1.1rem', fontWeight: '500' }}>{title}</Typography> | ||
<Typography sx={{ fontSize: '0.9rem', color: Theme.palette.text.secondary }}>{description}</Typography> | ||
</Grid> | ||
<Grid item xs={4}> | ||
<Box display='flex' justifyContent='flex-end'> | ||
<FormControl sx={{ minWidth: 120 }}> | ||
<Select | ||
value={value} | ||
onChange={onChange} | ||
displayEmpty | ||
size='small' | ||
inputProps={{ 'aria-label': 'Without label' }} | ||
> | ||
{settings.map((setting) => ( | ||
<MenuItem key={setting.value} value={setting.value}> | ||
{setting.label} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
</Grid> | ||
</Grid> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
app/front-end/src/components/modals/settingsDialog/settingsDialog.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import ColorModeSetting from '@/components/modals/settingsDialog/settingsFields/colorModeSetting'; | ||
import LanguageSetting from '@/components/modals/settingsDialog/settingsFields/languageSetting'; | ||
import TimeZoneSetting from '@/components/modals/settingsDialog/settingsFields/timeZoneSetting'; | ||
import { SettingSpacer } from '@/components/modals/settingsDialog/settingSpacer'; | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
import { Box, Grid } from '@mui/material'; | ||
import Dialog from '@mui/material/Dialog'; | ||
import DialogContent from '@mui/material/DialogContent'; | ||
import DialogTitle from '@mui/material/DialogTitle'; | ||
import IconButton from '@mui/material/IconButton'; | ||
import { styled, useTheme } from '@mui/material/styles'; | ||
justinnas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const BootstrapDialog = styled(Dialog)(({ theme }) => ({ | ||
backdropFilter: 'blur(5px)', | ||
'& .MuiDialogContent-root': { | ||
padding: '1.5rem', | ||
}, | ||
'& .MuiDialogActions-root': { | ||
padding: '1.5rem', | ||
}, | ||
'& .MuiDialog-paper': { | ||
borderRadius: '1.5rem', | ||
minWidth: '25%', | ||
backgroundColor: theme.palette.background.default, | ||
}, | ||
})); | ||
|
||
interface SettingsDialogProps { | ||
open: boolean; | ||
handleClose: () => void; | ||
} | ||
|
||
export default function SettingsDialog({ open, handleClose }: SettingsDialogProps) { | ||
justinnas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const Theme = useTheme(); | ||
|
||
return ( | ||
<BootstrapDialog onClose={handleClose} open={open}> | ||
<Grid container spacing={2} justifyContent='center' alignItems='center'> | ||
<Grid item xs={8}> | ||
<DialogTitle sx={{ color: Theme.palette.primary.main, pl: '1.5rem', pt: '1.5rem', fontWeight: '700' }}> | ||
Settings | ||
</DialogTitle> | ||
</Grid> | ||
<Grid item xs={4}> | ||
<Box display='flex' justifyContent='flex-end'> | ||
<IconButton | ||
aria-label='close' | ||
onClick={handleClose} | ||
sx={{ | ||
color: Theme.palette.primary.main, | ||
mt: '0.5rem', | ||
mr: '1.5rem', | ||
}} | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
</Box> | ||
</Grid> | ||
</Grid> | ||
<DialogContent dividers> | ||
<ColorModeSetting /> | ||
<SettingSpacer /> | ||
<LanguageSetting /> | ||
<SettingSpacer /> | ||
<TimeZoneSetting /> | ||
</DialogContent> | ||
</BootstrapDialog> | ||
); | ||
} |
29 changes: 29 additions & 0 deletions
29
app/front-end/src/components/modals/settingsDialog/settingsFields/colorModeSetting.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import SettingsSelectField from '@/components/modals/settingsDialog/settingsSelectField'; | ||
justinnas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { useThemeContext } from '@/hooks'; | ||
import { SelectChangeEvent } from '@mui/material'; | ||
import { useState } from 'react'; | ||
|
||
export default function ColorModeSetting() { | ||
justinnas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const ThemeContext = useThemeContext(); | ||
|
||
const [switchTheme, setSwitchTheme] = useState(ThemeContext.mode); | ||
justinnas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const handleThemeChange = (event: SelectChangeEvent<string>) => { | ||
const selectedTheme = event.target.value as 'light' | 'dark'; | ||
setSwitchTheme(selectedTheme); | ||
ThemeContext.update(); | ||
}; | ||
|
||
return ( | ||
<SettingsSelectField | ||
title='Color mode' | ||
description='Toggle between light and dark modes' | ||
settings={[ | ||
{ value: 'light', label: 'Light' }, | ||
{ value: 'dark', label: 'Dark' }, | ||
]} | ||
value={switchTheme} | ||
onChange={handleThemeChange} | ||
/> | ||
); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange
width
andheight
. Might be a problem in the future.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how it could be problematic.