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

fix(Avatar, Image): fixing fluid prop in Image and applying it in the Avatar component #77

Merged
merged 7 commits into from
Aug 10, 2018

Conversation

mnajdova
Copy link
Contributor

@mnajdova mnajdova commented Aug 9, 2018

Image

Applying the fluid prop to the avatar variations for the image.

Avatar

Using the fluid prop for the image component.

TODO

  • Conformance test
  • Minimal doc site example
  • Stardust base theme
  • Teams Light theme
  • Teams Dark theme
  • Teams Contrast theme
  • Confirm RTL usage
  • W3 accessibility check
  • Stardust accessibility check
  • Update glossary props table
  • Update the CHANGELOG.md

@codecov
Copy link

codecov bot commented Aug 9, 2018

Codecov Report

Merging #77 into master will decrease coverage by 0.07%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #77      +/-   ##
==========================================
- Coverage   85.97%   85.89%   -0.08%     
==========================================
  Files          76       76              
  Lines        1112     1113       +1     
  Branches      219      220       +1     
==========================================
  Hits          956      956              
- Misses        149      150       +1     
  Partials        7        7
Impacted Files Coverage Δ
src/components/Avatar/Avatar.tsx 92.1% <0%> (ø) ⬆️
src/themes/teams/components/Avatar/avatarStyles.ts 82.75% <100%> (ø) ⬆️
src/themes/teams/components/Image/imageStyles.ts 87.5% <50%> (-12.5%) ⬇️

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 a0f46e3...b2064fd. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 9, 2018

Codecov Report

Merging #77 into master will not change coverage.
The diff coverage is 75%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #77   +/-   ##
=======================================
  Coverage   86.29%   86.29%           
=======================================
  Files          39       39           
  Lines         664      664           
  Branches       99       99           
=======================================
  Hits          573      573           
  Misses         88       88           
  Partials        3        3
Impacted Files Coverage Δ
src/components/Icon/Icon.tsx 79.16% <ø> (ø) ⬆️
src/components/Image/Image.tsx 100% <100%> (ø) ⬆️
src/components/Avatar/Avatar.tsx 91.17% <66.66%> (ø) ⬆️

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 e345edf...f70e936. Read the comment docs.

@@ -4,11 +4,11 @@ export default {
root: ({ props, variables }) => ({
display: 'inline-block',
verticalAlign: 'middle',
width: variables.width || (props.fluid && '100%'),
Copy link
Contributor

@kuzhelov kuzhelov Aug 9, 2018

Choose a reason for hiding this comment

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

this, actually, imposes other problem. Variables are more specific than props (in terms of the styling aspects targeting), so for the following case where conflicting things are requested

<Image fluid variables={{ width: '100px' }} />

the result should be that Image will have 100px width. Essentially, the following principle should be preserved: more specific customization option should always win. With the proposed change it won't be the case anymore.

Copy link
Contributor Author

@mnajdova mnajdova Aug 9, 2018

Choose a reason for hiding this comment

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

I agree for the width, will change it, but for the avatar then we must provide something like variables.avatarSize || (props.fluid && '100%') || pxToRem(32)' and we can have that variable to be undefined by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After discussing, the decision was to have the prop be the first statement in the condition, because otherwise if the theme is specifying the default width, the fluid prop will never be correctly applied.

imageAvatar: ({ props: { size } }) => ({
width: pxToRem(getAvatarDimension(size)),
height: pxToRem(getAvatarDimension(size)),
imageAvatar: () => ({
verticalAlign: 'top !important',
Copy link
Member

Choose a reason for hiding this comment

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

😕 hmmm, let's not use important if we can avoid it. Betting this was copied cruft from SUIR? Let's try removing it please.

@kuzhelov
Copy link
Contributor

currently variables are passed down the tree by Avatar component - we should prevent it to happen by introducing them to handledProps set. The same story applies to 'styles'.

image

On a long-term, we should ensure that this is not happening by means of conformance tests (something that we've already discussed) - let me, please, take care of tests for this.

Copy link
Contributor

@kuzhelov kuzhelov left a comment

Choose a reason for hiding this comment

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

please, mark 'styles' and 'variables' as handled props - and we are good to go 👍

@mnajdova mnajdova merged commit de2cff1 into master Aug 10, 2018
@kuzhelov kuzhelov deleted the fix/avatar-image-size branch August 29, 2018 21:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants