Skip to content

Commit 0a2bfea

Browse files
committed
add support for icon
1 parent 98b66a2 commit 0a2bfea

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

site/src/pages/OrganizationSettingsPage/OrganizationSettingsPage.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
onChangeTrimmed,
2828
} from "utils/formUtils";
2929
import { useOrganizationSettings } from "./OrganizationSettingsLayout";
30+
import { IconField } from "components/IconField/IconField";
3031

3132
const MAX_DESCRIPTION_CHAR_LIMIT = 128;
3233
const MAX_DESCRIPTION_MESSAGE =
@@ -64,6 +65,7 @@ const OrganizationSettingsPage: FC = () => {
6465
name: org.name,
6566
display_name: org.display_name,
6667
description: org.description,
68+
icon: org.icon,
6769
},
6870
validationSchema: getValidationSchema(),
6971
onSubmit: (values) =>
@@ -113,6 +115,13 @@ const OrganizationSettingsPage: FC = () => {
113115
label="Description"
114116
rows={2}
115117
/>
118+
<IconField
119+
{...getFieldHelpers("icon")}
120+
disabled={form.isSubmitting}
121+
onChange={onChangeTrimmed(form)}
122+
fullWidth
123+
onPickEmoji={(value) => form.setFieldValue("icon", value)}
124+
/>
116125
</FormFields>
117126
</FormSection>
118127
<FormFooter isLoading={form.isSubmitting} />

site/src/pages/OrganizationSettingsPage/Sidebar.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { cx } from "@emotion/css";
2-
import GeneralIcon from "@mui/icons-material/SettingsOutlined";
3-
import type { ElementType, FC, ReactNode } from "react";
4-
import { NavLink } from "react-router-dom";
2+
import type { FC, ReactNode } from "react";
3+
import { Link, NavLink } from "react-router-dom";
54
import type { Organization } from "api/typesGenerated";
65
import { Sidebar as BaseSidebar } from "components/Sidebar/Sidebar";
76
import { Stack } from "components/Stack/Stack";
87
import { type ClassName, useClassName } from "hooks/useClassName";
98
import { useOrganizationSettings } from "./OrganizationSettingsLayout";
9+
import { UserAvatar } from "components/UserAvatar/UserAvatar";
1010

1111
export const Sidebar: FC = () => {
1212
const { currentOrganizationId, organizations } = useOrganizationSettings();
@@ -39,8 +39,16 @@ export const OrganizationBloob: FC<BloobProps> = ({ organization, active }) => {
3939
return (
4040
<>
4141
<SidebarNavItem
42+
active={active}
4243
href={urlForSubpage(organization.name)}
43-
icon={GeneralIcon}
44+
icon={
45+
<UserAvatar
46+
key={organization.id}
47+
size="sm"
48+
username={organization.display_name}
49+
avatarURL={organization.icon}
50+
/>
51+
}
4452
>
4553
{organization.display_name}
4654
</SidebarNavItem>
@@ -75,29 +83,28 @@ export const OrganizationBloob: FC<BloobProps> = ({ organization, active }) => {
7583
};
7684

7785
interface SidebarNavItemProps {
86+
active?: boolean;
7887
children?: ReactNode;
79-
icon: ElementType;
88+
icon: ReactNode;
8089
href: string;
8190
}
8291

8392
export const SidebarNavItem: FC<SidebarNavItemProps> = ({
93+
active,
8494
children,
8595
href,
86-
icon: Icon,
96+
icon,
8797
}) => {
8898
const link = useClassName(classNames.link, []);
8999
const activeLink = useClassName(classNames.activeLink, []);
90100

91101
return (
92-
<NavLink
93-
to={href}
94-
className={({ isActive }) => cx([link, isActive && activeLink])}
95-
>
102+
<Link to={href} className={cx([link, active && activeLink])}>
96103
<Stack alignItems="center" spacing={1.5} direction="row">
97-
<Icon css={{ width: 16, height: 16 }} />
104+
{icon}
98105
{children}
99106
</Stack>
100-
</NavLink>
107+
</Link>
101108
);
102109
};
103110

@@ -154,7 +161,7 @@ const classNames = {
154161
155162
display: block;
156163
font-size: 13px;
157-
margin-left: 35px;
164+
margin-left: 42px;
158165
padding: 4px 12px;
159166
border-radius: 4px;
160167
transition: background-color 0.15s ease-in-out;
@@ -167,6 +174,6 @@ const classNames = {
167174
`,
168175

169176
activeSubLink: (css) => css`
170-
font-weight: 500;
177+
font-weight: 600;
171178
`,
172179
} satisfies Record<string, ClassName>;

0 commit comments

Comments
 (0)