Skip to content

Commit f183151

Browse files
authored
459 - fix: stop styled component from forwarding isalternate prop (#485)
1 parent 0af4c3b commit f183151

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

frontend/components/Landing.tsx

+15-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { styled } from "@mui/material/styles";
33
import Image from "next/image";
44
import React, { useState } from "react";
55

6+
import transientOptions from "../utils/transientOptions";
67
import Faq from "./Faq";
78
import Features from "./Features";
89
import Sponsors from "./Sponsors";
@@ -40,14 +41,14 @@ const Landing = () => {
4041
<StyledImage
4142
src="/assets/landing_page/hero_panel.svg"
4243
alt="hero panel"
43-
isalternate
44+
$isalternate
4445
width="1249"
4546
height="1067"
4647
/>
4748
<StyledImage
4849
src={"/assets/landing_page/hero_panel_mobile.svg"}
4950
alt="hero panel"
50-
isalternate={false}
51+
$isalternate={false}
5152
width="562"
5253
height="547"
5354
/>
@@ -69,19 +70,20 @@ const LandingScreenContainer = styled(Stack)(({ theme }) => ({
6970
}));
7071

7172
interface StyledImageProps {
72-
isalternate: boolean;
73+
$isalternate: boolean;
7374
}
7475

75-
const StyledImage = styled(Image)<StyledImageProps>(
76-
({ theme, isalternate }) => ({
77-
height: "100%",
78-
width: "100%",
79-
display: isalternate ? "block" : "none",
80-
[theme.breakpoints.down("md")]: {
81-
display: isalternate ? "none" : "block",
82-
},
83-
})
84-
);
76+
const StyledImage = styled(
77+
Image,
78+
transientOptions
79+
)<StyledImageProps>(({ theme, $isalternate }) => ({
80+
height: "100%",
81+
width: "100%",
82+
display: $isalternate ? "block" : "none",
83+
[theme.breakpoints.down("md")]: {
84+
display: $isalternate ? "none" : "block",
85+
},
86+
}));
8587

8688
const HeroPanelContainer = styled(Stack)(({ theme }) => ({
8789
height: "100%",

frontend/utils/transientOptions.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { CreateStyled } from "@emotion/styled";
2+
3+
// see https://github.com/emotion-js/emotion/issues/2193
4+
const transientOptions: Parameters<CreateStyled>[1] = {
5+
shouldForwardProp: (propName: string) => !propName.startsWith("$"),
6+
};
7+
8+
export default transientOptions;

0 commit comments

Comments
 (0)