Skip to content

Commit f29bcb3

Browse files
authored
Changed mock image service (#161)
1 parent 6de6a15 commit f29bcb3

7 files changed

Lines changed: 26 additions & 26 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-storefront",
3-
"version": "8.17.3",
3+
"version": "8.17.4",
44
"description": "Build and deploy e-commerce progressive web apps (PWAs) in record time.",
55
"module": "./index.js",
66
"license": "Apache-2.0",

src/mock-connector/product.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fulfillAPIRequest from '..//props/fulfillAPIRequest'
1+
import fulfillAPIRequest from '../props/fulfillAPIRequest'
22
import createProduct from './utils/createProduct'
33
import createAppData from './utils/createAppData'
44
import getBase64ForImage from 'react-storefront/utils/getBase64ForImage'

src/mock-connector/searchSuggestions.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,31 @@ export default async function searchSuggestions(q, req, res) {
3434
text: 'Product 1',
3535
href: '/p/[productId]',
3636
as: '/p/1?s=1&c=1',
37-
thumbnail: { src: 'https://via.placeholder.com/120x120', alt: 'Product 1' },
37+
thumbnail: { src: 'https://dummyimage.com/120x120', alt: 'Product 1' },
3838
},
3939
{
4040
text: 'Product 2',
4141
href: '/p/[productId]',
4242
as: '/p/2?s=1&c=1',
43-
thumbnail: { src: 'https://via.placeholder.com/120x120', alt: 'Product 1' },
43+
thumbnail: { src: 'https://dummyimage.com/120x120', alt: 'Product 1' },
4444
},
4545
{
4646
text: 'Product 3',
4747
href: '/p/[productId]',
4848
as: '/p/3?s=1&c=1',
49-
thumbnail: { src: 'https://via.placeholder.com/120x120', alt: 'Product 1' },
49+
thumbnail: { src: 'https://dummyimage.com/120x120', alt: 'Product 1' },
5050
},
5151
{
5252
text: 'Product 4',
5353
href: '/p/[productId]',
5454
as: '/p/3?s=1&c=1',
55-
thumbnail: { src: 'https://via.placeholder.com/120x120', alt: 'Product 1' },
55+
thumbnail: { src: 'https://dummyimage.com/120x120', alt: 'Product 1' },
5656
},
5757
{
5858
text: 'Product 5',
5959
href: '/p/[productId]',
6060
as: '/p/5?s=1&c=1',
61-
thumbnail: { src: 'https://via.placeholder.com/120x120', alt: 'Product 1' },
61+
thumbnail: { src: 'https://dummyimage.com/120x120', alt: 'Product 1' },
6262
},
6363
],
6464
},

src/mock-connector/utils/createFacets.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export default function createFacets() {
1010
name: capitalize(name),
1111
code: `color:${name}`,
1212
image: {
13-
src: `https://via.placeholder.com/48x48/${
14-
colors[name].background
15-
}?text=${encodeURIComponent(' ')}`,
13+
src: `https://dummyimage.com/48x48/${colors[name].background}?text=${encodeURIComponent(
14+
' ',
15+
)}`,
1616
alt: name,
1717
},
1818
})),

