@malloydata/render 0.0.94-dev231005020107 → 0.0.94-dev231006230622

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.
Files changed (2) hide show
  1. package/dist/html/image.js +18 -4
  2. package/package.json +2 -2
@@ -33,11 +33,25 @@ class HTMLImageRenderer {
33
33
  if (!data.isString()) {
34
34
  return (0, utils_1.createErrorElement)(this.document, 'Invalid field for Image renderer');
35
35
  }
36
- if (data.isNull()) {
37
- return (0, utils_1.createNullElement)(this.document);
36
+ const element = data.isNull()
37
+ ? (0, utils_1.createNullElement)(this.document)
38
+ : this.document.createElement('img');
39
+ const { tag } = data.field.tagParse();
40
+ const width = tag.numeric('image', 'width');
41
+ const height = tag.numeric('image', 'height');
42
+ // Both image and null placeholder get matching size
43
+ if (width)
44
+ element.style.width = `${width}px`;
45
+ if (height)
46
+ element.style.height = `${height}px`;
47
+ // Image specific props
48
+ if (!data.isNull()) {
49
+ const alt = tag.text('image', 'alt');
50
+ const img = element;
51
+ img.src = data.value;
52
+ if (alt)
53
+ img.alt = alt;
38
54
  }
39
- const element = this.document.createElement('img');
40
- element.src = data.value;
41
55
  return element;
42
56
  }
43
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/render",
3
- "version": "0.0.94-dev231005020107",
3
+ "version": "0.0.94-dev231006230622",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "prepublishOnly": "npm run build"
19
19
  },
20
20
  "dependencies": {
21
- "@malloydata/malloy": "^0.0.94-dev231005020107",
21
+ "@malloydata/malloy": "^0.0.94-dev231006230622",
22
22
  "@types/luxon": "^2.4.0",
23
23
  "lodash": "^4.17.20",
24
24
  "luxon": "^2.4.0",