@metron-labs/quote-react 0.1.65 → 0.1.66
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/dist/app/EstimatingTools.js +8 -4
- package/dist/app/QuickQuote.js +4 -4
- package/dist/app/stages/BasketStage.d.ts +0 -2
- package/dist/app/stages/BasketStage.js +15 -19
- package/dist/app/stages/EntryStage.d.ts +0 -2
- package/dist/app/stages/EntryStage.js +16 -9
- package/dist/app/stages/ProcessingStage.js +1 -1
- package/dist/app/stages/ScheduleResultsStage.js +9 -9
- package/dist/components/ChevronIcon.d.ts +1 -0
- package/dist/components/ChevronIcon.js +4 -0
- package/dist/components/InsulationPlaceholder.d.ts +2 -0
- package/dist/components/InsulationPlaceholder.js +6 -0
- package/dist/components/ProductPlaceholder.d.ts +2 -0
- package/dist/components/ProductPlaceholder.js +6 -0
- package/dist/components/TrashIcon.d.ts +1 -0
- package/dist/components/TrashIcon.js +4 -0
- package/dist/components/estimators/EstimatorResults.js +3 -3
- package/dist/embed/quote.js +10 -29
- package/dist/lib/ProductImage.d.ts +9 -0
- package/dist/lib/ProductImage.js +25 -0
- package/package.json +1 -1
- package/dist/lib/productImage.d.ts +0 -1
- package/dist/lib/productImage.js +0 -75
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
description?: string;
|
|
3
|
+
photoUrl?: string | null;
|
|
4
|
+
className?: string;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
};
|
|
8
|
+
export default function ProductImage({ description, photoUrl, className, width, height }: Props): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { assetUrl } from "./assets";
|
|
3
|
+
import InsulationPlaceholder from "../components/InsulationPlaceholder";
|
|
4
|
+
import ProductPlaceholder from "../components/ProductPlaceholder";
|
|
5
|
+
// Bundled stand-in photos for common materials, matched on the description. Order matters:
|
|
6
|
+
// "loft insulation" must win over the generic insulation drawing below.
|
|
7
|
+
const PHOTOS = [
|
|
8
|
+
{ match: ["building sand"], path: "/schedule-products/building-sand.webp" },
|
|
9
|
+
{ match: ["drywall screw"], path: "/schedule-products/drywall-screws.webp" },
|
|
10
|
+
{ match: ["scrim"], path: "/schedule-products/scrim-tape.webp" },
|
|
11
|
+
{ match: ["loft insulation", "loft roll"], path: "/schedule-products/loft-insulation-roll.webp" },
|
|
12
|
+
{ match: ["wall tie"], path: "/schedule-products/wall-ties.webp" },
|
|
13
|
+
{ match: ["red multi", "multi stock", "brick"], path: "/schedule-products/red-multi-stock-bricks.webp" },
|
|
14
|
+
];
|
|
15
|
+
// The catalogue's own product photo when it has one, then a bundled photo, then a drawing.
|
|
16
|
+
// Decorative wherever it's used, since the product name always sits beside it.
|
|
17
|
+
export default function ProductImage({ description, photoUrl, className, width, height }) {
|
|
18
|
+
const text = (description || "").toLowerCase();
|
|
19
|
+
const bundled = PHOTOS.find((entry) => entry.match.some((word) => text.includes(word)));
|
|
20
|
+
const src = photoUrl || (bundled && assetUrl(bundled.path));
|
|
21
|
+
if (src)
|
|
22
|
+
return _jsx("img", { className: className, src: src, alt: "", width: width, height: height });
|
|
23
|
+
const Placeholder = text.includes("insulation") ? InsulationPlaceholder : ProductPlaceholder;
|
|
24
|
+
return _jsx(Placeholder, { className: className, width: width, height: height });
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function productImageSrc(description: string | undefined, productId?: string, pdpPhotoUrl?: string | null): string;
|
package/dist/lib/productImage.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { assetUrl } from "./assets";
|
|
2
|
-
function encodeSvg(svg) {
|
|
3
|
-
return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
|
|
4
|
-
}
|
|
5
|
-
// Bundled stand-in photos for common materials, matched on the description. Order matters:
|
|
6
|
-
// "loft insulation" must win over the generic insulation drawing below.
|
|
7
|
-
const PHOTOS = [
|
|
8
|
-
{ match: ["building sand"], path: "/schedule-products/building-sand.webp" },
|
|
9
|
-
{ match: ["drywall screw"], path: "/schedule-products/drywall-screws.webp" },
|
|
10
|
-
{ match: ["scrim"], path: "/schedule-products/scrim-tape.webp" },
|
|
11
|
-
{ match: ["loft insulation", "loft roll"], path: "/schedule-products/loft-insulation-roll.webp" },
|
|
12
|
-
{ match: ["wall tie"], path: "/schedule-products/wall-ties.webp" },
|
|
13
|
-
{ match: ["red multi", "multi stock", "brick"], path: "/schedule-products/red-multi-stock-bricks.webp" },
|
|
14
|
-
];
|
|
15
|
-
// Materials Market PDP photos used as a demo fallback when a candidate has no own photo.
|
|
16
|
-
// Keep specific matches above broad ones because several descriptions contain "cement".
|
|
17
|
-
const CATALOGUE_PHOTOS = [
|
|
18
|
-
{ match: ["mortar"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/Blue+Circle+Quality+Assured+Mortar+Mix+-+Photo.jpg" },
|
|
19
|
-
{ match: ["mot type 1"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/MOT+-+Photo+1.jpg" },
|
|
20
|
-
{ match: ["soft sand", "building sand"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/Soft+Building+Sand+-+Photo+1.jpg" },
|
|
21
|
-
{ match: ["cement"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/blue+circle+general+cement+bagged.jpg" },
|
|
22
|
-
{ match: ["brick"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/class+B+engineering+brick+smooth+red+perforated+65mm+-+Photo+1+comp.jpg" },
|
|
23
|
-
{ match: ["dense block", "concrete block"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/100mm+solid+dense+concrete+block+-+Photo+1+-+1920+comp.jpg" },
|
|
24
|
-
{ match: ["metal c stud", "c stud"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/70mm+c+stud+angle.jpg" },
|
|
25
|
-
{ match: ["timber", "carcassing", "sawn", "c24", "c16"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/47mm+x+100mm+sawn+treated+c16+-+Photo+1+1920.jpg" },
|
|
26
|
-
{ match: ["osb"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/18mm+structural+OSB+-+Photo+1+comp.jpg" },
|
|
27
|
-
{ match: ["dpc"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/225mm+damp+proof+course.jpg" },
|
|
28
|
-
{ match: ["soil pipe", "soil bend", "underground", "drainage"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/110mm+Soil+Pipe+Single+Socket+Black+3m+-+High+Res.jpg" },
|
|
29
|
-
{ match: ["nail"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/galvanised+round+wire+nail+vertical.jpg" },
|
|
30
|
-
{ match: ["retaining clip", "retaining clips", "insulation disc", "insulation disks"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/multiple+zinc+insulation+discs.jpg" },
|
|
31
|
-
{ match: ["wall tie"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/Type+4+Wall+Ties+-+Photo.jpg" },
|
|
32
|
-
{ match: ["loft insulation", "loft roll", "insulation roll"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/200mm+knauf+loft+roll+44+unwrapping.jpg" },
|
|
33
|
-
{ match: ["pir insulation", "insulation board", "celotex", "unilin", "indiboard"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/100mm+celotex+sheet+logo.jpg" },
|
|
34
|
-
{ match: ["plasterboard", "wallboard"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/12.5mm+wallboard+tapered+edge+corner.jpg" },
|
|
35
|
-
{ match: ["drywall screw"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/close+up+drywall+course+thread.jpg" },
|
|
36
|
-
{ match: ["scrim", "jointing tape", "paper tape"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/50mm+scrim+tape.jpg" },
|
|
37
|
-
{ match: ["adhesive", "high grab", "evostik", "stixall", "gripfill", "sealant", "ct1"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/Instant+Nails+Solvent+Free+Grab+Adhesive+White+290ml+-+Photo.jpg" },
|
|
38
|
-
];
|
|
39
|
-
// The catalogue's own product photo when it has one, then a bundled photo, then a drawing.
|
|
40
|
-
// ponytail: productId is unused for now; callers already pass it for when bundled images
|
|
41
|
-
// are keyed by product.
|
|
42
|
-
export function productImageSrc(description, productId, pdpPhotoUrl) {
|
|
43
|
-
if (pdpPhotoUrl)
|
|
44
|
-
return pdpPhotoUrl;
|
|
45
|
-
const text = (description || "").toLowerCase();
|
|
46
|
-
const cataloguePhoto = CATALOGUE_PHOTOS.find((entry) => entry.match.some((word) => text.includes(word)));
|
|
47
|
-
if (cataloguePhoto)
|
|
48
|
-
return cataloguePhoto.url;
|
|
49
|
-
const photo = PHOTOS.find((entry) => entry.match.some((word) => text.includes(word)));
|
|
50
|
-
if (photo)
|
|
51
|
-
return assetUrl(photo.path);
|
|
52
|
-
if (text.includes("insulation")) {
|
|
53
|
-
return encodeSvg(`
|
|
54
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 420">
|
|
55
|
-
<rect width="640" height="420" fill="#fbf1cf"/>
|
|
56
|
-
<rect x="88" y="78" width="432" height="264" rx="16" fill="#f0c43f"/>
|
|
57
|
-
<rect x="120" y="110" width="368" height="200" rx="10" fill="#ffd95e"/>
|
|
58
|
-
<g stroke="#e2b12e" stroke-width="8" opacity="0.75">
|
|
59
|
-
<line x1="140" y1="140" x2="468" y2="140"/>
|
|
60
|
-
<line x1="140" y1="190" x2="468" y2="190"/>
|
|
61
|
-
<line x1="140" y1="240" x2="468" y2="240"/>
|
|
62
|
-
</g>
|
|
63
|
-
</svg>
|
|
64
|
-
`);
|
|
65
|
-
}
|
|
66
|
-
return encodeSvg(`
|
|
67
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 420">
|
|
68
|
-
<rect width="640" height="420" fill="#edf1f5"/>
|
|
69
|
-
<rect x="132" y="108" width="376" height="204" rx="18" fill="#d5dde6"/>
|
|
70
|
-
<rect x="168" y="144" width="304" height="24" rx="12" fill="#9aa6b2"/>
|
|
71
|
-
<rect x="168" y="188" width="250" height="24" rx="12" fill="#aab5c0"/>
|
|
72
|
-
<rect x="168" y="232" width="220" height="24" rx="12" fill="#aab5c0"/>
|
|
73
|
-
</svg>
|
|
74
|
-
`);
|
|
75
|
-
}
|