Skip to content

Commit

Permalink
Checkout Responsive Design
Browse files Browse the repository at this point in the history
  • Loading branch information
zreecespieces committed Feb 14, 2021
1 parent ce73c0c commit a9b716b
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 19 deletions.
7 changes: 6 additions & 1 deletion frontend/src/components/auth/Fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ const useStyles = makeStyles(theme => ({
[theme.breakpoints.down("xs")]: {
width: ({ fullWidth }) => (fullWidth ? undefined : "15rem"),
},
[theme.breakpoints.up("xs")]: {
width: ({ xs }) => (xs ? "10rem" : undefined),
},
},
input: {
color: ({ isWhite }) => (isWhite ? "#fff" : theme.palette.secondary.main),
fontSize: ({ xs }) => (xs ? "1.25rem" : undefined),
},
}))

Expand All @@ -30,8 +34,9 @@ export default function Fields({
disabled,
fullWidth,
settings,
xs,
}) {
const classes = useStyles({ isWhite, fullWidth, settings })
const classes = useStyles({ isWhite, fullWidth, settings, xs })

return Object.keys(fields).map(field => {
const validateHelper = event => {
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/components/cart/BillingConfirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,18 @@ export default function BillingConfirmation({
{fields.map(field =>
field.hidden ? null : (
<Grid item key={field.title} classes={{ root: classes.wrapper }}>
<Typography variant="h4" classes={{ root: classes.heading }}>
<Typography
align="right"
variant="h4"
classes={{ root: classes.heading }}
>
{field.title}
</Typography>
<Typography variant="h3" classes={{ root: classes.values }}>
<Typography
align="right"
variant="h3"
classes={{ root: classes.values }}
>
{Object.keys(field.values).map(value => (
<span key={value}>
{field.values[value]}
Expand Down
51 changes: 44 additions & 7 deletions frontend/src/components/cart/CheckoutNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const useStyles = makeStyles(theme => ({
width: "40rem",
height: "5rem",
position: "relative",
[theme.breakpoints.down("sm")]: {
width: "100%",
},
},
back: {
visibility: ({ steps, selectedStep }) =>
Expand All @@ -36,15 +39,36 @@ const useStyles = makeStyles(theme => ({
icon: {
height: "2.25rem",
width: "2.25rem",
[theme.breakpoints.down("xs")]: {
height: "1.75rem",
width: "1.75rem",
},
},
delete: {
height: "2rem",
width: "2rem",
[theme.breakpoints.down("xs")]: {
height: "1.5rem",
width: "1.5rem",
},
},
iconButton: {
padding: 6,
},
actions: {
position: "absolute",
right: 0,
},
text: {
[theme.breakpoints.down("xs")]: {
fontSize: "1.25rem",
},
},
navButtons: {
width: "1.5rem",
height: "1.5rem",
minWidth: 0,
},
}))

export default function CheckoutNavigation({
Expand Down Expand Up @@ -138,22 +162,29 @@ export default function CheckoutNavigation({
classes={{ root: classes.navbar }}
>
<Grid item classes={{ root: classes.back }}>
<Button onClick={() => setSelectedStep(selectedStep - 1)}>
<Typography variant="h5">{"<"}</Typography>
<Button
classes={{ root: classes.navButtons }}
onClick={() => setSelectedStep(selectedStep - 1)}
>
<Typography variant="h5" classes={{ root: classes.text }}>
{"<"}
</Typography>
</Button>
</Grid>
<Grid item>
<Typography variant="h5">
<Typography variant="h5" classes={{ root: classes.text }}>
{steps[selectedStep].title.toUpperCase()}
</Typography>
</Grid>
<Grid item classes={{ root: classes.forward }}>
<Button
disabled={steps[selectedStep].error}
classes={{ disabled: classes.disabled }}
classes={{ root: classes.navButtons, disabled: classes.disabled }}
onClick={() => setSelectedStep(selectedStep + 1)}
>
<Typography variant="h5">{">"}</Typography>
<Typography variant="h5" classes={{ root: classes.text }}>
{">"}
</Typography>
</Button>
</Grid>
{steps[selectedStep].hasActions && user.username !== "Guest" ? (
Expand All @@ -163,7 +194,10 @@ export default function CheckoutNavigation({
{loading === "save" ? (
<CircularProgress />
) : (
<IconButton onClick={() => handleAction("save")}>
<IconButton
classes={{ root: classes.iconButton }}
onClick={() => handleAction("save")}
>
<img src={save} alt="save" className={classes.icon} />
</IconButton>
)}
Expand All @@ -172,7 +206,10 @@ export default function CheckoutNavigation({
{loading === "delete" ? (
<CircularProgress />
) : (
<IconButton onClick={() => handleAction("delete")}>
<IconButton
classes={{ root: classes.iconButton }}
onClick={() => handleAction("delete")}
>
<span className={classes.delete}>
<Delete color="#fff" />
</span>
Expand Down
20 changes: 19 additions & 1 deletion frontend/src/components/cart/CheckoutPortal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from "react"
import Grid from "@material-ui/core/Grid"
import Typography from "@material-ui/core/Typography"
import useMediaQuery from "@material-ui/core/useMediaQuery"
import { makeStyles } from "@material-ui/core/styles"

import CheckoutNavigation from "./CheckoutNavigation"
Expand All @@ -18,6 +19,14 @@ const useStyles = makeStyles(theme => ({
width: "40rem",
height: "25rem",
backgroundColor: theme.palette.primary.main,
[theme.breakpoints.down("sm")]: {
width: "100%",
},
},
container: {
[theme.breakpoints.down("md")]: {
marginBottom: "5rem",
},
},
"@global": {
".MuiInput-underline:before, .MuiInput-underline:hover:not(.Mui-disabled):before": {
Expand All @@ -31,6 +40,8 @@ const useStyles = makeStyles(theme => ({

export default function CheckoutPortal({ user }) {
const classes = useStyles()
const matchesMD = useMediaQuery(theme => theme.breakpoints.down("md"))

const [selectedStep, setSelectedStep] = useState(0)
const [detailValues, setDetailValues] = useState({
name: "",
Expand Down Expand Up @@ -243,7 +254,14 @@ export default function CheckoutPortal({ user }) {
}, [detailSlot, locationSlot, selectedStep])

return (
<Grid item container direction="column" alignItems="flex-end" lg={6}>
<Grid
item
container
direction="column"
classes={{ root: classes.container }}
alignItems={matchesMD ? "flex-start" : "flex-end"}
lg={6}
>
<CheckoutNavigation
steps={steps}
selectedStep={selectedStep}
Expand Down
21 changes: 19 additions & 2 deletions frontend/src/components/cart/Confirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Typography from "@material-ui/core/Typography"
import CircularProgress from "@material-ui/core/CircularProgress"
import Button from "@material-ui/core/Button"
import Chip from "@material-ui/core/Chip"
import useMediaQuery from "@material-ui/core/useMediaQuery"
import { makeStyles } from "@material-ui/core/styles"

import Fields from "../auth/Fields"
Expand Down Expand Up @@ -38,13 +39,19 @@ const useStyles = makeStyles(theme => ({
text: {
fontSize: "1rem",
color: "#fff",
[theme.breakpoints.down("xs")]: {
fontSize: "0.85rem",
},
},
card: {
height: 18,
width: 25,
},
priceLabel: {
fontSize: "1.5rem",
[theme.breakpoints.down("xs")]: {
fontSize: "0.85rem",
},
},
darkBackground: {
backgroundColor: theme.palette.secondary.main,
Expand All @@ -67,9 +74,16 @@ const useStyles = makeStyles(theme => ({
},
priceValue: {
marginRight: "1rem",
[theme.breakpoints.down("xs")]: {
fontSize: "0.85rem",
marginRight: "0.5rem",
},
},
fieldWrapper: {
marginLeft: "1.25rem",
[theme.breakpoints.down("xs")]: {
marginLeft: "0.25rem",
},
},
button: {
width: "100%",
Expand Down Expand Up @@ -117,6 +131,8 @@ export default function Confirmation({
setOrder,
}) {
const classes = useStyles()
const matchesXS = useMediaQuery(theme => theme.breakpoints.down("xs"))

const [loading, setLoading] = useState(false)
const { cart, dispatchCart } = useContext(CartContext)
const { dispatchFeedback } = useContext(FeedbackContext)
Expand Down Expand Up @@ -211,8 +227,8 @@ export default function Confirmation({
<Grid item xs={2} classes={{ root: classes.adornmentWrapper }}>
{adornment}
</Grid>
<Grid item xs={10} classes={{ root: classes.centerText }}>
<Typography variant="body1" classes={{ root: classes.text }}>
<Grid item xs={10} classes={{ root: classes.centerText }} zeroMinWidth>
<Typography noWrap variant="body1" classes={{ root: classes.text }}>
{value}
</Typography>
</Grid>
Expand Down Expand Up @@ -337,6 +353,7 @@ export default function Confirmation({
errors={promoError}
setErrors={setPromoError}
isWhite
xs={matchesXS}
/>
</span>
) : (
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/components/cart/Shipping.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ const useStyles = makeStyles(theme => ({
borderRadius: 15,
height: "10rem",
width: "10rem",
[theme.breakpoints.down("xs")]: {
height: "6rem",
width: "6rem",
},
"&:hover": {
backgroundColor: theme.palette.secondary.light,
},
},
label: {
fontSize: "1.5rem",
[theme.breakpoints.down("xs")]: {
fontSize: "0.9rem",
},
},
container: {
height: "100%",
Expand All @@ -29,6 +36,9 @@ const useStyles = makeStyles(theme => ({
},
price: {
color: "#fff",
[theme.breakpoints.down("xs")]: {
fontSize: "1.25rem",
},
},
selected: {
backgroundColor: "#fff",
Expand Down
31 changes: 28 additions & 3 deletions frontend/src/components/cart/ThankYou.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react"
import Grid from "@material-ui/core/Grid"
import Button from "@material-ui/core/Button"
import Typography from "@material-ui/core/Typography"
import useMediaQuery from "@material-ui/core/useMediaQuery"
import { Link } from "gatsby"
import { makeStyles } from "@material-ui/core/styles"

Expand All @@ -12,13 +13,24 @@ const useStyles = makeStyles(theme => ({
padding: "0.25rem 0",
textTransform: "none",
},
detailsText: {
[theme.breakpoints.down("xs")]: {
fontSize: "1rem",
},
},
order: {
fontWeight: 600,
[theme.breakpoints.down("xs")]: {
fontSize: "1rem",
},
},
shopText: {
fontSize: "2rem",
fontWeight: 600,
textTransform: "none",
[theme.breakpoints.down("xs")]: {
fontSize: "1.5rem",
},
},
container: {
height: "100%",
Expand All @@ -36,6 +48,7 @@ const useStyles = makeStyles(theme => ({

export default function ThankYou({ selectedShipping, order }) {
const classes = useStyles()
const matchesXS = useMediaQuery(theme => theme.breakpoints.down("xs"))

const addToDate = days => {
var date = new Date()
Expand Down Expand Up @@ -73,16 +86,28 @@ export default function ThankYou({ selectedShipping, order }) {
<img src={complete} alt="order placed" className={classes.icon} />
</Grid>
<Grid item>
<Typography variant="h4">Expected by {getExpected()}</Typography>
<Grid item container justify="space-between" alignItems="center">
<Typography variant="h4" align="center">
Expected by {getExpected()}
</Typography>
<Grid
item
container
justify={matchesXS ? "space-around" : "space-between"}
alignItems="center"
>
<Grid item>
<Typography variant="body2" classes={{ root: classes.order }}>
Order #{order.id.slice(order.id.length - 10, order.id.length)}
</Typography>
</Grid>
<Grid item>
<Button classes={{ root: classes.detailsButton }}>
<Typography variant="body2">Details ></Typography>
<Typography
variant="body2"
classes={{ root: classes.detailsText }}
>
Details >
</Typography>
</Button>
</Grid>
</Grid>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/settings/Details.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ const useStyles = makeStyles(theme => ({
switchLabel: {
color: "#fff",
fontWeight: 600,
[theme.breakpoints.down("xs")]: {
fontSize: "1rem",
},
},
"@global": {
".MuiInput-underline:before, .MuiInput-underline:hover:not(.Mui-disabled):before": {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/settings/Location.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const useStyles = makeStyles(theme => ({
switchLabel: {
color: "#fff",
fontWeight: 600,
[theme.breakpoints.down("xs")]: {
fontSize: "1rem",
},
},
locationContainer: {
position: "relative",
Expand Down
Loading

0 comments on commit a9b716b

Please sign in to comment.