From 56e33f465973ba5c00485ef33518ab1f0fa9285b Mon Sep 17 00:00:00 2001 From: asibs Date: Sun, 3 Mar 2024 11:13:55 +0000 Subject: [PATCH] Headers use Rubik font by default (#43) * Export css var for Rubik, make available in top-level layout, use it in Global CSS to set font for all headers. Remove className rubik from inline header HTML * Prettier fix --- app/constituencies/[slug]/page.tsx | 13 +++---------- app/donate/page.tsx | 3 +-- app/globals.scss | 3 ++- app/layout.tsx | 13 +++++++------ app/page.tsx | 5 ++--- components/Page.tsx | 3 +-- .../constituency_lookup/ConstituencyLookup.tsx | 2 +- components/footer/Footer.tsx | 5 +---- components/info_box/ImpliedChart.tsx | 5 +---- components/info_box/LocalTeamBox.tsx | 2 +- components/info_box/MRPChart.tsx | 5 +---- components/info_box/PlanToVoteBox.tsx | 3 +-- components/info_box/TacticalReasoningBox.tsx | 3 +-- components/page_content/ToggleText.tsx | 4 +--- components/sections/MovementSection.tsx | 17 +++++------------ utils/Fonts.ts | 13 ++++++++++--- 16 files changed, 39 insertions(+), 60 deletions(-) diff --git a/app/constituencies/[slug]/page.tsx b/app/constituencies/[slug]/page.tsx index c2392de..aa1977b 100644 --- a/app/constituencies/[slug]/page.tsx +++ b/app/constituencies/[slug]/page.tsx @@ -4,7 +4,6 @@ import ImpliedChart from "@/components/info_box/ImpliedChart"; import MRPChart from "@/components/info_box/MRPChart"; import PlanToVoteBox from "@/components/info_box/PlanToVoteBox"; import TacticalReasoningBox from "@/components/info_box/TacticalReasoningBox"; -import { rubik } from "@/utils/Fonts"; import { partyCssClassFromSlug, partyNameFromSlug } from "@/utils/Party"; import { readFileSync } from "fs"; import { unstable_cache } from "next/cache"; @@ -67,9 +66,7 @@ export default async function ConstituencyPage({ <>
-

- {constituencyData.constituencyIdentifiers.name} -

+

{constituencyData.constituencyIdentifiers.name}

Bookmark this page and check back before the election for updated info. @@ -82,17 +79,13 @@ export default async function ConstituencyPage({ -

- The tactical vote is -

+

The tactical vote is

diff --git a/app/donate/page.tsx b/app/donate/page.tsx index 95f5497..88cdc1a 100644 --- a/app/donate/page.tsx +++ b/app/donate/page.tsx @@ -5,7 +5,6 @@ import { useEffect } from "react"; import { useRouter } from "next/navigation"; import { Col, Container, Row } from "react-bootstrap"; import Header from "@/components/Header"; -import { rubik } from "@/utils/Fonts"; export default function Donate() { const url = "https://www.crowdfunder.co.uk/p/stopthetories"; @@ -20,7 +19,7 @@ export default function Donate() { <>
-

Donate

+

Donate

diff --git a/app/globals.scss b/app/globals.scss index e054a49..bf86123 100644 --- a/app/globals.scss +++ b/app/globals.scss @@ -138,9 +138,10 @@ h3, h4, h5, h6 { - line-height: 1; + font-family: var(--font-rubik); font-weight: bold; text-transform: uppercase; + line-height: 1; } /* FORM INPUTS */ diff --git a/app/layout.tsx b/app/layout.tsx index faaf8f4..68637ee 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,6 +1,6 @@ +import { rubik } from "@/utils/Fonts"; import "./globals.scss"; import type { Metadata } from "next"; -import { Inter } from "next/font/google"; import { storyblokInit, apiPlugin } from "@storyblok/react/rsc"; import StoryblokBridgeLoader from "@storyblok/react/bridge-loader"; import StoryblokProvider from "@/storyblok/components/StoryblokProvider"; @@ -11,9 +11,6 @@ import { ComponentsMap } from "@/storyblok/components/ComponentsMap"; // This avoids issues with the Storyblok js client, which has it's own built-in caching, and Next.js caching interferes with this... export const revalidate = 0; -// TODO: Decide whether we want Inter at all or just use default fonts? -const inter = Inter({ subsets: ["latin"] }); - storyblokInit({ accessToken: process.env.STORYBLOK_API_TOKEN, use: [apiPlugin], @@ -35,7 +32,11 @@ export default function RootLayout({ console.debug("layout.tsx: Enabling live-editing"); return ( - + {/* + Adding rubik.variable here makes the --font-rubik CSS var available + (used in globals.scss to style headers, etc) + */} + {/* */} @@ -48,7 +49,7 @@ export default function RootLayout({ } else { console.debug("layout.tsx: Disabling live-editing"); return ( - + {/* */} diff --git a/app/page.tsx b/app/page.tsx index 9ba10d2..bfd5a57 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,7 +1,6 @@ import Header from "@/components/Header"; import ConstituencyLookup from "@/components/constituency_lookup/ConstituencyLookup"; import MovementSection from "@/components/sections/MovementSection"; -import { rubik } from "@/utils/Fonts"; import { Col, Container, Row } from "react-bootstrap"; export default async function Index() { @@ -11,12 +10,12 @@ export default async function Index() { -

+

Your vote IS
your power

-

+

Join the movement that sticks together using it's votes collectively for change.

diff --git a/components/Page.tsx b/components/Page.tsx index 1bd4e53..2f5c32b 100644 --- a/components/Page.tsx +++ b/components/Page.tsx @@ -1,7 +1,6 @@ import { storyblokEditable, StoryblokComponent } from "@storyblok/react/rsc"; import Header from "./Header"; import { PageStoryblok } from "@/storyblok/types/storyblok-types"; -import { rubik } from "@/utils/Fonts"; import { Container } from "react-bootstrap"; const Page = ({ blok }: { blok: PageStoryblok }) => { @@ -9,7 +8,7 @@ const Page = ({ blok }: { blok: PageStoryblok }) => { <>
-

{blok.page_title}

+

{blok.page_title}

diff --git a/components/constituency_lookup/ConstituencyLookup.tsx b/components/constituency_lookup/ConstituencyLookup.tsx index e636e97..f33871c 100644 --- a/components/constituency_lookup/ConstituencyLookup.tsx +++ b/components/constituency_lookup/ConstituencyLookup.tsx @@ -268,7 +268,7 @@ const PostcodeLookup = () => { style={{ fontSize: "18px" }} >
-

Vote the Tories out

+

Vote the Tories out

Vote tactically at the General Election

diff --git a/components/footer/Footer.tsx b/components/footer/Footer.tsx index 88425bb..585f6a2 100644 --- a/components/footer/Footer.tsx +++ b/components/footer/Footer.tsx @@ -15,17 +15,14 @@ import { FaDiscord, FaFileArrowDown, FaMagnifyingGlass, - FaMastodon, FaPuzzlePiece, FaSquareFacebook, FaSquareInstagram, FaSquareThreads, FaSquareTwitter, FaSquareWhatsapp, - FaTelegram, } from "react-icons/fa6"; -import { MdGroups2 } from "react-icons/md"; -import { Button, ButtonGroup } from "react-bootstrap"; +import { ButtonGroup } from "react-bootstrap"; import { rubik } from "@/utils/Fonts"; const Footer = ({ blok }: { blok: FooterStoryblok }) => ( diff --git a/components/info_box/ImpliedChart.tsx b/components/info_box/ImpliedChart.tsx index 0546e7d..19bbc29 100644 --- a/components/info_box/ImpliedChart.tsx +++ b/components/info_box/ImpliedChart.tsx @@ -1,5 +1,4 @@ import InfoBox from "./InfoBox"; -import { rubik } from "@/utils/Fonts"; import { svgChart } from "@/utils/Echarts"; const ImpliedChart = ({ @@ -15,9 +14,7 @@ const ImpliedChart = ({ return ( <> -

- 2019 Election Results (Implied) -

+

2019 Election Results (Implied)

The 2019 implied results from your constituency:

{ return ( <> -

Your Constituency Team

+

Your Constituency Team

People in your local Movement Forward community are coming together to use their voting power. diff --git a/components/info_box/MRPChart.tsx b/components/info_box/MRPChart.tsx index b14c62c..c5996d3 100644 --- a/components/info_box/MRPChart.tsx +++ b/components/info_box/MRPChart.tsx @@ -1,5 +1,4 @@ import InfoBox from "./InfoBox"; -import { rubik } from "@/utils/Fonts"; import { svgChart } from "@/utils/Echarts"; const MRPChart = ({ @@ -12,9 +11,7 @@ const MRPChart = ({ return ( <> -

- Constituency Regression Polls -

+

Constituency Regression Polls

Average of last 6 months MRP models:

{ return ( <> -

Your Plan

+

Your Plan

<> -

Why?

+

Why?

{/* Always show previous general election winner */}

diff --git a/components/page_content/ToggleText.tsx b/components/page_content/ToggleText.tsx index 4e45ae6..b46a602 100644 --- a/components/page_content/ToggleText.tsx +++ b/components/page_content/ToggleText.tsx @@ -8,8 +8,6 @@ import { useState } from "react"; import { Col, Collapse, Container, Row } from "react-bootstrap"; import { FaCircleChevronRight } from "react-icons/fa6"; -import { rubik } from "@/utils/Fonts"; - const ToggleText = ({ blok }: { blok: ToggleTextStoryblok }) => { const [visible, setVisible] = useState(blok.text_shown_initially); @@ -37,7 +35,7 @@ const ToggleText = ({ blok }: { blok: ToggleTextStoryblok }) => { aria-expanded={visible} style={{ cursor: "pointer" }} > -

{blok.title}

+

{blok.title}

diff --git a/components/sections/MovementSection.tsx b/components/sections/MovementSection.tsx index a281bba..c6bec19 100644 --- a/components/sections/MovementSection.tsx +++ b/components/sections/MovementSection.tsx @@ -1,6 +1,5 @@ import Image from "next/image"; -import { rubik } from "@/utils/Fonts"; import { Col, Container, Row } from "react-bootstrap"; import asifKapadia from "@/assets/supporter_portraits/asif-kapadia-540.webp"; @@ -39,7 +38,7 @@ const MovementSection = () => { {/* PEOPLE */} -

+

Join A Movement building voter power, beyond this election.

@@ -74,10 +73,8 @@ const MovementSection = () => { -

We show up

-

- To get the tories out -

+

We show up

+

To get the tories out

In many places around the country, if we vote together for the most likely candidate to beat the Tory, out votes demolish them @@ -85,12 +82,8 @@ const MovementSection = () => {

-

- We stick together -

-

- To influence the next government -

+

We stick together

+

To influence the next government

A bigger influence on the next government than the media that currently shape the narrative. We stick together offering our diff --git a/utils/Fonts.ts b/utils/Fonts.ts index b493ef1..87e38f3 100644 --- a/utils/Fonts.ts +++ b/utils/Fonts.ts @@ -1,5 +1,12 @@ -import { Rubik } from "next/font/google"; +import { Rubik, Inter } from "next/font/google"; -const rubik = Rubik({ subsets: ["latin"], weight: "variable" }); +const rubik = Rubik({ + subsets: ["latin"], + weight: "variable", + variable: "--font-rubik", +}); -export { rubik }; +// TODO: Decide whether we want Inter at all or just use default fonts? +const inter = Inter({ subsets: ["latin"], variable: "--font-inter" }); + +export { rubik, inter };