Skip to content

Commit 0c7afa9

Browse files
authored
Replaced spinner with skeleton on plp (#117)
* Replaced spinner with skeleton on plp * Updated yarn.lock * Added material UI core * Fixed styling * Updated skeleton components * Removed material UI * Improved skeleton parent
1 parent 00eb8d6 commit 0c7afa9

File tree

5 files changed

+100
-11
lines changed

5 files changed

+100
-11
lines changed

src/Category.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
#{$block}__product {
4545
flex: 0 0 100%;
4646
text-align: center;
47+
48+
#{$block}__productskeleton {
49+
margin-bottom: 40px;
50+
}
4751
}
4852
}
4953

@@ -96,4 +100,15 @@
96100
width: 1000px;
97101
}
98102
}
103+
104+
@media (max-width: $mobileWidth - 1px) {
105+
#{$block}__productlist {
106+
#{$block}__product {
107+
#{$block}__productskeleton {
108+
margin: auto;
109+
width: 180px;
110+
}
111+
}
112+
}
113+
}
99114
}

src/Category.tsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ProductThumbnail } from './ProductThumbnail';
77
import { createCategoryUrl } from './routes';
88
import { Pagination } from './Pagination';
99
import { useResolve } from './hooks';
10+
import {config} from './config';
1011

1112
import './Category.scss';
1213

@@ -85,7 +86,40 @@ export const Category: React.FC = () => {
8586
</div>
8687
</>
8788
) : (
88-
<div className="loader" />
89+
<>
90+
<div className="category__breadcrumbs">
91+
<div className="skeleton" style={{width: 200}}>&nbsp;</div>
92+
</div>
93+
94+
<div className="category__categoryname">
95+
<div className="skeleton" style={{width: 150}}>&nbsp;</div>
96+
</div>
97+
98+
<ul className="category__productlist">
99+
{[...Array(config.categoryPageSize).keys()].map((index) =>
100+
<li key={`skeleton_${index}`} className="category__product">
101+
<div className="category__productskeleton">
102+
<div className="skeleton" style={{width: 180, height: 180}}/>
103+
<div className="skeleton" style={{width: 180, marginTop: 10}}>&nbsp;</div>
104+
<div className="skeleton" style={{width: 180, marginTop: 10}}>&nbsp;</div>
105+
<div className="skeleton" style={{width: 100, marginTop: 10}}>&nbsp;</div>
106+
<div className="skeleton" style={{width: 100, marginTop: 10}}>&nbsp;</div>
107+
<div className="skeleton" style={{width: 100, marginTop: 10}}>&nbsp;</div>
108+
</div>
109+
</li>
110+
)}
111+
</ul>
112+
113+
<div className="skeleton skeleton-parent">
114+
<div className="category__pagination">
115+
<Pagination
116+
totalPages={3}
117+
currentPage={1}
118+
formatUrl={(page) => createCategoryUrl("", page)}
119+
/>
120+
</div>
121+
</div>
122+
</>
89123
)}
90124
</div>
91125
);

