@springmicro/cart 0.5.16 → 0.5.17

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.5.16",
4
+ "version": "0.5.17",
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.5.16",
27
+ "@springmicro/utils": "0.5.17",
28
28
  "dotenv": "^16.4.5",
29
29
  "nanostores": "^0.10.3",
30
30
  "react": "^18.2.0",
@@ -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": "9adcb0aba821c9e30cb9c1c8d737e2426f7f29c6"
52
+ "gitHead": "915dac621fa9bf06ffe49dadd56452f28bbd5737"
53
53
  }
Binary file
@@ -1,16 +1,16 @@
1
- import { CartProduct } from "./types";
2
- import { addToCart } from "./utils/storage";
3
-
4
- type Props = {
5
- item: CartProduct;
6
- children: any;
7
- };
8
-
9
- export default function AddToCartForm({ item, children }: Props) {
10
- function addItemToCart(e: any) {
11
- e.preventDefault();
12
- addToCart(item);
13
- }
14
-
15
- return <form onSubmit={addItemToCart}>{children}</form>;
16
- }
1
+ import { CartProduct } from "./types";
2
+ import { addToCart } from "./utils/storage";
3
+
4
+ type Props = {
5
+ item: CartProduct;
6
+ children: any;
7
+ };
8
+
9
+ export default function AddToCartForm({ item, children }: Props) {
10
+ function addItemToCart(e: any) {
11
+ e.preventDefault();
12
+ addToCart(item);
13
+ }
14
+
15
+ return <form onSubmit={addItemToCart}>{children}</form>;
16
+ }
File without changes
@@ -1,106 +1,106 @@
1
- .card {
2
- display: flex;
3
- gap: 0.5rem;
4
- flex-direction: column;
5
- border-radius: 8px;
6
- padding: 1rem;
7
- box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0);
8
- transition: all 0.3s 0.1s;
9
- cursor: pointer;
10
- }
11
-
12
- .card:hover {
13
- box-shadow: 0px 2px 5px 2px #dfdfdfff;
14
- transition: all 0.3s 0s;
15
- }
16
-
17
- .card-section {
18
- display: flex;
19
- gap: 8px;
20
- flex-direction: column;
21
- align-items: center;
22
- }
23
-
24
- .image-container {
25
- width: 100%;
26
- background-color: #ccc;
27
- border-radius: 4px;
28
- aspect-ratio: 1.5;
29
- }
30
-
31
- .button-section {
32
- display: flex;
33
- justify-content: space-around;
34
- flex-direction: row;
35
- flex-wrap: wrap;
36
- margin: 4px 2rem 0px;
37
- gap: 0.5rem;
38
- }
39
-
40
- .addtocartbutton {
41
- color: white;
42
- background-color: rgb(39, 138, 230);
43
- padding: 4px 16px 6px;
44
- border-radius: 8px;
45
- outline: none;
46
- transition: all 0.3s;
47
- }
48
-
49
- .addtocartbutton.red {
50
- background-color: rgb(230, 39, 39);
51
- }
52
-
53
- .addtocartbutton.disabled {
54
- background-color: rgb(170, 170, 170);
55
- cursor: not-allowed;
56
- }
57
- .addtocartbutton.disabled:hover {
58
- background-color: rgb(170, 170, 170);
59
- }
60
-
61
- .addtocartbutton:hover {
62
- background-color: rgb(36, 124, 207);
63
- }
64
-
65
- .hover-button > .hover-section {
66
- display: none;
67
- position: absolute;
68
- width: 325px;
69
- margin-left: calc(-113.75px);
70
- padding: 1rem;
71
- color: black;
72
- }
73
-
74
- .hover-button:hover > .hover-section {
75
- display: flex;
76
- justify-content: center;
77
- }
78
-
79
- .hover-data {
80
- border-radius: 8px;
81
- padding: 1rem;
82
- box-shadow: 0px 2px 5px 2px rgb(173, 173, 173);
83
- background-color: white;
84
- }
85
-
86
- .hover-data > div {
87
- display: flex;
88
- flex-direction: column;
89
- background-color: rgb(203, 203, 203);
90
- gap: 1px;
91
- }
92
-
93
- .tieredpricingbutton {
94
- display: flex;
95
- flex-direction: column;
96
- justify-content: flex-start;
97
- align-items: flex-start;
98
- text-align: left;
99
- padding: 4px 0.5rem 8px;
100
- background-color: white;
101
- transition: all 0.3s;
102
- }
103
-
104
- .tieredpricingbutton:hover {
105
- background-color: rgb(233, 233, 233);
106
- }
1
+ .card {
2
+ display: flex;
3
+ gap: 0.5rem;
4
+ flex-direction: column;
5
+ border-radius: 8px;
6
+ padding: 1rem;
7
+ box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0);
8
+ transition: all 0.3s 0.1s;
9
+ cursor: pointer;
10
+ }
11
+
12
+ .card:hover {
13
+ box-shadow: 0px 2px 5px 2px #dfdfdfff;
14
+ transition: all 0.3s 0s;
15
+ }
16
+
17
+ .card-section {
18
+ display: flex;
19
+ gap: 8px;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ }
23
+
24
+ .image-container {
25
+ width: 100%;
26
+ background-color: #ccc;
27
+ border-radius: 4px;
28
+ aspect-ratio: 1.5;
29
+ }
30
+
31
+ .button-section {
32
+ display: flex;
33
+ justify-content: space-around;
34
+ flex-direction: row;
35
+ flex-wrap: wrap;
36
+ margin: 4px 2rem 0px;
37
+ gap: 0.5rem;
38
+ }
39
+
40
+ .addtocartbutton {
41
+ color: white;
42
+ background-color: rgb(39, 138, 230);
43
+ padding: 4px 16px 6px;
44
+ border-radius: 8px;
45
+ outline: none;
46
+ transition: all 0.3s;
47
+ }
48
+
49
+ .addtocartbutton.red {
50
+ background-color: rgb(230, 39, 39);
51
+ }
52
+
53
+ .addtocartbutton.disabled {
54
+ background-color: rgb(170, 170, 170);
55
+ cursor: not-allowed;
56
+ }
57
+ .addtocartbutton.disabled:hover {
58
+ background-color: rgb(170, 170, 170);
59
+ }
60
+
61
+ .addtocartbutton:hover {
62
+ background-color: rgb(36, 124, 207);
63
+ }
64
+
65
+ .hover-button > .hover-section {
66
+ display: none;
67
+ position: absolute;
68
+ width: 325px;
69
+ margin-left: calc(-113.75px);
70
+ padding: 1rem;
71
+ color: black;
72
+ }
73
+
74
+ .hover-button:hover > .hover-section {
75
+ display: flex;
76
+ justify-content: center;
77
+ }
78
+
79
+ .hover-data {
80
+ border-radius: 8px;
81
+ padding: 1rem;
82
+ box-shadow: 0px 2px 5px 2px rgb(173, 173, 173);
83
+ background-color: white;
84
+ }
85
+
86
+ .hover-data > div {
87
+ display: flex;
88
+ flex-direction: column;
89
+ background-color: rgb(203, 203, 203);
90
+ gap: 1px;
91
+ }
92
+
93
+ .tieredpricingbutton {
94
+ display: flex;
95
+ flex-direction: column;
96
+ justify-content: flex-start;
97
+ align-items: flex-start;
98
+ text-align: left;
99
+ padding: 4px 0.5rem 8px;
100
+ background-color: white;
101
+ transition: all 0.3s;
102
+ }
103
+
104
+ .tieredpricingbutton:hover {
105
+ background-color: rgb(233, 233, 233);
106
+ }
@@ -22,16 +22,19 @@ export type ProductCardComponentProps = {
22
22
  pricing;
23
23
  addToCart: (price_index?: number) => void;
24
24
  removeFromCart: (price?: boolean) => void;
25
+ disabled?: boolean;
25
26
  };
