Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
import { AppBar, Box, Toolbar, Typography, styled } from '@mui/material';
import { AppBar, Toolbar, Typography } from '@mui/material';
import { DatePicker } from './DatePicker';

export const Header = () => {
return (
<AppBar position="static">
<Toolbar>
<AppTitle variant="h5">Task Timer</AppTitle>
<DatePickerBox>
<DatePicker />
</DatePickerBox>
<Toolbar
sx={{
flexDirection: { xs: 'column', sm: 'row' },
py: { xs: 1, sm: 0 },
}}
>
<Typography
variant="h5"
sx={{
flexGrow: 1,
fontWeight: 'bold',
fontSize: { xs: '1.25rem', sm: '1.5rem' },
mb: { xs: 1, sm: 0 },
}}
>
Task Timer
</Typography>
<DatePicker />
</Toolbar>
</AppBar>
);
};

const AppTitle = styled(Typography)(() => ({
flexGrow: 1,
fontWeight: 'bold',
}));

const DatePickerBox = styled(Box)`
${(props) => props.theme.breakpoints.up('xs')} {
display: none;
}
${(props) => props.theme.breakpoints.up('sm')} {
display: block;
}
`;
8 changes: 7 additions & 1 deletion src/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ export const Layout = (props: LayoutProps) => {
<CssBaseline />
<Header />
<Container>
<Box p="20px">{props.children}</Box>
<Box
sx={{
p: { xs: 1, sm: 2, md: 2.5 },
}}
>
{props.children}
</Box>
<Footer />
</Container>
</ThemeProvider>
Expand Down
9 changes: 7 additions & 2 deletions src/components/layout/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@ export const Table = () => {
<TableContainer
component={Paper}
ref={tableRef}
style={{ marginBottom: '10px', position: 'relative' }}
sx={{
mb: { xs: 1, sm: 1.25 },
position: 'relative',
overflowX: 'auto',
WebkitOverflowScrolling: 'touch',
}}
>
<TimeCursor
hoursPositionLeft={hoursPosition?.hoursLeftPosition}
hoursPositionRight={hoursPosition?.hoursRightPosition}
hoursHeight={timeHeight}
/>
<MuiTable size="small">
<MuiTable size="small" sx={{ minWidth: { xs: 800, sm: 'auto' } }}>
<TableHead>
<TableRow>
<TableCell className="icon" />
Expand Down
92 changes: 53 additions & 39 deletions src/components/task/TaskCreationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
TableCell,
Select,
MenuItem,
Box,
} from '@mui/material';
import { TimeSummaryCell } from '../time/TimeSummaryCell';
import { useAppDispatch, useAppSelector } from '../../app/hooks';
Expand All @@ -14,7 +15,7 @@ import { type TaskTime, getTimesForDate } from '../../app/slices/timeSlice';
import { getSelectedDate } from '../../app/slices/appSlice';
import { addTaskToDate } from '../../app/slices/dateSlice';
import { DEFAULT_TASK_TYPES } from '../../types/taskTypes';
import { MAX_TASK_DESCRIPTION_LENGTH, UI } from '../../app/constants';
import { MAX_TASK_DESCRIPTION_LENGTH } from '../../app/constants';

export const TaskCreationRow = () => {
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -68,46 +69,59 @@ export const TaskCreationRow = () => {
<TableRow>
<TableCell className="icon" />
<TableCell>
<Select
value={taskType}
onChange={(event) => setTaskType(event.target.value)}
size="small"
style={{
fontSize: UI.SELECT.FONT_SIZE,
marginRight: UI.SELECT.MARGIN_RIGHT,
minWidth: UI.SELECT.MIN_WIDTH,
<Box
sx={{
display: 'flex',
flexDirection: { xs: 'column', sm: 'row' },
gap: { xs: 1, sm: 1 },
alignItems: { xs: 'stretch', sm: 'center' },
}}
>
{DEFAULT_TASK_TYPES.map((type) => (
<MenuItem key={type.id} value={type.id}>
{type.name}
</MenuItem>
))}
</Select>
<Input
inputRef={inputRef}
style={{ fontSize: UI.INPUT.FONT_SIZE }}
placeholder="Task name/description"
value={description}
onChange={(event) => setDescription(event.target.value)}
onKeyDown={(event) => {
if (event.key === 'Enter') {
addTask();
} else if (event.key === 'Escape') {
setDescription('');
inputRef.current?.blur();
}
}}
/>
<Button
color="secondary"
size="small"
variant="contained"
style={{ marginLeft: UI.BUTTON.MARGIN_LEFT }}
onClick={addTask}
>
Add Task
</Button>
<Select
value={taskType}
onChange={(event) => setTaskType(event.target.value)}
size="small"
sx={{
fontSize: { xs: 14, sm: 13 },
minWidth: { xs: '100%', sm: 100 },
}}
>
{DEFAULT_TASK_TYPES.map((type) => (
<MenuItem key={type.id} value={type.id}>
{type.name}
</MenuItem>
))}
</Select>
<Input
inputRef={inputRef}
sx={{
fontSize: { xs: 14, sm: 13 },
flex: { sm: 1 },
}}
placeholder="Task name/description"
value={description}
onChange={(event) => setDescription(event.target.value)}
onKeyDown={(event) => {
if (event.key === 'Enter') {
addTask();
} else if (event.key === 'Escape') {
setDescription('');
inputRef.current?.blur();
}
}}
/>
<Button
color="secondary"
size="small"
variant="contained"
sx={{
minHeight: { xs: 44, sm: 'auto' },
}}
onClick={addTask}
>
Add Task
</Button>
</Box>
</TableCell>
<TableCell colSpan={11}></TableCell>
<TimeSummaryCell totalMinutes={totalMinutes} />
Expand Down
108 changes: 62 additions & 46 deletions src/components/task/TaskRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Select,
MenuItem,
Chip,
Box,
} from '@mui/material';
import HighlightOffIcon from '@mui/icons-material/HighlightOff';
import { TimeRowCell } from '../time/TimeRow';
Expand All @@ -28,7 +29,7 @@ import {
} from '../../app/slices/timeSlice';
import { removeTaskFromDate } from '../../app/slices/dateSlice';
import { DEFAULT_TASK_TYPES, getTaskType } from '../../types/taskTypes';
import { MAX_TASK_DESCRIPTION_LENGTH, UI } from '../../app/constants';
import { MAX_TASK_DESCRIPTION_LENGTH } from '../../app/constants';

interface TaskRowProps {
taskId: number;
Expand Down Expand Up @@ -170,7 +171,9 @@ export const TaskRow = (props: TaskRowProps) => {
<HighlightOffIcon
onClick={doDeleteTask}
className="taskDelete"
fontSize="small"
sx={{
fontSize: { xs: '1.5rem', sm: '1.25rem' },
}}
role="button"
aria-label={`Delete task: ${task.description}`}
tabIndex={0}
Expand Down Expand Up @@ -203,9 +206,9 @@ export const TaskRow = (props: TaskRowProps) => {
backgroundColor: currentTaskType.color,
color: '#fff',
fontWeight: 'bold',
fontSize: UI.CHIP.FONT_SIZE,
height: UI.CHIP.HEIGHT,
marginRight: UI.CHIP.MARGIN_RIGHT,
fontSize: { xs: '0.75rem', sm: '0.7rem' },
height: { xs: 24, sm: 20 },
marginRight: 1,
}}
/>
{task.description}
Expand All @@ -218,50 +221,63 @@ export const TaskRow = (props: TaskRowProps) => {
<TableRow>
<TableCell className="icon" />
<TableCell component="th" scope="row" className="cell">
<Select
value={taskType}
onChange={(event) => setTaskType(event.target.value)}
size="small"
style={{
fontSize: UI.SELECT.FONT_SIZE,
marginRight: UI.SELECT.MARGIN_RIGHT,
minWidth: UI.SELECT.MIN_WIDTH,
<Box
sx={{
display: 'flex',
flexDirection: { xs: 'column', sm: 'row' },
gap: { xs: 1, sm: 1 },
alignItems: { xs: 'stretch', sm: 'center' },
}}
>
{DEFAULT_TASK_TYPES.map((type) => (
<MenuItem key={type.id} value={type.id}>
{type.name}
</MenuItem>
))}
</Select>
<Input
inputRef={inputRef}
style={{ fontSize: UI.INPUT.FONT_SIZE }}
value={description}
onChange={(event) => setDescription(event.target.value)}
onKeyDown={(event) => {
if (!editing) {
return;
}
<Select
value={taskType}
onChange={(event) => setTaskType(event.target.value)}
size="small"
sx={{
fontSize: { xs: 14, sm: 13 },
minWidth: { xs: '100%', sm: 100 },
}}
>
{DEFAULT_TASK_TYPES.map((type) => (
<MenuItem key={type.id} value={type.id}>
{type.name}
</MenuItem>
))}
</Select>
<Input
inputRef={inputRef}
sx={{
fontSize: { xs: 14, sm: 13 },
flex: { sm: 1 },
}}
value={description}
onChange={(event) => setDescription(event.target.value)}
onKeyDown={(event) => {
if (!editing) {
return;
}

if (event.key === 'Enter') {
doUpdateTask();
} else if (event.key === 'Escape') {
dispatch(endTaskEdit());
setDescription(task.description);
setTaskType(task.type || 'task');
}
}}
/>
<Button
color="secondary"
size="small"
variant="contained"
style={{ marginLeft: UI.BUTTON.MARGIN_LEFT }}
onClick={doUpdateTask}
>
Update Task
</Button>
if (event.key === 'Enter') {
doUpdateTask();
} else if (event.key === 'Escape') {
dispatch(endTaskEdit());
setDescription(task.description);
setTaskType(task.type || 'task');
}
}}
/>
<Button
color="secondary"
size="small"
variant="contained"
sx={{
minHeight: { xs: 44, sm: 'auto' },
}}
onClick={doUpdateTask}
>
Update Task
</Button>
</Box>
</TableCell>
{taskRowTime()}
</TableRow>
Expand Down
8 changes: 8 additions & 0 deletions src/components/time/TimeRow.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
z-index: 200;
}

/* Larger touch targets on mobile */
@media (max-width: 599px) {
.increment {
width: 16px;
height: 32px;
}
}

.increment:hover {
background-color: #f9643d;
cursor: pointer;
Expand Down
Loading