Sorry, but you either have no stories or none are selected somehow.
If the problem persists, check the browser console, or the terminal you've run Storybook from.
The component failed to render properly, likely due to a configuration issue in Storybook. Here are some common causes and how you can address them:
This is a pre-release version and is not production ready. For new and ongoing projects, please refer to the latest Design System version.
Display a user's profile picture or their initials if the picture is unavailable.
next.design-system.post.ch/?path=/docs/09aac03d-220e-4885-8fb8-1cfa01add188--docs&story=Default#09aac03d-220e-4885-8fb8-1cfa01add188--default
/?path=/story/09aac03d-220e-4885-8fb8-1cfa01add188--default&full=true
<post-avatar firstname="Firstname"></post-avatar>
Name | Description | Default | Control |
---|---|---|---|
props | |||
firstname* | Defines the users firstname. string | ||
lastname | Defines the users lastname. string | ||
userid | Defines the company internal userId. string | ||
Defines the users email address associated with a gravatar profile picture. string | |||
Content | |||
imageSrc | Define an image src to insert a custom image.string | - | |
slots | |||
default | Slot for inserting a custom image as avatar. HTMLImageElement | - | - |
Nest the <post-avatar>
component inside an anchor tag to make it clickable.
Use this approach to create a link to the user profile.
<a href="#"><post-avatar firstname="Firstname"></post-avatar></a>
Nest the <post-avatar>
component inside a button tag to make it clickable.
Use this approach to use the component as a menu toggler, ...
<button><post-avatar firstname="Firstname"></post-avatar></button>
The component provides some css-variables, which allow you to switch the background and the foreground color if needed.
post-avatar { --post-avatar-bg: {your-custom-bg-color}; --post-avatar-fg: {your-custom-fg-color}; }
The <post-avatar>
component provides several possibilities to change its appearance. While the only required property is firstname
, you can choose freely, which of the other properties you want to use. You can even combine them. The component will always try to show a picture, if possible, and fallback to initials, if not.
Please notice, that if you combine several methods to show a picture, the component will use the first one it can get a picture from.
The properties are used in the order as follows:
<img>
tag in the default slot (for example to show a self hosted image), this will override the other properties.userid
property (to show a company internal user picture) and a picture is available, this will override the email
property, as well as firstname
and lastname
.email
property (to show a users picture provided through gravatar.com) and a picture is available, this will override the firstname
and lastname
properties.firstname
and lastname
properties are used to show at least some initials. And as an addition, firstname
and lastname
(if defined) are also used on all the other methods to set the alt
tag of the image (if not already defined).If your project includes the Content-Security-Policy response header (usually in index.html
),
make sure that default-src
is set to 'self'
. The <post-avatar>
component is capable of loading images from gravatar, therefore you need to add https://gravatar.com
to the connect-src
in index.html. This is because the component tries to load a profile picture from there, through the provided email
property.