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(Avatar): add avatar component #1510

Merged
merged 1 commit into from
Mar 1, 2023
Merged

Conversation

booc0mtaco
Copy link
Contributor

@booc0mtaco booc0mtaco commented Feb 25, 2023

Summary:

  • implement core component
  • add in variants, sizes, and shapes
  • add tests and stories

Test Plan:

  • Wrote automated tests
  • CI tests / new tests are not applicable
  • Manually tested my changes, but I want to keep the details secret
  • Manually tested my changes, and here are the details:
    • Create an alpha publish and try out in edu-stack or traject as a sanity check if changes affect build or deploy, or are breaking, such as token changes, widely used component updates, hooks changes, and major dependency upgrades.

@codecov
Copy link

codecov bot commented Feb 25, 2023

Codecov Report

❗ No coverage uploaded for pull request base (next@84e66a9). Click here to learn what that means.
The diff coverage is 91.89%.

@@           Coverage Diff           @@
##             next    #1510   +/-   ##
=======================================
  Coverage        ?   91.91%           
=======================================
  Files           ?      280           
  Lines           ?     4216           
  Branches        ?      767           
=======================================
  Hits            ?     3875           
  Misses          ?      316           
  Partials        ?       25           
Impacted Files Coverage Δ
src/icons/spritemap.tsx 100.00% <ø> (ø)
src/components/Avatar/Avatar.tsx 88.00% <88.00%> (ø)
src/components/Avatar/Avatar.stories.ts 100.00% <100.00%> (ø)
src/components/Avatar/index.ts 100.00% <100.00%> (ø)
src/index.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link

github-actions bot commented Feb 25, 2023

size-limit report 📦

Path Size
components 121.1 KB (+1.15% 🔺)
styles 3.1 KB (0%)

@booc0mtaco
Copy link
Contributor Author

Pending:

  • a11y fixes
  • play to show focus state
  • discuss with design on the different color variants (to account for dynamic treatment, boring avatars, etc.)

@booc0mtaco booc0mtaco force-pushed the eds-824-create-avatar-component branch 3 times, most recently from 56e7135 to 91dd309 Compare February 27, 2023 23:46
@booc0mtaco booc0mtaco marked this pull request as ready for review February 27, 2023 23:47
@booc0mtaco booc0mtaco requested a review from a team February 27, 2023 23:47
@booc0mtaco booc0mtaco force-pushed the eds-824-create-avatar-component branch 2 times, most recently from faf9d46 to ca1d56c Compare February 28, 2023 00:07
@booc0mtaco booc0mtaco force-pushed the eds-824-create-avatar-component branch 2 times, most recently from 8074a90 to 4904c19 Compare February 28, 2023 00:24
`Avatar for ${!user && 'unknown'} user ${user?.fullName || ''}`;

// when not a button, add some props to allow focus states
const a11yProps = TagName === 'button' ? {} : { role: 'button', tabIndex: 0 };
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the scenario for using a div vs button?

Wondering if this should either be:

  • Always a div, since I don't see an onClick handler or other interaction?
  • Always a button, since we're giving it a button role anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are these two cases:

  • an avatar can appear as an inert component in things like cards, or profiles (where there is no interaction)
  • as an actual button (imagine a profile menu, where clicking the avatar shows a Menu's content below)

Now that I think about it, in the former case it wouldn't need such a role or tab index b/c there's nothing to do ... its essentially an image then. This was initially to ensure focus state was working but should be removed now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ahuth it may be true that it should never be a button, and cases where it is clickable would be wrapped by a button? maybe I should just take this part out for now, and keep it simple

Copy link
Contributor

Choose a reason for hiding this comment

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

I personally think avatar should beinert, and if interactive functionality is needed, it will be wrapped by an appropriate element.
However, this does complicate focus states, but using will assume to better fit target size requirements

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure of the right answer, but maybe it's best to start with the simpler solution. Can add in a button later if we think it's better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jinlee93 @ahuth Agreed. I thought about it some more , and i think what's happening here is actually more like "an avatar can be wrapped by an 'invisible' button" where the button itself has the focus ring instead of the avatar... I'm gonna take this out and let the avatar be more image-like.

There are actually 1-2 other things behaving like this in EDS already, and I've seen this variant in other design systems i've worked on, so i will try some things out in a follow-up

@booc0mtaco booc0mtaco force-pushed the eds-824-create-avatar-component branch 2 times, most recently from ad559ed to ab9fcab Compare February 28, 2023 17:25
Copy link
Contributor

@ahuth ahuth left a comment

Choose a reason for hiding this comment

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

LGTM 🤘

- implement core component
- add in variants, sizes, and shapes
- add in new avatar icon to spritesheet
- specify default aria label
- add tests and stories
- add test for focus state
@booc0mtaco booc0mtaco force-pushed the eds-824-create-avatar-component branch from ab9fcab to a2b97ef Compare March 1, 2023 16:58
@booc0mtaco booc0mtaco merged commit bc21f85 into next Mar 1, 2023
@booc0mtaco booc0mtaco deleted the eds-824-create-avatar-component branch March 1, 2023 19:34
@booc0mtaco booc0mtaco mentioned this pull request Mar 2, 2023
booc0mtaco added a commit that referenced this pull request Mar 2, 2023
## [10.0.0](v9.1.0...v10.0.0) (2023-03-02)


### ⚠ BREAKING CHANGES

* remove data-bootstrap-override EDS-850

### Features

* **Avatar:** add avatar component ([#1510](#1510)) ([bc21f85](bc21f85))
* **slider:** create slider ([#1503](#1503)) ([e7ced34](e7ced34))
* **TextareaField:** add TextArea base component and TextareaField ([#1493](#1493)) ([f2ba31d](f2ba31d))


### Bug Fixes

* remove data-bootstrap-override EDS-850 ([3b5d59b](3b5d59b))
* remove old, outdated, unnecessary snapshot ([fb63a34](fb63a34))
* **Select:** sync label design with form fields ([#1506](#1506)) ([efe9330](efe9330))
* update deps ([9a80e7f](9a80e7f))
* upgrade axe-core from 4.4.3 to 4.6.3 ([af3f9c5](af3f9c5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants