@oneblink/apps-react 1.2.3 → 1.2.4-beta.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.
@@ -1,19 +1,23 @@
1
1
  import { localisationService } from '@oneblink/apps';
2
2
  export default function (file, canvas) {
3
- const context = canvas.getContext('2d');
4
- if (context) {
3
+ const ctx = canvas.getContext('2d');
4
+ if (ctx) {
5
5
  const now = localisationService.formatDatetime(new Date(file.lastModified));
6
- const textHeight = 20;
7
- context.font = `${textHeight}px Arial`;
8
- const { width: textWidth } = context.measureText(now);
9
- const backgroundMargin = 10;
10
- const backgroundPadding = backgroundMargin;
11
- const backgroundWidth = backgroundPadding * 2 + textWidth;
12
- const backgroundHeight = backgroundPadding * 2 + textHeight;
13
- context.fillStyle = 'rgba(20, 20, 20, 0.6)';
14
- context.fillRect(canvas.width - backgroundWidth - backgroundMargin, canvas.height - backgroundHeight - backgroundMargin, backgroundWidth, backgroundHeight);
15
- context.fillStyle = '#FFF';
16
- context.fillText(now, canvas.width - textWidth - backgroundPadding - backgroundMargin, canvas.height - 22);
6
+ const imageHeightMultiplierCoefficient = 0.0021;
7
+ const textHeightCoefficient = 20;
8
+ const backgroundMarginCoefficient = 10;
9
+ const textHeight = imageHeightMultiplierCoefficient * canvas.height * textHeightCoefficient;
10
+ const backgroundMargin = imageHeightMultiplierCoefficient *
11
+ canvas.height *
12
+ backgroundMarginCoefficient;
13
+ ctx.font = `${textHeight}px Arial`;
14
+ const { width: textWidth } = ctx.measureText(now);
15
+ const backgroundWidth = backgroundMargin * 2 + textWidth;
16
+ const backgroundHeight = backgroundMargin * 2 + textHeight;
17
+ ctx.fillStyle = 'rgba(20, 20, 20, 0.6)';
18
+ ctx.fillRect(canvas.width - backgroundWidth - backgroundMargin, canvas.height - backgroundHeight - backgroundMargin, backgroundWidth, backgroundHeight);
19
+ ctx.fillStyle = '#FFF';
20
+ ctx.fillText(now, canvas.width - textWidth - backgroundMargin * 2, canvas.height - textHeight - backgroundMargin / 3);
17
21
  }
18
22
  }
19
23
  //# sourceMappingURL=drawTimestampOnCanvas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"drawTimestampOnCanvas.js","sourceRoot":"","sources":["../../src/services/drawTimestampOnCanvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,CAAC,OAAO,WAAW,IAAU,EAAE,MAAyB;IAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvC,IAAI,OAAO,EAAE;QACX,MAAM,GAAG,GAAG,mBAAmB,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAA;QAC3E,MAAM,UAAU,GAAG,EAAE,CAAA;QACrB,OAAO,CAAC,IAAI,GAAG,GAAG,UAAU,UAAU,CAAA;QACtC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QACrD,MAAM,gBAAgB,GAAG,EAAE,CAAA;QAC3B,MAAM,iBAAiB,GAAG,gBAAgB,CAAA;QAC1C,MAAM,eAAe,GAAG,iBAAiB,GAAG,CAAC,GAAG,SAAS,CAAA;QACzD,MAAM,gBAAgB,GAAG,iBAAiB,GAAG,CAAC,GAAG,UAAU,CAAA;QAC3D,OAAO,CAAC,SAAS,GAAG,uBAAuB,CAAA;QAC3C,OAAO,CAAC,QAAQ,CACd,MAAM,CAAC,KAAK,GAAG,eAAe,GAAG,gBAAgB,EACjD,MAAM,CAAC,MAAM,GAAG,gBAAgB,GAAG,gBAAgB,EACnD,eAAe,EACf,gBAAgB,CACjB,CAAA;QAED,OAAO,CAAC,SAAS,GAAG,MAAM,CAAA;QAC1B,OAAO,CAAC,QAAQ,CACd,GAAG,EACH,MAAM,CAAC,KAAK,GAAG,SAAS,GAAG,iBAAiB,GAAG,gBAAgB,EAC/D,MAAM,CAAC,MAAM,GAAG,EAAE,CACnB,CAAA;KACF;AACH,CAAC","sourcesContent":["import { localisationService } from '@oneblink/apps'\n\nexport default function (file: File, canvas: HTMLCanvasElement): void {\n const context = canvas.getContext('2d')\n if (context) {\n const now = localisationService.formatDatetime(new Date(file.lastModified))\n const textHeight = 20\n context.font = `${textHeight}px Arial`\n const { width: textWidth } = context.measureText(now)\n const backgroundMargin = 10\n const backgroundPadding = backgroundMargin\n const backgroundWidth = backgroundPadding * 2 + textWidth\n const backgroundHeight = backgroundPadding * 2 + textHeight\n context.fillStyle = 'rgba(20, 20, 20, 0.6)'\n context.fillRect(\n canvas.width - backgroundWidth - backgroundMargin,\n canvas.height - backgroundHeight - backgroundMargin,\n backgroundWidth,\n backgroundHeight,\n )\n\n context.fillStyle = '#FFF'\n context.fillText(\n now,\n canvas.width - textWidth - backgroundPadding - backgroundMargin,\n canvas.height - 22,\n )\n }\n}\n"]}
1
+ {"version":3,"file":"drawTimestampOnCanvas.js","sourceRoot":"","sources":["../../src/services/drawTimestampOnCanvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,CAAC,OAAO,WAAW,IAAU,EAAE,MAAyB;IAC5D,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,GAAG,EAAE;QACP,MAAM,GAAG,GAAG,mBAAmB,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAA;QAC3E,MAAM,gCAAgC,GAAG,MAAM,CAAA;QAC/C,MAAM,qBAAqB,GAAG,EAAE,CAAA;QAChC,MAAM,2BAA2B,GAAG,EAAE,CAAA;QAEtC,MAAM,UAAU,GACd,gCAAgC,GAAG,MAAM,CAAC,MAAM,GAAG,qBAAqB,CAAA;QAE1E,MAAM,gBAAgB,GACpB,gCAAgC;YAChC,MAAM,CAAC,MAAM;YACb,2BAA2B,CAAA;QAE7B,GAAG,CAAC,IAAI,GAAG,GAAG,UAAU,UAAU,CAAA;QAClC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QAEjD,MAAM,eAAe,GAAG,gBAAgB,GAAG,CAAC,GAAG,SAAS,CAAA;QACxD,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,CAAC,GAAG,UAAU,CAAA;QAE1D,GAAG,CAAC,SAAS,GAAG,uBAAuB,CAAA;QACvC,GAAG,CAAC,QAAQ,CACV,MAAM,CAAC,KAAK,GAAG,eAAe,GAAG,gBAAgB,EACjD,MAAM,CAAC,MAAM,GAAG,gBAAgB,GAAG,gBAAgB,EACnD,eAAe,EACf,gBAAgB,CACjB,CAAA;QAED,GAAG,CAAC,SAAS,GAAG,MAAM,CAAA;QACtB,GAAG,CAAC,QAAQ,CACV,GAAG,EACH,MAAM,CAAC,KAAK,GAAG,SAAS,GAAG,gBAAgB,GAAG,CAAC,EAC/C,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,gBAAgB,GAAG,CAAC,CAClD,CAAA;KACF;AACH,CAAC","sourcesContent":["import { localisationService } from '@oneblink/apps'\n\nexport default function (file: File, canvas: HTMLCanvasElement): void {\n const ctx = canvas.getContext('2d')\n if (ctx) {\n const now = localisationService.formatDatetime(new Date(file.lastModified))\n const imageHeightMultiplierCoefficient = 0.0021\n const textHeightCoefficient = 20\n const backgroundMarginCoefficient = 10\n\n const textHeight =\n imageHeightMultiplierCoefficient * canvas.height * textHeightCoefficient\n\n const backgroundMargin =\n imageHeightMultiplierCoefficient *\n canvas.height *\n backgroundMarginCoefficient\n\n ctx.font = `${textHeight}px Arial`\n const { width: textWidth } = ctx.measureText(now)\n\n const backgroundWidth = backgroundMargin * 2 + textWidth\n const backgroundHeight = backgroundMargin * 2 + textHeight\n\n ctx.fillStyle = 'rgba(20, 20, 20, 0.6)'\n ctx.fillRect(\n canvas.width - backgroundWidth - backgroundMargin,\n canvas.height - backgroundHeight - backgroundMargin,\n backgroundWidth,\n backgroundHeight,\n )\n\n ctx.fillStyle = '#FFF'\n ctx.fillText(\n now,\n canvas.width - textWidth - backgroundMargin * 2,\n canvas.height - textHeight - backgroundMargin / 3,\n )\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oneblink/apps-react",
3
3
  "description": "Helper functions for OneBlink apps in ReactJS.",
4
- "version": "1.2.3",
4
+ "version": "1.2.4-beta.1",
5
5
  "author": "OneBlink <developers@oneblink.io> (https://oneblink.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/oneblink/apps-react/issues"