From 92f155fb8d262624d501a78068ca2d4d12f31a35 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 15 May 2024 13:40:12 -0700 Subject: [PATCH] [C] update library --- helpers/assets.ts | 15 +++++++++++++++ helpers/widgets.ts | 5 +++-- package.json | 2 +- yarn.lock | 18 +++--------------- 4 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 helpers/assets.ts diff --git a/helpers/assets.ts b/helpers/assets.ts new file mode 100644 index 00000000..427d4c19 --- /dev/null +++ b/helpers/assets.ts @@ -0,0 +1,15 @@ +type ValidCantoSize = 100 | 240 | 320 | 500 | 640 | 800 | 2050; + +const ValidCantoSizes: Array = [ + 100, 240, 320, 500, 640, 800, 2050, +]; + +export const resizeCantoImage = (previewUrl: string, size: ValidCantoSize) => { + if (ValidCantoSizes.includes(size)) { + const urlWithoutConstraint = previewUrl.slice(0, -3); + + return urlWithoutConstraint.concat(size.toString()); + } + + return previewUrl; +}; diff --git a/helpers/widgets.ts b/helpers/widgets.ts index 518ea042..42fcc73c 100644 --- a/helpers/widgets.ts +++ b/helpers/widgets.ts @@ -1,10 +1,11 @@ import { Alert } from "@/lib/api/hooks/useAlerts"; +import { resizeCantoImage } from "./assets"; export const combineAlertsAndImages = ( alerts: Array, images: Array ) => { - const size = 200; + const size = 240; return { alerts: alerts.map((alert, i) => { @@ -18,7 +19,7 @@ export const combineAlertsAndImages = ( image: { width: size, height: size, - url: directUrlPreview, + url: resizeCantoImage(directUrlPreview, size), }, }; }), diff --git a/package.json b/package.json index 6cfbb3c6..4e898b45 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@greatsumini/react-facebook-login": "^3.3.3", "@react-oauth/google": "^0.11.0", "@rubin-epo/epo-react-lib": "^2.0.24", - "@rubin-epo/epo-widget-lib": "^0.9.11-beta.1", + "@rubin-epo/epo-widget-lib": "^0.9.12", "@unly/universal-language-detector": "^2.0.3", "@urql/core": "^4.1.0", "@urql/next": "^1.1.0", diff --git a/yarn.lock b/yarn.lock index f686c769..e6e61d87 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3057,22 +3057,10 @@ react-uid "^2.3.2" styled-components "^6.1.1" -"@rubin-epo/epo-widget-lib@file:../epo-react-lib/packages/epo-widget-lib/tempPublish": - version "0.9.12" - dependencies: - "@rubin-epo/epo-react-lib" "2.0.24" - context-filter-polyfill "^0.3.6" - d3-array "^3.2.4" - d3-geo "^3.1.0" - d3-geo-projection "^4.0.0" - lodash "^4.17.21" - react-slider "^2.0.6" - skia-canvas "^1.0.1" - styled-components "^6.1.1" - use-resize-observer "^9.1.0" - -"@rubin-epo/epo-widget-lib@file:/Users/agoff/Documents/workspace/epo-react-lib/packages/epo-widget-lib/tempPublish": +"@rubin-epo/epo-widget-lib@^0.9.12": version "0.9.12" + resolved "https://registry.yarnpkg.com/@rubin-epo/epo-widget-lib/-/epo-widget-lib-0.9.12.tgz#91facebe49705c9932c100169b87a506d73d8490" + integrity sha512-6MRYFdQ0QATuGVqOYVpfXLASwujBrqXfTZLn62WbAMgUNCq1LWiX5rT9OHb4bmT5PUgOfxbcVDbskcBBwnl7uQ== dependencies: "@rubin-epo/epo-react-lib" "2.0.24" context-filter-polyfill "^0.3.6"