Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: display workspace avatars correctly when URLs fail to load#14814

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Parkreiner merged 13 commits intomainfrommes/avatar-fix-2
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
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
17 changes: 15 additions & 2 deletionssite/src/components/AvatarData/AvatarData.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,18 +8,31 @@ export interface AvatarDataProps {
subtitle?: ReactNode;
src?: string;
avatar?: React.ReactNode;

/**
* Lets you specify the character(s) displayed in an avatar when an image is
* unavailable (like when the network request fails).
*
* If not specified, the component will try to parse the first character
* from the title prop if it is a string.
*/
imgFallbackText?: string;
}

export const AvatarData: FC<AvatarDataProps> = ({
title,
subtitle,
src,
imgFallbackText,
avatar,
}) => {
const theme = useTheme();

if (!avatar) {
avatar = <Avatar src={src}>{title}</Avatar>;
avatar = (
<Avatar background src={src}>
{(typeof title === "string" ? title : imgFallbackText) || "-"}
</Avatar>
);
}

return (
Expand Down
78 changes: 39 additions & 39 deletionssite/src/pages/ManagementSettingsPage/SidebarView.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -389,49 +389,49 @@ const styles = {

const classNames = {
link: (css, theme) => css`
color: inherit;
display: block;
font-size: 14px;
text-decoration: none;
padding: 10px 12px 10px 16px;
border-radius: 4px;
transition: background-color 0.15s ease-in-out;
position: relative;

&:hover {
background-color: ${theme.palette.action.hover};
}

border-left: 3px solid transparent;
`,
color: inherit;
display: block;
font-size: 14px;
text-decoration: none;
padding: 10px 12px 10px 16px;
border-radius: 4px;
transition: background-color 0.15s ease-in-out;
position: relative;

&:hover {
background-color: ${theme.palette.action.hover};
}

border-left: 3px solid transparent;
`,

activeLink: (css, theme) => css`
border-left-color: ${theme.palette.primary.main};
border-top-left-radius: 0;
border-bottom-left-radius: 0;
`,
border-left-color: ${theme.palette.primary.main};
border-top-left-radius: 0;
border-bottom-left-radius: 0;
`,

subLink: (css, theme) => css`
color: ${theme.palette.text.secondary};
text-decoration: none;

display: block;
font-size: 13px;
margin-left: 44px;
padding: 4px 12px;
border-radius: 4px;
transition: background-color 0.15s ease-in-out;
margin-bottom: 1px;
position: relative;

&:hover {
color: ${theme.palette.text.primary};
background-color: ${theme.palette.action.hover};
}
`,
color: ${theme.palette.text.secondary};
text-decoration: none;

display: block;
font-size: 13px;
margin-left: 44px;
padding: 4px 12px;
border-radius: 4px;
transition: background-color 0.15s ease-in-out;
margin-bottom: 1px;
position: relative;

&:hover {
color: ${theme.palette.text.primary};
background-color: ${theme.palette.action.hover};
}
`,

activeSubLink: (css, theme) => css`
color: ${theme.palette.text.primary};
font-weight: 600;
`,
color: ${theme.palette.text.primary};
font-weight: 600;
`,
} satisfies Record<string, ClassName>;
17 changes: 15 additions & 2 deletionssite/src/pages/WorkspacePage/WorkspaceTopbar.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,6 +25,7 @@ import { WorkspaceStatusBadge } from "modules/workspaces/WorkspaceStatusBadge/Wo
import type { FC } from "react";
import { useQuery } from "react-query";
import { Link as RouterLink } from "react-router-dom";
import { isEmojiUrl } from "utils/appearance";
import { displayDormantDeletion } from "utils/dormant";
import { WorkspaceActions } from "./WorkspaceActions/WorkspaceActions";
import { WorkspaceNotifications } from "./WorkspaceNotifications/WorkspaceNotifications";
Expand DownExpand Up@@ -344,9 +345,15 @@ const OrganizationBreadcrumb: FC<OrganizationBreadcrumbProps> = ({
subtitle="Organization"
avatar={
orgIconUrl && (
<ExternalAvatar src={orgIconUrl} variant="square" fitImage />
<ExternalAvatar
src={orgIconUrl}
title={orgName}
variant={isEmojiUrl(orgIconUrl) ? "square" : "circular"}
fitImage
/>
)
}
imgFallbackText={orgName}
/>
</HelpTooltipContent>
</Popover>
Expand DownExpand Up@@ -405,8 +412,14 @@ const WorkspaceBreadcrumb: FC<WorkspaceBreadcrumbProps> = ({
</Link>
}
avatar={
<ExternalAvatar src={templateIconUrl} variant="square" fitImage />
<ExternalAvatar
src={templateIconUrl}
title={workspaceName}
variant={isEmojiUrl(templateIconUrl) ? "square" : "circular"}
fitImage
/>
}
imgFallbackText={templateVersionDisplayName}
/>
</HelpTooltipContent>
</Popover>
Expand Down
6 changes: 3 additions & 3 deletionssite/src/theme/externalImages.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,8 +75,8 @@ const parseInvertFilterParameters = (

let extraStyles: CSSObject | undefined;

const brightness = params.get("brightness");
if (multiplier.test(brightness!)) {
const brightness = params.get("brightness") ?? "";
if (multiplier.test(brightness)) {
let filter = baseStyles.filter ?? "";
filter += ` brightness(${brightness})`;
extraStyles = { ...extraStyles, filter };
Expand DownExpand Up@@ -131,7 +131,7 @@ export function getExternalImageStylesFromUrl(
) {
return parseImageParameters(
modes,
defaultParametersForBuiltinIcons.get(url.pathname)!,
defaultParametersForBuiltinIcons.get(url.pathname) as string,
);
}

Expand Down
15 changes: 15 additions & 0 deletionssite/src/utils/appearance.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,3 +14,18 @@ export const getLogoURL = (): string => {
?.getAttribute("content");
return c && !c.startsWith("{{ .") ? c : "";
};

/**
* Exposes an easy way to determine if a given URL is for an emoji hosted on
* the Coder deployment.
*
* Helps when you need to style emojis differently (i.e., not adding rounding to
* the container so that the emoji doesn't get cut off).
*/
export function isEmojiUrl(url: string | undefined): boolean {
if (!url) {
return false;
}

return url.startsWith("/emojis/");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

hmm. I'm skeptic about adding special handling like this, but I get the motivation.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp