Skip to content

Commit

Permalink
fix: upgrade to v6
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsuh committed Sep 21, 2024
1 parent 8b27af8 commit d41fe3f
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 44 deletions.
6 changes: 3 additions & 3 deletions src/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ function AppRouter() {
return (
<Routes>
{plans.map((plan) => (
<Route key={plan.id} path={`/${plan.id}`} element={<PlanPage />} />
<Route element={<PlanPage />} key={plan.id} path={`/${plan.id}`} />
))}
<Route path="/" element={<Navigate to={`/${id}`} />} />
<Route path="*" element={<Navigate to={`/${id}`} />} />
<Route element={<Navigate to={`/${id}`} />} path="/" />
<Route element={<Navigate to={`/${id}`} />} path="*" />
</Routes>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ModeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function ModeSelect({ subject }: { subject: SubjectProps }) {

return (
<FormControl fullWidth sx={{ mt: 1, mx: 1 }}>
<InputLabel variant="standard" htmlFor={`${subject.id}-input-label`}>
<InputLabel htmlFor={`${subject.id}-input-label`} variant="standard">
Modalidad
</InputLabel>
<NativeSelect
Expand Down
7 changes: 4 additions & 3 deletions src/components/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PlanSelect } from '@/components';
import GitHubIcon from '@mui/icons-material/GitHub';
import { AppBar, Grid, IconButton, Toolbar, Typography } from '@mui/material';
import { AppBar, IconButton, Toolbar, Typography } from '@mui/material';
import Grid from '@mui/material/Grid2';

function NavBar() {
return (
Expand All @@ -15,10 +16,10 @@ function NavBar() {
container
sx={{
alignItems: 'center',
flex: 'auto',
justifyContent: { xs: 'center', sm: 'space-between' },
rowGap: 1,
}}
style={{ flexFlow: 'wrap' }}
rowGap={1}
>
<Typography
component="div"
Expand Down
13 changes: 8 additions & 5 deletions src/components/StatusMarker.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { PlanContext } from '@/context';
import type { PlanContextProps, Status, SubjectProps } from '@/types';
import { Box, Divider, Link } from '@mui/material';
import { dividerClasses } from '@mui/material/Divider';
import { useContext } from 'react';

function StatusMarker({
status,
levelSubjects,
renderDivider,
status,
}: {
status: Status;
levelSubjects: ReadonlyArray<SubjectProps>;
renderDivider: boolean;
status: Status;
}) {
const { updateStatuses } = useContext<PlanContextProps>(PlanContext);

Expand All @@ -20,20 +23,20 @@ function StatusMarker({
return (
<Box
sx={{
'& hr': {
[`& .${dividerClasses.root}`]: {
mx: 0.5,
},
display: 'flex',
}}
>
<Link
onClick={handleClickStatusMarker}
component="button"
onClick={handleClickStatusMarker}
underline="hover"
>
{status.name}
</Link>
<Divider orientation="vertical" flexItem />
{renderDivider ? <Divider flexItem orientation="vertical" /> : null}
</Box>
);
}
Expand Down
25 changes: 14 additions & 11 deletions src/components/Subject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ import { ModeSelect, StatusRadioGroup } from '@/components';
import { PlanContext } from '@/context';
import type { PlanContextProps, SubjectProps } from '@/types';
import CircleIcon from '@mui/icons-material/Circle';
import {
Card,
CardActions,
CardContent,
Grid,
Typography,
} from '@mui/material';
import { Card, CardActions, CardContent, Typography } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { useContext } from 'react';

function Subject({ subject }: { subject: SubjectProps }) {
Expand All @@ -18,9 +13,16 @@ function Subject({ subject }: { subject: SubjectProps }) {
const color = contextSubject.status.color;

return (
<Grid item xs={12} sm={6} md={4} lg={3} xl={2}>
<Grid
size={{
xs: 12,
sm: 6,
md: 4,
lg: 3,
xl: 2,
}}
>
<Card
variant="outlined"
sx={{
borderRadius: 0,
display: 'flex',
Expand All @@ -29,22 +31,23 @@ function Subject({ subject }: { subject: SubjectProps }) {
justifyContent: 'space-between',
p: 2,
}}
variant="outlined"
>
<CardContent
sx={{
p: 0,
display: 'flex',
justifyContent: 'space-between',
p: 0,
}}
>
<Typography component="h4" variant="h6">
{subject.name}
</Typography>
<CircleIcon
sx={{
color,
fontSize: 24,
ml: 1,
color,
}}
/>
</CardContent>
Expand Down
3 changes: 1 addition & 2 deletions src/components/SubjectGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Subject } from '@/components';
import type { SubjectProps } from '@/types';
import { Grid } from '@mui/material';
import Grid from '@mui/material/Grid2';

function SubjectGrid({
levelSubjects,
Expand All @@ -10,7 +10,6 @@ function SubjectGrid({
return (
<Grid
container
item
sx={{
display: 'flex',
flexWrap: 'wrap',
Expand Down
14 changes: 8 additions & 6 deletions src/components/SubjectStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { PlanContext } from '@/context';
import { statuses } from '@/data';
import type { PlanContextProps } from '@/types';
import { findPlanById, replaceWhiteSpace } from '@/utils';
import { Box, Grid, Stack, Typography } from '@mui/material';
import { Box, Stack, Typography } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { useContext } from 'react';

function SubjectStack() {
const { contextPlan } = useContext<PlanContextProps>(PlanContext);
const plan = findPlanById(contextPlan.id);
const subjectsByLevel = plan.subjects;
const statusesMaxIndex = Object.values(statuses).length - 1;

return (
<Stack spacing={3}>
Expand All @@ -20,10 +22,10 @@ function SubjectStack() {
key={`level-${index + 1}-grid`}
sx={{
flexDirection: 'column',
flexWrap: 'nowrap',
}}
>
<Grid
item
sx={{
alignItems: 'baseline',
display: 'flex',
Expand All @@ -32,22 +34,22 @@ function SubjectStack() {
}}
>
<Box>
<Typography variant="h3" sx={{ ml: 1 }}>
<Typography sx={{ ml: 1 }} variant="h3">
{index + 1}° año
</Typography>
</Box>
<Grid
item
sx={{ display: 'flex', flexWrap: 'wrap', userSelect: 'none' }}
>
<Typography sx={{ mr: 0.5 }}>Marcar a todas como:</Typography>
{Object.values(statuses).map((status) => (
{Object.values(statuses).map((status, index) => (
<StatusMarker
key={`${replaceWhiteSpace(
`${status.name}-status-marker-${index}`,
)}`}
status={status}
levelSubjects={levelSubjects}
renderDivider={index < statusesMaxIndex}
status={status}
/>
))}
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion src/context/PlanContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { createContext } from 'react';

const PlanContext = createContext<PlanContextProps>({
contextPlan: {
id: '',
branch: '',
id: '',
subjects: {},
},
updateMode: () => {},
Expand Down
2 changes: 1 addition & 1 deletion src/layout/PlanLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function PlanLayout({ children }: { children: ReactNode }) {
<>
<NavBar />
<Box component="main" sx={{ overflowWrap: 'anywhere' }}>
<Toolbar disableGutters sx={{ my: { xs: 8.5, sm: 0.5 } }} />
<Toolbar disableGutters sx={{ my: { xs: 8, sm: 2 } }} />
{children}
</Box>
</>
Expand Down
19 changes: 8 additions & 11 deletions src/views/PlanView.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import { ExportSVGButton, ShowDigraphButton, SubjectStack } from '@/components';
import { Box, Grid } from '@mui/material';
import { Box } from '@mui/material';
import Grid from '@mui/material/Grid2';

function PlanView() {
return (
<Box sx={{ m: 4 }}>
<Box sx={{ m: 4, mt: 0 }}>
<Box
sx={{
display: 'flex',
justifyContent: 'flex-end',
mb: 2.5,
justifyContent: { xs: 'center', sm: 'end' },
py: 3.5,
}}
>
<Grid
container
spacing={1.5}
sx={{ justifyContent: { xs: 'center', sm: 'end' }, my: 1 }}
>
<Grid item>
<Grid container spacing={1.5} sx={{ justifyContent: { xs: 'center' } }}>
<Grid>
<ShowDigraphButton />
</Grid>
<Grid item>
<Grid>
<ExportSVGButton />
</Grid>
</Grid>
Expand Down

0 comments on commit d41fe3f

Please sign in to comment.