Skip to content

Commit 8f872c3

Browse files
committed
Alignment on desktop
1 parent 2983a19 commit 8f872c3

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

site/src/components/WorkspaceScheduleButton/EditHours.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Button from "@material-ui/core/Button"
22
import { makeStyles } from "@material-ui/core/styles"
33
import TextField from "@material-ui/core/TextField"
4+
import { Stack } from "components/Stack/Stack"
45
import { useState } from "react"
56
import { useTranslation } from "react-i18next"
67

@@ -15,6 +16,7 @@ export const EditHours = ({ handleSubmit }: EditHoursProps): JSX.Element => {
1516

1617
return (
1718
<form onSubmit={() => handleSubmit(hours)}>
19+
<Stack direction="row" alignItems="baseline" spacing={1}>
1820
<TextField
1921
className={styles.inputField}
2022
inputProps={{ min: 0, step: 1 }}
@@ -23,15 +25,25 @@ export const EditHours = ({ handleSubmit }: EditHoursProps): JSX.Element => {
2325
onChange={(e) => setHours(parseInt(e.target.value))}
2426
type="number"
2527
/>
26-
<Button type="submit">
28+
<Button className={styles.button} type="submit">
2729
{t("workspaceScheduleButton.submitDeadline")}
2830
</Button>
31+
</Stack>
2932
</form>
3033
)
3134
}
3235

3336
const useStyles = makeStyles(() => ({
3437
inputField: {
35-
width: '70px'
38+
width: '70px',
39+
"& .MuiOutlinedInput-root": {
40+
height: '30px'
41+
}
42+
},
43+
button: {
44+
"&.MuiButton-root": {
45+
minHeight: '30px',
46+
height: '30px'
47+
}
3648
}
3749
}))

site/src/components/WorkspaceScheduleButton/WorkspaceScheduleButton.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import AddIcon from "@material-ui/icons/Add"
77
import RemoveIcon from "@material-ui/icons/Remove"
88
import ScheduleIcon from "@material-ui/icons/Schedule"
99
import { Maybe } from "components/Conditionals/Maybe"
10+
import { Stack } from "components/Stack/Stack"
1011
import dayjs from "dayjs"
1112
import advancedFormat from "dayjs/plugin/advancedFormat"
1213
import duration from "dayjs/plugin/duration"
@@ -76,19 +77,21 @@ export const WorkspaceScheduleButton: React.FC<
7677
}
7778

7879
const handleSubmitHours = (hours: number) => {
79-
if (editMode === "add") {
80-
onDeadlinePlus(hours)
81-
}
82-
if (editMode === "subtract") {
83-
onDeadlineMinus(hours)
80+
if (hours !== 0) {
81+
if (editMode === "add") {
82+
onDeadlinePlus(hours)
83+
}
84+
if (editMode === "subtract") {
85+
onDeadlineMinus(hours)
86+
}
8487
}
8588
setEditMode("off")
8689
}
8790

8891
return (
8992
<span className={styles.wrapper}>
9093
<Maybe condition={shouldDisplayScheduleLabel(workspace)}>
91-
<span className={styles.label}>
94+
<Stack className={styles.label} spacing={1} direction="row" alignItems="center" >
9295
<WorkspaceScheduleLabel workspace={workspace} />
9396
<Maybe condition={canUpdateWorkspace && canEditDeadline(workspace)}>
9497
<span className={styles.actions}>
@@ -121,7 +124,7 @@ export const WorkspaceScheduleButton: React.FC<
121124
<EditHours handleSubmit={handleSubmitHours} />
122125
</Maybe>
123126
</Maybe>
124-
</span>
127+
</Stack>
125128
</Maybe>
126129
<>
127130
<Button
@@ -218,13 +221,13 @@ const useStyles = makeStyles<Theme, StyleProps>((theme) => ({
218221
},
219222
addButton: {
220223
borderRadius: theme.shape.borderRadius,
221-
backgroundColor: ({ editMode }) =>
222-
editMode === "add" ? theme.palette.primary.main : "inherit",
224+
border: ({ editMode }) =>
225+
editMode === "add" ? `2px solid ${theme.palette.primary.main}` : "2px solid transparent",
223226
},
224227
subtractButton: {
225228
borderRadius: theme.shape.borderRadius,
226-
backgroundColor: ({ editMode }) =>
227-
editMode === "subtract" ? theme.palette.primary.main : "inherit",
229+
border: ({ editMode }) =>
230+
editMode === "subtract" ? `2px solid ${theme.palette.primary.main}` : "2px solid transparent"
228231
},
229232
popoverPaper: {
230233
padding: `${theme.spacing(2)}px ${theme.spacing(3)}px ${theme.spacing(

site/src/components/WorkspaceScheduleButton/WorkspaceScheduleLabel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export const WorkspaceScheduleLabel: React.FC<{ workspace: Workspace }> = ({
4545

4646
const useStyles = makeStyles((theme) => ({
4747
labelText: {
48-
marginRight: theme.spacing(2),
48+
marginRight: theme.spacing(1),
49+
marginLeft: theme.spacing(1),
4950
lineHeight: "160%",
5051

5152
[theme.breakpoints.down("sm")]: {

0 commit comments

Comments
 (0)