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): Support overriding the Avatar img element. Fixes #482 #483

Merged
merged 1 commit into from
Dec 11, 2022

Conversation

alexanderson1993
Copy link
Contributor

@alexanderson1993 alexanderson1993 commented Dec 9, 2022

Description

Changes the Avatar img prop to either be a string or a render prop that returns a React element. That makes it so any of the props can be overridden, or an entirely different element could be used in its place.

The docs site doesn't support the render prop syntax by default, so I added a small extension that allows the docs pages to provide a rawCode property which is passed directly to the syntax highlighter instead of generating the code sample from the code JSX.

Fixes #482

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change contains documentation update

How Has This Been Tested?

  • Automated test that renders using the new render props and checks to see if a special attribute is included on the rendered element.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

It accomplishes this by changing the `img` prop to either be a
string or a render prop that returns a React element.
That makes it so any of the props can be overridden, or an entirely
different element could be used in its place.

The docs site doesn't support the render prop syntax by default, so I
added a small extension that allows the docs pages to provide a
`rawCode` property which is passed directly to the syntax highlighter
instead of generating the code sample from the `code` JSX.

Includes a new passing test and a Storybook example.
@codecov
Copy link

codecov bot commented Dec 9, 2022

Codecov Report

Base: 97.36% // Head: 97.37% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (28665de) compared to base (765fedb).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #483   +/-   ##
=======================================
  Coverage   97.36%   97.37%           
=======================================
  Files         127      127           
  Lines        5358     5364    +6     
  Branches      441      443    +2     
=======================================
+ Hits         5217     5223    +6     
  Misses        141      141           
Impacted Files Coverage Δ
src/lib/components/Avatar/Avatar.tsx 98.52% <100.00%> (+0.06%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@tulup-conner
Copy link
Collaborator

LGTM, I think the logic in this component is getting a bit complicated to read but I don't know how to fix that at all.

@rluders rluders merged commit 8f87019 into themesberg:main Dec 11, 2022
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.

Allow the <img> component in <Avatar> to be overridden by the user
3 participants