Skip to content

Commit

Permalink
fix: wrap avatar with container
Browse files Browse the repository at this point in the history
  • Loading branch information
stakbucks committed Aug 26, 2024
1 parent a225564 commit d0f8efb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 18 additions & 0 deletions apps/bottle/src/components/avatar/avatarStyle.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@ import { colors } from '@bottlesteam/ui';
import { style } from '@vanilla-extract/css';
import { recipe } from '@vanilla-extract/recipes';

export const containerStyle = recipe({
base: {
borderRadius: '50%',
},
variants: {
size: {
sm: {
width: '48px',
height: '48px',
},
lg: {
width: '80px',
height: '80px',
},
},
},
});

export const avatarStyle = recipe({
base: {
borderRadius: '50%',
Expand Down
6 changes: 3 additions & 3 deletions apps/bottle/src/components/avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Image from 'next/image';
import type { ImageProps } from 'next/image';
import { avatarStyle, placeholderStyle } from './avatarStyle.css';
import { avatarStyle, containerStyle, placeholderStyle } from './avatarStyle.css';

export interface AvatarProps extends Omit<ImageProps, 'alt' | 'width' | 'height'> {
size: 'sm' | 'lg';
Expand All @@ -11,7 +11,7 @@ export function Avatar({ size: _size, blur, ...props }: AvatarProps) {
const size = _size === 'sm' ? 48 : 80;

return (
<>
<div className={containerStyle({ size: _size })}>
{props.src != null ? (
<Image
priority
Expand All @@ -24,7 +24,7 @@ export function Avatar({ size: _size, blur, ...props }: AvatarProps) {
) : (
<Placeholder size={size} />
)}
</>
</div>
);
}

Expand Down

0 comments on commit d0f8efb

Please sign in to comment.