Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

fix(avatar): font icons sizing issue #846

Closed
wants to merge 2 commits into from

Conversation

kuzhelov
Copy link
Contributor

@kuzhelov kuzhelov commented Feb 5, 2019

This PR fixes appearance of Icon component when it is provided into image slot of Avatar component (originally reported here #795):

<>
  { /* benchmark */ }
  <Avatar size='largest' ... /> 

  { /* with font-icon-based 'image' slot */ }
  <Avatar
    size='largest'
    image={<Icon size='largest' ... />}
  />
</>

Was

image

Now

image

image

@@ -1,6 +1,10 @@
import { Func } from '../types'

// https://jsperf.com/startdust-callable
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 may safely remove this reference as

  • it is pointing to stale document
  • we have all the necessary tooling now to measure performance on the Stardust's side

Copy link
Member

Choose a reason for hiding this comment

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

Let's remove it 👍


import { sizeToPxValue as avatarSizeToPxValue } from '../Avatar/avatarStyles'

const sizeToIconPaddingInPx: Record<SizeValue, number> = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these values need to be refined

@DustyTheBot
Copy link
Collaborator

Warnings
⚠️ There are no updates provided to CHANGELOG. Ensure there are no publicly visible changes introduced by this PR.

Generated by 🚫 dangerJS

@codecov
Copy link

codecov bot commented Feb 5, 2019

Codecov Report

Merging #846 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #846   +/-   ##
=======================================
  Coverage   93.54%   93.54%           
=======================================
  Files          21       21           
  Lines         728      728           
  Branches       69       73    +4     
=======================================
  Hits          681      681           
  Misses         47       47

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dbe337d...49d892a. Read the comment docs.

@@ -1,8 +1,8 @@
import { pxToRem } from '../../../../lib'
import { ComponentSlotStylesInput, ICSSInJSStyle } from '../../../types'
import { AvatarProps } from '../../../../components/Avatar/Avatar'
import { AvatarProps } from '../../../..'
Copy link
Member

Choose a reason for hiding this comment

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

Can we still use the direct import?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, thanks for catching this thing!


[`&.${Avatar.slotClassNames.image}`]: {
...(isFontBased && getAvatarFontIconStyles(size, v)),
},
Copy link
Member

Choose a reason for hiding this comment

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

Actually, this is a single thing that stops me from the approve button.

I understand why Avatar can know about Icon, because it's a slot of Avatar. But, I want to avoid the reserve coupling because Icon is a primitive component  🤔

@kuzhelov kuzhelov closed this Feb 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants