-
Notifications
You must be signed in to change notification settings - Fork 42
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
<Avatar/>
supports svgs passed to image
prop
#1040
Conversation
…pes of icons (svg, <Icon.iui-svg-icon>, .iui-icon)
There's no benefit. I just thought that since we're allowing users to wrap svgs in
I could reuse the
I included that test since that is how icons are added in avatars in the avatar HTML demo page. Also, the styling in avatar.scss targets |
If there is no benefit, then lets not add the extra complexity. Currently the icon component is coupled to the avatar for no reason.
The class names are considered "implementation detail" for React components. It's totally fine to support them in CSS, but React users are never expected to pass the |
image
prop in favor of child
prop<Avatar/>
supports svgs passed to image
prop
@@ -48,7 +48,7 @@ | |||
font-size: var(--_iui-avatar-font-size); | |||
} | |||
|
|||
> .iui-icon { | |||
svg { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this considered a breaking change for our CSS pkg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, right, it looks like a breaking change. It also breaks the avatar demo html page.
I auto-committed the suggestion (#1040 (comment)), but I think it needs some editing. Will look into it more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be alright? This keeps the html demos the same, is not a breaking change, and also targets svgs without .iui-icon
which is likely how icons are passed on the react side.
svg { | |
> .iui-icon, > svg { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like you need to add these three lines to fix the positioning
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
and then the wrapping section would need display: flex; align-items: end
alternatively, display: grid
could be used instead of position: absolute
to center the svg. I think this would avoid the need to set styles on the wrapper.
i do not think it would be a breaking change because anyone using iui-icon
will be unaffected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the first option you mentioned worked. Now targeting the avatar's svg
instead of > .iui-icon
(7a2f509
(#1040))
…n/iTwinUI into rohan/avatar-react-pass-svg
…n/iTwinUI into rohan/avatar-react-pass-svg
…n/iTwinUI into rohan/avatar-react-pass-svg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just need @FlyersPh9's help to find a new default color (#1040 (comment))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go once this change is made.
Changes
Avatar's
image
prop can now accept<svg>
children and display it correctly.Testing
Added a unit test to confirm svgs passed to the
image
prop is included in the dom. Added aWith Icon
story and tested the the svg displays properly with the background color.Docs
Added a changeset
TODOs