src/ProductMainImage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ export const ProductMainImage: React.FC<ProductMainImageProps> = (props) => {
2929

3030
return (
3131
<>
32-
{productImageUrl && (
32+
{productImageUrl ? (
3333
<ImageContainer
3434
imgClassName="productmainimage"
3535
imgUrl={productImageUrl}
3636
alt={props.product.name}
3737
imageStyle={{ width: props.size, height: props.size, objectFit: 'fill', backgroundColor: productBackground }}
3838
/>
39+
) : (
40+
<div className="skeleton" style={{width: props.size || 180, height: props.size || 180}} />
3941
)}
4042
</>
4143
);

src/index.scss

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,44 @@ $shopkitBtnOutlineText: $firstComplimentColor;
507507
);
508508
}
509509

510+
@keyframes skeleton-animation {
511+
0% {
512+
transform: translateX(-100%);
513+
}
514+
100% {
515+
transform: translateX(100%);
516+
}
517+
}
518+
519+
.skeleton {
520+
background-color: rgba(0, 0, 0, 0.1);
521+
overflow: hidden;
522+
position: relative;
523+
&::after {
524+
display:block;
525+
position: absolute;
526+
top: 0;
527+
left: 0;
528+
width: 100%;
529+
height: 100%;
530+
background: linear-gradient(
531+
90deg,
532+
rgba(lightgrey, 0) 0,
533+
rgba(lightgrey, .8) 50%,
534+
rgba(lightgrey, 0) 100%
535+
);
536+
content:'';
537+
animation: skeleton-animation 2s infinite;
538+
}
539+
}
540+
541+
.skeleton-parent {
542+
width: fit-content;
543+
> * {
544+
visibility: hidden;
545+
}
546+
}
547+
510548
@media (max-width: $mobileWidth - 1px) {
511549
.appheader .shopkit-cart-button {
512550
border: none;

yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,15 +1458,15 @@
14581458
"@types/istanbul-reports" "^1.1.1"
14591459
"@types/yargs" "^13.0.0"
14601460

1461-
"@moltin/sdk@5.5.0":
1462-
version "5.5.0"
1463-
resolved "https://registry.yarnpkg.com/@moltin/sdk/-/sdk-5.5.0.tgz#55b7c33df0f437cdf76ce7bf04344bf7ba76cbd0"
1464-
integrity sha512-TzNBdnv/eI5Bi4FrE3zxpp6Udn7QEl4XnZZXjpwJKTSJQhxGhdpP1au4p5fVdeD3QD8T2cwyJ0H9FE8k6vC8cA==
1461+
"@moltin/sdk@6.3.0":
1462+
version "6.3.0"
1463+
resolved "https://registry.yarnpkg.com/@moltin/sdk/-/sdk-6.3.0.tgz#9e5680cef86efa5f10d1b087c9ba9b1c9c082966"
1464+
integrity sha512-2ZZdb6kyZSuC9YOKo85a90oTwnsASluEhf4IdaZ0h5fkwt45wmPjuBjg7604KSNPlXo6Zuty83J/bzRlu+KbTw==
14651465
dependencies:
14661466
es6-promise "^4.0.5"
14671467
fetch-everywhere "^1.0.5"
14681468
inflected "^2.0.1"
1469-
node-localstorage "^1.3.0"
1469+
node-localstorage "^2.0.0"
14701470

14711471
"@mrmlnc/readdir-enhanced@^2.2.1":
14721472
version "2.2.1"
@@ -8355,10 +8355,10 @@ node-libs-browser@^2.2.1:
83558355
util "^0.11.0"
83568356
vm-browserify "^1.0.1"
83578357

8358-
node-localstorage@^1.3.0:
8359-
version "1.3.1"
8360-
resolved "https://registry.yarnpkg.com/node-localstorage/-/node-localstorage-1.3.1.tgz#3177ef42837f398aee5dd75e319b281e40704243"
8361-
integrity sha512-NMWCSWWc6JbHT5PyWlNT2i8r7PgGYXVntmKawY83k/M0UJScZ5jirb61TLnqKwd815DfBQu+lR3sRw08SPzIaQ==
8358+
node-localstorage@^2.0.0:
8359+
version "2.1.6"
8360+
resolved "https://registry.yarnpkg.com/node-localstorage/-/node-localstorage-2.1.6.tgz#7c62120beff8abbf960c858da70fddcfc336898a"
8361+
integrity sha512-yE7AycE5G2hU55d+F7Ona9nx97C+enJzWWx6jrsji7fuPZFJOvuW3X/LKKAcXRBcEIJPDOKt8ZiFWFmShR/irg==
83628362
dependencies:
83638363
write-file-atomic "^1.1.4"
83648364

0 commit comments

Comments
 (0)