Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Avatar Component #40

Merged
merged 7 commits into from
Aug 7, 2024

Conversation

GODrums
Copy link
Collaborator

@GODrums GODrums commented Aug 7, 2024

Description

Add an avatar component with Storybook page.
Fixes #30

Key Changes / Features

  • Uses NgOptimizedImage to optimize performance
  • Supports manual and default fallbacks through an image placeholder
  • Storybook story with random avatar images

Further Resources

Checklist

General

  • PR title is clear and descriptive
  • PR description explains the purpose and changes
  • Code follows project coding standards
  • Self-review of the code has been done
  • Changes have been tested locally
  • Screenshots have been attached (if applicable)

Client (if applicable)

  • UI changes look good on all screen sizes and browsers
  • User experience and accessibility have been tested
  • Added Storybook stories for new components
  • Components follow design system guidelines (if applicable)

Screenshots

image
image

@GODrums GODrums added enhancement New feature or request client size:M This PR changes 30-99 lines, ignoring generated files. labels Aug 7, 2024
@GODrums GODrums added this to the Initial Project Setup milestone Aug 7, 2024
@GODrums GODrums self-assigned this Aug 7, 2024
@GODrums GODrums linked an issue Aug 7, 2024 that may be closed by this pull request
webapp/src/app/ui/avatar/avatar.component.ts Outdated Show resolved Hide resolved
webapp/src/app/ui/avatar/avatar.stories.ts Outdated Show resolved Hide resolved
args: {
size: 'default',
src: 'foobar.jpg',
fallback: 'https://placehold.co/40',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Works for me, I might try to do a follow-up that uses content projection just to see how that works.

Copy link
Collaborator Author

@GODrums GODrums Aug 7, 2024

Choose a reason for hiding this comment

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

The disadvantage of the current approach (variables) vs. child-components is of course that it's not possible to use anything other than image URLs.
Spartan's approach of doubled components with child directives was the only alternative I was able to find.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is possible via contentChild in an app-avatar component and then having app-avatar-image and app-avatar-fallback as children 🤔

webapp/src/app/ui/avatar/avatar.component.ts Outdated Show resolved Hide resolved
webapp/src/app/ui/avatar/avatar.stories.ts Outdated Show resolved Hide resolved

render: (args) => ({
props: args,
template: `<app-avatar ${argsToTemplate(args)}></app-avatar>`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can also define the template shared for all stories somehow if it is the same for all.

@FelixTJDietrich
Copy link
Collaborator

Generally looks good :)

Copy link
Collaborator

@FelixTJDietrich FelixTJDietrich left a comment

Choose a reason for hiding this comment

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

LGTM

@FelixTJDietrich FelixTJDietrich merged commit 7d9131a into develop Aug 7, 2024
2 checks passed
@FelixTJDietrich FelixTJDietrich deleted the 30-webapp-dev-create-avatar-component branch August 7, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Webapp-Dev: Create Avatar Component
2 participants