From 249ba027658fca8c1059fb646c4f115b22272d33 Mon Sep 17 00:00:00 2001
From: Marcel Gerber
Date: Tue, 6 Aug 2024 14:49:27 +0100
Subject: [PATCH 01/11] enhance(noscript): consistently apply css classes if JS
disabled
---
site/Head.tsx | 32 ++++++++++++++++++++++++++++++++
site/owid.entry.ts | 2 +-
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/site/Head.tsx b/site/Head.tsx
index 5de698edf0d..ac6f8ae2fcb 100644
--- a/site/Head.tsx
+++ b/site/Head.tsx
@@ -99,6 +99,38 @@ export const Head = (props: {
{stylesheets}
{props.children}
+
+ {/* */}
)
diff --git a/site/owid.entry.ts b/site/owid.entry.ts
index 06bbb7c8fea..8b84df48d06 100644
--- a/site/owid.entry.ts
+++ b/site/owid.entry.ts
@@ -86,7 +86,7 @@ if (BUGSNAG_API_KEY) {
const analytics = new SiteAnalytics(ENV)
-document.querySelector("html")?.classList.add("js")
+document.documentElement?.classList.add("js-loaded")
try {
// Cookie access can be restricted by iframe sandboxing, in which case the below code will throw an error
From 159d5ebc75ed04299cf5dccf0f3c38df80b8b6d5 Mon Sep 17 00:00:00 2001
From: Marcel Gerber
Date: Tue, 6 Aug 2024 14:59:01 +0100
Subject: [PATCH 02/11] enhance(noscript): render ``
by default, immediately getting updated on load
---
site/BlogIndexPage.tsx | 5 +++--
site/ChartsIndexPage.tsx | 5 +++--
site/CountriesIndexPage.tsx | 5 +++--
site/CountryProfilePage.tsx | 5 +++--
site/DataInsightsIndexPage.tsx | 5 +++--
site/DataPageV2.tsx | 5 +++--
site/DonatePage.tsx | 5 +++--
site/ExplorerPage.tsx | 5 +++--
site/FeedbackPage.tsx | 5 +++--
site/GrapherPage.tsx | 5 +++--
site/Html.tsx | 11 +++++++++++
site/LongFormPage.tsx | 5 +++--
site/NotFoundPage.tsx | 5 +++--
site/ThankYouPage.tsx | 5 +++--
site/collections/DynamicCollectionPage.tsx | 5 +++--
site/collections/StaticCollectionPage.tsx | 5 +++--
site/gdocs/OwidGdocPage.tsx | 5 +++--
site/multiembedder/MultiEmbedderTestPage.tsx | 5 +++--
site/search/SearchPage.tsx | 5 +++--
19 files changed, 65 insertions(+), 36 deletions(-)
create mode 100644 site/Html.tsx
diff --git a/site/BlogIndexPage.tsx b/site/BlogIndexPage.tsx
index 36819fa550a..72ec99d9d8a 100644
--- a/site/BlogIndexPage.tsx
+++ b/site/BlogIndexPage.tsx
@@ -4,6 +4,7 @@ import { SiteHeader } from "./SiteHeader.js"
import { SiteFooter } from "./SiteFooter.js"
import { range, IndexPost } from "@ourworldindata/utils"
import PostCard from "./PostCard/PostCard.js"
+import { Html } from "./Html.js"
export const BlogIndexPage = (props: {
posts: IndexPost[]
@@ -16,7 +17,7 @@ export const BlogIndexPage = (props: {
const pageTitle = "Latest"
return (
-
+
-
+
)
}
diff --git a/site/ChartsIndexPage.tsx b/site/ChartsIndexPage.tsx
index 8832710058d..bbfc8a8d082 100644
--- a/site/ChartsIndexPage.tsx
+++ b/site/ChartsIndexPage.tsx
@@ -9,6 +9,7 @@ import { slugify } from "@ourworldindata/utils"
import { ExplorerProgram } from "../explorer/ExplorerProgram.js"
import { BAKED_BASE_URL } from "../settings/serverSettings.js"
import { EXPLORERS_ROUTE_FOLDER } from "../explorer/ExplorerConstants.js"
+import { Html } from "./Html.js"
export interface ChartIndexItem {
id: number
@@ -81,7 +82,7 @@ export const ChartsIndexPage = (props: {
)
return (
-
+
-
+
)
}
diff --git a/site/CountriesIndexPage.tsx b/site/CountriesIndexPage.tsx
index 7be14987236..15dc70da374 100644
--- a/site/CountriesIndexPage.tsx
+++ b/site/CountriesIndexPage.tsx
@@ -3,6 +3,7 @@ import { Head } from "./Head.js"
import { SiteHeader } from "./SiteHeader.js"
import { SiteFooter } from "./SiteFooter.js"
import { Country, sortBy } from "@ourworldindata/utils"
+import { Html } from "./Html.js"
export const CountriesIndexPage = (props: {
countries: Country[]
@@ -13,7 +14,7 @@ export const CountriesIndexPage = (props: {
const sortedCountries = sortBy(countries, (country) => country.name)
return (
-
+
{/* */}
-
+
)
}
diff --git a/site/CountryProfilePage.tsx b/site/CountryProfilePage.tsx
index ccd6b6b7877..9cf15071f07 100644
--- a/site/CountryProfilePage.tsx
+++ b/site/CountryProfilePage.tsx
@@ -4,6 +4,7 @@ import { SiteHeader } from "./SiteHeader.js"
import { SiteFooter } from "./SiteFooter.js"
import urljoin from "url-join"
import { Country } from "@ourworldindata/utils"
+import { Html } from "./Html.js"
export interface CountryProfileIndicator {
name: string
@@ -35,7 +36,7 @@ export const CountryProfilePage = (props: CountryProfilePageProps) => {
const script = `window.runCountryProfilePage()`
return (
-
+
{
dangerouslySetInnerHTML={{ __html: script }}
/>
-
+
)
}
diff --git a/site/DataInsightsIndexPage.tsx b/site/DataInsightsIndexPage.tsx
index 4f59e744b1c..bc5e3c10ad9 100644
--- a/site/DataInsightsIndexPage.tsx
+++ b/site/DataInsightsIndexPage.tsx
@@ -13,6 +13,7 @@ import {
} from "./DataInsightsIndexPageContent.js"
import { DATA_INSIGHT_ATOM_FEED_PROPS } from "./gdocs/utils.js"
import { DebugProvider } from "./gdocs/DebugContext.js"
+import { Html } from "./Html.js"
export interface DataInsightsIndexPageProps {
dataInsights: OwidGdocDataInsightInterface[]
@@ -25,7 +26,7 @@ export interface DataInsightsIndexPageProps {
export const DataInsightsIndexPage = (props: DataInsightsIndexPageProps) => {
const { baseUrl, isPreviewing } = props
return (
-
+
{
}}
/>
-
+
)
}
diff --git a/site/DataPageV2.tsx b/site/DataPageV2.tsx
index 83877927fa5..2e032155f5d 100644
--- a/site/DataPageV2.tsx
+++ b/site/DataPageV2.tsx
@@ -33,6 +33,7 @@ import { SiteFooter } from "./SiteFooter.js"
import { SiteHeader } from "./SiteHeader.js"
import { IFrameDetector } from "./IframeDetector.js"
import { DebugProvider } from "./gdocs/DebugContext.js"
+import { Html } from "./Html.js"
export const DataPageV2 = (props: {
grapher: GrapherInterface | undefined
@@ -109,7 +110,7 @@ export const DataPageV2 = (props: {
)
return (
-
+
-
+
)
}
diff --git a/site/DonatePage.tsx b/site/DonatePage.tsx
index de13e9dd519..9874ad5571a 100644
--- a/site/DonatePage.tsx
+++ b/site/DonatePage.tsx
@@ -6,13 +6,14 @@ import { IMAGES_DIRECTORY, OwidGdocPostInterface } from "@ourworldindata/utils"
import { ArticleBlocks } from "./gdocs/components/ArticleBlocks.js"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js"
import { faArrowDown } from "@fortawesome/free-solid-svg-icons"
+import { Html } from "./Html.js"
export const DonatePage = (props: {
baseUrl: string
faqsGdoc: OwidGdocPostInterface
recaptchaKey: string
}) => (
-
+
-
+
)
diff --git a/site/ExplorerPage.tsx b/site/ExplorerPage.tsx
index f3c2a86fcbc..1d9f67a1672 100644
--- a/site/ExplorerPage.tsx
+++ b/site/ExplorerPage.tsx
@@ -22,6 +22,7 @@ import { IFrameDetector } from "../site/IframeDetector.js"
import { SiteFooter } from "../site/SiteFooter.js"
import { SiteHeader } from "../site/SiteHeader.js"
import { SiteSubnavigation } from "../site/SiteSubnavigation.js"
+import { Html } from "./Html.js"
interface ExplorerPageSettings {
program: ExplorerProgram
@@ -97,7 +98,7 @@ const urlMigrationSpec = ${
window.Explorer.renderSingleExplorerOnExplorerPage(explorerProgram, grapherConfigs, partialGrapherConfigs, urlMigrationSpec);`
return (
-
+
-
+