Skip to content

Commit 2e52186

Browse files
prevent hero layout shift (#2370)
* prevent hero layout shift * simplify button styling * fix a ts error
1 parent 0cb6656 commit 2e52186

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

frontends/main/src/page-components/AiChat/AskTimDrawerButton.tsx

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,29 @@
11
import React from "react"
2-
import { Typography, styled } from "ol-components"
3-
import { ButtonLink } from "@mitodl/smoot-design"
2+
import { Typography, styled, LinkAdapter } from "ol-components"
43
import { RiSparkling2Line } from "@remixicon/react"
54
import AiRecommendationBotDrawer from "./AiRecommendationBotDrawer"
65
import { RECOMMENDER_QUERY_PARAM } from "@/common/urls"
76

8-
const StyledButton = styled(ButtonLink)(({ theme }) => ({
7+
const StyledButton = styled(LinkAdapter)(({ theme }) => ({
98
display: "flex",
109
flexDirection: "row",
1110
gap: "8px",
12-
minWidth: "auto",
1311
padding: "4px 0",
1412
color: theme.custom.colors.darkGray2,
15-
border: "none",
16-
background: "none",
1713
svg: {
1814
fill: theme.custom.colors.lightRed,
1915
width: "20px",
2016
height: "20px",
2117
},
22-
"&&": {
23-
":hover": {
24-
background: "none",
25-
color: theme.custom.colors.red,
26-
p: {
27-
color: theme.custom.colors.red,
28-
},
29-
},
18+
"&:hover": {
19+
color: theme.custom.colors.red,
3020
},
3121
}))
3222

3323
const AskTIMButton = () => {
3424
return (
3525
<>
36-
<StyledButton
37-
shallow
38-
variant="bordered"
39-
edge="rounded"
40-
href={`?${RECOMMENDER_QUERY_PARAM}`}
41-
>
26+
<StyledButton shallow href={`?${RECOMMENDER_QUERY_PARAM}`}>
4227
<RiSparkling2Line />
4328
<Typography variant="body1">
4429
Ask<strong>TIM</strong>

frontends/main/src/page-components/HeroSearch/HeroSearch.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ const ActionStrip = styled.div(({ theme }) => ({
142142
gap: "24px",
143143
marginTop: "16px",
144144
marginBottom: "24px",
145+
/**
146+
* minHeight 28px avoids layout shift as feature flag for AskTim button loads.
147+
*/
148+
minHeight: "28px",
145149
[theme.breakpoints.down("sm")]: {
146150
marginTop: "0",
147151
},

frontends/ol-components/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ export type {
149149
SelectFieldProps,
150150
} from "./components/SelectField/SelectField"
151151

152+
export { LinkAdapter } from "./components/LinkAdapter/LinkAdapter"
153+
export type { LinkAdapterProps } from "./components/LinkAdapter/LinkAdapter"
154+
152155
export { Link, linkStyles } from "./components/Link/Link"
153156
export type { LinkProps } from "./components/Link/Link"
154157

0 commit comments

Comments
 (0)