@quintype/components 3.5.2 → 3.5.3-fix-image-sizes.1

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/cjs/index.js CHANGED
@@ -1856,11 +1856,16 @@ function responsiveProps(props) {
1856
1856
  }, props.imgParams));
1857
1857
  }
1858
1858
 
1859
+ function generateSizes() {
1860
+ return "(max-width: 600px) 100vw, (max-width: 900px) 50vw, 33vw";
1861
+ }
1862
+
1859
1863
  return {
1860
1864
  src: generatePath(props.defaultWidth),
1861
1865
  srcSet: props.widths ? props.widths.map(function (size) {
1862
1866
  return "".concat(generatePath(size), " ").concat(size, "w");
1863
1867
  }).join(",") : undefined,
1868
+ sizes: generateSizes(),
1864
1869
  key: hashString(props.slug)
1865
1870
  };
1866
1871
  }
@@ -1910,7 +1915,7 @@ var ThumborImage = /*#__PURE__*/function (_React$Component) {
1910
1915
  ref: function ref(dom) {
1911
1916
  return _this2.dom = dom;
1912
1917
  },
1913
- className: this.props.className ? "qt-image ".concat(this.props.className) : 'qt-image'
1918
+ className: this.props.className ? "qt-image ".concat(this.props.className) : "qt-image"
1914
1919
  }));
1915
1920
  }
