Skip to content

Commit

Permalink
fix(dark mode): fix dark mode in form editor and other areas
Browse files Browse the repository at this point in the history
  • Loading branch information
tran-christian committed Oct 10, 2023
1 parent 5f70cc1 commit 7265616
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 23 deletions.
27 changes: 26 additions & 1 deletion pages/course/[courseid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
ToggleButton,
ToggleButtonGroup,
Typography,
useTheme,
} from '@mui/material';
import Link from '@src/Link';
import {
Expand Down Expand Up @@ -82,6 +83,8 @@ const CourseId: NextPage<CoursePageProps> = ({
({ user } = authContext);
}

const theme = useTheme();

const [activeSemesters, setActiveSemesters] = useState<TActiveSemesters>(
defaultSemesterToggles,
);
Expand Down Expand Up @@ -386,7 +389,7 @@ const CourseId: NextPage<CoursePageProps> = ({
<Grid container rowSpacing={5} sx={{ mt: 1 }}>
{mapPayloadToArray(courseReviews, REVIEW_ID, DESC).map(
(value: Review) => (
<Grid sx={{ width: `100%` }} key={value.reviewId} item>
<Grid sx={{ width: `100%` }} key={value.reviewId} item>
<ReviewCard {...value}></ReviewCard>
</Grid>
),
Expand Down Expand Up @@ -414,13 +417,25 @@ const CourseId: NextPage<CoursePageProps> = ({
onClose={handleReviewModalClose}
maxWidth='md'
closeAfterTransition
PaperProps={{sx:{backgroundImage: 'none'}}}
>
<ReviewForm {...{ courseData, handleReviewModalClose }} />
</Dialog>
<SpeedDial
ariaLabel='Review Dial'
sx={{ position: 'fixed', bottom: 40, right: 40 }}
icon={<SpeedDialIcon />}
FabProps={{
sx :{
border: `1px solid ${theme.palette.secondary.contrastText}`,
backgroundColor: `${theme.palette.secondary.main}`,
color: `${theme.palette.secondary.contrastText}`,
"&:hover":{
backgroundColor:`${theme.palette.secondary.contrastText}`,
color:`${theme.palette.secondary.main}`
}
}
}}
>
{actions
.flatMap((action) => {
Expand All @@ -431,9 +446,19 @@ const CourseId: NextPage<CoursePageProps> = ({
})
.map((action) => (
<SpeedDialAction
sx={{
border: `1px solid ${theme.palette.secondary.contrastText}`,
backgroundColor: `${theme.palette.secondary.main}`,
color: `${theme.palette.secondary.contrastText}`,
"&:hover":{
backgroundColor:`${theme.palette.secondary.contrastText}`,
color:`${theme.palette.secondary.contrastText}`
}
}}
key={action.name}
icon={action.icon}
tooltipTitle={action.name}
arrow
onClick={action.clickAction}
/>
))}
Expand Down
13 changes: 9 additions & 4 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import backend from '@backend/index';
import { courseFields } from '@globals/constants';
import { Course } from '@globals/types';
import { mapDynamicCoursesDataToCourses } from '@globals/utilities';
import { Tooltip, useMediaQuery, Box, Container, Grid, Typography } from '@mui/material';
import { Tooltip, useMediaQuery, Box, Container, Grid, Typography, useTheme } from '@mui/material';

import {
DataGrid,
Expand All @@ -26,6 +26,9 @@ const Home: NextPage<HomePageProps> = ({ allCourseData }) => {
allCourseData,
courseFields.NAME,
);

Check notice on line 28 in pages/index.tsx

View check run for this annotation

codefactor.io / CodeFactor

pages/index.tsx#L23-L28

Complex Method

const theme = useTheme();

const courses = coursesArray.map((data, i) => ({ ...data, id: i }));

const columns: GridColDef[] = [
Expand All @@ -35,8 +38,8 @@ const Home: NextPage<HomePageProps> = ({ allCourseData }) => {
flex: isDesktop ? 1 : 0,
minWidth: isDesktop ? 50 : 200,
renderCell: (params: GridRenderCellParams) => (
<Tooltip title={`View review page for ${params.row.courseId}`}>
<Link color='secondary' href='/course/[courseid]' as={`/course/${params.row.courseId}`}>
<Tooltip arrow title={`View review page for ${params.row.courseId}`}>
<Link color={`${theme.palette.mode == 'dark' ? 'secondary.contrastText' : 'secondary.main'}`} href='/course/[courseid]' as={`/course/${params.row.courseId}`}>
{params.row.name}
</Link>
</Tooltip>
Expand Down Expand Up @@ -134,7 +137,9 @@ const Home: NextPage<HomePageProps> = ({ allCourseData }) => {
disableDensitySelector: true,
showQuickFilter: true,
sx:{

'& .MuiButton-root':{
color: `${theme.palette.mode == 'dark' ? 'secondary.contrastText' : 'secondary.main'}`,
}
}
},
}}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ClassCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ClassCard = ({ ...props }: ClassCardProps) => {
const router = useRouter();

return (
<Card sx={{ width: 350, boxShadow: `0 5px 15px 0 ${grey[300]}` }}>
<Card sx={{ width: 350, boxShadow: `0 5px 0px 0 ${grey[200]}` }}>
<CardActionArea
onClick={() => {
router.push({
Expand Down
47 changes: 47 additions & 0 deletions src/components/FormEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Box } from '@mui/material';
import { useTheme } from '@mui/material/styles';
import '@toast-ui/editor/dist/toastui-editor.css';
import { Editor } from '@toast-ui/react-editor';
Expand All @@ -23,6 +24,51 @@ export default function FormEditor({
onChange(clean);
}
return (
<Box sx={{
"& .toastui-editor-dark":{
borderColor: "#494c56",
"& .ProseMirror":{
color:`${theme.palette.secondary.contrastText}`
},
"& .toastui-editor-contents p":{
color: `${theme.palette.secondary.contrastText}`
},
"& .toastui-editor-md-splitter":{
backgroundColor: `${theme.palette.secondary.light}`
},
"& .toastui-editor-main":{
backgroundColor:`${theme.palette.secondary.main}`
},
"& .toastui-editor-defaultUI-toolbar":{
backgroundColor:`${theme.palette.secondary.light}`,
borderColor: '#494c56',
"& button":{
borderColor:"#232428",
"&:not(:disabled):hover":{
backgroundColor: "#36383f",
borderColor: "#36383f"
}
}
},
"& .toastui-editor-ww-container":{
backgroundColor:`${theme.palette.secondary.main}`
},
"& .toastui-editor-mode-switch":{
borderTop: '1px solid #393b42',
backgroundColor:`${theme.palette.secondary.light}`,
"& .tab-item":{
backgroundColor: `${theme.palette.secondary.light}`,
border: 'none',
borderTopColor: '#393b42',
"&.active":{
borderTopColor: `${theme.palette.secondary.main}`,
backgroundColor: `${theme.palette.secondary.main}`,
}
}
}
}
}}
>
<Editor
height='auto'
initialValue={initialValue}
Expand All @@ -41,5 +87,6 @@ export default function FormEditor({
]}
customHTMLSanitizer={DOMPurify.sanitize}
/>
</Box>
);
}
22 changes: 15 additions & 7 deletions src/components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ export const NavBar = ({ ...props }: NavBarProps) => {
return (
<Box sx={{ flexGrow: 1 }}>
<AppBar
color='secondary'
color={theme.palette.mode == 'dark' ? 'primary' : 'secondary'}
position='static'
elevation={0}
{...props}
>
<Toolbar color='inherit'>
<Box sx={{ flexGrow: 1, display: { xs: 'none', md: 'flex' } }}>
<Tooltip arrow title={"Home"}>

<Link
variant='button'
color='inherit'
color='secondary.contrastText'
href='/'
sx={{
display: { xs: 'none', md: 'flex' },
Expand All @@ -73,11 +75,15 @@ export const NavBar = ({ ...props }: NavBarProps) => {
OMSHub
</Typography>
</Link>
</Tooltip>

</Box>

<Box sx={{ flexGrow: 0, display: { xs: 'none', md: 'flex' } }}>
{Object.keys(navigationMenuItems).map(
(name: string, index: number) => (
<Tooltip
arrow
key={index}
title={`${navigationMenuItems[name][`tooltip`]}`}
>
Expand All @@ -96,6 +102,7 @@ export const NavBar = ({ ...props }: NavBarProps) => {
</Tooltip>
),
)}
<Tooltip arrow title={`${theme.palette.mode} mode`}>
<IconButton
sx={{
p: 0,
Expand All @@ -105,14 +112,15 @@ export const NavBar = ({ ...props }: NavBarProps) => {
onClick={()=>setMode(mode == 'light' ? 'dark' : 'light')}
color="inherit"
>
<Tooltip disableInteractive disableFocusListener disableTouchListener title={`${theme.palette.mode} mode`}>
{theme.palette.mode === 'dark' ? (
<Brightness7Icon />
) : (
<Brightness4Icon />
)}
</Tooltip>
)}
</IconButton>
</Tooltip>
<Tooltip arrow title={`Website's Github`}>

<Link
variant='button'
color='inherit'
Expand All @@ -122,10 +130,10 @@ export const NavBar = ({ ...props }: NavBarProps) => {
mx: 1.5,
}}
>
<Tooltip title={`Website's Github`}>
<GitHubIcon />
</Tooltip>
</Link>
</Tooltip>

</Box>
<MobileMenu {...navigationMenuItems} />
{/* User Profile Side */}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProfileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ProfileMenu = (profileMenuItems: MenuLinksProps) => {
return (
<>
<Container sx={{color:'inherit'}}>
<Tooltip title='Profile Menu'>
<Tooltip arrow title='Profile Menu'>
<Avatar
aria-controls={menuId}
onClick={handleProfileMenuOpen}
Expand Down
16 changes: 12 additions & 4 deletions src/components/ReviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,18 @@ const ReviewCard = ({
return (
<div ref={clipboardRef!}>
<Card
color='inherit'
sx={{
backgroundImage: "none",
p: 1,
borderRadius: '10px',
boxShadow: `0 5px 15px 0 ${grey[400]}`,
borderRadius: '15px',
boxShadow: `0 5px 10px 0 ${grey[500]}`,
"& a":{
color:"#6495ED",
"&:visited":{
color:"#8a2be2"
}
}
}}
>
<CardContent>
Expand Down Expand Up @@ -235,7 +243,7 @@ const ReviewCard = ({
<Grid textAlign='right'>
{/* Not User View */}
{!isFirefox && (
<Tooltip title='Screenshot Review'>
<Tooltip arrow title='Screenshot Review'>
<IconButton onClick={handleCopyToClipboard}>
<PhotoCameraIcon />
</IconButton>
Expand All @@ -255,7 +263,7 @@ const ReviewCard = ({
{/* User Review View */}
{isUserReviewsView ? (
<>
<Tooltip title='Delete Review'>
<Tooltip arrow title='Delete Review'>
<IconButton onClick={handleDeleteDialogOpen}>
<DeleteIcon />
</IconButton>
Expand Down
3 changes: 2 additions & 1 deletion src/components/ReviewForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,10 @@ const ReviewForm = ({

return (
<Grid
color='inherit'
container
rowSpacing={4}
sx={{ px: 5, py: 10 }}
sx={{ px: 5, py: 10, backgroundImage: 'none' }}
justifyContent='center'
>
<Typography variant='h6'>{`Add Review for ${courseData.courseId}: ${courseData.name}`}</Typography>
Expand Down
11 changes: 7 additions & 4 deletions src/theme.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PaletteMode } from '@mui/material';
import { red } from '@mui/material/colors';
import { navyBlue, techGold } from '@src/colorPalette';
import { navyBlue } from '@src/colorPalette';



Expand All @@ -17,6 +17,7 @@ export const getDesignTokens = (mode: PaletteMode ) => ({
},
secondary: {
main: navyBlue,
contrastText: '#FFF'
},
error: {
main: red.A400,
Expand All @@ -29,11 +30,13 @@ export const getDesignTokens = (mode: PaletteMode ) => ({
//Dark
{
primary: {
main: '#FFF',
contrastText: '#000',
main: '#000',
contrastText: '#FFF',
},
secondary: {
main: techGold,
main: '#121212',
light: '#232428',
contrastText: "#FFF"
},
error: {
main: red.A400,
Expand Down

0 comments on commit 7265616

Please sign in to comment.