Skip to content

Commit ae5c50d

Browse files
committed
emotion: Expander
1 parent c824abc commit ae5c50d

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed
Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import { type Interpolation, type Theme } from "@emotion/react";
12
import Collapse from "@mui/material/Collapse";
23
import Link from "@mui/material/Link";
3-
import makeStyles from "@mui/styles/makeStyles";
44
import { DropdownArrow } from "components/DropdownArrow/DropdownArrow";
55
import { type FC, type PropsWithChildren } from "react";
6-
import { combineClasses } from "utils/combineClasses";
76

87
export interface ExpanderProps {
98
expanded: boolean;
@@ -15,29 +14,27 @@ export const Expander: FC<PropsWithChildren<ExpanderProps>> = ({
1514
setExpanded,
1615
children,
1716
}) => {
18-
const styles = useStyles();
19-
2017
const toggleExpanded = () => setExpanded(!expanded);
2118

2219
return (
2320
<>
2421
{!expanded && (
25-
<Link onClick={toggleExpanded} className={styles.expandLink}>
26-
<span className={styles.text}>
22+
<Link onClick={toggleExpanded} css={styles.expandLink}>
23+
<span css={styles.text}>
2724
Click here to learn more
2825
<DropdownArrow margin={false} />
2926
</span>
3027
</Link>
3128
)}
3229
<Collapse in={expanded}>
33-
<div className={styles.text}>{children}</div>
30+
<div css={styles.text}>{children}</div>
3431
</Collapse>
3532
{expanded && (
3633
<Link
3734
onClick={toggleExpanded}
38-
className={combineClasses([styles.expandLink, styles.collapseLink])}
35+
css={[styles.expandLink, styles.collapseLink]}
3936
>
40-
<span className={styles.text}>
37+
<span css={styles.text}>
4138
Click here to hide
4239
<DropdownArrow margin={false} close />
4340
</span>
@@ -47,18 +44,18 @@ export const Expander: FC<PropsWithChildren<ExpanderProps>> = ({
4744
);
4845
};
4946

50-
const useStyles = makeStyles((theme) => ({
51-
expandLink: {
47+
const styles = {
48+
expandLink: (theme) => ({
5249
cursor: "pointer",
5350
color: theme.palette.text.secondary,
54-
},
55-
collapseLink: {
51+
}),
52+
collapseLink: (theme) => ({
5653
marginTop: theme.spacing(2),
57-
},
58-
text: {
54+
}),
55+
text: (theme) => ({
5956
display: "flex",
6057
alignItems: "center",
6158
color: theme.palette.text.secondary,
6259
fontSize: theme.typography.caption.fontSize,
63-
},
64-
}));
60+
}),
61+
} satisfies Record<string, Interpolation<Theme>>;

0 commit comments

Comments
 (0)