|
1 |
| -import { makeStyles } from "@mui/styles"; |
2 |
| -import { FC, PropsWithChildren } from "react"; |
3 |
| -import { combineClasses } from "utils/combineClasses"; |
| 1 | +import { type CSSObject, useTheme } from "@emotion/react"; |
| 2 | +import { type FC, type PropsWithChildren } from "react"; |
4 | 3 |
|
5 | 4 | export const FullWidthPageHeader: FC<
|
6 | 5 | PropsWithChildren & { sticky?: boolean }
|
7 | 6 | > = ({ children, sticky = true }) => {
|
8 |
| - const styles = useStyles(); |
9 |
| - |
| 7 | + const theme = useTheme(); |
10 | 8 | return (
|
11 | 9 | <header
|
12 |
| - className={combineClasses([styles.header, sticky ? styles.sticky : ""])} |
13 | 10 | data-testid="header"
|
| 11 | + css={[ |
| 12 | + { |
| 13 | + ...(theme.typography.body2 as CSSObject), |
| 14 | + padding: theme.spacing(3), |
| 15 | + background: theme.palette.background.paper, |
| 16 | + borderBottom: `1px solid ${theme.palette.divider}`, |
| 17 | + display: "flex", |
| 18 | + alignItems: "center", |
| 19 | + gap: theme.spacing(6), |
| 20 | + |
| 21 | + zIndex: 10, |
| 22 | + flexWrap: "wrap", |
| 23 | + |
| 24 | + [theme.breakpoints.down("lg")]: { |
| 25 | + position: "unset", |
| 26 | + alignItems: "flex-start", |
| 27 | + }, |
| 28 | + [theme.breakpoints.down("md")]: { |
| 29 | + flexDirection: "column", |
| 30 | + }, |
| 31 | + }, |
| 32 | + sticky && { |
| 33 | + position: "sticky", |
| 34 | + top: 0, |
| 35 | + }, |
| 36 | + ]} |
14 | 37 | >
|
15 | 38 | {children}
|
16 | 39 | </header>
|
17 | 40 | );
|
18 | 41 | };
|
19 | 42 |
|
20 | 43 | export const PageHeaderActions: FC<PropsWithChildren> = ({ children }) => {
|
21 |
| - const styles = useStyles(); |
22 |
| - return <div className={styles.actions}>{children}</div>; |
| 44 | + const theme = useTheme(); |
| 45 | + return ( |
| 46 | + <div |
| 47 | + css={{ |
| 48 | + marginLeft: "auto", |
| 49 | + [theme.breakpoints.down("md")]: { |
| 50 | + marginLeft: "unset", |
| 51 | + }, |
| 52 | + }} |
| 53 | + > |
| 54 | + {children} |
| 55 | + </div> |
| 56 | + ); |
23 | 57 | };
|
24 | 58 |
|
25 | 59 | export const PageHeaderTitle: FC<PropsWithChildren> = ({ children }) => {
|
26 |
| - const styles = useStyles(); |
27 |
| - return <h1 className={styles.title}>{children}</h1>; |
| 60 | + return ( |
| 61 | + <h1 |
| 62 | + css={{ |
| 63 | + fontSize: 18, |
| 64 | + fontWeight: 500, |
| 65 | + margin: 0, |
| 66 | + lineHeight: "24px", |
| 67 | + }} |
| 68 | + > |
| 69 | + {children} |
| 70 | + </h1> |
| 71 | + ); |
28 | 72 | };
|
29 | 73 |
|
30 | 74 | export const PageHeaderSubtitle: FC<PropsWithChildren> = ({ children }) => {
|
31 |
| - const styles = useStyles(); |
32 |
| - return <span className={styles.subtitle}>{children}</span>; |
| 75 | + const theme = useTheme(); |
| 76 | + return ( |
| 77 | + <span |
| 78 | + css={{ |
| 79 | + fontSize: 14, |
| 80 | + color: theme.palette.text.secondary, |
| 81 | + display: "block", |
| 82 | + }} |
| 83 | + > |
| 84 | + {children} |
| 85 | + </span> |
| 86 | + ); |
33 | 87 | };
|
34 |
| - |
35 |
| -const useStyles = makeStyles((theme) => ({ |
36 |
| - header: { |
37 |
| - ...theme.typography.body2, |
38 |
| - padding: theme.spacing(3), |
39 |
| - background: theme.palette.background.paper, |
40 |
| - borderBottom: `1px solid ${theme.palette.divider}`, |
41 |
| - display: "flex", |
42 |
| - alignItems: "center", |
43 |
| - gap: theme.spacing(6), |
44 |
| - |
45 |
| - zIndex: 10, |
46 |
| - flexWrap: "wrap", |
47 |
| - |
48 |
| - [theme.breakpoints.down("lg")]: { |
49 |
| - position: "unset", |
50 |
| - alignItems: "flex-start", |
51 |
| - }, |
52 |
| - [theme.breakpoints.down("md")]: { |
53 |
| - flexDirection: "column", |
54 |
| - }, |
55 |
| - }, |
56 |
| - sticky: { |
57 |
| - position: "sticky", |
58 |
| - top: 0, |
59 |
| - }, |
60 |
| - actions: { |
61 |
| - marginLeft: "auto", |
62 |
| - [theme.breakpoints.down("md")]: { |
63 |
| - marginLeft: "unset", |
64 |
| - }, |
65 |
| - }, |
66 |
| - title: { |
67 |
| - fontSize: 18, |
68 |
| - fontWeight: 500, |
69 |
| - margin: 0, |
70 |
| - lineHeight: "24px", |
71 |
| - }, |
72 |
| - subtitle: { |
73 |
| - fontSize: 14, |
74 |
| - color: theme.palette.text.secondary, |
75 |
| - display: "block", |
76 |
| - }, |
77 |
| -})); |
|
0 commit comments