Skip to content

feat: add /icons page #10093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add a page title
  • Loading branch information
aslilac committed Oct 6, 2023
commit bdec89a6e7334dacdcdffb231e37a9be18d24c81
230 changes: 120 additions & 110 deletions site/src/pages/IconsPage/IconsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import SearchIcon from "@mui/icons-material/SearchOutlined";
import ClearIcon from "@mui/icons-material/CloseOutlined";
import { useTheme } from "@emotion/react";
import { type FC, type ReactNode, useMemo, useState } from "react";
import { Helmet } from "react-helmet-async";
import uFuzzy from "ufuzzy";
import { CopyableValue } from "components/CopyableValue/CopyableValue";
import { EmptyState } from "components/EmptyState/EmptyState";
Expand All @@ -19,6 +20,7 @@ import {
} from "components/PageHeader/PageHeader";
import { Stack } from "components/Stack/Stack";
import icons from "theme/icons.json";
import { pageTitle } from "utils/page";

const iconsWithoutSuffix = icons.map((icon) => icon.split(".")[0]);
const fuzzyFinder = new uFuzzy({
Expand Down Expand Up @@ -68,118 +70,126 @@ export const IconsPage: FC = () => {
}, [searchText]);

return (
<Margins>
<PageHeader
actions={
<Tooltip
placement="bottom-end"
title={
<Box
css={{
padding: theme.spacing(1),
fontSize: 13,
lineHeight: 1.5,
}}
>
You can suggest a new icon by submitting a Pull Request to our
public GitHub repository. Just keep in mind that it should be
relevant to many Coder users, and redistributable under a
permissive license.
</Box>
}
>
<Link href="https://github.com/coder/coder/tree/main/site/static/icon">
Suggest an icon
</Link>
</Tooltip>
}
>
<PageHeaderTitle>Icons</PageHeaderTitle>
<PageHeaderSubtitle>
All of the icons included with Coder
</PageHeaderSubtitle>
</PageHeader>
<TextField
size="small"
InputProps={{
"aria-label": "Filter",
name: "query",
placeholder: "Search…",
value: searchInputText,
onChange: (event) => setSearchInputText(event.target.value),
sx: {
borderRadius: "6px",
marginLeft: "-1px",
"& input::placeholder": {
color: theme.palette.text.secondary,
<>
<Helmet>
<title>{pageTitle("Icons")}</title>
</Helmet>
<Margins>
<PageHeader
actions={
<Tooltip
placement="bottom-end"
title={
<Box
css={{
padding: theme.spacing(1),
fontSize: 13,
lineHeight: 1.5,
}}
>
You can suggest a new icon by submitting a Pull Request to our
public GitHub repository. Just keep in mind that it should be
relevant to many Coder users, and redistributable under a
permissive license.
</Box>
}
>
<Link href="https://github.com/coder/coder/tree/main/site/static/icon">
Suggest an icon
</Link>
</Tooltip>
}
>
<PageHeaderTitle>Icons</PageHeaderTitle>
<PageHeaderSubtitle>
All of the icons included with Coder
</PageHeaderSubtitle>
</PageHeader>
<TextField
size="small"
InputProps={{
"aria-label": "Filter",
name: "query",
placeholder: "Search…",
value: searchInputText,
onChange: (event) => setSearchInputText(event.target.value),
sx: {
borderRadius: "6px",
marginLeft: "-1px",
"& input::placeholder": {
color: theme.palette.text.secondary,
},
"& .MuiInputAdornment-root": {
marginLeft: 0,
},
},
"& .MuiInputAdornment-root": {
marginLeft: 0,
},
},
startAdornment: (
<InputAdornment position="start">
<SearchIcon
sx={{
fontSize: 14,
color: theme.palette.text.secondary,
}}
/>
</InputAdornment>
),
endAdornment: searchInputText && (
<InputAdornment position="end">
<Tooltip title="Clear filter">
<IconButton size="small" onClick={() => setSearchInputText("")}>
<ClearIcon sx={{ fontSize: 14 }} />
</IconButton>
</Tooltip>
</InputAdornment>
),
}}
/>
startAdornment: (
<InputAdornment position="start">
<SearchIcon
sx={{
fontSize: 14,
color: theme.palette.text.secondary,
}}
/>
</InputAdornment>
),
endAdornment: searchInputText && (
<InputAdornment position="end">
<Tooltip title="Clear filter">
<IconButton
size="small"
onClick={() => setSearchInputText("")}
>
<ClearIcon sx={{ fontSize: 14 }} />
</IconButton>
</Tooltip>
</InputAdornment>
),
}}
/>

<Stack
direction="row"
wrap="wrap"
spacing={1}
justifyContent="center"
css={(theme) => ({ marginTop: theme.spacing(4) })}
>
{searchedIcons.length === 0 && (
<EmptyState message="No results matched your search" />
)}
{searchedIcons.map((icon) => (
<CopyableValue key={icon.url} value={icon.url} placement="bottom">
<Stack alignItems="center" css={{ margin: theme.spacing(1.5) }}>
<img
alt={icon.url}
src={icon.url}
css={{
width: 60,
height: 60,
objectFit: "contain",
pointerEvents: "none",
padding: theme.spacing(1.5),
}}
/>
<figcaption
css={{
width: 88,
height: 48,
fontSize: 13,
textOverflow: "ellipsis",
textAlign: "center",
overflow: "hidden",
}}
>
{icon.description}
</figcaption>
</Stack>
</CopyableValue>
))}
</Stack>
</Margins>
<Stack
direction="row"
wrap="wrap"
spacing={1}
justifyContent="center"
css={(theme) => ({ marginTop: theme.spacing(4) })}
>
{searchedIcons.length === 0 && (
<EmptyState message="No results matched your search" />
)}
{searchedIcons.map((icon) => (
<CopyableValue key={icon.url} value={icon.url} placement="bottom">
<Stack alignItems="center" css={{ margin: theme.spacing(1.5) }}>
<img
alt={icon.url}
src={icon.url}
css={{
width: 60,
height: 60,
objectFit: "contain",
pointerEvents: "none",
padding: theme.spacing(1.5),
}}
/>
<figcaption
css={{
width: 88,
height: 48,
fontSize: 13,
textOverflow: "ellipsis",
textAlign: "center",
overflow: "hidden",
}}
>
{icon.description}
</figcaption>
</Stack>
</CopyableValue>
))}
</Stack>
</Margins>
</>
);
};

Expand Down