src/mock-connector/utils/createMedia.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import colors from './colors'
33
export default function createMedia(id, color) {
44
return {
55
full: [color].map((key, i) => ({
6-
src: `https://via.placeholder.com/${i === 2 ? 400 : 600}x${i === 1 ? 400 : 600}/${
6+
src: `https://dummyimage.com/${i === 2 ? 400 : 600}x${i === 1 ? 400 : 600}/${
77
colors[key].background
88
}/${colors[key].foreground}?text=${encodeURIComponent('Product ' + id)}`,
99
alt: `Product ${id}`,
1010
magnify: {
1111
height: i === 1 ? 800 : 1200,
1212
width: i === 2 ? 800 : 1200,
13-
src: `https://via.placeholder.com/${i === 2 ? 800 : 1200}x${i === 1 ? 800 : 1200}/${
13+
src: `https://dummyimage.com/${i === 2 ? 800 : 1200}x${i === 1 ? 800 : 1200}/${
1414
colors[key].background
1515
}/${colors[key].foreground}?text=${encodeURIComponent('Product ' + id)}`,
1616
},
1717
})),
1818
thumbnails: [color].map((key, i) => ({
19-
src: `https://via.placeholder.com/${i === 2 ? 300 : 400}x${i === 1 ? 300 : 400}/${
19+
src: `https://dummyimage.com/${i === 2 ? 300 : 400}x${i === 1 ? 300 : 400}/${
2020
colors[key].background
2121
}?text=${encodeURIComponent(`Product ${id}`)}`,
2222
alt: key,

src/mock-connector/utils/createProduct.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ export default function createProduct(id, numColors = 4) {
1515
priceText: `$${price}`,
1616
rating: (10 - (id % 10)) / 2.0,
1717
thumbnail: {
18-
src: `https://via.placeholder.com/400x400/${colors[color].background}/${
18+
src: `https://dummyimage.com/400x400/${colors[color].background}/${
1919
colors[color].foreground
2020
}?text=${encodeURIComponent('Product ' + id)}`,
2121
alt: `Product ${id}`,
2222
},
2323
media: {
2424
full: variants.map((key, i) => ({
25-
src: `https://via.placeholder.com/${i === 2 ? 400 : 600}x${i === 1 ? 400 : 600}/${
25+
src: `https://dummyimage.com/${i === 2 ? 400 : 600}x${i === 1 ? 400 : 600}/${
2626
colors[key].background
2727
}/${colors[key].foreground}?text=${encodeURIComponent('Product ' + id)}`,
2828
alt: `Product ${id}`,
2929
magnify: {
3030
height: i === 1 ? 800 : 1200,
3131
width: i === 2 ? 800 : 1200,
32-
src: `https://via.placeholder.com/${i === 2 ? 800 : 1200}x${i === 1 ? 800 : 1200}/${
32+
src: `https://dummyimage.com/${i === 2 ? 800 : 1200}x${i === 1 ? 800 : 1200}/${
3333
colors[key].background
3434
}/${colors[key].foreground}?text=${encodeURIComponent('Product ' + id)}`,
3535
},
3636
})),
3737
thumbnails: variants.map((key, i) => ({
38-
src: `https://via.placeholder.com/${i === 2 ? 233 : 300}x${i === 1 ? 233 : 300}/${
38+
src: `https://dummyimage.com/${i === 2 ? 233 : 300}x${i === 1 ? 233 : 300}/${
3939
colors[key].background
4040
}/${colors[key].foreground}?text=${encodeURIComponent('Product ' + id)}`,
4141
alt: `Product ${id}`,
@@ -57,33 +57,33 @@ export default function createProduct(id, numColors = 4) {
5757
id: name,
5858
disabled: idx === 2,
5959
image: {
60-
src: `https://via.placeholder.com/48x48/${
61-
colors[name].background
62-
}?text=${encodeURIComponent(' ')}`,
60+
src: `https://dummyimage.com/48x48/${colors[name].background}?text=${encodeURIComponent(
61+
' ',
62+
)}`,
6363
alt: name,
6464
},
6565
media: {
6666
full: [name, name, name].map((key, i) => ({
67-
src: `https://via.placeholder.com/${i === 2 ? 400 : 600}x${i === 1 ? 400 : 600}/${
67+
src: `https://dummyimage.com/${i === 2 ? 400 : 600}x${i === 1 ? 400 : 600}/${
6868
colors[key].background
6969
}/${colors[key].foreground}?text=${encodeURIComponent('Product ' + id)}`,
7070
alt: `Product ${id}`,
7171
magnify: {
7272
height: i === 1 ? 800 : 1200,
7373
width: i === 2 ? 800 : 1200,
74-
src: `https://via.placeholder.com/${i === 2 ? 800 : 1200}x${i === 1 ? 800 : 1200}/${
74+
src: `https://dummyimage.com/${i === 2 ? 800 : 1200}x${i === 1 ? 800 : 1200}/${
7575
colors[key].background
7676
}/${colors[key].foreground}?text=${encodeURIComponent('Product ' + id)}`,
7777
},
7878
})),
7979
thumbnails: [name, name, name].map((key, i) => ({
80-
src: `https://via.placeholder.com/${i === 2 ? 300 : 400}x${i === 1 ? 300 : 400}/${
80+
src: `https://dummyimage.com/${i === 2 ? 300 : 400}x${i === 1 ? 300 : 400}/${
8181
colors[key].background
8282
}/${colors[key].foreground}?text=${encodeURIComponent(`Product ${id}`)}`,
8383
alt: key,
8484
})),
8585
thumbnail: [name].map(key => ({
86-
src: `https://via.placeholder.com/400x400/${colors[key].background}/${
86+
src: `https://dummyimage.com/400x400/${colors[key].background}/${
8787
colors[key].foreground
8888
}?text=${encodeURIComponent('Product ' + id)}`,
8989
alt: `Product ${id}`,

src/utils/getBase64ForImage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fetch from '../fetch'
22

3-
export default async function getBase64ForImage(src) {
4-
const res = await fetch(src)
3+
export default async function getBase64ForImage(...args) {
4+
const res = await fetch(...args)
55
const contentType = res.headers.get('content-type')
66
const buffer = await res.buffer()
77
return `data:${contentType};base64,${buffer.toString('base64')}`

0 commit comments

Comments
 (0)