Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b49f62

Browse files
committed
emotion: FullWidthPageHeader
1 parent 04adebe commit 2b49f62

File tree

1 file changed

+66
-56
lines changed

1 file changed

+66
-56
lines changed

site/src/components/PageHeader/FullWidthPageHeader.tsx

Lines changed: 66 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,87 @@
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";
43

54
export const FullWidthPageHeader: FC<
65
PropsWithChildren & { sticky?: boolean }
76
> = ({ children, sticky = true }) => {
8-
const styles = useStyles();
9-
7+
const theme = useTheme();
108
return (
119
<header
12-
className={combineClasses([styles.header, sticky ? styles.sticky : ""])}
1310
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+
]}
1437
>
1538
{children}
1639
</header>
1740
);
1841
};
1942

2043
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+
);
2357
};
2458

2559
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+
);
2872
};
2973

3074
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+
);
3387
};
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

Comments
 (0)