Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dbf1eb9
Add avatarLetters utility
BrunoQuaresma Dec 17, 2024
8f24c9e
Fix avatar for non squared icon
BrunoQuaresma Dec 17, 2024
e689d42
Replace avatar o template menu
BrunoQuaresma Dec 17, 2024
6f8c280
Move UserAvatar to modules/users
BrunoQuaresma Dec 17, 2024
e72cecb
Only use one letter on fallback to simplify changes
BrunoQuaresma Dec 17, 2024
758f240
Refactor UserAvatar to user the new Avatar component
BrunoQuaresma Dec 17, 2024
22c241c
Move GroupAvatar to modules/groups
BrunoQuaresma Dec 17, 2024
8ecbfc5
Update GroupAvatar to use latest Avatar component
BrunoQuaresma Dec 17, 2024
081bb47
Move BuildAvatar to modules/builds
BrunoQuaresma Dec 17, 2024
83ca623
Update BuildAvatar to use latest Avatar component
BrunoQuaresma Dec 17, 2024
dff92f7
Move AvatarCard to components/Avatar
BrunoQuaresma Dec 17, 2024
52ea623
Update AccountUserGroups to use the new Avatar component
BrunoQuaresma Dec 17, 2024
16c194d
Move AvatarData to components/Avatar
BrunoQuaresma Dec 17, 2024
1caeffd
Update AvatarData to use new Avatar component
BrunoQuaresma Dec 17, 2024
4f12e95
Update remaining components
BrunoQuaresma Dec 17, 2024
76c211d
Fix lint issues
BrunoQuaresma Dec 17, 2024
08fee38
Remove deprecated Avatar
BrunoQuaresma Dec 17, 2024
bfd9244
Merge branch 'main' of https://github.com/coder/coder into bq/use-new…
BrunoQuaresma Dec 18, 2024
d6fc56b
Merge branch 'main' of https://github.com/coder/coder into bq/use-new…
BrunoQuaresma Dec 18, 2024
f47ed9d
Align avatar with the timeline vertical line
BrunoQuaresma Dec 18, 2024
7304999
Fix selected template avatar
BrunoQuaresma Dec 18, 2024
9fdb4fd
Adjust components for the new Avatar
BrunoQuaresma Dec 18, 2024
0a0b1cf
Fix a few style inconsistencies
BrunoQuaresma Dec 18, 2024
f079dcd
Merge branch 'main' of https://github.com/coder/coder into bq/use-new…
BrunoQuaresma Dec 19, 2024
dc410a7
Simplify Avatar usage
BrunoQuaresma Dec 19, 2024
37a678d
Fix missed src
BrunoQuaresma Dec 19, 2024
9e03115
Fix remaining issues
BrunoQuaresma Dec 19, 2024
6453ce3
E2E fix + review requests
BrunoQuaresma Dec 19, 2024
bb8e9af
Fix fmt
BrunoQuaresma Dec 19, 2024
417cab7
Fix assertions
BrunoQuaresma Dec 20, 2024
ad61871
Fix locators
BrunoQuaresma Dec 20, 2024
d57833b
Change locator to use .summary
BrunoQuaresma Dec 20, 2024
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
Next Next commit
Adjust components for the new Avatar
  • Loading branch information
