Skip to content

Commit f915bdf

Browse files
authored
feat: support links with custom icons (#11629)
1 parent 5c310ec commit f915bdf

File tree

8 files changed

+46
-14
lines changed

8 files changed

+46
-14
lines changed

coderd/apidoc/docs.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codersdk/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ type SupportConfig struct {
18901890
type LinkConfig struct {
18911891
Name string `json:"name" yaml:"name"`
18921892
Target string `json:"target" yaml:"target"`
1893-
Icon string `json:"icon" yaml:"icon"`
1893+
Icon string `json:"icon" yaml:"icon" enums:"bug,chat,docs"`
18941894
}
18951895

18961896
// DeploymentOptionsWithoutSecrets returns a copy of the OptionSet with secret values omitted.

docs/api/enterprise.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/general.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/schemas.md

Lines changed: 14 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/components/Dashboard/Navbar/UserDropdown/UserDropdown.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const meta: Meta<typeof UserDropdown> = {
1313
{ icon: "docs", name: "Documentation", target: "" },
1414
{ icon: "bug", name: "Report a bug", target: "" },
1515
{ icon: "chat", name: "Join the Coder Discord", target: "" },
16+
{ icon: "/icon/aws.svg", name: "Amazon Web Services", target: "" },
1617
],
1718
},
1819
};

site/src/components/Dashboard/Navbar/UserDropdown/UserDropdownContent.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
type Theme,
1818
} from "@emotion/react";
1919
import { usePopover } from "components/Popover/Popover";
20+
import { ExternalImage } from "components/ExternalImage/ExternalImage";
2021

2122
export const Language = {
2223
accountLabel: "Account",
@@ -98,6 +99,24 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
9899
popover.setIsOpen(false);
99100
};
100101

102+
const renderMenuIcon = (icon: string): JSX.Element => {
103+
switch (icon) {
104+
case "bug":
105+
return <BugIcon css={styles.menuItemIcon} />;
106+
case "chat":
107+
return <ChatIcon css={styles.menuItemIcon} />;
108+
case "docs":
109+
return <DocsIcon css={styles.menuItemIcon} />;
110+
default:
111+
return (
112+
<ExternalImage
113+
src={icon}
114+
css={{ maxWidth: "20px", maxHeight: "20px" }}
115+
/>
116+
);
117+
}
118+
};
119+
101120
return (
102121
<div>
103122
<Stack css={styles.info} spacing={0}>
@@ -131,9 +150,7 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
131150
css={styles.link}
132151
>
133152
<MenuItem css={styles.menuItem} onClick={onPopoverClose}>
134-
{link.icon === "bug" && <BugIcon css={styles.menuItemIcon} />}
135-
{link.icon === "chat" && <ChatIcon css={styles.menuItemIcon} />}
136-
{link.icon === "docs" && <DocsIcon css={styles.menuItemIcon} />}
153+
{renderMenuIcon(link.icon)}
137154
<span css={styles.menuItemText}>{link.name}</span>
138155
</MenuItem>
139156
</a>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy