@pradip1995/segment-powerhouse-deals 0.1.1 → 0.1.2
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 +1 -1
- package/src/deal-card.tsx +26 -11
- package/src/deals.css +95 -24
package/package.json
CHANGED
package/src/deal-card.tsx
CHANGED
|
@@ -24,12 +24,17 @@ export default function DealCard({ product, region, countryCode }: Props) {
|
|
|
24
24
|
const onSale = originalPrice != null && price != null && originalPrice > price
|
|
25
25
|
const saved = onSale && originalPrice != null && price != null ? originalPrice - price : null
|
|
26
26
|
const inventory = variant?.inventory_quantity
|
|
27
|
+
const inStock =
|
|
28
|
+
variant?.manage_inventory === false ||
|
|
29
|
+
variant?.allow_backorder === true ||
|
|
30
|
+
(inventory ?? 0) > 0
|
|
27
31
|
const href = `/products/${product.handle}`
|
|
32
|
+
const hasOptions = (product.variants?.length ?? 0) > 1
|
|
28
33
|
|
|
29
34
|
const handleAdd = async (event: React.MouseEvent) => {
|
|
30
35
|
event.preventDefault()
|
|
31
36
|
event.stopPropagation()
|
|
32
|
-
if (!variant?.id || adding) return
|
|
37
|
+
if (!variant?.id || adding || !inStock || hasOptions) return
|
|
33
38
|
setAdding(true)
|
|
34
39
|
try {
|
|
35
40
|
await addToCart({
|
|
@@ -59,6 +64,7 @@ export default function DealCard({ product, region, countryCode }: Props) {
|
|
|
59
64
|
{onSale && saved != null ? (
|
|
60
65
|
<span className="powerhouse-deals__badge">Save {formatPrice(saved, currency)}</span>
|
|
61
66
|
) : null}
|
|
67
|
+
{!inStock ? <span className="powerhouse-deals__sold">Sold out</span> : null}
|
|
62
68
|
</LocalizedLink>
|
|
63
69
|
|
|
64
70
|
<div className="powerhouse-deals__card-info">
|
|
@@ -79,21 +85,30 @@ export default function DealCard({ product, region, countryCode }: Props) {
|
|
|
79
85
|
|
|
80
86
|
{inventory != null && inventory > 0 && inventory <= 5 ? (
|
|
81
87
|
<p className="powerhouse-deals__stock">Only {inventory} left!</p>
|
|
82
|
-
) :
|
|
88
|
+
) : !inStock ? (
|
|
89
|
+
<p className="powerhouse-deals__stock is-out">Out of stock</p>
|
|
90
|
+
) : (
|
|
91
|
+
<p className="powerhouse-deals__stock">in stock</p>
|
|
92
|
+
)}
|
|
83
93
|
|
|
84
94
|
<div className="powerhouse-deals__actions">
|
|
85
95
|
<LocalizedLink href={href} countryCode={countryCode} className="powerhouse-deals__quickshop">
|
|
86
96
|
Quick shop
|
|
87
97
|
</LocalizedLink>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
{hasOptions ? (
|
|
99
|
+
<LocalizedLink href={href} countryCode={countryCode} className="powerhouse-deals__atc">
|
|
100
|
+
Choose options
|
|
101
|
+
</LocalizedLink>
|
|
102
|
+
) : (
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
className="powerhouse-deals__atc"
|
|
106
|
+
onClick={handleAdd}
|
|
107
|
+
disabled={adding || !variant?.id || !inStock}
|
|
108
|
+
>
|
|
109
|
+
{adding ? "Adding…" : !inStock ? "Sold out" : "Add to cart"}
|
|
110
|
+
</button>
|
|
111
|
+
)}
|
|
97
112
|
</div>
|
|
98
113
|
</div>
|
|
99
114
|
</article>
|
package/src/deals.css
CHANGED
|
@@ -38,6 +38,12 @@
|
|
|
38
38
|
height: 100%;
|
|
39
39
|
object-fit: cover;
|
|
40
40
|
object-position: center;
|
|
41
|
+
transform: scale(1);
|
|
42
|
+
transition: transform 0.5s cubic-bezier(0, 0, 0.2, 1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.powerhouse-deals__promo:hover .powerhouse-deals__promo-image {
|
|
46
|
+
transform: scale(1.05);
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
.powerhouse-deals__promo-link {
|
|
@@ -117,16 +123,14 @@
|
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
.powerhouse-deals__card {
|
|
126
|
+
position: relative;
|
|
127
|
+
z-index: 1;
|
|
120
128
|
display: flex;
|
|
121
129
|
flex-direction: column;
|
|
122
130
|
height: 100%;
|
|
123
131
|
padding: 0.6875rem;
|
|
132
|
+
border: 1px solid #dddddd;
|
|
124
133
|
background: #fff;
|
|
125
|
-
transition: box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.powerhouse-deals__card:hover {
|
|
129
|
-
box-shadow: 0 2px 8px #80808033;
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
.powerhouse-deals__card-media {
|
|
@@ -143,6 +147,12 @@
|
|
|
143
147
|
height: 100%;
|
|
144
148
|
object-fit: cover;
|
|
145
149
|
display: block;
|
|
150
|
+
transform: scale(1);
|
|
151
|
+
transition: transform 0.5s cubic-bezier(0, 0, 0.2, 1);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.powerhouse-deals__card:hover .powerhouse-deals__card-image {
|
|
155
|
+
transform: scale(1.05);
|
|
146
156
|
}
|
|
147
157
|
|
|
148
158
|
.powerhouse-deals__badge {
|
|
@@ -158,6 +168,19 @@
|
|
|
158
168
|
line-height: 1.2;
|
|
159
169
|
}
|
|
160
170
|
|
|
171
|
+
.powerhouse-deals__sold {
|
|
172
|
+
position: absolute;
|
|
173
|
+
bottom: 0.6rem;
|
|
174
|
+
left: 0.6rem;
|
|
175
|
+
padding: 0.2rem 0.45rem;
|
|
176
|
+
background: #1d1d1d;
|
|
177
|
+
color: #fff;
|
|
178
|
+
font-family: var(--font-sans, inherit);
|
|
179
|
+
font-size: 0.75rem;
|
|
180
|
+
font-weight: 600;
|
|
181
|
+
line-height: 1.2;
|
|
182
|
+
}
|
|
183
|
+
|
|
161
184
|
.powerhouse-deals__card-info {
|
|
162
185
|
display: flex;
|
|
163
186
|
flex-direction: column;
|
|
@@ -167,6 +190,7 @@
|
|
|
167
190
|
|
|
168
191
|
.powerhouse-deals__price {
|
|
169
192
|
margin-top: 0.25rem;
|
|
193
|
+
min-height: 2.7rem;
|
|
170
194
|
}
|
|
171
195
|
|
|
172
196
|
.powerhouse-deals__price-compare {
|
|
@@ -190,7 +214,12 @@
|
|
|
190
214
|
}
|
|
191
215
|
|
|
192
216
|
.powerhouse-deals__card-title {
|
|
217
|
+
display: -webkit-box;
|
|
218
|
+
-webkit-box-orient: vertical;
|
|
219
|
+
-webkit-line-clamp: 2;
|
|
220
|
+
overflow: hidden;
|
|
193
221
|
margin: 0.625rem 0 0;
|
|
222
|
+
min-height: calc(1em * 1.3125 * 2);
|
|
194
223
|
font-family: var(--font-sans, inherit);
|
|
195
224
|
font-size: 1rem;
|
|
196
225
|
font-weight: 300;
|
|
@@ -204,31 +233,41 @@
|
|
|
204
233
|
|
|
205
234
|
.powerhouse-deals__stock {
|
|
206
235
|
margin: 0.5rem 0 0;
|
|
236
|
+
min-height: 1.2em;
|
|
207
237
|
color: #688600;
|
|
208
238
|
font-size: 0.875rem;
|
|
209
239
|
}
|
|
210
240
|
|
|
241
|
+
.powerhouse-deals__stock.is-out {
|
|
242
|
+
color: #6e6e6e;
|
|
243
|
+
}
|
|
244
|
+
|
|
211
245
|
.powerhouse-deals__actions {
|
|
212
246
|
display: flex;
|
|
213
|
-
flex-
|
|
214
|
-
|
|
247
|
+
flex-direction: column;
|
|
248
|
+
flex-wrap: nowrap;
|
|
249
|
+
gap: 0.4rem;
|
|
215
250
|
margin-top: auto;
|
|
216
251
|
padding-top: 0.75rem;
|
|
217
252
|
}
|
|
218
253
|
|
|
219
254
|
.powerhouse-deals__quickshop,
|
|
220
255
|
.powerhouse-deals__atc {
|
|
221
|
-
display:
|
|
256
|
+
display: flex;
|
|
222
257
|
align-items: center;
|
|
223
258
|
justify-content: center;
|
|
259
|
+
width: 100%;
|
|
224
260
|
min-height: 2.5rem;
|
|
225
|
-
padding: 0.
|
|
261
|
+
padding: 0.5rem 0.45rem;
|
|
226
262
|
border-radius: 2px;
|
|
263
|
+
box-sizing: border-box;
|
|
227
264
|
font-family: var(--font-sans, inherit);
|
|
228
|
-
font-size: 0.
|
|
229
|
-
font-weight:
|
|
230
|
-
letter-spacing: 0
|
|
265
|
+
font-size: 0.8125rem;
|
|
266
|
+
font-weight: 600;
|
|
267
|
+
letter-spacing: 0;
|
|
231
268
|
text-decoration: none;
|
|
269
|
+
text-align: center;
|
|
270
|
+
white-space: nowrap;
|
|
232
271
|
cursor: pointer;
|
|
233
272
|
}
|
|
234
273
|
|
|
@@ -254,7 +293,7 @@
|
|
|
254
293
|
|
|
255
294
|
.powerhouse-deals__atc:disabled {
|
|
256
295
|
opacity: 0.65;
|
|
257
|
-
cursor:
|
|
296
|
+
cursor: not-allowed;
|
|
258
297
|
}
|
|
259
298
|
|
|
260
299
|
@media screen and (min-width: 720px) {
|
|
@@ -281,9 +320,52 @@
|
|
|
281
320
|
padding: 1.75rem;
|
|
282
321
|
}
|
|
283
322
|
|
|
323
|
+
.powerhouse-deals__grid {
|
|
324
|
+
align-items: stretch;
|
|
325
|
+
overflow: visible;
|
|
326
|
+
}
|
|
327
|
+
|
|
284
328
|
.powerhouse-deals__card {
|
|
285
329
|
padding: 1rem;
|
|
286
330
|
}
|
|
331
|
+
|
|
332
|
+
.powerhouse-deals__card:hover,
|
|
333
|
+
.powerhouse-deals__card:focus-within {
|
|
334
|
+
z-index: 8;
|
|
335
|
+
box-shadow: 0 6px 18px rgba(29, 29, 29, 0.12);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.powerhouse-deals__actions {
|
|
339
|
+
position: absolute;
|
|
340
|
+
left: -1px;
|
|
341
|
+
right: -1px;
|
|
342
|
+
top: calc(100% - 1px);
|
|
343
|
+
flex-direction: row;
|
|
344
|
+
margin-top: 0;
|
|
345
|
+
padding: 0.75rem 1rem 1rem;
|
|
346
|
+
border: 1px solid #dddddd;
|
|
347
|
+
border-top: 0;
|
|
348
|
+
background: #fff;
|
|
349
|
+
box-sizing: border-box;
|
|
350
|
+
opacity: 0;
|
|
351
|
+
visibility: hidden;
|
|
352
|
+
pointer-events: none;
|
|
353
|
+
transition: opacity 0.2s ease, visibility 0.2s ease;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.powerhouse-deals__quickshop,
|
|
357
|
+
.powerhouse-deals__atc {
|
|
358
|
+
flex: 1 1 0;
|
|
359
|
+
width: auto;
|
|
360
|
+
min-width: 0;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.powerhouse-deals__card:hover .powerhouse-deals__actions,
|
|
364
|
+
.powerhouse-deals__card:focus-within .powerhouse-deals__actions {
|
|
365
|
+
opacity: 1;
|
|
366
|
+
visibility: visible;
|
|
367
|
+
pointer-events: auto;
|
|
368
|
+
}
|
|
287
369
|
}
|
|
288
370
|
|
|
289
371
|
@media screen and (min-width: 1080px) {
|
|
@@ -301,17 +383,6 @@
|
|
|
301
383
|
.powerhouse-deals__promo-title {
|
|
302
384
|
font-size: 2.55rem;
|
|
303
385
|
}
|
|
304
|
-
|
|
305
|
-
.powerhouse-deals__actions {
|
|
306
|
-
opacity: 0;
|
|
307
|
-
pointer-events: none;
|
|
308
|
-
transition: opacity 0.2s ease;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
.powerhouse-deals__card:hover .powerhouse-deals__actions {
|
|
312
|
-
opacity: 1;
|
|
313
|
-
pointer-events: auto;
|
|
314
|
-
}
|
|
315
386
|
}
|
|
316
387
|
|
|
317
388
|
@media screen and (max-width: 859px) {
|