BrunoQuaresma committed Dec 18, 2024
commit 9fdb4fd810b3d3861608fb62af0dc0559d140c70
6 changes: 3 additions & 3 deletions site/src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ const avatarVariants = cva(
{
size: "lg",
variant: "icon",
className: "p-[9px]",
className: "p-2",
},
{
size: "default",
variant: "icon",
className: "p-[3px]",
className: "p-1",
},
{
size: "sm",
variant: "icon",
className: "p-[2px]",
className: "p-[3px]",
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Avatar/AvatarCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const AvatarCard: FC<AvatarCardProps> = ({
)}
</div>

<Avatar>
<Avatar size="lg">
<AvatarImage src={imgUrl} alt={altText} />
<AvatarFallback>{avatarLetter(header)}</AvatarFallback>
</Avatar>
Expand Down
3 changes: 1 addition & 2 deletions site/src/components/Avatar/AvatarData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ export const AvatarData: FC<AvatarDataProps> = ({

return (
<Stack
spacing={1.5}
spacing={1}
direction="row"
alignItems="center"
css={{
minHeight: 40, // Make it predictable for the skeleton
width: "100%",
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/FullPageLayout/Topbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const TopbarDivider: FC<HTMLAttributes<HTMLSpanElement>> = (props) => {

export const TopbarAvatar: FC<{ src: string }> = ({ src }) => {
return (
<Avatar variant="icon">
<Avatar variant="icon" size="sm">
<AvatarImage src={src} />
</Avatar>
);
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const SidebarHeader: FC<SidebarHeaderProps> = ({
linkTo,
}) => {
return (
<Stack direction="row" alignItems="center" css={styles.info}>
<Stack direction="row" spacing={1} css={styles.info}>
{avatar}
<div
css={{
Expand Down
38 changes: 9 additions & 29 deletions site/src/modules/builds/BuildAvatar/BuildAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,18 @@ export interface BuildAvatarProps {

export const BuildAvatar: FC<BuildAvatarProps> = ({ build, size }) => {
const theme = useTheme();
const { status, type } = getDisplayWorkspaceBuildStatus(theme, build);
const badgeType = useClassName(
(css, theme) => css({ backgroundColor: theme.roles[type].fill.solid }),
const { type } = getDisplayWorkspaceBuildStatus(theme, build);
const iconColor = useClassName(
(css, theme) => css({ color: theme.roles[type].fill.solid }),
[type],
);

return (
<Badge
role="status"
aria-label={status}
title={status}
overlap="circular"
anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
badgeContent={<div></div>}
classes={{ badge: cx(classNames.badge, badgeType) }}
>
<Avatar size={size}>
<BuildIcon transition={build.transition} className="w-full h-full" />
</Avatar>
</Badge>
<Avatar size={size} variant="icon">
<BuildIcon
transition={build.transition}
className={`w-full h-full ${iconColor}`}
/>
</Avatar>
);
};

const classNames = {
badge: css({
borderRadius: "100%",
width: 8,
minWidth: 8,
height: 8,
display: "block",
padding: 0,
right: 0,
bottom: 0,
}),
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const UserDropdown: FC<UserDropdownProps> = ({
<div css={styles.badgeContainer}>
<Badge overlap="circular">
<UserAvatar
size="sm"
username={user.username}
Copy link
Contributor

Choose a reason for hiding this comment

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

based on the designs for the topbar navigation, https://www.figma.com/design/WfqIgsTFXN2BscBSSyXWF8/Coder-kit?node-id=656-2354&t=ZPGincsj3IkIlTun-1

The size for the UserAvatar should be size="lg"

avatarURL={user.avatar_url}
/>
Expand Down
39 changes: 4 additions & 35 deletions site/src/modules/groups/GroupAvatar/GroupAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import Group from "@mui/icons-material/Group";
import Badge from "@mui/material/Badge";
import {
Avatar,
AvatarFallback,
AvatarImage,
avatarLetter,
} from "components/Avatar/Avatar";
import { type ClassName, useClassName } from "hooks/useClassName";
import type { FC } from "react";

export interface GroupAvatarProps {
Expand All @@ -15,38 +12,10 @@ export interface GroupAvatarProps {
}

export const GroupAvatar: FC<GroupAvatarProps> = ({ name, avatarURL }) => {
const badge = useClassName(classNames.badge, []);

return (
<Badge
overlap="circular"
anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
badgeContent={<Group />}
classes={{ badge }}
>
<Avatar size="lg">
<AvatarImage src={avatarURL} />
<AvatarFallback>{avatarLetter(name)}</AvatarFallback>
</Avatar>
</Badge>
<Avatar>
<AvatarImage src={avatarURL} />
<AvatarFallback>{avatarLetter(name)}</AvatarFallback>
</Avatar>
);
};

const classNames = {
badge: (css, theme) =>
css({
backgroundColor: theme.palette.background.paper,
border: `1px solid ${theme.palette.divider}`,
borderRadius: "100%",
width: 24,
height: 24,
display: "flex",
alignItems: "center",
justifyContent: "center",

"& svg": {
width: 14,
height: 14,
},
}),
} satisfies Record<string, ClassName>;
18 changes: 12 additions & 6 deletions site/src/modules/management/SidebarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import type { Interpolation, Theme } from "@emotion/react";
import AddIcon from "@mui/icons-material/Add";
import SettingsIcon from "@mui/icons-material/Settings";
import type { AuthorizationResponse, Organization } from "api/typesGenerated";
import {
Avatar,
AvatarFallback,
AvatarImage,
avatarLetter,
} from "components/Avatar/Avatar";
import { FeatureStageBadge } from "components/FeatureStageBadge/FeatureStageBadge";
import { Loader } from "components/Loader/Loader";
import { Sidebar as BaseSidebar } from "components/Sidebar/Sidebar";
Expand Down Expand Up @@ -259,12 +265,12 @@ const OrganizationSettingsNavigation: FC<
active={active}
href={urlForSubpage(organization.name)}
icon={
<UserAvatar
key={organization.id}
size="sm"
username={organization.display_name}
avatarURL={organization.icon}
/>
<Avatar variant="icon">
<AvatarImage src={organization.icon} />
<AvatarFallback>
{avatarLetter(organization.display_name)}
</AvatarFallback>
</Avatar>
}
>
{organization.display_name}
Expand Down
4 changes: 2 additions & 2 deletions site/src/modules/resources/AgentRowPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ const styles = {
backgroundColor: theme.palette.divider,
position: "absolute",
top: 0,
left: 49,
left: 43,
},
}),

agentStatusWrapper: {
width: 36,
width: 24,
display: "flex",
justifyContent: "center",
flexShrink: 0,
Expand Down
6 changes: 1 addition & 5 deletions site/src/modules/resources/ResourceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ export const ResourceCard: FC<ResourceCardProps> = ({ resource, agentRow }) => {
css={styles.resourceCardHeader}
spacing={10}
>
<Stack
direction="row"
alignItems="center"
css={styles.resourceCardProfile}
>
<Stack direction="row" spacing={1} css={styles.resourceCardProfile}>
<div>
<ResourceAvatar resource={resource} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
return (
<Margins size="medium">
<PageHeader actions={<Button onClick={onCancel}>Cancel</Button>}>
<Stack direction="row" spacing={3} alignItems="center">
<Stack direction="row">
<Avatar variant="icon" size="lg">
<AvatarImage src={template.icon} />
<AvatarFallback>{avatarLetter(template.name)}</AvatarFallback>
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/CreateWorkspacePage/SelectedTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface SelectedTemplateProps {

export const SelectedTemplate: FC<SelectedTemplateProps> = ({ template }) => {
return (
<Stack direction="row" spacing={2} css={styles.template}>
<Stack direction="row" css={styles.template}>
<Avatar variant="icon" size="lg">
<AvatarImage src={template.icon} />
<AvatarFallback>{avatarLetter(template.name)}</AvatarFallback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const OAuth2AppRow: FC<OAuth2AppRowProps> = ({ app }) => {
title={app.name}
avatar={
Boolean(app.icon) && (
<Avatar variant="icon">
<Avatar variant="icon" size="lg">
<AvatarImage src={app.icon} />
</Avatar>
)
Expand Down
7 changes: 5 additions & 2 deletions site/src/pages/ExternalAuthPage/ExternalAuthPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ const ExternalAuthPageView: FC<ExternalAuthPageViewProps> = ({
</p>

{externalAuth.installations.length > 0 && (
<div css={styles.authorizedInstalls}>
<div
css={styles.authorizedInstalls}
className="flex gap-2 items-center"
>
{externalAuth.installations.map((install) => {
if (!install.account) {
return;
Expand All @@ -93,7 +96,7 @@ const ExternalAuthPageView: FC<ExternalAuthPageViewProps> = ({
target="_blank"
rel="noreferrer"
>
<Avatar size="sm">
<Avatar>
<AvatarImage src={install.account.avatar_url} />
<AvatarFallback>
{avatarLetter(install.account.login)}
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/GroupsPage/GroupsPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const GroupsPageView: FC<GroupsPageViewProps> = ({
<AvatarGroup
max={10}
total={group.members.length}
css={{ justifyContent: "flex-end" }}
css={{ justifyContent: "flex-end", gap: 4 }}
>
{group.members.map((member) => (
<UserAvatar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const GroupRow: FC<GroupRowProps> = ({ group }) => {
<AvatarGroup
max={10}
total={group.members.length}
css={{ justifyContent: "flex-end" }}
css={{ justifyContent: "flex-end", gap: 8 }}
>
{group.members.map((member) => (
<UserAvatar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { AvatarFallback, AvatarImage } from "@radix-ui/react-avatar";
import type { Organization } from "api/typesGenerated";
import { Avatar } from "components/Avatar/Avatar";
import {
PageHeader,
PageHeaderSubtitle,
Expand All @@ -23,13 +25,13 @@ export const OrganizationSummaryPageView: FC<
paddingTop: 0,
}}
>
<Stack direction="row" spacing={3} alignItems="center">
<UserAvatar
key={organization.id}
size="lg"
username={organization.display_name || organization.name}
avatarURL={organization.icon}
/>
<Stack direction="row">
<Avatar key={organization.id} size="lg" variant="icon">
<AvatarImage src={organization.icon} />
<AvatarFallback>
{organization.display_name || organization.name}
</AvatarFallback>
</Avatar>
<div>
<PageHeaderTitle>
{organization.display_name || organization.name}
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/TemplatePage/TemplatePageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const TemplatePageHeader: FC<TemplatePageHeaderProps> = ({
</>
}
>
<Stack direction="row" spacing={3} alignItems="center">
<Stack direction="row">
<Avatar size="lg" variant="icon">
<AvatarImage src={template.icon} />
<AvatarFallback>{avatarLetter(template.name)}</AvatarFallback>
Expand Down
Loading