Skip to content

Commit

Permalink
Addressed all the issues
Browse files Browse the repository at this point in the history
  • Loading branch information
justinnas committed Aug 25, 2024
2 parents 6b94544 + 7824a49 commit 2b35ef8
Show file tree
Hide file tree
Showing 20 changed files with 315 additions and 90 deletions.
62 changes: 35 additions & 27 deletions app/front-end/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,53 @@
font-family: 'Nunito', sans-serif;
}
</style>
<link rel="icon" type="image/svg+xml" href="/Kath_OnlyLogo.svg" />
<link rel="preload" href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap" as="style" onload="this.onload=null;this.rel='stylesheet'">
<link rel="icon" type="image/svg+xml" href="/Kath_Favicon.svg" />
<link
rel="preload"
href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap"
as="style"
onload="this.onload=null;this.rel='stylesheet'"
/>
<noscript>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap">
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap"
/>
</noscript>
<title>Kath</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script>
// Retrieve color mode from localStorage
const colorMode = localStorage.getItem('color-mode');
// Retrieve color mode from localStorage
const colorMode = localStorage.getItem('color-mode');

// Function to set background color based on color mode
function setBackgroundColor(colorMode) {
if (colorMode === 'dark') {
document.body.style.backgroundColor = '#203238'; // Dark background color
} else {
document.body.style.backgroundColor = '#4C7380'; // Light background color
}
}
// Function to set background color based on color mode
function setBackgroundColor(colorMode) {
if (colorMode === 'dark') {
document.body.style.backgroundColor = '#1C2427'; // Dark background color
} else {
document.body.style.backgroundColor = '#4C7380'; // Light background color
}
}

// Check if color mode is stored in localStorage
if (colorMode) {
setBackgroundColor(colorMode);
} else {
// Retrieve system's preferred color mode using matchMedia
const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
// Check if color mode is stored in localStorage
if (colorMode) {
setBackgroundColor(colorMode);
} else {
// Retrieve system's preferred color mode using matchMedia
const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;

// Set color mode based on system preference
const systemColorMode = prefersDarkMode ? 'dark' : 'light';
// Set color mode based on system preference
const systemColorMode = prefersDarkMode ? 'dark' : 'light';

// Store the system color mode in localStorage
localStorage.setItem('color-mode', systemColorMode);
// Store the system color mode in localStorage
localStorage.setItem('color-mode', systemColorMode);

// Set background color based on system color mode
setBackgroundColor(systemColorMode);
}
</script>
// Set background color based on system color mode
setBackgroundColor(systemColorMode);
}
</script>
</body>
</html>
1 change: 1 addition & 0 deletions app/front-end/public/Kath_Favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 0 additions & 20 deletions app/front-end/public/Kath_OnlyLogo.svg

This file was deleted.

7 changes: 5 additions & 2 deletions app/front-end/src/components/buttons/IconTitleButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Colors } from '@/types';
import { Box, IconButton, Typography } from '@mui/material';
import { alpha, Box, IconButton, Typography, useTheme } from '@mui/material';

interface Props {
icon: React.ReactNode;
Expand Down Expand Up @@ -30,6 +30,7 @@ interface Props {
* @returns {JSX.Element} The `IconTitleButton` component rendering an icon button and an optional title.
*/
export const IconTitleButton: React.FC<Props> = ({ icon, title, width, height, borderRadius, onClick }) => {
const Theme = useTheme();
return (
<Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
<IconButton
Expand All @@ -39,7 +40,9 @@ export const IconTitleButton: React.FC<Props> = ({ icon, title, width, height, b
height: height || '3rem',
borderRadius: borderRadius || '1rem',
transition: 'background-color 0.5s ease',
':hover': { backgroundColor: 'rgba(216, 228, 232, 0.5)' }, // TODO: fix this to be responsive to theme
':hover': {
backgroundColor: alpha(Theme.palette.primary.contrastText, 0.2),
},
}}
onClick={onClick}
>
Expand Down
3 changes: 3 additions & 0 deletions app/front-end/src/components/dialogs/settingsDialog/index.ts
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';
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { SettingSpacer } from '@/components/dialogs/settingsDialog';
import { ColorModeSetting, LanguageSetting, TimeZoneSetting } from '@/components/dialogs/settingsDialog/settingsFields';
import { Close as CloseIcon } from '@mui/icons-material';
import { 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.default,
},
}));

interface SettingsDialogProps {
open: boolean;
handleClose: () => void;
}

export const SettingsDialog: React.FC<SettingsDialogProps> = ({ open, handleClose }) => {
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>
);
};
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}
/>
);
};
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';
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}
/>
);
};
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}
/>
);
};
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>
);
};
Loading

0 comments on commit 2b35ef8

Please sign in to comment.