From 4c728b0609b4058d1da997141ad9f775593c37ab Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Tue, 2 Nov 2021 18:00:44 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Affichage=20imm=C3=A9diat=20de?= =?UTF-8?q?=20la=20couleur=20personnalis=C3=A9e=20dans=20les=20int=C3=A9gr?= =?UTF-8?q?ations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mon-entreprise/index.html | 72 ++++++++++++++----- mon-entreprise/source/Provider.tsx | 12 ++-- .../source/components/utils/colors.tsx | 1 + .../source/iframe-integration-script.js | 3 +- mon-entreprise/webpack.prod.js | 14 ++-- yarn.lock | 5 ++ 6 files changed, 72 insertions(+), 35 deletions(-) diff --git a/mon-entreprise/index.html b/mon-entreprise/index.html index 4606eccde..198f77a9f 100644 --- a/mon-entreprise/index.html +++ b/mon-entreprise/index.html @@ -66,9 +66,7 @@ - - <%= htmlWebpackPlugin.options.title %> - + <%= htmlWebpackPlugin.options.title %> <% for (var css in htmlWebpackPlugin.files.css) { %> @@ -193,7 +191,12 @@ Un service de l'État français
@@ -212,36 +215,70 @@ // Hack to force styled components to render styles during prerender if (window.__PRERENDER_INJECTED) { window.onload = () => { - var el = document.createElement('style'); + var el = document.createElement('style') document.head.appendChild(el) var styles = document.querySelectorAll('style[data-styled]') for (style of styles.values()) { - for (rule of style.sheet.rules) { - el.appendChild(document.createTextNode(rule.cssText)) - } + for (rule of style.sheet.rules) { + el.appendChild(document.createTextNode(rule.cssText)) + } } + } } - };
+ + - <% for (var chunk in htmlWebpackPlugin.files.chunks) { %> - <% } %> - - <% for (var chunk in htmlWebpackPlugin.files.chunks) { %> + <% } %> <% for (var chunk in htmlWebpackPlugin.files.chunks) { %> <% } %> diff --git a/mon-entreprise/source/Provider.tsx b/mon-entreprise/source/Provider.tsx index 02d2dcd81..d0ca79574 100644 --- a/mon-entreprise/source/Provider.tsx +++ b/mon-entreprise/source/Provider.tsx @@ -116,10 +116,12 @@ export default function Provider({ display: none !important; }` document.body.appendChild(css) - const iframeCouleur = - new URLSearchParams(document?.location.search.substring(1)).get( - 'couleur' - ) ?? undefined + // Note that the iframeColor is first set in the index.html file, but without + // the full palette generation that happen here. This is to prevent a UI + // flash, cf. #1786. + const iframeCouleur = new URLSearchParams( + document.location.search.substring(1) + ).get('couleur') return ( ({ +const prerenderConfig = { staticDir: path.resolve('dist'), renderer: new Renderer({ renderAfterTime: 5000, @@ -26,10 +26,6 @@ const prerenderConfig = () => ({ }), postProcess: (context) => { const $ = cheerio.load(context.html) - // force https on twitter emoji cdn - $('img[src^="http://twemoji.maxcdn.com"]').each((i, el) => { - $(el).attr('src', (_, path) => path.replace('http://', 'https://')) - }) // Remove loader $('#outdated-browser').after(` `) - // Remove piwik script - $('script[src$="stats.data.gouv.fr/piwik.js"]').remove() context.html = $.html() return context }, -}) +} module.exports = { ...common, @@ -86,14 +80,14 @@ module.exports = { }), process.env.ANALYZE_BUNDLE !== '1' && new PrerenderSPAPlugin({ - ...prerenderConfig(), + ...prerenderConfig, outputDir: path.resolve('dist', 'prerender', 'infrance'), routes: ['/', '/calculators/salary', '/iframes/simulateur-embauche'], indexPath: path.resolve('dist', 'infrance.html'), }), process.env.ANALYZE_BUNDLE !== '1' && new PrerenderSPAPlugin({ - ...prerenderConfig(), + ...prerenderConfig, outputDir: path.resolve('dist', 'prerender', 'mon-entreprise'), routes: [ '/', diff --git a/yarn.lock b/yarn.lock index 42a4ad46f..b237c6497 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5917,6 +5917,11 @@ classnames@^2.2.5: resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce" integrity sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q== +classnames@^2.2.6: + version "2.3.1" + resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.3.1.tgz#dfcfa3891e306ec1dad105d0e88f4417b8535e8e" + integrity sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA== + clean-css@4.2.x: version "4.2.3" resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.3.tgz#507b5de7d97b48ee53d84adb0160ff6216380f78"