Skip to content

Commit 6f820c1

Browse files
committed
emotion: UserAutocomplete
1 parent 4bd9a7e commit 6f820c1

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

site/src/components/UserAutocomplete/UserAutocomplete.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
import { css } from "@emotion/css";
2+
import { type Interpolation, type Theme, useTheme } from "@emotion/react";
13
import CircularProgress from "@mui/material/CircularProgress";
2-
import { makeStyles } from "@mui/styles";
34
import TextField from "@mui/material/TextField";
45
import Autocomplete from "@mui/material/Autocomplete";
5-
import { User } from "api/typesGenerated";
6+
import type { User } from "api/typesGenerated";
67
import { Avatar } from "components/Avatar/Avatar";
78
import { AvatarData } from "components/AvatarData/AvatarData";
8-
import { ChangeEvent, ComponentProps, FC, useState } from "react";
9+
import {
10+
type ChangeEvent,
11+
type ComponentProps,
12+
type FC,
13+
useState,
14+
} from "react";
915
import Box from "@mui/material/Box";
1016
import { useDebouncedFunction } from "hooks/debounce";
1117
import { useQuery } from "react-query";
@@ -27,7 +33,7 @@ export const UserAutocomplete: FC<UserAutocompleteProps> = ({
2733
className,
2834
size = "small",
2935
}) => {
30-
const styles = useStyles();
36+
const theme = useTheme();
3137
const [autoComplete, setAutoComplete] = useState<{
3238
value: string;
3339
open: boolean;
@@ -101,7 +107,11 @@ export const UserAutocomplete: FC<UserAutocompleteProps> = ({
101107
size={size}
102108
label={label}
103109
placeholder="User email or username"
104-
className={styles.textField}
110+
css={{
111+
"&:not(:has(label))": {
112+
margin: 0,
113+
},
114+
}}
105115
InputProps={{
106116
...params.InputProps,
107117
onChange: debouncedInputOnChange,
@@ -119,7 +129,12 @@ export const UserAutocomplete: FC<UserAutocompleteProps> = ({
119129
</>
120130
),
121131
classes: {
122-
root: styles.inputRoot,
132+
root: css`
133+
padding-left: ${theme.spacing(
134+
1.75,
135+
)} !important; // Same padding left as input
136+
gap: ${theme.spacing(0.5)};
137+
`,
123138
},
124139
}}
125140
InputLabelProps={{
@@ -130,15 +145,3 @@ export const UserAutocomplete: FC<UserAutocompleteProps> = ({
130145
/>
131146
);
132147
};
133-
134-
export const useStyles = makeStyles((theme) => ({
135-
textField: {
136-
"&:not(:has(label))": {
137-
margin: 0,
138-
},
139-
},
140-
inputRoot: {
141-
paddingLeft: `${theme.spacing(1.75)} !important`, // Same padding left as input
142-
gap: theme.spacing(0.5),
143-
},
144-
}));

0 commit comments

Comments
 (0)