@parameter1/base-cms-marko-web 3.7.7 → 3.8.0
Sign up to get free protection for your applications and to get access to all the features.
- package/components/element/components/image.marko +5 -3
- package/components/element/marko.json +12 -3
- package/components/element/picture.marko +2 -0
- package/components/node/image.marko +25 -10
- package/components/node/marko.json +1 -0
- package/components/node/utils/image-height.js +3 -5
- package/components/node/utils/image-values.js +8 -3
- package/package.json +4 -4
@@ -1,4 +1,5 @@
|
|
1
|
-
import { getAsArray } from "@parameter1/base-cms-object-path";
|
1
|
+
import { getAsArray, getAsObject } from "@parameter1/base-cms-object-path";
|
2
|
+
import imageHeight from "../../node/utils/image-height";
|
2
3
|
|
3
4
|
$ const { config } = out.global;
|
4
5
|
$ const { src, alt } = input;
|
@@ -7,10 +8,11 @@ $ const srcset = getAsArray(input.srcset).join(", ") || null;
|
|
7
8
|
|
8
9
|
$ const classNames = [input.class];
|
9
10
|
$ if (lazyload) classNames.push("lazyload");
|
11
|
+
$ const attrs = getAsObject(input.attrs);
|
10
12
|
|
11
13
|
<if(lazyload)>
|
12
14
|
<img
|
13
|
-
...
|
15
|
+
...attrs
|
14
16
|
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
|
15
17
|
srcset=null
|
16
18
|
data-src=src
|
@@ -21,7 +23,7 @@ $ if (lazyload) classNames.push("lazyload");
|
|
21
23
|
</if>
|
22
24
|
<else>
|
23
25
|
<img
|
24
|
-
...
|
26
|
+
...attrs
|
25
27
|
src=src
|
26
28
|
srcset=srcset
|
27
29
|
class=classNames
|
@@ -63,7 +63,10 @@
|
|
63
63
|
},
|
64
64
|
"@class": "string",
|
65
65
|
"@attrs": "object",
|
66
|
-
"@link": "object"
|
66
|
+
"@link": "object",
|
67
|
+
"@width": "number",
|
68
|
+
"@height": "number",
|
69
|
+
"@ar": "string"
|
67
70
|
},
|
68
71
|
"<marko-web-link>": {
|
69
72
|
"template": "./link.marko",
|
@@ -175,7 +178,10 @@
|
|
175
178
|
},
|
176
179
|
"@class": "string",
|
177
180
|
"@attrs": "object",
|
178
|
-
"@link": "object"
|
181
|
+
"@link": "object",
|
182
|
+
"@width": "string",
|
183
|
+
"@height": "string",
|
184
|
+
"@ar": "string"
|
179
185
|
},
|
180
186
|
"<link>": {
|
181
187
|
"<before>": {},
|
@@ -195,7 +201,10 @@
|
|
195
201
|
"@srcset": {
|
196
202
|
"type": "array",
|
197
203
|
"required": true
|
198
|
-
}
|
204
|
+
},
|
205
|
+
"@width": "number",
|
206
|
+
"@height": "number",
|
207
|
+
"@ar": "string"
|
199
208
|
}
|
200
209
|
}
|
201
210
|
}
|
@@ -1,20 +1,35 @@
|
|
1
|
-
import { buildImgixUrl } from "@parameter1/base-cms-image";
|
2
|
-
import { get } from "@parameter1/base-cms-object-path";
|
1
|
+
import { buildImgixUrl, getRelativeAspectRatioHeight, getRelativeAspectRatioWidth } from "@parameter1/base-cms-image";
|
2
|
+
import { get, getAsObject } from "@parameter1/base-cms-object-path";
|
3
3
|
|
4
4
|
$ const element = "node__image";
|
5
5
|
$ const hasImage = Boolean(input.src);
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
+
-->
|
11
12
|
|
12
|
-
$ const
|
13
|
-
|
14
|
-
|
13
|
+
$ const { width, height } = input;
|
14
|
+
$ const options = getAsObject(input, "options");
|
15
|
+
|
16
|
+
$ if (width || height) {
|
17
|
+
options.w = width || undefined;
|
18
|
+
options.h = height || undefined;
|
15
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;
|
16
31
|
|
17
|
-
|
32
|
+
$ const attrs = { ...input.attrs, width: options.w, height: options.h };
|
18
33
|
|
19
34
|
<if(hasImage)>
|
20
35
|
$ const src = buildImgixUrl(input.src, options, input.defaultOptions, input.isLogo);
|
@@ -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
|
}
|