Skip to content

Commit

Permalink
chore: requested changes and update recipe to simplify component file
Browse files Browse the repository at this point in the history
  • Loading branch information
Twonarly1 committed Sep 28, 2023
1 parent 9faa4ec commit 81f884d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
9 changes: 4 additions & 5 deletions examples/next/src/components/AvatarDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ const AvatarToggleDemo = () => {
return (
<Wrapper title="Avatar">
<Flex direction="column" gap={2}>
{isLoaded ? (
<Avatar src="/img/logo.png" alt="avatar" />
) : (
<Avatar src="" alt="" />
)}
<Avatar
src={isLoaded ? "/img/logo.png" : ""}
alt={isLoaded ? "avatar" : ""}
/>
<Button
data-testid="toggle"
variant="ghost"
Expand Down
9 changes: 4 additions & 5 deletions examples/vite-react/src/components/AvatarDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ const AvatarToggleDemo = () => {
return (
<Wrapper title="Avatar">
<Flex direction="column" gap={2}>
{isLoaded ? (
<Avatar src="/img/logo.png" alt="avatar" />
) : (
<Avatar src="" alt="" />
)}
<Avatar
src={isLoaded ? "/img/logo.png" : ""}
alt={isLoaded ? "avatar" : ""}
/>
<Button
data-testid="toggle"
variant="ghost"
Expand Down
11 changes: 8 additions & 3 deletions src/components/core/Avatar/Avatar.recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ export const avatarRecipe = defineSlotRecipe({
root: {
height: 10,
width: 10,
m: "-1px",
borderColor: "border.default",
borderRadius: "full",
borderWidth: "1px",
alignItems: "center",
flexShrink: 0,
justifyContent: "center",
},
fallback: {
alignItems: "center",
background: "bg.subtle",
display: "flex",
fontWeight: "semibold",
color: "fg.default",
height: "inherit",
textStyle: "md",
justifyContent: "center",
},
image: {
objectFit: "cover",
Expand Down
10 changes: 5 additions & 5 deletions src/components/core/Avatar/Avatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const AvatarToggle = () => {

return (
<Flex direction="column" gap={2}>
{isLoaded ? (
<Avatar src="/img/logo.png" alt="avatar" />
) : (
<Avatar src="" />
)}
<Avatar
src={isLoaded ? "/img/logo.png" : ""}
alt={isLoaded ? "avatar" : ""}
/>

<Button
data-testid="toggle"
variant="ghost"
Expand Down
17 changes: 7 additions & 10 deletions src/components/core/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
PrimitiveAvatarFallback,
PrimitiveAvatarImage,
} from "components/primitives";
import { panda } from "generated/panda/jsx";
import { avatar } from "generated/panda/recipes";
import { useIsMounted } from "lib/hooks";

Expand Down Expand Up @@ -39,16 +38,14 @@ const Avatar = ({
return (
<PrimitiveAvatar className={classNames.root} {...rest}>
<PrimitiveAvatarFallback className={classNames.fallback}>
<panda.div
height="inherit"
justifyContent="center"
alignItems="center"
display="flex"
>
{fallback}
</panda.div>
{fallback}
</PrimitiveAvatarFallback>
<PrimitiveAvatarImage className={classNames.image} src={src} alt={alt} />
<PrimitiveAvatarImage
objectFit="contain"
className={classNames.image}
src={src}
alt={alt}
/>
</PrimitiveAvatar>
);
};
Expand Down

0 comments on commit 81f884d

Please sign in to comment.