1916
1921
  }, {
@@ -1950,7 +1955,7 @@ function loadGumlet() {
1950
1955
  return;
1951
1956
  }
1952
1957
 
1953
- if (process.env.NODE_ENV == 'development') {
1958
+ if (process.env.NODE_ENV == "development") {
1954
1959
  console.warn("Loading Gumlet Dynamically! This is really bad for page speed. Please see https://developers.quintype.com/malibu/tutorial/gumlet-integration");
1955
1960
  }
1956
1961
 
@@ -1958,9 +1963,9 @@ function loadGumlet() {
1958
1963
  window.GUMLET_CONFIG = window.GUMLET_CONFIG || {
1959
1964
  hosts: []
1960
1965
  };
1961
- var script = document.createElement('script');
1962
- script.type = 'text/javascript';
1963
- script.src = 'https://cdn.gumlet.com/gumlet.js/2.0/gumlet.min.js';
1966
+ var script = document.createElement("script");
1967
+ script.type = "text/javascript";
1968
+ script.src = "https://cdn.gumlet.com/gumlet.js/2.0/gumlet.min.js";
1964
1969
  document.body.appendChild(script);
1965
1970
  }
1966
1971
 
@@ -1973,15 +1978,30 @@ function GumletImage(props) {
1973
1978
  reactTag = props.reactTag,
1974
1979
  className = props.className;
1975
1980
  var image = new quintypeJs.FocusedImage(slug, metadata);
1981
+
1982
+ function generatePath(size) {
1983
+ return "//" + imageCDN + "/" + image.path(aspectRatio, Object.assign({
1984
+ w: size
1985
+ }, imgParams));
1986
+ }
1987
+
1988
+ function generateSizes() {
1989
+ return "(max-width: 600px) 100vw, (max-width: 900px) 50vw, 33vw";
1990
+ }
1991
+
1976
1992
  var imageProps = {
1977
1993
  src: emptyWebGif__default["default"],
1978
1994
  "data-src": "https://" + imageCDN + "/" + image.path(aspectRatio, imgParams),
1995
+ srcSet: props.widths ? props.widths.map(function (size) {
1996
+ return "".concat(generatePath(size), " ").concat(size, "w");
1997
+ }).join(",") : undefined,
1998
+ sizes: generateSizes(),
1979
1999
  key: hashString(slug)
1980
2000
  };
1981
2001
  var Tag = reactTag || "img";
1982
2002
  React.useEffect(loadGumlet);
1983
2003
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Tag, _extends__default["default"]({}, imageProps, omit__default["default"](props, USED_PARAMS), {
1984
- className: className ? "qt-image ".concat(className) : 'qt-image'
2004
+ className: className ? "qt-image ".concat(className) : "qt-image"
1985
2005
  })), /*#__PURE__*/React__default["default"].createElement("noscript", null, /*#__PURE__*/React__default["default"].createElement("img", {
1986
2006
  src: "https://".concat(imageCDN, "/").concat(image.path(aspectRatio, _objectSpread$4(_objectSpread$4({}, imgParams), {}, {
1987
2007
  w: 1200
@@ -5,11 +5,11 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
5
5
 
6
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7
7
 
8
- import React, { useEffect } from "react";
9
- import emptyWebGif from 'empty-web-gif';
8
+ import omit from "@babel/runtime/helpers/objectWithoutProperties";
9
+ import emptyWebGif from "empty-web-gif";
10
10
  import { FocusedImage } from "quintype-js";
11
+ import React, { useEffect } from "react";
11
12
  import { hashString, USED_PARAMS } from "./image-utils";
12
- import omit from '@babel/runtime/helpers/objectWithoutProperties';
13
13
  var forceLoadingGumlet = false;
14
14
 
15
15
  function loadGumlet() {
@@ -17,7 +17,7 @@ function loadGumlet() {
17
17
  return;
18
18
  }
19
19
 
20
- if (process.env.NODE_ENV == 'development') {
20
+ if (process.env.NODE_ENV == "development") {
21
21
  console.warn("Loading Gumlet Dynamically! This is really bad for page speed. Please see https://developers.quintype.com/malibu/tutorial/gumlet-integration");
22
22
  }
23
23
 
@@ -25,9 +25,9 @@ function loadGumlet() {
25
25
  window.GUMLET_CONFIG = window.GUMLET_CONFIG || {
26
26
  hosts: []
27
27
  };
28
- var script = document.createElement('script');
29
- script.type = 'text/javascript';
30
- script.src = 'https://cdn.gumlet.com/gumlet.js/2.0/gumlet.min.js';
28
+ var script = document.createElement("script");
29
+ script.type = "text/javascript";
30
+ script.src = "https://cdn.gumlet.com/gumlet.js/2.0/gumlet.min.js";
31
31
  document.body.appendChild(script);
32
32
  }
33
33
 
@@ -40,15 +40,30 @@ export function GumletImage(props) {
40
40
  reactTag = props.reactTag,
41
41
  className = props.className;
42
42
  var image = new FocusedImage(slug, metadata);
43
+
44
+ function generatePath(size) {
45
+ return "//" + imageCDN + "/" + image.path(aspectRatio, Object.assign({
46
+ w: size
47
+ }, imgParams));
48
+ }
49
+
50
+ function generateSizes() {
51
+ return "(max-width: 600px) 100vw, (max-width: 900px) 50vw, 33vw";
52
+ }
53
+
43
54
  var imageProps = {
44
55
  src: emptyWebGif,
45
56
  "data-src": "https://" + imageCDN + "/" + image.path(aspectRatio, imgParams),
57
+ srcSet: props.widths ? props.widths.map(function (size) {
58
+ return "".concat(generatePath(size), " ").concat(size, "w");
59
+ }).join(",") : undefined,
60
+ sizes: generateSizes(),
46
61
  key: hashString(slug)
47
62
  };
48
63
  var Tag = reactTag || "img";
49
64
  useEffect(loadGumlet);
50
65
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tag, _extends({}, imageProps, omit(props, USED_PARAMS), {
51
- className: className ? "qt-image ".concat(className) : 'qt-image'
66
+ className: className ? "qt-image ".concat(className) : "qt-image"
52
67
  })), /*#__PURE__*/React.createElement("noscript", null, /*#__PURE__*/React.createElement("img", {
53
68
  src: "https://".concat(imageCDN, "/").concat(image.path(aspectRatio, _objectSpread(_objectSpread({}, imgParams), {}, {
54
69
  w: 1200
@@ -8,12 +8,12 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
8
8
 
9
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
10
 
11
- import React from "react";
12
- import emptyWebGif from 'empty-web-gif';
13
- import omit from '@babel/runtime/helpers/objectWithoutProperties';
14
- import { func } from 'prop-types';
11
+ import omit from "@babel/runtime/helpers/objectWithoutProperties";
12
+ import emptyWebGif from "empty-web-gif";
13
+ import { func } from "prop-types";
15
14
  import { FocusedImage } from "quintype-js";
16
- import { USED_PARAMS, hashString } from './image-utils';
15
+ import React from "react";
16
+ import { USED_PARAMS, hashString } from "./image-utils";
17
17
  export function responsiveProps(props) {
18
18
  var image = new FocusedImage(props.slug, props.metadata);
19
19
 
@@ -23,11 +23,16 @@ export function responsiveProps(props) {
23
23
  }, props.imgParams));
24
24
  }
25
25
 
26
+ function generateSizes() {
27
+ return "(max-width: 600px) 100vw, (max-width: 900px) 50vw, 33vw";
28
+ }
29
+
26
30
  return {
27
31
  src: generatePath(props.defaultWidth),
28
32
  srcSet: props.widths ? props.widths.map(function (size) {
29
33
  return "".concat(generatePath(size), " ").concat(size, "w");
30
34
  }).join(",") : undefined,
35
+ sizes: generateSizes(),
31
36
  key: hashString(props.slug)
32
37
  };
33
38
  }
@@ -77,7 +82,7 @@ export var ThumborImage = /*#__PURE__*/function (_React$Component) {
77
82
  ref: function ref(dom) {
78
83
  return _this2.dom = dom;
79
84
  },
80
- className: this.props.className ? "qt-image ".concat(this.props.className) : 'qt-image'
85
+ className: this.props.className ? "qt-image ".concat(this.props.className) : "qt-image"
81
86
  }));
82
87
  }
83
88
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/components",
3
- "version": "3.5.2",
3
+ "version": "3.5.3-fix-image-sizes.1",
4
4
  "description": "Components to help build Quintype Node.js apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",