- Notifications
You must be signed in to change notification settings - Fork925
refactor: replace and remove deprecated Avatar component#15930
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
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
32 commits Select commitHold shift + click to select a range
dbf1eb9
Add avatarLetters utility
BrunoQuaresma8f24c9e
Fix avatar for non squared icon
BrunoQuaresmae689d42
Replace avatar o template menu
BrunoQuaresma6f8c280
Move UserAvatar to modules/users
BrunoQuaresmae72cecb
Only use one letter on fallback to simplify changes
BrunoQuaresma758f240
Refactor UserAvatar to user the new Avatar component
BrunoQuaresma22c241c
Move GroupAvatar to modules/groups
BrunoQuaresma8ecbfc5
Update GroupAvatar to use latest Avatar component
BrunoQuaresma081bb47
Move BuildAvatar to modules/builds
BrunoQuaresma83ca623
Update BuildAvatar to use latest Avatar component
BrunoQuaresmadff92f7
Move AvatarCard to components/Avatar
BrunoQuaresma52ea623
Update AccountUserGroups to use the new Avatar component
BrunoQuaresma16c194d
Move AvatarData to components/Avatar
BrunoQuaresma1caeffd
Update AvatarData to use new Avatar component
BrunoQuaresma4f12e95
Update remaining components
BrunoQuaresma76c211d
Fix lint issues
BrunoQuaresma08fee38
Remove deprecated Avatar
BrunoQuaresmabfd9244
Merge branch 'main' of https://github.com/coder/coder into bq/use-new…
BrunoQuaresmad6fc56b
Merge branch 'main' of https://github.com/coder/coder into bq/use-new…
BrunoQuaresmaf47ed9d
Align avatar with the timeline vertical line
BrunoQuaresma7304999
Fix selected template avatar
BrunoQuaresma9fdb4fd
Adjust components for the new Avatar
BrunoQuaresma0a0b1cf
Fix a few style inconsistencies
BrunoQuaresmaf079dcd
Merge branch 'main' of https://github.com/coder/coder into bq/use-new…
BrunoQuaresmadc410a7
Simplify Avatar usage
BrunoQuaresma37a678d
Fix missed src
BrunoQuaresma9e03115
Fix remaining issues
BrunoQuaresma6453ce3
E2E fix + review requests
BrunoQuaresmabb8e9af
Fix fmt
BrunoQuaresma417cab7
Fix assertions
BrunoQuaresmaad61871
Fix locators
BrunoQuaresmad57833b
Change locator to use .summary
BrunoQuaresmaFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
32 changes: 14 additions & 18 deletionssite/e2e/tests/deployment/workspaceProxies.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
39 changes: 21 additions & 18 deletionssite/src/components/Avatar/Avatar.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
98 changes: 48 additions & 50 deletionssite/src/components/Avatar/Avatar.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,92 @@ | ||
/** | ||
* Copied from shadc/ui on 12/16/2024 | ||
* @see {@link https://ui.shadcn.com/docs/components/avatar} | ||
* | ||
* This component was updated to support the variants and match the styles from | ||
* the Figma design: | ||
* @see {@link https://www.figma.com/design/WfqIgsTFXN2BscBSSyXWF8/Coder-kit?node-id=711-383&t=xqxOSUk48GvDsjGK-0} | ||
* | ||
* It was also simplified to make usage easier and reduce boilerplate. | ||
* @see {@link https://github.com/coder/coder/pull/15930#issuecomment-2552292440} | ||
*/ | ||
import { useTheme } from "@emotion/react"; | ||
import * as AvatarPrimitive from "@radix-ui/react-avatar"; | ||
import { type VariantProps, cva } from "class-variance-authority"; | ||
import * as React from "react"; | ||
import { getExternalImageStylesFromUrl } from "theme/externalImages"; | ||
import { cn } from "utils/cn"; | ||
const avatarVariants = cva( | ||
"relative flex shrink-0 overflow-hidden rounded border border-solid bg-surface-secondary text-content-secondary", | ||
{ | ||
variants: { | ||
size: { | ||
lg: "h-[--avatar-lg] w-[--avatar-lg] rounded-[6px] text-sm font-medium", | ||
md: "h-[--avatar-default] w-[--avatar-default] text-2xs", | ||
sm: "h-[--avatar-sm] w-[--avatar-sm] text-[8px]", | ||
}, | ||
variant: { | ||
default:null, | ||
icon:null, | ||
}, | ||
}, | ||
defaultVariants: { | ||
size: "md", | ||
}, | ||
compoundVariants: [ | ||
{ | ||
size: "lg", | ||
variant: "icon", | ||
className: "p-2", | ||
}, | ||
{ | ||
size: "md", | ||
variant: "icon", | ||
className: "p-1", | ||
}, | ||
{ | ||
size: "sm", | ||
variant: "icon", | ||
className: "p-[3px]", | ||
}, | ||
], | ||
}, | ||
); | ||
export type AvatarProps = AvatarPrimitive.AvatarProps & | ||
VariantProps<typeof avatarVariants> & { | ||
src?: string; | ||
fallback?: string; | ||
}; | ||
const Avatar = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Root>, | ||
AvatarProps | ||
>(({ className, size, variant, src, fallback, children, ...props }, ref) => { | ||
const theme = useTheme(); | ||
return ( | ||
<AvatarPrimitive.Root | ||
ref={ref} | ||
className={cn(avatarVariants({ size, variant, className }))} | ||
{...props} | ||
> | ||
<AvatarPrimitive.Image | ||
src={src} | ||
className="aspect-square h-full w-full object-contain" | ||
css={getExternalImageStylesFromUrl(theme.externalImages, src)} | ||
/> | ||
{fallback && ( | ||
<AvatarPrimitive.Fallback className="flex h-full w-full items-center justify-center rounded-full"> | ||
{fallback.charAt(0).toUpperCase()} | ||
</AvatarPrimitive.Fallback> | ||
)} | ||
{children} | ||
</AvatarPrimitive.Root> | ||
); | ||
}); | ||
Avatar.displayName = AvatarPrimitive.Root.displayName; | ||
export { Avatar }; |
1 change: 0 additions & 1 deletion...ponents/AvatarCard/AvatarCard.stories.tsx → .../components/Avatar/AvatarCard.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
11 changes: 2 additions & 9 deletions.../src/components/AvatarCard/AvatarCard.tsx → site/src/components/Avatar/AvatarCard.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
File renamed without changes.
12 changes: 6 additions & 6 deletions.../src/components/AvatarData/AvatarData.tsx → site/src/components/Avatar/AvatarData.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.