From e607c5aec4e229c2700f7d6ba0620bd568dc23ed Mon Sep 17 00:00:00 2001 From: Dana Johnson Date: Wed, 28 Jun 2023 11:55:14 -0700 Subject: [PATCH 01/59] [B] Fix missing translations in client components --- lib/i18n/client.ts | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/i18n/client.ts b/lib/i18n/client.ts index 525c82d1..44510eb8 100644 --- a/lib/i18n/client.ts +++ b/lib/i18n/client.ts @@ -1,17 +1,41 @@ "use client"; import i18next from "i18next"; +import resourcesToBackend from "i18next-resources-to-backend"; import { initReactI18next, useTranslation as useTranslationOrg, } from "react-i18next"; import LanguageDetector from "i18next-browser-languagedetector"; -import { getOptions } from "./settings"; +import { fallbackLng, defaultNS, getOptions } from "./settings"; // on client side the normal singleton is ok i18next .use(initReactI18next) .use(LanguageDetector) + .use( + resourcesToBackend((language: string, namespace: string, callback) => { + if (namespace === "epo-react-lib") { + import( + `@rubin-epo/epo-react-lib/localeStrings/${language}/${namespace}.json` + ) + .then(({ default: resources }) => { + callback(null, resources); + }) + .catch((error) => { + callback(error, null); + }); + } else { + import(`../../public/localeStrings/${language}/${namespace}.json`) + .then(({ default: resources }) => { + callback(null, resources); + }) + .catch((error) => { + callback(error, null); + }); + } + }) + ) .init({ ...getOptions(), lng: undefined, // let detect the language on client side @@ -20,7 +44,11 @@ i18next }, }); -export function useTranslation(lng: string, ns: string, options: any) { +export function useTranslation( + lng: string = fallbackLng, + ns: string = defaultNS, + options?: any +) { if (i18next.resolvedLanguage !== lng) i18next.changeLanguage(lng); return useTranslationOrg(ns, options); } From 7deb519cd6a3783710f9c4eb8aaca1ee6c10f9f1 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 10 Jul 2023 10:37:33 -0700 Subject: [PATCH 02/59] [C] update libraries and packages --- package.json | 6 +- yarn.lock | 238 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 150 insertions(+), 94 deletions(-) diff --git a/package.json b/package.json index 87f59b4d..c4c58d26 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ }, "dependencies": { "@castiron/style-mixins": "^1.0.6", - "@rubin-epo/epo-react-lib": "1.3.0-alpha.7", + "@rubin-epo/epo-react-lib": "^2.0.0-beta.4", "@rubin-epo/epo-widget-lib": "^0.2.1", "accept-language-parser": "^1.5.0", "classnames": "^2.3.2", @@ -59,7 +59,7 @@ "i18next": "^22.4.10", "i18next-resources-to-backend": "^1.1.4", "lodash": "^4.17.21", - "next": "^13.4.6", + "next": "^13.4.9", "next-build-id": "^3.0.0", "next-intl": "^2.14.6", "npm-run-all": "^4.1.5", @@ -69,7 +69,7 @@ "react-is": "^18.2.0", "react-uid": "^2.3.2", "screenfull": "^6.0.2", - "styled-components": "6.0.0-rc.2", + "styled-components": "6.0.2", "swr": "1.3.0", "universal-cookie": "^4.0.4", "use-resize-observer": "^9.1.0", diff --git a/yarn.lock b/yarn.lock index 3e9948f4..900ffd14 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1221,7 +1221,7 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== -"@emotion/is-prop-valid@^1.1.0": +"@emotion/is-prop-valid@^1.1.0", "@emotion/is-prop-valid@^1.2.1": version "1.2.1" resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-1.2.1.tgz#23116cf1ed18bfeac910ec6436561ecb1a3885cc" integrity sha512-61Mf7Ufx4aDxx1xlDeOm8aFFigGHE4z+0sKCa+IHCeZKiyP9RLD0Mmx7m8b9/Cf37f7NAvQOOJAbQQGVr5uERw== @@ -1621,10 +1621,10 @@ pump "^3.0.0" tar-fs "^2.1.1" -"@next/env@13.4.6": - version "13.4.6" - resolved "https://registry.yarnpkg.com/@next/env/-/env-13.4.6.tgz#3f2041c7758660d7255707ae4cb9166519113dea" - integrity sha512-nqUxEtvDqFhmV1/awSg0K2XHNwkftNaiUqCYO9e6+MYmqNObpKVl7OgMkGaQ2SZnFx5YqF0t60ZJTlyJIDAijg== +"@next/env@13.4.9": + version "13.4.9" + resolved "https://registry.yarnpkg.com/@next/env/-/env-13.4.9.tgz#b77759514dd56bfa9791770755a2482f4d6ca93e" + integrity sha512-vuDRK05BOKfmoBYLNi2cujG2jrYbEod/ubSSyqgmEx9n/W3eZaJQdRNhTfumO+qmq/QTzLurW487n/PM/fHOkw== "@next/eslint-plugin-next@13.4.3": version "13.4.3" @@ -1633,50 +1633,50 @@ dependencies: glob "7.1.7" -"@next/swc-darwin-arm64@13.4.6": - version "13.4.6" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.6.tgz#47485f3deaee6681b4a4036c74bb9c4b728d5ddd" - integrity sha512-ahi6VP98o4HV19rkOXPSUu+ovfHfUxbJQ7VVJ7gL2FnZRr7onEFC1oGQ6NQHpm8CxpIzSSBW79kumlFMOmZVjg== - -"@next/swc-darwin-x64@13.4.6": - version "13.4.6" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.6.tgz#a6a5b232ec0f2079224fb8ed6bf11dc479af1acf" - integrity sha512-13cXxKFsPJIJKzUqrU5XB1mc0xbUgYsRcdH6/rB8c4NMEbWGdtD4QoK9ShN31TZdePpD4k416Ur7p+deMIxnnA== - -"@next/swc-linux-arm64-gnu@13.4.6": - version "13.4.6" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.6.tgz#2a67144e863d9c45fdbd13c7827370e7f2a28405" - integrity sha512-Ti+NMHEjTNktCVxNjeWbYgmZvA2AqMMI2AMlzkXsU7W4pXCMhrryAmAIoo+7YdJbsx01JQWYVxGe62G6DoCLaA== - -"@next/swc-linux-arm64-musl@13.4.6": - version "13.4.6" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.6.tgz#5a191ac3575a70598e9e9c6e7264fc0b8a90b2db" - integrity sha512-OHoC6gO7XfjstgwR+z6UHKlvhqJfyMtNaJidjx3sEcfaDwS7R2lqR5AABi8PuilGgi0BO0O0sCXqLlpp3a0emQ== - -"@next/swc-linux-x64-gnu@13.4.6": - version "13.4.6" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.6.tgz#d38adf842a8b8f9de492454328fd32a2c53350f3" - integrity sha512-zHZxPGkUlpfNJCboUrFqwlwEX5vI9LSN70b8XEb0DYzzlrZyCyOi7hwDp/+3Urm9AB7YCAJkgR5Sp1XBVjHdfQ== - -"@next/swc-linux-x64-musl@13.4.6": - version "13.4.6" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.6.tgz#74c745774358b78be7f958e7a8b7d93936cd6ebc" - integrity sha512-K/Y8lYGTwTpv5ME8PSJxwxLolaDRdVy+lOd9yMRMiQE0BLUhtxtCWC9ypV42uh9WpLjoaD0joOsB9Q6mbrSGJg== - -"@next/swc-win32-arm64-msvc@13.4.6": - version "13.4.6" - resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.6.tgz#1e1e02c175573e64808fc1a7e8650e3e217f1edc" - integrity sha512-U6LtxEUrjBL2tpW+Kr1nHCSJWNeIed7U7l5o7FiKGGwGgIlFi4UHDiLI6TQ2lxi20fAU33CsruV3U0GuzMlXIw== - -"@next/swc-win32-ia32-msvc@13.4.6": - version "13.4.6" - resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.6.tgz#2b528ae3ec7f6e727f4f0d81a1015f63da55c7a6" - integrity sha512-eEBeAqpCfhdPSlCZCayjCiyIllVqy4tcqvm1xmg3BgJG0G5ITiMM4Cw2WVeRSgWDJqQGRyyb+q8Y2ltzhXOWsQ== - -"@next/swc-win32-x64-msvc@13.4.6": - version "13.4.6" - resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.6.tgz#38620bd68267ff13e50ecd432f1822eac51382a8" - integrity sha512-OrZs94AuO3ZS5tnqlyPRNgfWvboXaDQCi5aXGve3o3C+Sj0ctMUV9+Do+0zMvvLRumR8E0PTWKvtz9n5vzIsWw== +"@next/swc-darwin-arm64@13.4.9": + version "13.4.9" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.9.tgz#0ed408d444bbc6b0a20f3506a9b4222684585677" + integrity sha512-TVzGHpZoVBk3iDsTOQA/R6MGmFp0+17SWXMEWd6zG30AfuELmSSMe2SdPqxwXU0gbpWkJL1KgfLzy5ReN0crqQ== + +"@next/swc-darwin-x64@13.4.9": + version "13.4.9" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.9.tgz#a08fccdee68201522fe6618ec81f832084b222f8" + integrity sha512-aSfF1fhv28N2e7vrDZ6zOQ+IIthocfaxuMWGReB5GDriF0caTqtHttAvzOMgJgXQtQx6XhyaJMozLTSEXeNN+A== + +"@next/swc-linux-arm64-gnu@13.4.9": + version "13.4.9" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.9.tgz#1798c2341bb841e96521433eed00892fb24abbd1" + integrity sha512-JhKoX5ECzYoTVyIy/7KykeO4Z2lVKq7HGQqvAH+Ip9UFn1MOJkOnkPRB7v4nmzqAoY+Je05Aj5wNABR1N18DMg== + +"@next/swc-linux-arm64-musl@13.4.9": + version "13.4.9" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.9.tgz#cee04c51610eddd3638ce2499205083656531ea0" + integrity sha512-OOn6zZBIVkm/4j5gkPdGn4yqQt+gmXaLaSjRSO434WplV8vo2YaBNbSHaTM9wJpZTHVDYyjzuIYVEzy9/5RVZw== + +"@next/swc-linux-x64-gnu@13.4.9": + version "13.4.9" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.9.tgz#1932d0367916adbc6844b244cda1d4182bd11f7a" + integrity sha512-iA+fJXFPpW0SwGmx/pivVU+2t4zQHNOOAr5T378PfxPHY6JtjV6/0s1vlAJUdIHeVpX98CLp9k5VuKgxiRHUpg== + +"@next/swc-linux-x64-musl@13.4.9": + version "13.4.9" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.9.tgz#a66aa8c1383b16299b72482f6360facd5cde3c7a" + integrity sha512-rlNf2WUtMM+GAQrZ9gMNdSapkVi3koSW3a+dmBVp42lfugWVvnyzca/xJlN48/7AGx8qu62WyO0ya1ikgOxh6A== + +"@next/swc-win32-arm64-msvc@13.4.9": + version "13.4.9" + resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.9.tgz#39482ee856c867177a612a30b6861c75e0736a4a" + integrity sha512-5T9ybSugXP77nw03vlgKZxD99AFTHaX8eT1ayKYYnGO9nmYhJjRPxcjU5FyYI+TdkQgEpIcH7p/guPLPR0EbKA== + +"@next/swc-win32-ia32-msvc@13.4.9": + version "13.4.9" + resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.9.tgz#29db85e34b597ade1a918235d16a760a9213c190" + integrity sha512-ojZTCt1lP2ucgpoiFgrFj07uq4CZsq4crVXpLGgQfoFq00jPKRPgesuGPaz8lg1yLfvafkU3Jd1i8snKwYR3LA== + +"@next/swc-win32-x64-msvc@13.4.9": + version "13.4.9" + resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.9.tgz#0c2758164cccd61bc5a1c6cd8284fe66173e4a2b" + integrity sha512-QbT03FXRNdpuL+e9pLnu+XajZdm/TtIXVYY4lA9t+9l0fLZbHXDYEKitAqxrOj37o3Vx5ufxiRAniaIebYDCgw== "@nicolo-ribaudo/chokidar-2@2.1.8-no-fsevents.3": version "2.1.8-no-fsevents.3" @@ -1738,35 +1738,36 @@ schema-utils "^3.0.0" source-map "^0.7.3" -"@rubin-epo/epo-react-lib@1.3.0-alpha.7": - version "1.3.0-alpha.7" - resolved "https://registry.yarnpkg.com/@rubin-epo/epo-react-lib/-/epo-react-lib-1.3.0-alpha.7.tgz#234ac4526346aaea81b0c8fb1c6b268037ec1a89" - integrity sha512-7FqB9JlIEhKo3bsWRwW/rWBMydR7SZqFII81lcNA9imXMd2+BwXXwCLWyGk4xEyiIVtK1U19tnCG0jFc8oJaYA== +"@rubin-epo/epo-react-lib@^1.1.5": + version "1.2.6" + resolved "https://registry.yarnpkg.com/@rubin-epo/epo-react-lib/-/epo-react-lib-1.2.6.tgz#d415687936b855b2985775439b2da8eea20bb4e6" + integrity sha512-Y+GUWck2OJLzwQr2bZih+WOyn2QwbYCsrbyzWiMKp1Bt/S0bpye2FNzZMKoxAz/17U2DcS4rGvZZIiGKBcXkOw== dependencies: - "@castiron/style-mixins" "^1.0.6" - "@headlessui/react" "^1.7.5" flickity "^3.0.0" - i18next "^22.4.10" - react "^18.2.0" - react-dom "^18.2.0" - react-i18next "^12.0.0" react-player "^2.11.0" react-share "^4.4.1" react-slider "^2.0.4" react-uid "^2.3.2" - styled-components "6.0.0-rc.2" + styled-components "^5.3.6" -"@rubin-epo/epo-react-lib@^1.1.5": - version "1.2.6" - resolved "https://registry.yarnpkg.com/@rubin-epo/epo-react-lib/-/epo-react-lib-1.2.6.tgz#d415687936b855b2985775439b2da8eea20bb4e6" - integrity sha512-Y+GUWck2OJLzwQr2bZih+WOyn2QwbYCsrbyzWiMKp1Bt/S0bpye2FNzZMKoxAz/17U2DcS4rGvZZIiGKBcXkOw== +"@rubin-epo/epo-react-lib@^2.0.0-beta.4": + version "2.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@rubin-epo/epo-react-lib/-/epo-react-lib-2.0.0-beta.4.tgz#939e7b9a5df7c2259e51630f2079b0b43d4a4100" + integrity sha512-FJBScbH2H2yI/qawfZhrnXlprKSH4dgVuB5qlDza5ySwhSabaLBaX6T8aRPoIfF9kBt/twovsnaq++8J+M6FaA== dependencies: + "@castiron/style-mixins" "^1.0.6" + "@headlessui/react" "^1.7.5" flickity "^3.0.0" - react-player "^2.11.0" + focus-trap "^7.4.2" + i18next "^22.4.10" + react "^18.2.0" + react-dom "^18.2.0" + react-i18next "^12.0.0" + react-player "^2.12.0" react-share "^4.4.1" react-slider "^2.0.4" react-uid "^2.3.2" - styled-components "^5.3.6" + styled-components "^6.0.2" "@rubin-epo/epo-widget-lib@^0.2.1": version "0.2.1" @@ -3003,6 +3004,11 @@ resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c" integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw== +"@types/stylis@^4.0.2": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@types/stylis/-/stylis-4.2.0.tgz#199a3f473f0c3a6f6e4e1b17cdbc967f274bdc6b" + integrity sha512-n4sx2bqL0mW1tvDf/loQ+aMX7GQD3lc3fkCMC55VFNDu/vBOabO+LTIeXKM14xK0ppk5TUGcWRjiSpIlUpghKw== + "@types/unist@^2.0.0": version "2.0.6" resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.6.tgz#250a7b16c3b91f672a24552ec64678eeb1d3a08d" @@ -4575,7 +4581,7 @@ cssesc@^3.0.0: resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee" integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg== -csstype@^3.0.2: +csstype@^3.0.2, csstype@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.2.tgz#1d4bf9d572f11c14031f0436e1c10bc1f571f50b" integrity sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ== @@ -5797,6 +5803,13 @@ focus-trap@^7.3.1: dependencies: tabbable "^6.1.2" +focus-trap@^7.4.2: + version "7.5.2" + resolved "https://registry.yarnpkg.com/focus-trap/-/focus-trap-7.5.2.tgz#e5ee678d10a18651f2591ffb66c949fb098d57cf" + integrity sha512-p6vGNNWLDGwJCiEjkSK6oERj/hEyI9ITsSwIUICBoKLlWiTWXJRfQibCwcoi50rTZdbi87qDtUlMCmQwsGSgPw== + dependencies: + tabbable "^6.2.0" + focus-visible@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/focus-visible/-/focus-visible-5.2.0.tgz#3a9e41fccf587bd25dcc2ef045508284f0a4d6b3" @@ -7680,12 +7693,12 @@ next-intl@^2.14.6: negotiator "^0.6.3" use-intl "^2.14.6" -next@^13.4.6: - version "13.4.6" - resolved "https://registry.yarnpkg.com/next/-/next-13.4.6.tgz#ebe52f5c74d60176d45b45e73f25a51103713ea4" - integrity sha512-sjVqjxU+U2aXZnYt4Ud6CTLNNwWjdSfMgemGpIQJcN3Z7Jni9xRWbR0ie5fQzCg87aLqQVhKA2ud2gPoqJ9lGw== +next@^13.4.9: + version "13.4.9" + resolved "https://registry.yarnpkg.com/next/-/next-13.4.9.tgz#473de5997cb4c5d7a4fb195f566952a1cbffbeba" + integrity sha512-vtefFm/BWIi/eWOqf1GsmKG3cjKw1k3LjuefKRcL3iiLl3zWzFdPG3as6xtxrGO6gwTzzaO1ktL4oiHt/uvTjA== dependencies: - "@next/env" "13.4.6" + "@next/env" "13.4.9" "@swc/helpers" "0.5.1" busboy "1.6.0" caniuse-lite "^1.0.30001406" @@ -7694,15 +7707,15 @@ next@^13.4.6: watchpack "2.4.0" zod "3.21.4" optionalDependencies: - "@next/swc-darwin-arm64" "13.4.6" - "@next/swc-darwin-x64" "13.4.6" - "@next/swc-linux-arm64-gnu" "13.4.6" - "@next/swc-linux-arm64-musl" "13.4.6" - "@next/swc-linux-x64-gnu" "13.4.6" - "@next/swc-linux-x64-musl" "13.4.6" - "@next/swc-win32-arm64-msvc" "13.4.6" - "@next/swc-win32-ia32-msvc" "13.4.6" - "@next/swc-win32-x64-msvc" "13.4.6" + "@next/swc-darwin-arm64" "13.4.9" + "@next/swc-darwin-x64" "13.4.9" + "@next/swc-linux-arm64-gnu" "13.4.9" + "@next/swc-linux-arm64-musl" "13.4.9" + "@next/swc-linux-x64-gnu" "13.4.9" + "@next/swc-linux-x64-musl" "13.4.9" + "@next/swc-win32-arm64-msvc" "13.4.9" + "@next/swc-win32-ia32-msvc" "13.4.9" + "@next/swc-win32-x64-msvc" "13.4.9" nice-try@^1.0.4: version "1.0.5" @@ -8652,6 +8665,15 @@ postcss@^8.2.14, postcss@^8.3.11, postcss@^8.4.19, postcss@^8.4.21, postcss@^8.4 picocolors "^1.0.0" source-map-js "^1.0.2" +postcss@^8.4.23: + version "8.4.25" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.25.tgz#4a133f5e379eda7f61e906c3b1aaa9b81292726f" + integrity sha512-7taJ/8t2av0Z+sQEvNzCkpDynl0tX3uJMCODi6nT3PfASC7dYCWV9aQ+uiCf+KBD4SEFcu+GvJdGdwzQ6OSjCw== + dependencies: + nanoid "^3.3.6" + picocolors "^1.0.0" + source-map-js "^1.0.2" + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" @@ -8970,7 +8992,7 @@ react-is@^18.0.0, react-is@^18.2.0: resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b" integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w== -react-player@^2.11.0: +react-player@^2.11.0, react-player@^2.12.0: version "2.12.0" resolved "https://registry.yarnpkg.com/react-player/-/react-player-2.12.0.tgz#2fc05dbfec234c829292fbca563b544064bd14f0" integrity sha512-rymLRz/2GJJD+Wc01S7S+i9pGMFYnNmQibR2gVE3KmHJCBNN8BhPAlOPTGZtn1uKpJ6p4RPLlzPQ1OLreXd8gw== @@ -9902,10 +9924,10 @@ style-search@^0.1.0: resolved "https://registry.yarnpkg.com/style-search/-/style-search-0.1.0.tgz#7958c793e47e32e07d2b5cafe5c0bf8e12e77902" integrity sha512-Dj1Okke1C3uKKwQcetra4jSuk0DqbzbYtXipzFlFMZtowbF1x7BKJwB9AayVMyFARvU8EDrZdcax4At/452cAg== -styled-components@6.0.0-rc.2: - version "6.0.0-rc.2" - resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-6.0.0-rc.2.tgz#926f60b248d68b7bedb2a07930ba4a8530f97f05" - integrity sha512-Rtgv4GQu2XrMGybwUqI+uoD5OTeldyedAiO2eVWtM3aF4qUoKTrWN/Y4uHtSlX+DVzXpH7W/DXFH+noKKxui0Q== +styled-components@6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-6.0.2.tgz#97e94d33422d7634b5c9915a4f33c628da94c0f4" + integrity sha512-CRWTuYme0W4zVqzXpODByyocgVbBpRoXmaEgPGb67dvweV1igp7Ik4Z5C9e83wZ2l2hPg/XKV7cjuNxhRlC7Mg== dependencies: "@babel/cli" "^7.21.0" "@babel/core" "^7.21.0" @@ -9917,10 +9939,14 @@ styled-components@6.0.0-rc.2: "@babel/preset-react" "^7.18.6" "@babel/preset-typescript" "^7.21.0" "@babel/traverse" "^7.21.2" + "@emotion/is-prop-valid" "^1.2.1" "@emotion/unitless" "^0.8.0" + "@types/stylis" "^4.0.2" css-to-react-native "^3.2.0" + csstype "^3.1.2" + postcss "^8.4.23" shallowequal "^1.1.0" - stylis "^4.2.0" + stylis "^4.3.0" tslib "^2.5.0" styled-components@^5.3.6, styled-components@^5.3.9: @@ -9939,6 +9965,31 @@ styled-components@^5.3.6, styled-components@^5.3.9: shallowequal "^1.1.0" supports-color "^5.5.0" +styled-components@^6.0.2: + version "6.0.3" + resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-6.0.3.tgz#03863133b8340912f52be623e3262ba9eb87ccc0" + integrity sha512-qEyWvDK4CYCyDckNIruRJIcQSvcUR3dVEw/fwxu1v0LFzUMPr2uf5PhXHp17FkGK+S4TkglOS+XIealo1MssQA== + dependencies: + "@babel/cli" "^7.21.0" + "@babel/core" "^7.21.0" + "@babel/helper-module-imports" "^7.18.6" + "@babel/plugin-external-helpers" "^7.18.6" + "@babel/plugin-proposal-class-properties" "^7.18.6" + "@babel/plugin-proposal-object-rest-spread" "^7.20.7" + "@babel/preset-env" "^7.20.2" + "@babel/preset-react" "^7.18.6" + "@babel/preset-typescript" "^7.21.0" + "@babel/traverse" "^7.21.2" + "@emotion/is-prop-valid" "^1.2.1" + "@emotion/unitless" "^0.8.0" + "@types/stylis" "^4.0.2" + css-to-react-native "^3.2.0" + csstype "^3.1.2" + postcss "^8.4.23" + shallowequal "^1.1.0" + stylis "^4.3.0" + tslib "^2.5.0" + styled-jsx@5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-5.1.1.tgz#839a1c3aaacc4e735fed0781b8619ea5d0009d1f" @@ -10044,10 +10095,10 @@ stylelint@^14.5.1: v8-compile-cache "^2.3.0" write-file-atomic "^4.0.2" -stylis@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.2.0.tgz#79daee0208964c8fe695a42fcffcac633a211a51" - integrity sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw== +stylis@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.3.0.tgz#abe305a669fc3d8777e10eefcfc73ad861c5588c" + integrity sha512-E87pIogpwUsUwXw7dNyU4QDjdgVMy52m+XEOPEKUn161cCzWjjhPSQhByfd1CcNvrOLnXQ6OnnZDwnJrz/Z4YQ== supports-color@^5.3.0, supports-color@^5.5.0: version "5.5.0" @@ -10116,6 +10167,11 @@ tabbable@^6.1.2: resolved "https://registry.yarnpkg.com/tabbable/-/tabbable-6.1.2.tgz#b0d3ca81d582d48a80f71b267d1434b1469a3703" integrity sha512-qCN98uP7i9z0fIS4amQ5zbGBOq+OSigYeGvPy7NDk8Y9yncqDZ9pRPgfsc2PJIVM9RrJj7GIfuRgmjoUU9zTHQ== +tabbable@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/tabbable/-/tabbable-6.2.0.tgz#732fb62bc0175cfcec257330be187dcfba1f3b97" + integrity sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew== + table@^6.8.1: version "6.8.1" resolved "https://registry.yarnpkg.com/table/-/table-6.8.1.tgz#ea2b71359fe03b017a5fbc296204471158080bdf" From 1aa40acd426beb6c6106c91679fbe3af79886986 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 10 Jul 2023 11:59:03 -0700 Subject: [PATCH 03/59] [C] add encoding package --- package.json | 1 + yarn.lock | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c4c58d26..2c1d6d9f 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "@rubin-epo/epo-widget-lib": "^0.2.1", "accept-language-parser": "^1.5.0", "classnames": "^2.3.2", + "encoding": "^0.1.13", "focus-trap": "^7.3.1", "focus-visible": "^5.2.0", "graphql": "^16.3.0", diff --git a/yarn.lock b/yarn.lock index 900ffd14..d2b9b459 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4944,6 +4944,13 @@ encodeurl@~1.0.2: resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" integrity sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w== +encoding@^0.1.13: + version "0.1.13" + resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9" + integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A== + dependencies: + iconv-lite "^0.6.2" + end-of-stream@^1.0.0, end-of-stream@^1.1.0, end-of-stream@^1.4.1: version "1.4.4" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" @@ -6456,6 +6463,13 @@ iconv-lite@0.4.24: dependencies: safer-buffer ">= 2.1.2 < 3" +iconv-lite@^0.6.2: + version "0.6.3" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501" + integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw== + dependencies: + safer-buffer ">= 2.1.2 < 3.0.0" + icss-utils@^5.0.0, icss-utils@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-5.1.0.tgz#c6be6858abd013d768e98366ae47e25d5887b1ae" @@ -9384,7 +9398,7 @@ safe-regex-test@^1.0.0: get-intrinsic "^1.1.3" is-regex "^1.1.4" -"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.1.0: +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.1.0: version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== From 692245f70b449a2ea321ec5423642d02d7eeb181 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Mon, 10 Jul 2023 12:09:53 -0700 Subject: [PATCH 04/59] [C] fix typing --- components/layout/WidgetContainer/WidgetContainer.tsx | 3 +-- components/layout/WidgetContainer/styles.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/components/layout/WidgetContainer/WidgetContainer.tsx b/components/layout/WidgetContainer/WidgetContainer.tsx index 64ca15da..52d65103 100644 --- a/components/layout/WidgetContainer/WidgetContainer.tsx +++ b/components/layout/WidgetContainer/WidgetContainer.tsx @@ -1,13 +1,12 @@ import { FunctionComponent, PropsWithChildren } from "react"; import { BaseContentBlockProps } from "@/components/shapes"; -import { SpacingSize } from "@rubin-epo/epo-react-lib/dist/styles/mixins/layout"; import ExpandContract from "@/atomic/ExpandContract"; import * as Styled from "./styles"; interface WidgetContainerProps extends BaseContentBlockProps { caption?: string; bgColor?: "white" | "gray"; - paddingSize?: SpacingSize | "none"; + paddingSize?: "large" | "medium" | "small" | "none"; } const WidgetContainer: FunctionComponent< diff --git a/components/layout/WidgetContainer/styles.ts b/components/layout/WidgetContainer/styles.ts index 69fcab6f..900dce9d 100644 --- a/components/layout/WidgetContainer/styles.ts +++ b/components/layout/WidgetContainer/styles.ts @@ -1,4 +1,3 @@ -import { SpacingSize } from "@rubin-epo/epo-react-lib/dist/styles/mixins/layout"; import styled, { css } from "styled-components"; const padding = { @@ -16,7 +15,7 @@ const backgrounds = { export const WidgetContainer = styled.section<{ $isOpen: boolean; $bgColor: "white" | "gray"; - $paddingSize: SpacingSize | "none"; + $paddingSize: "large" | "medium" | "small" | "none"; }>` ${({ $bgColor, $paddingSize, $isOpen }) => css` --widget-header-padding: calc(var(--PADDING_SMALL, 20px) / 4); From 053c43020db0e92aa5a215008d17c56a898e8973 Mon Sep 17 00:00:00 2001 From: Dana Johnson Date: Thu, 29 Jun 2023 16:44:29 -0700 Subject: [PATCH 05/59] [F] Implement typing and data fragments with graphql-codegen --- .eslintrc.js | 1 + .../[investigation]/[...uriSegments]/page.tsx | 74 +- app/[locale]/layout.tsx | 69 +- app/[locale]/page.tsx | 41 +- codegen.ts | 15 + components/content-blocks/Modal/Modal.tsx | 8 +- components/content-blocks/Text/Text.tsx | 22 +- .../factories/ContentBlockFactory/Blocks.tsx | 0 .../ContentBlockFactory.tsx | 54 +- .../SimpleContentBlockFactory.tsx | 36 +- .../TemplateFactory/TemplateFactory.tsx | 24 + components/factories/TemplateFactory/index.ts | 1 + components/shapes/contentBlock.ts | 2 +- components/templates/HomePage/index.js | 31 - components/templates/HomePage/index.tsx | 41 + components/templates/Page/index.tsx | 43 +- components/templates/index.ts | 3 + contexts/GlobalData.tsx | 22 +- gql/fragment-masking.ts | 85 + gql/gql.ts | 87 + gql/graphql.ts | 5484 +++++++++++++++++ gql/index.ts | 2 + helpers/index.ts | 14 +- hooks/index.ts | 2 - hooks/useGlobalData.ts | 3 +- hooks/useList.ts | 61 - hooks/useListForBlock.ts | 25 - lib/api/datalist.js | 55 - lib/api/entry.js | 21 - lib/api/fragments/content-blocks.js | 17 - lib/api/fragments/homepage.js | 18 - lib/api/fragments/page.js | 20 - lib/api/global.js | 116 - package.json | 8 +- tsconfig.json | 7 +- yarn.lock | 1844 +++++- 36 files changed, 7792 insertions(+), 564 deletions(-) create mode 100644 codegen.ts delete mode 100644 components/factories/ContentBlockFactory/Blocks.tsx create mode 100644 components/factories/TemplateFactory/TemplateFactory.tsx create mode 100644 components/factories/TemplateFactory/index.ts delete mode 100644 components/templates/HomePage/index.js create mode 100644 components/templates/HomePage/index.tsx create mode 100644 components/templates/index.ts create mode 100644 gql/fragment-masking.ts create mode 100644 gql/gql.ts create mode 100644 gql/graphql.ts create mode 100644 gql/index.ts delete mode 100644 hooks/useList.ts delete mode 100644 hooks/useListForBlock.ts delete mode 100644 lib/api/datalist.js delete mode 100644 lib/api/entry.js delete mode 100644 lib/api/fragments/content-blocks.js delete mode 100644 lib/api/fragments/homepage.js delete mode 100644 lib/api/fragments/page.js delete mode 100644 lib/api/global.js diff --git a/.eslintrc.js b/.eslintrc.js index 507b00ef..8065d5cc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -103,6 +103,7 @@ module.exports = { "spaced-comment": 2, "unused-imports/no-unused-imports": 2, "@typescript-eslint/no-var-requires": "warn", + "no-use-before-define": 0, }, plugins: [ "jsx-a11y", diff --git a/app/[locale]/[investigation]/[...uriSegments]/page.tsx b/app/[locale]/[investigation]/[...uriSegments]/page.tsx index adeea964..4baad93f 100644 --- a/app/[locale]/[investigation]/[...uriSegments]/page.tsx +++ b/app/[locale]/[investigation]/[...uriSegments]/page.tsx @@ -1,14 +1,10 @@ import { notFound } from "next/navigation"; -import PageTemplate from "@/templates/Page"; +import { createClient, fetchExchange } from "@urql/core"; +import { graphql } from "@/gql"; +import TemplateFactory from "@/components/factories/TemplateFactory"; import { UriSegmentsProps } from "./layout"; -import { getEntrySectionByUri } from "@/api/entries"; -import { getEntryDataByUri } from "@/api/entry"; import { Metadata } from "next"; -async function getEntryData(uri: string, site: string, previewToken: any) { - return await getEntryDataByUri(uri, site, previewToken); -} - export const revalidate = 60; export async function generateMetadata({ @@ -18,36 +14,66 @@ export async function generateMetadata({ // add _es to property names if site is not English const uri: string = uriSegments.join("/"); - const entryData = await getEntryData(uri, site, null); + const client = createClient({ + url: process.env.NEXT_PUBLIC_API_URL as string, + exchanges: [fetchExchange], + }); + + const data = await client + .query(MetadataQuery, { + site: [site], + uri: [uri], + }) + .toPromise() + .then((result) => { + return result.data; + }); - const { title = null } = entryData || {}; + const title = data?.entry?.title; - return { title, twitter: { title } }; + return title ? { title, twitter: { title } } : {}; } const UriSegments: (props: UriSegmentsProps) => Promise = async ({ params: { locale, uriSegments }, - previewData, + // previewData, }) => { const site = locale === "en" ? "default" : locale; // add _es to property names if site is not English const uri: string = uriSegments.join("/"); - const section = await getEntrySectionByUri(uri, site); - - const entryData = await getEntryData(uri, site, previewData?.previewToken); - - const currentId = entryData?.id || entryData?.entry?.id; - - if (!currentId) { - notFound(); - } - - const sectionMap: { [key: string]: any } = {}; + const client = createClient({ + url: process.env.NEXT_PUBLIC_API_URL as string, + exchanges: [fetchExchange], + }); - const Template = sectionMap[section] || PageTemplate; + const data = await client + .query(Query, { + site: [site], + uri: [uri], + }) + .toPromise() + .then((result) => { + return result.data; + }); - return