26
27
 
27
28
  export default function ProductCard({
28
29
  product,
29
30
  component,
30
31
  priceTierName,
32
+ disabled,
31
33
  }: {
32
34
  product: Product;
33
35
  component?: React.FC<ProductCardComponentProps>;
34
36
  priceTierName?: string; // Might have incomplete code for cases where the tier name doesn't match.
37
+ disabled?: boolean;
35
38
  }) {
36
39
  const cart = JSON.parse(useStore(cartStore));
37
40
 
@@ -64,6 +67,7 @@ export default function ProductCard({
64
67
 
65
68
  const props: ProductCardComponentProps = {
66
69
  product,
70
+ disabled,
67
71
  foundInCart: {
68
72
  product: productFoundInCart,
69
73
  price: pi != -1 ? !!~priceInCartIndex : null,
@@ -88,6 +92,7 @@ function DefaultProductCard({
88
92
  pricing,
89
93
  addToCart,
90
94
  removeFromCart,
95
+ disabled,
91
96
  }: ProductCardComponentProps) {
92
97
  return (
93
98
  <div
@@ -112,6 +117,7 @@ function DefaultProductCard({
112
117
  onClick={() => {
113
118
  removeFromCart();
114
119
  }}
120
+ disabled={disabled}
115
121
  >
116
122
  Remove from cart
117
123
  </button>
@@ -121,6 +127,7 @@ function DefaultProductCard({
121
127
  onClick={() => {
122
128
  addToCart();
123
129
  }}
130
+ disabled={disabled}
124
131
  >
125
132
  Add {formatPricing(pricing[0])}
126
133
  </button>
@@ -140,6 +147,7 @@ function DefaultProductCard({
140
147
  onClick={() => {
141
148
  addToCart(i);
142
149
  }}
150
+ disabled={disabled}
143
151
  >
144
152
  Tier {i + 1}:
145
153
  <br />
@@ -1,93 +1,93 @@
1
- .two-col {
2
- display: flex;
3
- /* grid-template-columns: 1fr 1fr; */
4
- margin-top: 2rem;
5
- align-items: flex-start;
6
- }
7
-
8
- .two-col > * {
9
- width: 50%;
10
- }
11
-
12
- .checkout-list {
13
- display: flex;
14
- flex-direction: column;
15
- align-items: center;
16
- gap: 1rem;
17
- padding: 8px 4px;
18
- margin-top: 1rem;
19
- max-height: 50vh;
20
- overflow: auto;
21
- }
22
-
23
- @keyframes cardanimate {
24
- 0% {
25
- box-shadow: 0px 2px 5px 2px #dfdfdfff;
26
- }
27
- 50% {
28
- box-shadow: 0px 0px 0px 0px #ffffff00;
29
- }
30
- 100% {
31
- box-shadow: 0px 2px 5px 2px #dfdfdfff;
32
- }
33
- }
34
-
35
- .skeleton-card {
36
- min-height: 318px;
37
- border-radius: 8px;
38
- box-shadow: 0px 2px 5px 2px #dfdfdfff;
39
- animation: cardanimate 1.25s linear infinite;
40
- }
41
-
42
- #status-bar {
43
- display: flex;
44
- flex-direction: row;
45
- gap: 1rem;
46
- align-items: center;
47
- margin-left: -29px;
48
- margin-bottom: 1rem;
49
- margin-top: 2rem;
50
- font-size: 18px;
51
- font-weight: 600;
52
- }
53
-
54
- .status-bar {
55
- width: 200px;
56
- height: 6px;
57
- background: linear-gradient(
58
- 90deg,
59
- rgb(40, 130, 213) 0%,
60
- rgb(40, 130, 213) 50%,
61
- lightgrey 50%,
62
- lightgrey 100%
63
- );
64
- background-position: 100% 0;
65
- transition: color 0.3s 0s; /* active -> inactive */
66
- background-size: 200% 100%;
67
- border-radius: 16px;
68
- }
69
-
70
- .status-bar.active {
71
- background-position: 0 0;
72
- transition: background-position 0.75s; /* inactive -> active */
73
- }
74
-
75
- .status-text {
76
- color: lightgrey;
77
- transition: color 0.3s 0s; /* active -> inactive */
78
- }
79
-
80
- .status-text.active {
81
- color: rgb(40, 130, 213);
82
- transition: color 0.5s 0.65s; /* inactive -> active */
83
- }
84
-
85
- .shopping-button {
86
- color: white;
87
- background-color: rgb(39, 138, 230);
88
- padding: 4px 16px 6px;
89
- border-radius: 8px;
90
- outline: none;
91
- transition: all 0.3s;
92
- text-decoration: none;
93
- }
1
+ .two-col {
2
+ display: flex;
3
+ /* grid-template-columns: 1fr 1fr; */
4
+ margin-top: 2rem;
5
+ align-items: flex-start;
6
+ }
7
+
8
+ .two-col > * {
9
+ width: 50%;
10
+ }
11
+
12
+ .checkout-list {
13
+ display: flex;
14
+ flex-direction: column;
15
+ align-items: center;
16
+ gap: 1rem;
17
+ padding: 8px 4px;
18
+ margin-top: 1rem;
19
+ max-height: 50vh;
20
+ overflow: auto;
21
+ }
22
+
23
+ @keyframes cardanimate {
24
+ 0% {
25
+ box-shadow: 0px 2px 5px 2px #dfdfdfff;
26
+ }
27
+ 50% {
28
+ box-shadow: 0px 0px 0px 0px #ffffff00;
29
+ }
30
+ 100% {
31
+ box-shadow: 0px 2px 5px 2px #dfdfdfff;
32
+ }
33
+ }
34
+
35
+ .skeleton-card {
36
+ min-height: 318px;
37
+ border-radius: 8px;
38
+ box-shadow: 0px 2px 5px 2px #dfdfdfff;
39
+ animation: cardanimate 1.25s linear infinite;
40
+ }
41
+
42
+ #status-bar {
43
+ display: flex;
44
+ flex-direction: row;
45
+ gap: 1rem;
46
+ align-items: center;
47
+ margin-left: -29px;
48
+ margin-bottom: 1rem;
49
+ margin-top: 2rem;
50
+ font-size: 18px;
51
+ font-weight: 600;
52
+ }
53
+
54
+ .status-bar {
55
+ width: 200px;
56
+ height: 6px;
57
+ background: linear-gradient(
58
+ 90deg,
59
+ rgb(40, 130, 213) 0%,
60
+ rgb(40, 130, 213) 50%,
61
+ lightgrey 50%,
62
+ lightgrey 100%
63
+ );
64
+ background-position: 100% 0;
65
+ transition: color 0.3s 0s; /* active -> inactive */
66
+ background-size: 200% 100%;
67
+ border-radius: 16px;
68
+ }
69
+
70
+ .status-bar.active {
71
+ background-position: 0 0;
72
+ transition: background-position 0.75s; /* inactive -> active */
73
+ }
74
+
75
+ .status-text {
76
+ color: lightgrey;
77
+ transition: color 0.3s 0s; /* active -> inactive */
78
+ }
79
+
80
+ .status-text.active {
81
+ color: rgb(40, 130, 213);
82
+ transition: color 0.5s 0.65s; /* inactive -> active */
83
+ }
84
+
85
+ .shopping-button {
86
+ color: white;
87
+ background-color: rgb(39, 138, 230);
88
+ padding: 4px 16px 6px;
89
+ border-radius: 8px;
90
+ outline: none;
91
+ transition: all 0.3s;
92
+ text-decoration: none;
93
+ }
File without changes
File without changes
File without changes
File without changes
@@ -1,67 +1,67 @@
1
- .product-card {
2
- width: 500px;
3
- /* display: flex;
4
- flex-direction: row;
5
- justify-content: space-between; */
6
- display: grid;
7
- grid-template-columns: 1fr 40px;
8
- gap: 0.5rem;
9
- border-radius: 8px;
10
- padding: 1rem;
11
- box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0);
12
- transition: all 0.3s 0.1s;
13
- cursor: pointer;
14
- min-height: 48px;
15
- flex-shrink: 0;
16
- }
17
-
18
- .product-card:hover {
19
- box-shadow: 0px 2px 5px 2px #dfdfdfff;
20
- transition: all 0.3s 0s;
21
- }
22
-
23
- .left-section {
24
- display: flex;
25
- flex-direction: row;
26
- gap: 1rem;
27
- flex-grow: 1;
28
- }
29
-
30
- .left-section > img,
31
- .missing-image {
32
- min-height: 100%;
33
- max-height: 100px;
34
- aspect-ratio: 1;
35
- border-radius: 6px;
36
- overflow: hidden;
37
- }
38
-
39
- .missing-image {
40
- background-color: rgb(222, 222, 222);
41
- }
42
-
43
- .two-row {
44
- display: flex;
45
- flex-direction: column;
46
- }
47
-
48
- .two-row :nth-child(1) {
49
- font-size: 20px;
50
- }
51
-
52
- .two-row :nth-child(2) {
53
- font-size: 14px;
54
- }
55
-
56
- .two-row > * {
57
- margin: 0;
58
- }
59
-
60
- .remove-button {
61
- color: #ff000040 !important;
62
- transition: all 0.2s !important;
63
- }
64
-
65
- .product-card:hover .remove-button {
66
- color: red !important;
67
- }
1
+ .product-card {
2
+ width: 500px;
3
+ /* display: flex;
4
+ flex-direction: row;
5
+ justify-content: space-between; */
6
+ display: grid;
7
+ grid-template-columns: 1fr 40px;
8
+ gap: 0.5rem;
9
+ border-radius: 8px;
10
+ padding: 1rem;
11
+ box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0);
12
+ transition: all 0.3s 0.1s;
13
+ cursor: pointer;
14
+ min-height: 48px;
15
+ flex-shrink: 0;
16
+ }
17
+
18
+ .product-card:hover {
19
+ box-shadow: 0px 2px 5px 2px #dfdfdfff;
20
+ transition: all 0.3s 0s;
21
+ }
22
+
23
+ .left-section {
24
+ display: flex;
25
+ flex-direction: row;
26
+ gap: 1rem;
27
+ flex-grow: 1;
28
+ }
29
+
30
+ .left-section > img,
31
+ .missing-image {
32
+ min-height: 100%;
33
+ max-height: 100px;
34
+ aspect-ratio: 1;
35
+ border-radius: 6px;
36
+ overflow: hidden;
37
+ }
38
+
39
+ .missing-image {
40
+ background-color: rgb(222, 222, 222);
41
+ }
42
+
43
+ .two-row {
44
+ display: flex;
45
+ flex-direction: column;
46
+ }
47
+
48
+ .two-row :nth-child(1) {
49
+ font-size: 20px;
50
+ }
51
+
52
+ .two-row :nth-child(2) {
53
+ font-size: 14px;
54
+ }
55
+
56
+ .two-row > * {
57
+ margin: 0;
58
+ }
59
+
60
+ .remove-button {
61
+ color: #ff000040 !important;
62
+ transition: all 0.2s !important;
63
+ }
64
+
65
+ .product-card:hover .remove-button {
66
+ color: red !important;
67
+ }
File without changes