Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/perky-teeth-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scouterna/ui-webc": major
---

New component Avatar
2 changes: 1 addition & 1 deletion packages/storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ export default defineMain({
},
} satisfies UserConfig);
},
staticDirs: ["../public"],
staticDirs: ["../public", "../../ui-webc/dist/ui-webc/assets"],
});
21 changes: 21 additions & 0 deletions packages/storybook/src/stories/avatar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ScoutAvatar } from "@scouterna/ui-react";
import preview from "#.storybook/preview";

const meta = preview.meta({
title: "Basics/Avatar",
component: ScoutAvatar,
parameters: {
layout: "centered",
},
});

export default meta;

export const BasicExample = meta.story({
args: {},
render: (args) => (
<div style={{ width: "200px" }}>
<ScoutAvatar {...args} />
</div>
),
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions packages/ui-webc/src/components/avatar/avatar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:host {
display: flex;
aspect-ratio: 1 / 1;
}
img {
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

The component claims it “scales to fit container”, but the <img> isn’t styled to fill the host. Without width/height: 100% (and usually object-fit: cover), the image will render at its intrinsic size and may not scale/crop correctly inside the container.

Suggested change
img {
img {
width: 100%;
height: 100%;
object-fit: cover;

Copilot uses AI. Check for mistakes.
border-radius: 50%;
}
47 changes: 47 additions & 0 deletions packages/ui-webc/src/components/avatar/avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {
Component,
type ComponentInterface,
getAssetPath,
h,
Prop,
Comment on lines +4 to +6
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

Minor grammar: “scales to fit container” reads like it’s missing an article. Since this JSDoc is used for generated docs, please fix the wording here (and regenerate) rather than editing the generated readme directly.

Copilot uses AI. Check for mistakes.
} from "@stencil/core";

/**
* The avatar component is used to display the user's profile picture.
* Wrap it with a container, to determine its size, since it scales to fit container.
*/
@Component({
tag: "scout-avatar",
styleUrl: "avatar.css",
shadow: {
delegatesFocus: true,
},
assetsDirs: ["assets"],
})
export class ScoutAvatar implements ComponentInterface {
/**
* The source URL of the user image.
*/
@Prop() imageSrc = "";

/**
* The name of the user.
*/
@Prop() alt = "";

render() {
const getImagePath = () => {
if (this.imageSrc) {
return this.imageSrc;
}
try {
return getAssetPath("assets/fallbackImage.png");
} catch (_e) {
console.info("In storybook, rendering from storybook asset");
return "fallbackImage.png";
}
};

return <img src={getImagePath()} alt={this.alt} />;
}
}
21 changes: 21 additions & 0 deletions packages/ui-webc/src/components/avatar/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# scout-avatar

<!-- Auto Generated Below -->


## Overview

The avatar component is used to display the user's profile picture.
Wrap it with a container, to determine its size, since it scales to fit container.

## Properties

| Property | Attribute | Description | Type | Default |
| ---------- | ----------- | --------------------------------- | -------- | ------- |
| `alt` | `alt` | The name of the user. | `string` | `""` |
| `imageSrc` | `image-src` | The source URL of the user image. | `string` | `""` |


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*