@springmicro/cart 0.7.25 → 0.7.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@springmicro/cart",
3
3
  "private": false,
4
- "version": "0.7.25",
4
+ "version": "0.7.26",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "@nanostores/persistent": "^0.10.1",
25
25
  "@nanostores/query": "^0.3.3",
26
26
  "@nanostores/react": "^0.7.2",
27
- "@springmicro/utils": "^0.7.25",
27
+ "@springmicro/utils": "^0.7.26",
28
28
  "dotenv": "^16.4.5",
29
29
  "nanostores": "^0.10.3",
30
30
  "react": "18.3.1",
@@ -49,5 +49,5 @@
49
49
  "vite-plugin-css-injected-by-js": "^3.5.1",
50
50
  "yup": "^1.4.0"
51
51
  },
52
- "gitHead": "e67eb316de4309e612e59ca86e3ad73e4aab5e7a"
52
+ "gitHead": "fb10f8c2a5f1bdc81700ba962f1e8cac0168247f"
53
53
  }
@@ -18,6 +18,7 @@
18
18
  margin-top: 1rem;
19
19
  max-height: 50vh;
20
20
  overflow: auto;
21
+ width: calc(100% - 4rem);
21
22
  }
22
23
 
23
24
  @keyframes cardanimate {
@@ -10,6 +10,7 @@ import {
10
10
  Fade,
11
11
  Typography,
12
12
  IconButton,
13
+ Container,
13
14
  } from "@mui/material";
14
15
  import { setOrder as cartSetOrder } from "../utils/storage";
15
16
  import { AddCard, CCFocus, CreditCardValues } from "./components/AddCard";
@@ -450,14 +451,16 @@ export default function ReviewAndCalculateTaxes({
450
451
  gap: 2,
451
452
  }}
452
453
  >
453
- {CollectExtraInfo && <CollectExtraInfo formik={formik} />}
454
- <CheckoutActionFields
455
- formik={formik}
456
- prices={prices}
457
- products={products}
458
- hideFields={hideFields}
459
- disableFields={disableFields}
460
- />
454
+ <Container>
455
+ {CollectExtraInfo && <CollectExtraInfo formik={formik} />}
456
+ <CheckoutActionFields
457
+ formik={formik}
458
+ prices={prices}
459
+ products={products}
460
+ hideFields={hideFields}
461
+ disableFields={disableFields}
462
+ />
463
+ </Container>
461
464
  <AddCard
462
465
  cardRequired={cardRequired}
463
466
  onSubmit={createOrderAndGetTaxes}
@@ -519,7 +522,7 @@ function CheckoutActionFields({
519
522
  };
520
523
  // console.log({ checkoutFields });
521
524
  return (
522
- <Box sx={{ display: "flex", flexDirection: "column", mx: 3, gap: 2 }}>
525
+ <Box sx={{ display: "flex", flexDirection: "column", gap: 2 }}>
523
526
  {Object.keys(checkoutFields)
524
527
  .filter(
525
528
  (key) =>
@@ -295,18 +295,24 @@ export const AddCard = ({
295
295
  payment information.
296
296
  </Typography>
297
297
  )}
298
- <Button
299
- size="large"
300
- sx={{ mt: 3 }}
301
- variant="contained"
302
- // onClick={formik.handleSubmit}
303
- type="submit"
304
- disabled={formDisabled}
305
- color={formError ? "error" : undefined}
298
+ <Box
299
+ sx={{
300
+ display: "flex",
301
+ flexDirection: "row",
302
+ justifyContent: "space-between",
303
+ mt: 1,
304
+ mb: 4,
305
+ }}
306
306
  >
307
- Review
308
- </Button>
309
- <Box sx={{ mt: 1 }}>
307
+ <Button
308
+ size="large"
309
+ variant="contained"
310
+ type="submit"
311
+ disabled={formDisabled}
312
+ color={formError ? "error" : undefined}
313
+ >
314
+ Review
315
+ </Button>
310
316
  <StripeLogoLink />
311
317
  </Box>
312
318
  </form>
@@ -46,7 +46,7 @@ export function CartList({
46
46
  sx={{
47
47
  display: "flex",
48
48
  flexDirection: "column",
49
- maxWidth: 650,
49
+ maxWidth: { xs: 300, sm: 650 },
50
50
  alignItems: "center",
51
51
  boxShadow: "0px 2px 5px 2px #dfdfdfff",
52
52
  margin: "4px",
@@ -58,36 +58,32 @@ export function CartList({
58
58
  <Typography style={{ fontSize: "30px", fontWeight: "bold" }}>
59
59
  Checkout
60
60
  </Typography>
61
+
61
62
  <Box
62
63
  sx={{
63
- width: "50%",
64
- display: "flex",
65
- justifyContent: "space-between",
64
+ display: "grid",
65
+ gridTemplateColumns: { xs: "1fr", sm: "1fr 1fr" },
66
+ gap: { sm: 2 },
67
+ mt: { xs: 2, sm: 1 },
66
68
  }}
67
69
  >
68
- <Typography sx={{ fontSize: "20px", p: 1 }}>
70
+ <Typography sx={{ fontSize: "20px" }}>
69
71
  Subtotal: {formatPrice(subtotal)}
70
72
  </Typography>
71
- <Typography sx={{ fontSize: "20px", p: 1 }}>
73
+ <Typography sx={{ fontSize: "20px" }}>
72
74
  Taxes: {formatPrice(taxes)}
73
75
  </Typography>
74
- </Box>
75
- {(discount != 0 || shipping != 0) && (
76
- <Box
77
- sx={{
78
- width: "50%",
79
- display: "flex",
80
- justifyContent: "space-between",
81
- }}
82
- >
83
- <Typography sx={{ fontSize: "20px", p: 1 }}>
84
- {shipping && <>Shipping: {formatPrice(shipping)}</>}
76
+ {!!shipping && (
77
+ <Typography sx={{ fontSize: "20px" }}>
78
+ Shipping: {formatPrice(shipping)}
85
79
  </Typography>
86
- <Typography sx={{ fontSize: "20px", p: 1 }}>
87
- {discount && <>Discount: {formatPrice(discount)}</>}
80
+ )}
81
+ {!!discount && (
82
+ <Typography sx={{ fontSize: "20px" }}>
83
+ Discount: {formatPrice(discount)}
88
84
  </Typography>
89
- </Box>
90
- )}
85
+ )}
86
+ </Box>
91
87
  <Box>
92
88
  <Typography style={{ fontSize: "26px" }}>
93
89
  Total:{" "}
@@ -1,8 +1,8 @@
1
1
  .product-card {
2
- width: 500px;
3
2
  /* display: flex;
4
3
  flex-direction: row;
5
4
  justify-content: space-between; */
5
+ width: 100%;
6
6
  display: grid;
7
7
  grid-template-columns: 1fr 40px;
8
8
  gap: 0.5rem;
@@ -82,6 +82,13 @@ export function CartProductCard({
82
82
  >
83
83
  <IconButton
84
84
  className="remove-button"
85
+ sx={{
86
+ color: { xs: "red !important", md: "#ff000040 !important" },
87
+ transition: "all 0.2s !important",
88
+ ":hover": {
89
+ color: "red !important",
90
+ },
91
+ }}
85
92
  onClick={() => {
86
93
  removeFromCart(i);
87
94
  }}
@@ -1,40 +1,191 @@
1
- import { Box, IconButton, Typography, Tooltip } from "@mui/material";
2
- import ArrowBackIcon from "@mui/icons-material/ArrowBack";
1
+ import { Box, IconButton, Tooltip, Typography } from "@mui/material";
2
+ import CheckIcon from "@mui/icons-material/Check";
3
+ import CloseIcon from "@mui/icons-material/Close";
4
+
5
+ const BLUE = "rgb(40, 130, 213)";
6
+ const STEPS = ["PAYMENT DETAILS", "CONFIRMATION", "ORDER PLACED"];
7
+
8
+ function ProgressDots({ status }) {
9
+ return (
10
+ <Box sx={{ display: "flex", gap: "5px", alignItems: "center", ml: "14px" }}>
11
+ {STEPS.map((_, i) => {
12
+ const isCurrent = i === status;
13
+ const isDone = i < status;
14
+ return (
15
+ <Box
16
+ key={i}
17
+ sx={{
18
+ height: 6,
19
+ width: isCurrent ? 18 : 6,
20
+ borderRadius: isCurrent ? "3px" : "50%",
21
+ background:
22
+ isDone || isCurrent
23
+ ? BLUE
24
+ : "var(--color-border-tertiary, lightgrey)",
25
+ transition:
26
+ "width 0.3s ease, border-radius 0.3s ease, background 0.3s ease",
27
+ flexShrink: 0,
28
+ }}
29
+ />
30
+ );
31
+ })}
32
+ </Box>
33
+ );
34
+ }
3
35
 
4
36
  export function StatusBar({ status, backlink = "" }) {
37
+ const isLast = status >= STEPS.length - 1;
38
+
5
39
  return (
6
40
  <Box
7
- style={{
41
+ sx={{
8
42
  display: "flex",
9
- justifyContent: "center",
10
- flexDirection: "row",
43
+ alignItems: "center",
44
+ width: "100%",
45
+ py: 1.5,
46
+ boxSizing: "border-box",
11
47
  }}
12
48
  >
13
- <Box sx={{ flex: "1 1" }}>
49
+ {/* Back button */}
50
+ <Box
51
+ sx={{
52
+ flexShrink: 0,
53
+ width: 30,
54
+ position: "absolute",
55
+ top: { xs: 8, md: 20 },
56
+ left: { xs: 8, md: 20 },
57
+ }}
58
+ >
14
59
  <Tooltip title="Exit checkout">
15
- <IconButton href={`/${backlink}`}>
16
- <ArrowBackIcon />
60
+ <IconButton href={`/${backlink}`} size="small">
61
+ <CloseIcon fontSize="small" />
17
62
  </IconButton>
18
63
  </Tooltip>
19
64
  </Box>
20
- <Box id="status-bar">
21
- <Typography className="status-text active">PAYMENT DETAILS</Typography>
22
- <Box
23
- className={"status-bar" + (status > 0 ? " active" : "")}
24
- sx={{ display: { xs: "none", md: "block" } }}
25
- ></Box>
26
- <Typography className={"status-text" + (status > 0 ? " active" : "")}>
27
- CONFIRMATION
28
- </Typography>
65
+
66
+ {/* Center content */}
67
+ <Box
68
+ sx={{
69
+ flex: 1,
70
+ display: "flex",
71
+ alignItems: "center",
72
+ justifyContent: "center",
73
+ flexDirection: "column",
74
+ gap: "12px",
75
+ minWidth: 0,
76
+ }}
77
+ >
29
78
  <Box
30
- className={"status-bar" + (status > 1 ? " active" : "")}
31
- sx={{ display: { xs: "none", md: "block" } }}
32
- ></Box>
33
- <Typography className={"status-text" + (status > 1 ? " active" : "")}>
34
- ORDER PLACED
35
- </Typography>
79
+ sx={{
80
+ flex: 1,
81
+ display: "flex",
82
+ alignItems: "center",
83
+ justifyContent: "center",
84
+ gap: "12px",
85
+ minWidth: 0,
86
+ }}
87
+ >
88
+ {isLast ? (
89
+ /* Order placed — done state */
90
+ <Box sx={{ display: "flex", alignItems: "center", gap: "8px" }}>
91
+ <Box
92
+ sx={{
93
+ width: 22,
94
+ height: 22,
95
+ borderRadius: "50%",
96
+ background: BLUE,
97
+ display: "flex",
98
+ alignItems: "center",
99
+ justifyContent: "center",
100
+ flexShrink: 0,
101
+ }}
102
+ >
103
+ <CheckIcon sx={{ fontSize: 13, color: "white" }} />
104
+ </Box>
105
+ <Typography
106
+ sx={{
107
+ fontSize: "15px",
108
+ fontWeight: 600,
109
+ color: BLUE,
110
+ letterSpacing: "0.03em",
111
+ }}
112
+ >
113
+ ORDER PLACED
114
+ </Typography>
115
+ </Box>
116
+ ) : (
117
+ <>
118
+ {/* Current step */}
119
+ <Box
120
+ sx={{ display: "flex", flexDirection: "column", gap: "2px" }}
121
+ >
122
+ <Typography
123
+ sx={{
124
+ fontSize: "10px",
125
+ fontWeight: 600,
126
+ letterSpacing: "0.09em",
127
+ color: "text.disabled",
128
+ textTransform: "uppercase",
129
+ }}
130
+ >
131
+ Current
132
+ </Typography>
133
+ <Typography
134
+ sx={{
135
+ fontSize: "15px",
136
+ fontWeight: 600,
137
+ color: BLUE,
138
+ letterSpacing: "0.03em",
139
+ whiteSpace: "nowrap",
140
+ }}
141
+ >
142
+ {STEPS[status]}
143
+ </Typography>
144
+ </Box>
145
+
146
+ {/* Divider */}
147
+ <Box
148
+ sx={{
149
+ width: "1px",
150
+ height: 28,
151
+ background: "divider",
152
+ flexShrink: 0,
153
+ }}
154
+ />
155
+
156
+ {/* Next step */}
157
+ <Box
158
+ sx={{ display: "flex", flexDirection: "column", gap: "2px" }}
159
+ >
160
+ <Typography
161
+ sx={{
162
+ fontSize: "10px",
163
+ fontWeight: 600,
164
+ letterSpacing: "0.09em",
165
+ color: "text.disabled",
166
+ textTransform: "uppercase",
167
+ }}
168
+ >
169
+ Next
170
+ </Typography>
171
+ <Typography
172
+ sx={{
173
+ fontSize: "13px",
174
+ fontWeight: 500,
175
+ color: "text.secondary",
176
+ whiteSpace: "nowrap",
177
+ }}
178
+ >
179
+ {STEPS[status + 1]}
180
+ </Typography>
181
+ </Box>
182
+
183
+ {/* Progress dots */}
184
+ </>
185
+ )}
186
+ </Box>
187
+ {!isLast && <ProgressDots status={status} />}
36
188
  </Box>
37
- <Box sx={{ flex: "1 1" }} />
38
189
  </Box>
39
190
  );
40
191
  }