Skip to content

Commit 06c166d

Browse files
committed
make things prettier
1 parent 61552be commit 06c166d

File tree

1 file changed

+65
-15
lines changed

1 file changed

+65
-15
lines changed

site/src/pages/IconsPage/IconsPage.tsx

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
import TextField from "@mui/material/TextField";
2+
import InputAdornment from "@mui/material/InputAdornment";
3+
import Tooltip from "@mui/material/Tooltip";
4+
import IconButton from "@mui/material/IconButton";
5+
import SearchIcon from "@mui/icons-material/SearchOutlined";
6+
import ClearIcon from "@mui/icons-material/CloseOutlined";
7+
import { useTheme } from "@emotion/react";
18
import { type ReactNode, useMemo, useState } from "react";
29
import uFuzzy from "ufuzzy";
310
import { CopyableValue } from "components/CopyableValue/CopyableValue";
411
import { Margins } from "components/Margins/Margins";
12+
import { PageHeader, PageHeaderTitle } from "components/PageHeader/PageHeader";
513
import { Stack } from "components/Stack/Stack";
6-
import { colors } from "theme/colors";
714
import icons from "theme/icons.json";
815

916
const iconsWithoutSuffix = icons.map((icon) => icon.split(".")[0]);
@@ -16,6 +23,7 @@ const fuzzyFinder = new uFuzzy({
1623
});
1724

1825
export default function () {
26+
const theme = useTheme();
1927
const [searchText, setSearchText] = useState("");
2028

2129
const searchedIcons = useMemo(() => {
@@ -53,32 +61,74 @@ export default function () {
5361

5462
return (
5563
<Margins>
56-
<input
57-
type="search"
58-
onChange={(event) => setSearchText(event.target.value)}
64+
<PageHeader>
65+
<PageHeaderTitle>Icons</PageHeaderTitle>
66+
</PageHeader>
67+
<TextField
68+
size="small"
69+
InputProps={{
70+
"aria-label": "Filter",
71+
name: "query",
72+
placeholder: "Search...",
73+
value: searchText,
74+
onChange: (e) => {
75+
setSearchText(e.target.value);
76+
},
77+
sx: {
78+
borderRadius: "6px",
79+
marginLeft: "-1px",
80+
"& input::placeholder": {
81+
color: theme.palette.text.secondary,
82+
},
83+
"& .MuiInputAdornment-root": {
84+
marginLeft: 0,
85+
},
86+
},
87+
startAdornment: (
88+
<InputAdornment position="start">
89+
<SearchIcon
90+
sx={{
91+
fontSize: 14,
92+
color: theme.palette.text.secondary,
93+
}}
94+
/>
95+
</InputAdornment>
96+
),
97+
endAdornment: searchText && (
98+
<InputAdornment position="end">
99+
<Tooltip title="Clear filter">
100+
<IconButton size="small" onClick={() => setSearchText("")}>
101+
<ClearIcon sx={{ fontSize: 14 }} />
102+
</IconButton>
103+
</Tooltip>
104+
</InputAdornment>
105+
),
106+
}}
59107
/>
60-
<Stack direction="row" wrap="wrap" spacing={1} justifyContent="center">
108+
109+
<Stack
110+
direction="row"
111+
wrap="wrap"
112+
spacing={1}
113+
justifyContent="center"
114+
css={(theme) => ({ marginTop: theme.spacing(4) })}
115+
>
61116
{searchedIcons.map((icon) => (
62117
<CopyableValue key={icon.url} value={icon.url} placement="bottom">
63-
<Stack
64-
alignItems="center"
65-
css={(theme) => ({ margin: theme.spacing(1.5) })}
66-
>
118+
<Stack alignItems="center" css={{ margin: theme.spacing(1.5) }}>
67119
<img
68120
src={icon.url}
69121
css={{
70-
width: 64,
71-
height: 64,
122+
width: 60,
123+
height: 60,
72124
objectFit: "contain",
73125
pointerEvents: "none",
74-
backgroundColor: colors.gray[14],
75-
borderRadius: 8,
76-
padding: 8,
126+
padding: theme.spacing(1.5),
77127
}}
78128
/>
79129
<p
80130
css={{
81-
width: 96,
131+
width: 72,
82132
fontSize: 13,
83133
textOverflow: "ellipsis",
84134
textAlign: "center",

0 commit comments

Comments
 (0)