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

feat: adding avatar base component to design system react #390

Merged
merged 7 commits into from
Feb 4, 2025

Conversation

georgewrmarshall
Copy link
Contributor

@georgewrmarshall georgewrmarshall commented Jan 30, 2025

Description

This PR adds the initial AvatarBase component to design system react.

Key features:

  1. Five size variants: xs (16px), sm (24px), md (32px), lg (40px), and xl (48px)
  2. Support for different content types: text, images, and icons
  3. Customizable styling through className prop using Tailwind classes
  4. Built-in accessibility features through Radix UI's Slot primitive
  5. Comprehensive test coverage and Storybook documentation

Related issues

Fixes: #359

Manual testing steps

  1. Run Storybook locally (yarn storybook)
  2. Navigate to React Components/AvatarBase
  3. Check the docs align with component and make sense
  4. Verify controls work

Screenshots/Recordings

Before

N/A - New component

After

after720.mov

Pre-merge author checklist

  • I've followed MetaMask Contributor Docs
  • I've completed the PR template to the best of my ability
  • I've included tests (unit tests and Storybook stories)
  • I've documented my code using JSDoc format
  • I've applied the right labels on the PR

Pre-merge reviewer checklist

  • I've manually tested the PR
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@georgewrmarshall georgewrmarshall marked this pull request as ready for review January 30, 2025 21:42
@georgewrmarshall georgewrmarshall requested a review from a team as a code owner January 30, 2025 21:42
Copy link
Contributor

@brianacnguyen brianacnguyen left a comment

Choose a reason for hiding this comment

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

Let's not merge these until design is ready

@georgewrmarshall georgewrmarshall force-pushed the feat/359/avatar-base branch 3 times, most recently from 52d19f3 to aa4022a Compare February 3, 2025 19:42
Comment on lines +45 to +53
<Text
variant={AVATAR_BASE_SIZE_TO_TEXT_VARIANT_MAP[size]}
fontWeight={FontWeight.Bold}
asChild
{...fallbackTextProps}
>
{/* asChild prop renders Text component as a span, it does not create an additional element */}
<span>{fallbackText}</span>
</Text>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are still waiting on design for full confirmation of fallback ticket created here: #411

@georgewrmarshall georgewrmarshall merged commit 4812f88 into main Feb 4, 2025
30 checks passed
@georgewrmarshall georgewrmarshall deleted the feat/359/avatar-base branch February 4, 2025 16:16
brianacnguyen pushed a commit that referenced this pull request Feb 5, 2025
Has a dependency on `AvatarBase`
#390

## **Description**

This PR adds the new AvatarToken component to design system react

Key features:
- Displays token logos with consistent sizing and styling
- Provides fallback text display when images are unavailable
- Supports multiple size variants
- Built on top of the AvatarBase component
- Fully tested and documented

## **Related issues**

Fixes: #364

## **Manual testing steps**

1. Run Storybook (`yarn storybook`)
2. Navigate to React Components/AvatarToken
3. Test different component variations:
   - With and without images
   - Different sizes
   - Fallback text behavior
   - Custom className application
4. Verify responsive behavior and image handling
5. Check accessibility features (alt text, etc.)

## **Screenshots/Recordings**

### **Before**
N/A (New component)

### **After**


https://github.com/user-attachments/assets/81103ad2-7124-4971-92fb-fdb799ecac9f


## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs)
- [x] I've completed the PR template to the best of my ability
- [x] I've included comprehensive tests for the AvatarToken component
- [x] I've documented the code using [JSDoc](https://jsdoc.app/) format
- [x] I've applied the right labels on the PR
- [x] I've ensured the component meets accessibility standards

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR in Storybook
- [ ] I confirm that this PR addresses all acceptance criteria for the
AvatarToken component
- [ ] I've verified the component works correctly with and without
images
- [ ] I've checked that the component integrates properly with the
existing design system
brianacnguyen pushed a commit that referenced this pull request Feb 5, 2025
Has a dependency on `AvatarBase`
#390

## **Description**

This PR adds a new `AvatarFavicon` component to the design system. 

Key features:
- Displays dapp favicon/logo images with consistent sizing and styling
- Provides text fallback when image is not available (uses first letter
of name or custom fallback text)
- Supports multiple sizes (xs, sm, md, lg, xl) with appropriate text
scaling
- Handles alt text and accessibility concerns
- Allows customization of both image and fallback text properties

## **Related issues**

Fixes: #368

## **Manual testing steps**

1. Run storybook (`yarn storybook`)
2. Navigate to React Components/AvatarFavicon
3. Test different component configurations:
   - With and without image source
   - Different sizes
   - Custom fallback text
   - Custom styling via className and props

## **Screenshots/Recordings**

### **Before**
N/A - New component

### **After**


https://github.com/user-attachments/assets/fca9b112-d0f3-454d-baa0-b3ef8e953e1a

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs)
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests for the new AvatarFavicon component
- [x] I've documented the code using [JSDoc](https://jsdoc.app/) format
- [x] I've applied the right labels on the PR

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run
storybook, test AvatarFavicon component)
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[React]: Create AvatarBase component in shared UI component library
2 participants