Skip to content

Commit

Permalink
Merge pull request #2165 from anth-volk/feat/uk-autumn-budget-banner
Browse files Browse the repository at this point in the history
UK autumn budget banner
  • Loading branch information
anth-volk authored Nov 4, 2024
2 parents c2334ea + 67e57d3 commit 9c42c07
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 8 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions src/pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import HomeTransparency from "./home/HomeTransparency";
import Footer from "../layout/Footer";
import HomeQuoteCarousel from "./home/HomeQuoteCarousel";
import { Helmet } from "react-helmet";
import HomeElectionBanner from "./home/HomeElectionBanner.jsx";
import UK2024AutumnBudgetBanner from "./home/banners/UK2024AutumnBudgetBanner";
import US2024ElectionBanner from "./home/banners/US2024ElectionBanner.jsx";
import useCountryId from "../hooks/useCountryId";

export default function Home() {
Expand All @@ -21,7 +22,9 @@ export default function Home() {
</Helmet>
<div>
<Header />
{countryId === "us" && <HomeElectionBanner />}
{countryId === "uk" && <UK2024AutumnBudgetBanner />}

{countryId === "us" && <US2024ElectionBanner />}
<HomeLanding />
<HomeUsedBy />
<HomeBlogPreview />
Expand Down
199 changes: 199 additions & 0 deletions src/pages/home/banners/UK2024AutumnBudgetBanner.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import LinkButton from "../../../controls/LinkButton";
import style from "../../../style";
import reeves from "../../../images/home/chancellor_reeves_2024_autumn_budget.jpg";
import useDisplayCategory from "../../../hooks/useDisplayCategory";
import { useWindowWidth } from "../../../hooks/useWindow";

const articles = [
{
title: "Employer National Insurance Contributions",
shortTitle: "Employer NICs",
link: "/uk/research/autumn-budget-24-employer-ni",
},
{
title: "Private School Value-Added Tax",
shortTitle: "Private School VAT",
link: "/uk/research/vat-school-comparison",
},
{
title: "Fuel Duty",
shortTitle: "Fuel Duty",
link: "/uk/research/autumn-budget-24-fuel-duty",
},
];

export default function UK2024AutumnBudgetBanner() {
const dC = useDisplayCategory();
const windowWidth = useWindowWidth();

const title =
"Read PolicyEngine's detailed costings of the 2024 Autumn Budget";
const subtitle =
"View our in-depth analysis of each major provision from Number 11";
const ariaLabel =
"Chancellor of the Exchequer Rachel Reeves holding a budget box in front of Number 11 Downing Street" +
"Courtesy of HM Treasury, https://www.flickr.com/photos/hmtreasury/54104908129/";

const shouldUseShortTitle = windowWidth < 1150;

const articlesJSX = articles.map((article, index) => {
return (
<LinkButton
type="primary"
text={shouldUseShortTitle ? article.shortTitle : article.title}
link={article.link}
key={String(index).concat(article.text)}
style={{
height: "65px",
width: "100%",
}}
/>
);
});

if (windowWidth < 800) {
return (
<div
style={{
width: "100%",
minHeight: "fit-content",
display: "flex",
flexDirection: "column",
justifyContent: "flex-start",
alignItems: "center",
backgroundColor: style.colors.LIGHT_GRAY,
paddingLeft: "40px",
paddingRight: "40px",
paddingTop: "24px",
paddingBottom: "24px",
}}
>
<div
style={{
position: "relative",
width: "100%",
display: "flex",
backgroundImage: `url(${reeves})`,
backgroundColor: style.colors.BLUE_LIGHT,
backgroundSize: "cover",
minHeight: "fit-content",
marginBottom: "24px",
}}
role="img"
aria-label={ariaLabel}
>
<div
style={{
minHeight: "fit-content",
width: "100%",
backgroundColor: "rgba(44, 100, 150, 0.88)",
display: "flex",
flexDirection: "column",
padding: "24px",
justifyContent: "flex-end",
alignItems: "flex-start",
margin: "24px",
}}
>
<h3 style={{ color: style.colors.WHITE }}>{title}</h3>
<p style={{ color: style.colors.WHITE }}>{subtitle}</p>
</div>
</div>
<div
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
gap: "16px",
height: "100%",
width: "100%",
}}
>
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(3, 1fr)",
gap: "16px",
width: "100%",
}}
>
{articlesJSX}
</div>
</div>
</div>
);
}

return (
<div
style={{
width: "100%",
height: "max-content",
minHeight: "50vh",
display: "flex",
justifyContent: "center",
gap: "24px",
backgroundColor: style.colors.LIGHT_GRAY,
paddingLeft: dC === "desktop" ? "calc((100% - 1200px) / 2)" : "100px",
paddingRight: dC === "desktop" ? "calc((100% - 1200px) / 2)" : "100px",
paddingTop: "24px",
paddingBottom: "24px",
alignItems: "stretch",
}}
>
{/* Image and overlay container */}
<div
style={{
position: "relative",
backgroundImage: `url(${reeves})`,
// Fallback
backgroundColor: style.colors.BLUE_LIGHT,
backgroundSize: "cover",
backgroundPosition: "right top",
}}
role="img"
aria-label={ariaLabel}
>
<div
style={{
// Margin doesn't count as part of percentage-based width.
// Instead of struggling to find the right solution, just set to 90%
// instead of 100% since this behavior only desired at select
// visual breakpoint (like 800px width)
width: "min(620px, 90%)",
backgroundColor: "rgba(44, 100, 150, 0.88)",
display: "flex",
flexDirection: "column",
padding: "36px",
gap: "16px",
margin: "24px",
}}
>
<h3 style={{ color: style.colors.WHITE }}>{title}</h3>
<p style={{ color: style.colors.WHITE }}>{subtitle}</p>
</div>
</div>
<div
style={{
height: "auto",
width: "1px",
flexShrink: 0,
backgroundColor: style.colors.GRAY,
}}
/>
{/* Buttons section */}
<div
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
gap: "16px",
}}
>
{articlesJSX}
</div>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import LinkButton from "../../controls/LinkButton";
import style from "../../style";
import usFlags from "../../images/home/american-flags-flagpoles-blue-sky.jpg";
import useDisplayCategory from "../../hooks/useDisplayCategory";
import { useWindowWidth } from "../../hooks/useWindow";
import LinkButton from "../../../controls/LinkButton";
import style from "../../../style";
import usFlags from "../../../images/home/american-flags-flagpoles-blue-sky.jpg";
import useDisplayCategory from "../../../hooks/useDisplayCategory";
import { useWindowWidth } from "../../../hooks/useWindow";

const primaryArticles = [
{
Expand Down Expand Up @@ -55,7 +55,7 @@ const secondaryArticles = [
},
];

export default function HomeElectionBanner() {
export default function US2024ElectionBanner() {
const dC = useDisplayCategory();
const windowWidth = useWindowWidth();

Expand Down

0 comments on commit 9c42c07

Please sign in to comment.