Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 43 additions & 0 deletions platforms/metagram/src/lib/ui/Avatar/Avatar.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { ComponentProps } from "svelte";
import Avatar from "./Avatar.svelte";

export default {
title: "UI/Avatar",
component: Avatar,
tags: ["autodocs"],
render: (args: {
Component: Avatar;
props: ComponentProps<typeof Avatar>;
}) => ({
Component: Avatar,
props: args,
}),
};

export const Large = {
args: {
src: "https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250",
size: "lg",
},
};

export const Medium = {
args: {
src: "https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250",
size: "md",
},
};

export const Small = {
args: {
src: "https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250",
size: "sm",
},
};

export const ExtraSmall = {
args: {
src: "https://www.gravatar.com/avatar/2c7d99fe281ecd3bcd65ab915bac6dd5?s=250",
size: "xs",
},
};
52 changes: 52 additions & 0 deletions platforms/metagram/src/lib/ui/Avatar/Avatar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<script lang="ts">
import { cn } from "$lib/utils";
import type { HTMLImgAttributes } from "svelte/elements";
interface IAvatarProps extends HTMLImgAttributes {
src: string;
alt?: string;
size?: "xs" | "sm" | "md" | "lg";
}
const {
src,
alt = "User Avatar",
size = "md",
...restProps
}: IAvatarProps = $props();
const sizeVariant = {
xs: "w-6 h-6",
sm: "w-10 h-10",
md: "w-12 h-12",
lg: "w-30 h-30",
};
Comment on lines +18 to +23
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify Tailwind class compatibility for large size variant

The large size variant uses w-30 h-30 classes, but standard Tailwind CSS typically only includes classes up to w-24/h-24 (96px). Ensure these classes are properly defined in your Tailwind configuration, or consider using standard classes like w-[120px] h-[120px] instead.


🏁 Script executed:

#!/bin/bash
# Check if w-30 and h-30 are defined in the Tailwind config
grep -r "w-30\|h-30" platforms/metagram/tailwind.config.*

Length of output: 131


🏁 Script executed:

#!/bin/bash
# Locate Tailwind config files across the repo
configs=$(find . -maxdepth 4 -type f -iname "tailwind.config.*")
echo "Configs found:"
echo "$configs"

for cfg in $configs; do
  echo
  echo "---- Inspecting $cfg ----"
  echo "Checking for custom spacing definitions:"
  grep -R "spacing" -n "$cfg" || echo "  No 'spacing' key found in $cfg"
  echo
  echo "Looking for a '30' spacing entry (e.g., 30: '7.5rem'):"
  grep -R "30\s*:" -n "$cfg" || echo "  No '30:' entry found under spacing in $cfg"
done

if [ -z "$configs" ]; then
  echo "No Tailwind config file detected in the repository."
fi

Length of output: 246


Add custom spacing for 30 or switch to arbitrary values

Tailwind’s default spacing scale doesn’t include a 30 key, and no tailwind.config.* was detected in the repo, so w-30 h-30 won’t be generated out of the box. You can either:

• Extend the spacing scale in your Tailwind config (create one at the repo root if needed):

// tailwind.config.js
module.exports = {
  theme: {
    extend: {
      spacing: {
        30: '7.5rem', // 120px
      },
    },
  },
};

• Or use arbitrary values directly in the component:

--- platforms/metagram/src/lib/ui/Avatar/Avatar.svelte
@@ const sizeVariant = {
-   lg: "w-30 h-30",
+   lg: "w-[120px] h-[120px]",
};

Locations to update:

  • platforms/metagram/src/lib/ui/Avatar/Avatar.svelte (lines 18–23)

const classes = $derived({
common: cn("rounded-full"),
size: sizeVariant[size] || sizeVariant.md,
});
</script>

<img
{...restProps}
{src}
{alt}
class={cn([classes.common, classes.size, restProps.class].join(' '))}
/>

<!--
@component
@name Avatar
@description Avatar component for displaying user profile pictures or icons.
@props
- src: The source URL of the image.
- alt: The alternative text for the image.
- size: The size of the avatar. Can be 'xs', 'sm', 'md', or 'lg'. Default is 'md'.
@usage
<script>
import { Avatar } from "$lib/ui";
</script>
<Avatar src="https://example.com/avatar.jpg" alt="User Avatar" size="lg" />
-->
3 changes: 2 additions & 1 deletion platforms/metagram/src/lib/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as Button } from './Button/Button.svelte';
export { default as Button } from "./Button/Button.svelte";
export { default as Avatar } from "./Avatar/Avatar.svelte";
Loading