@pradip1995/segment-powerhouse-carousel 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/carousel.css +102 -24
- package/src/product-card.tsx +26 -11
package/package.json
CHANGED
package/src/carousel.css
CHANGED
|
@@ -90,16 +90,14 @@
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
.powerhouse-carousel__card {
|
|
93
|
+
position: relative;
|
|
94
|
+
z-index: 1;
|
|
93
95
|
display: flex;
|
|
94
96
|
flex-direction: column;
|
|
95
97
|
height: 100%;
|
|
96
98
|
padding: 0.6875rem;
|
|
99
|
+
border: 1px solid #dddddd;
|
|
97
100
|
background: #fff;
|
|
98
|
-
transition: box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.powerhouse-carousel__card:hover {
|
|
102
|
-
box-shadow: 0 2px 8px #80808033;
|
|
103
101
|
}
|
|
104
102
|
|
|
105
103
|
.powerhouse-carousel__card-media {
|
|
@@ -116,6 +114,12 @@
|
|
|
116
114
|
height: 100%;
|
|
117
115
|
object-fit: cover;
|
|
118
116
|
display: block;
|
|
117
|
+
transform: scale(1);
|
|
118
|
+
transition: transform 0.5s cubic-bezier(0, 0, 0.2, 1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.powerhouse-carousel__card:hover .powerhouse-carousel__card-image {
|
|
122
|
+
transform: scale(1.05);
|
|
119
123
|
}
|
|
120
124
|
|
|
121
125
|
.powerhouse-carousel__badge {
|
|
@@ -131,6 +135,19 @@
|
|
|
131
135
|
line-height: 1.2;
|
|
132
136
|
}
|
|
133
137
|
|
|
138
|
+
.powerhouse-carousel__sold {
|
|
139
|
+
position: absolute;
|
|
140
|
+
bottom: 0.6rem;
|
|
141
|
+
left: 0.6rem;
|
|
142
|
+
padding: 0.2rem 0.45rem;
|
|
143
|
+
background: #1d1d1d;
|
|
144
|
+
color: #fff;
|
|
145
|
+
font-family: var(--font-sans, inherit);
|
|
146
|
+
font-size: 0.75rem;
|
|
147
|
+
font-weight: 600;
|
|
148
|
+
line-height: 1.2;
|
|
149
|
+
}
|
|
150
|
+
|
|
134
151
|
.powerhouse-carousel__card-info {
|
|
135
152
|
display: flex;
|
|
136
153
|
flex-direction: column;
|
|
@@ -140,6 +157,7 @@
|
|
|
140
157
|
|
|
141
158
|
.powerhouse-carousel__price {
|
|
142
159
|
margin-top: 0.25rem;
|
|
160
|
+
min-height: 2.7rem;
|
|
143
161
|
}
|
|
144
162
|
|
|
145
163
|
.powerhouse-carousel__price-compare {
|
|
@@ -163,7 +181,12 @@
|
|
|
163
181
|
}
|
|
164
182
|
|
|
165
183
|
.powerhouse-carousel__card-title {
|
|
184
|
+
display: -webkit-box;
|
|
185
|
+
-webkit-box-orient: vertical;
|
|
186
|
+
-webkit-line-clamp: 2;
|
|
187
|
+
overflow: hidden;
|
|
166
188
|
margin: 0.625rem 0 0;
|
|
189
|
+
min-height: calc(1em * 1.3125 * 2);
|
|
167
190
|
font-family: var(--font-sans, inherit);
|
|
168
191
|
font-size: 1rem;
|
|
169
192
|
font-weight: 300;
|
|
@@ -177,31 +200,41 @@
|
|
|
177
200
|
|
|
178
201
|
.powerhouse-carousel__stock {
|
|
179
202
|
margin: 0.5rem 0 0;
|
|
203
|
+
min-height: 1.2em;
|
|
180
204
|
color: #688600;
|
|
181
205
|
font-size: 0.875rem;
|
|
182
206
|
}
|
|
183
207
|
|
|
208
|
+
.powerhouse-carousel__stock.is-out {
|
|
209
|
+
color: #6e6e6e;
|
|
210
|
+
}
|
|
211
|
+
|
|
184
212
|
.powerhouse-carousel__actions {
|
|
185
213
|
display: flex;
|
|
186
|
-
flex-
|
|
187
|
-
|
|
214
|
+
flex-direction: column;
|
|
215
|
+
flex-wrap: nowrap;
|
|
216
|
+
gap: 0.4rem;
|
|
188
217
|
margin-top: auto;
|
|
189
218
|
padding-top: 0.75rem;
|
|
190
219
|
}
|
|
191
220
|
|
|
192
221
|
.powerhouse-carousel__quickshop,
|
|
193
222
|
.powerhouse-carousel__atc {
|
|
194
|
-
display:
|
|
223
|
+
display: flex;
|
|
195
224
|
align-items: center;
|
|
196
225
|
justify-content: center;
|
|
226
|
+
width: 100%;
|
|
197
227
|
min-height: 2.5rem;
|
|
198
|
-
padding: 0.
|
|
228
|
+
padding: 0.5rem 0.45rem;
|
|
199
229
|
border-radius: 2px;
|
|
230
|
+
box-sizing: border-box;
|
|
200
231
|
font-family: var(--font-sans, inherit);
|
|
201
|
-
font-size: 0.
|
|
202
|
-
font-weight:
|
|
203
|
-
letter-spacing: 0
|
|
232
|
+
font-size: 0.8125rem;
|
|
233
|
+
font-weight: 600;
|
|
234
|
+
letter-spacing: 0;
|
|
204
235
|
text-decoration: none;
|
|
236
|
+
text-align: center;
|
|
237
|
+
white-space: nowrap;
|
|
205
238
|
cursor: pointer;
|
|
206
239
|
}
|
|
207
240
|
|
|
@@ -227,7 +260,7 @@
|
|
|
227
260
|
|
|
228
261
|
.powerhouse-carousel__atc:disabled {
|
|
229
262
|
opacity: 0.65;
|
|
230
|
-
cursor:
|
|
263
|
+
cursor: not-allowed;
|
|
231
264
|
}
|
|
232
265
|
|
|
233
266
|
@media screen and (min-width: 720px) {
|
|
@@ -239,16 +272,40 @@
|
|
|
239
272
|
@media screen and (min-width: 860px) {
|
|
240
273
|
.powerhouse-carousel {
|
|
241
274
|
margin-top: 1.75rem;
|
|
275
|
+
overflow: visible;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.powerhouse-carousel__viewport,
|
|
279
|
+
.powerhouse-carousel__track {
|
|
280
|
+
overflow: visible;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.powerhouse-carousel__track {
|
|
284
|
+
overflow-x: auto;
|
|
285
|
+
padding-bottom: 4.5rem;
|
|
286
|
+
margin-bottom: -3rem;
|
|
242
287
|
}
|
|
243
288
|
|
|
244
289
|
.powerhouse-carousel__heading {
|
|
245
290
|
margin-bottom: 1.75rem;
|
|
246
291
|
}
|
|
247
292
|
|
|
293
|
+
.powerhouse-carousel__slide {
|
|
294
|
+
display: flex;
|
|
295
|
+
align-items: stretch;
|
|
296
|
+
}
|
|
297
|
+
|
|
248
298
|
.powerhouse-carousel__card {
|
|
299
|
+
width: 100%;
|
|
249
300
|
padding: 1rem;
|
|
250
301
|
}
|
|
251
302
|
|
|
303
|
+
.powerhouse-carousel__card:hover,
|
|
304
|
+
.powerhouse-carousel__card:focus-within {
|
|
305
|
+
z-index: 8;
|
|
306
|
+
box-shadow: 0 6px 18px rgba(29, 29, 29, 0.12);
|
|
307
|
+
}
|
|
308
|
+
|
|
252
309
|
.powerhouse-carousel__arrow--prev {
|
|
253
310
|
left: 2.1875rem;
|
|
254
311
|
}
|
|
@@ -256,6 +313,38 @@
|
|
|
256
313
|
.powerhouse-carousel__arrow--next {
|
|
257
314
|
right: 2.1875rem;
|
|
258
315
|
}
|
|
316
|
+
|
|
317
|
+
.powerhouse-carousel__actions {
|
|
318
|
+
position: absolute;
|
|
319
|
+
left: -1px;
|
|
320
|
+
right: -1px;
|
|
321
|
+
top: calc(100% - 1px);
|
|
322
|
+
flex-direction: row;
|
|
323
|
+
margin-top: 0;
|
|
324
|
+
padding: 0.75rem 1rem 1rem;
|
|
325
|
+
border: 1px solid #dddddd;
|
|
326
|
+
border-top: 0;
|
|
327
|
+
background: #fff;
|
|
328
|
+
box-sizing: border-box;
|
|
329
|
+
opacity: 0;
|
|
330
|
+
visibility: hidden;
|
|
331
|
+
pointer-events: none;
|
|
332
|
+
transition: opacity 0.2s ease, visibility 0.2s ease;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.powerhouse-carousel__quickshop,
|
|
336
|
+
.powerhouse-carousel__atc {
|
|
337
|
+
flex: 1 1 0;
|
|
338
|
+
width: auto;
|
|
339
|
+
min-width: 0;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.powerhouse-carousel__card:hover .powerhouse-carousel__actions,
|
|
343
|
+
.powerhouse-carousel__card:focus-within .powerhouse-carousel__actions {
|
|
344
|
+
opacity: 1;
|
|
345
|
+
visibility: visible;
|
|
346
|
+
pointer-events: auto;
|
|
347
|
+
}
|
|
259
348
|
}
|
|
260
349
|
|
|
261
350
|
@media screen and (min-width: 1080px) {
|
|
@@ -266,17 +355,6 @@
|
|
|
266
355
|
.powerhouse-carousel__slide {
|
|
267
356
|
flex-basis: calc(25% - 15px);
|
|
268
357
|
}
|
|
269
|
-
|
|
270
|
-
.powerhouse-carousel__actions {
|
|
271
|
-
opacity: 0;
|
|
272
|
-
pointer-events: none;
|
|
273
|
-
transition: opacity 0.2s ease;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
.powerhouse-carousel__card:hover .powerhouse-carousel__actions {
|
|
277
|
-
opacity: 1;
|
|
278
|
-
pointer-events: auto;
|
|
279
|
-
}
|
|
280
358
|
}
|
|
281
359
|
|
|
282
360
|
@media screen and (min-width: 1280px) {
|
package/src/product-card.tsx
CHANGED
|
@@ -24,12 +24,17 @@ export default function ProductCard({ 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 ProductCard({ product, region, countryCode }: Props) {
|
|
|
59
64
|
{onSale && saved != null ? (
|
|
60
65
|
<span className="powerhouse-carousel__badge">Save {formatPrice(saved, currency)}</span>
|
|
61
66
|
) : null}
|
|
67
|
+
{!inStock ? <span className="powerhouse-carousel__sold">Sold out</span> : null}
|
|
62
68
|
</LocalizedLink>
|
|
63
69
|
|
|
64
70
|
<div className="powerhouse-carousel__card-info">
|
|
@@ -79,21 +85,30 @@ export default function ProductCard({ product, region, countryCode }: Props) {
|
|
|
79
85
|
|
|
80
86
|
{inventory != null && inventory > 0 && inventory <= 5 ? (
|
|
81
87
|
<p className="powerhouse-carousel__stock">Only {inventory} left!</p>
|
|
82
|
-
) :
|
|
88
|
+
) : !inStock ? (
|
|
89
|
+
<p className="powerhouse-carousel__stock is-out">Out of stock</p>
|
|
90
|
+
) : (
|
|
91
|
+
<p className="powerhouse-carousel__stock">in stock</p>
|
|
92
|
+
)}
|
|
83
93
|
|
|
84
94
|
<div className="powerhouse-carousel__actions">
|
|
85
95
|
<LocalizedLink href={href} countryCode={countryCode} className="powerhouse-carousel__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-carousel__atc">
|
|
100
|
+
Choose options
|
|
101
|
+
</LocalizedLink>
|
|
102
|
+
) : (
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
className="powerhouse-carousel__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>
|