@parameter1/base-cms-marko-web 3.7.11 → 3.8.0
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.
@@ -9,11 +9,6 @@ $ const srcset = getAsArray(input.srcset).join(", ") || null;
|
|
9
9
|
$ const classNames = [input.class];
|
10
10
|
$ if (lazyload) classNames.push("lazyload");
|
11
11
|
$ const attrs = getAsObject(input.attrs);
|
12
|
-
$ if (input.width && input.width > 0 && !attrs.width && !attrs.height) {
|
13
|
-
attrs.width = input.width;
|
14
|
-
const height = input.height || imageHeight(input.width, input.ar) || undefined;
|
15
|
-
if (height) attrs.height = height;
|
16
|
-
};
|
17
12
|
|
18
13
|
<if(lazyload)>
|
19
14
|
<img
|
@@ -1,26 +1,35 @@
|
|
1
|
-
import { buildImgixUrl } from "@parameter1/base-cms-image";
|
2
|
-
import { get } from "@parameter1/base-cms-object-path";
|
3
|
-
import imageHeight from "./utils/image-height";
|
1
|
+
import { buildImgixUrl, getRelativeAspectRatioHeight, getRelativeAspectRatioWidth } from "@parameter1/base-cms-image";
|
2
|
+
import { get, getAsObject } from "@parameter1/base-cms-object-path";
|
4
3
|
|
5
4
|
$ const element = "node__image";
|
6
5
|
$ const hasImage = Boolean(input.src);
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
<!--
|
8
|
+
1. If either width or height input is set, use them as the options.w and options.h
|
9
|
+
2. Using options.w and options.h, determine relative w and h when not present
|
10
|
+
3. Finally, using options, set the image width and height attrs
|
11
|
+
-->
|
12
12
|
|
13
|
-
$ const
|
14
|
-
|
15
|
-
...input.options,
|
16
|
-
}
|
13
|
+
$ const { width, height } = input;
|
14
|
+
$ const options = getAsObject(input, "options");
|
17
15
|
|
18
|
-
$ if (
|
19
|
-
|
20
|
-
|
16
|
+
$ if (width || height) {
|
17
|
+
options.w = width || undefined;
|
18
|
+
options.h = height || undefined;
|
21
19
|
}
|
20
|
+
$ if (input.ar) options.ar = input.ar;
|
21
|
+
|
22
|
+
$ const {
|
23
|
+
w,
|
24
|
+
h,
|
25
|
+
ar,
|
26
|
+
fit,
|
27
|
+
} = options;
|
28
|
+
$ if (w && !h) options.h = ar ? getRelativeAspectRatioHeight(w, ar) : undefined;
|
29
|
+
$ if (h && !w) options.w = ar ? getRelativeAspectRatioWidth(h, ar) : undefined;
|
30
|
+
$ if (!fit) options.fit = options.w && options.h ? "crop" : undefined;
|
22
31
|
|
23
|
-
|
32
|
+
$ const attrs = { ...input.attrs, width: options.w, height: options.h };
|
24
33
|
|
25
34
|
<if(hasImage)>
|
26
35
|
$ const src = buildImgixUrl(input.src, options, input.defaultOptions, input.isLogo);
|
@@ -32,8 +41,6 @@ $ if (options.w) {
|
|
32
41
|
attrs=attrs
|
33
42
|
class=[element, input.class]
|
34
43
|
lazyload=input.lazyload
|
35
|
-
width=input.width
|
36
|
-
height=input.height
|
37
44
|
/>
|
38
45
|
</if>
|
39
46
|
<else-if(input.usePlaceholder)>
|
@@ -1,12 +1,17 @@
|
|
1
1
|
const imageHeight = require('./image-height');
|
2
2
|
|
3
|
-
module.exports = ({
|
3
|
+
module.exports = ({
|
4
|
+
fluid,
|
5
|
+
ar,
|
6
|
+
width = 320,
|
7
|
+
delimiter = ':',
|
8
|
+
}) => {
|
4
9
|
if (fluid === true) {
|
5
|
-
if (ar) return { modifier: `fluid-${ar.replace(
|
10
|
+
if (ar) return { modifier: `fluid-${ar.replace(delimiter, 'by')}` };
|
6
11
|
return { modifier: 'fluid' };
|
7
12
|
}
|
8
13
|
if (ar) {
|
9
|
-
return { width, height: imageHeight(width, ar) };
|
14
|
+
return { width, height: imageHeight(width, ar, delimiter) };
|
10
15
|
}
|
11
16
|
return { width };
|
12
17
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@parameter1/base-cms-marko-web",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.8.0",
|
4
4
|
"description": "Core Marko+Express components for BaseCMS websites",
|
5
5
|
"author": "Jacob Bare <jacob@parameter1.com>",
|
6
6
|
"main": "index.js",
|
@@ -16,10 +16,10 @@
|
|
16
16
|
"dependencies": {
|
17
17
|
"@godaddy/terminus": "^4.9.0",
|
18
18
|
"@parameter1/base-cms-apollo-ssr": "^3.0.0",
|
19
|
-
"@parameter1/base-cms-embedded-media": "^3.
|
19
|
+
"@parameter1/base-cms-embedded-media": "^3.8.0",
|
20
20
|
"@parameter1/base-cms-express-apollo": "^3.0.0",
|
21
21
|
"@parameter1/base-cms-graphql-fragment-types": "^3.0.0",
|
22
|
-
"@parameter1/base-cms-image": "^3.
|
22
|
+
"@parameter1/base-cms-image": "^3.8.0",
|
23
23
|
"@parameter1/base-cms-inflector": "^3.0.0",
|
24
24
|
"@parameter1/base-cms-marko-node-require": "^3.0.0",
|
25
25
|
"@parameter1/base-cms-object-path": "^3.0.0",
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"publishConfig": {
|
47
47
|
"access": "public"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "de7ed3f6665b430872553b8f5b51e4cf51db4066"
|
50
50
|
}
|