Skip to content

Commit 0ae6f41

Browse files
authored
Fixes top margin at <md breakpoint (#2636)
* Top margin at <md breakpoint * Update breakpoint for nav and scroll padding * Set header height values locally * Use px unit for multiline string css * Use constants in page wrapper * Fix import
1 parent ade355f commit 0ae6f41

File tree

6 files changed

+34
-19
lines changed

6 files changed

+34
-19
lines changed

frontends/main/src/app-pages/DashboardPage/DashboardLayout.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
TabList,
2020
Typography,
2121
styled,
22+
HEADER_HEIGHT,
2223
} from "ol-components"
2324
import { TabButtonLink, TabButtonList } from "@mitodl/smoot-design"
2425
import Link from "next/link"
@@ -99,16 +100,16 @@ const DashboardGridItem = styled.div({
99100
},
100101
})
101102

102-
const ProfileSidebar = styled(Card)(({ theme }) => ({
103+
const ProfileSidebar = styled(Card)({
103104
position: "sticky",
104-
top: `${theme.custom.dimensions.headerHeight + PADDING_TOP}px`,
105+
top: `${HEADER_HEIGHT + PADDING_TOP}px`,
105106
display: "flex",
106107
flexDirection: "column",
107108
alignItems: "flex-start",
108109
width: "300px",
109110
boxShadow: "-4px 4px 0px 0px #A31F34",
110111
transform: "translateX(4px)", // keep solid shadow from bleeding into page margins
111-
}))
112+
})
112113

113114
const ProfilePhotoContainer = styled.div(({ theme }) => ({
114115
display: "flex",

frontends/main/src/app/styled.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client"
22

3-
import { styled } from "ol-components"
3+
import { styled, HEADER_HEIGHT, HEADER_HEIGHT_MD } from "ol-components"
44

55
/*
66
* Use in server components gives:
@@ -11,11 +11,11 @@ import { styled } from "ol-components"
1111
export const PageWrapper = styled.div(({ theme }) => ({
1212
display: "flex",
1313
flexDirection: "column",
14-
height: "calc(100vh - 72px)",
15-
marginTop: "72px",
16-
[theme.breakpoints.down("sm")]: {
17-
marginTop: "60px",
18-
height: "calc(100vh - 60px)",
14+
height: `calc(100vh - ${HEADER_HEIGHT}px)`,
15+
marginTop: HEADER_HEIGHT,
16+
[theme.breakpoints.down("md")]: {
17+
marginTop: HEADER_HEIGHT_MD,
18+
height: `calc(100vh - ${HEADER_HEIGHT_MD}px)`,
1919
},
2020
}))
2121

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
import React, { FunctionComponent } from "react"
44
import type { NavData } from "ol-components"
5-
import { styled, AppBar, NavDrawer, Toolbar } from "ol-components"
5+
import {
6+
styled,
7+
AppBar,
8+
NavDrawer,
9+
Toolbar,
10+
HEADER_HEIGHT,
11+
HEADER_HEIGHT_MD,
12+
} from "ol-components"
613
import { ActionButtonLink } from "@mitodl/smoot-design"
714
import {
815
RiSearch2Line,
@@ -50,9 +57,9 @@ const Bar = styled(AppBar)(({ theme }) => ({
5057
".MuiToolbar-root": {
5158
minHeight: "auto",
5259
},
53-
height: theme.custom.dimensions.headerHeight,
60+
height: HEADER_HEIGHT,
5461
[theme.breakpoints.down("md")]: {
55-
height: theme.custom.dimensions.headerHeightSm,
62+
height: HEADER_HEIGHT_MD,
5663
padding: "0",
5764
},
5865
}))

frontends/ol-components/src/components/NavDrawer/NavDrawer.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ import Link from "next/link"
66
import React, { ReactElement } from "react"
77
import { RiCloseLargeLine } from "@remixicon/react"
88
import { ActionButton } from "@mitodl/smoot-design"
9+
import {
10+
HEADER_HEIGHT,
11+
HEADER_HEIGHT_MD,
12+
} from "../ThemeProvider/MITLearnGlobalStyles"
913

1014
const DrawerContent = styled.div(({ theme }) => ({
11-
paddingTop: theme.custom.dimensions.headerHeight,
15+
paddingTop: HEADER_HEIGHT,
1216
width: "366px",
1317
height: "100%",
1418
background: theme.custom.colors.white,
1519
borderRight: `1px solid ${theme.custom.colors.lightGray2}`,
16-
[theme.breakpoints.down("sm")]: {
17-
paddingTop: theme.custom.dimensions.headerHeightSm,
20+
[theme.breakpoints.down("md")]: {
21+
paddingTop: HEADER_HEIGHT_MD,
1822
},
1923
}))
2024

frontends/ol-components/src/components/ThemeProvider/MITLearnGlobalStyles.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
import React from "react"
44
import { css, Global, Theme } from "@emotion/react"
55

6+
export const HEADER_HEIGHT = 72
7+
export const HEADER_HEIGHT_MD = 60
8+
69
const pageCss = (theme: Theme) => css`
710
html {
811
font-family: ${theme.typography.body1.fontFamily};
912
color: ${theme.typography.body1.color};
10-
scroll-padding-top: ${theme.custom.dimensions.headerHeight};
11-
${theme.breakpoints.down("sm")} {
12-
scroll-padding-top: ${theme.custom.dimensions.headerHeightSm};
13+
scroll-padding-top: ${HEADER_HEIGHT}px;
14+
${theme.breakpoints.down("md")} {
15+
scroll-padding-top: ${HEADER_HEIGHT_MD}px;
1316
}
1417
}
1518

frontends/ol-components/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export { Link, linkStyles } from "./components/Link/Link"
167167
export type { LinkProps } from "./components/Link/Link"
168168

169169
export { pxToRem } from "./components/ThemeProvider/typography"
170-
export { MITLearnGlobalStyles } from "./components/ThemeProvider/MITLearnGlobalStyles"
170+
export * from "./components/ThemeProvider/MITLearnGlobalStyles"
171171

172172
export { AppRouterCacheProvider as NextJsAppRouterCacheProvider } from "@mui/material-nextjs/v15-appRouter"
173173

0 commit comments

Comments
 (0)