-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add <Avatar> to display an image along with the text #208
Conversation
Fix the proptypes of Avatar
packages/core/src/styles/Avatar.scss
Outdated
// ---------------------- | ||
// Inner image | ||
// ---------------------- | ||
> img { |
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.
You probably need a &
here?
> img { | |
& > img { |
packages/form/src/SelectRow.js
Outdated
* @param {array} fromOptions | ||
* @return {Map} | ||
*/ | ||
function getValueAvatarMap(fromChildren = []) { |
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.
Can this be merged with getValueLabelMap
so we don't need to iterate the Array twice, only for deriving different data?
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.
Nice suggestion. Thanks!
import DebugBox from 'utils/DebugBox'; | ||
|
||
function BasicCheckboxExample() { | ||
const rdAvatar = <Avatar type="square" alt="Avatar of RD" src="https://api.adorable.io/avatars/285/rd@ichef.tw" />; |
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.
Can we change the email here to more generic one, maybe johndoe@example.com
?
@@ -17,6 +17,7 @@ export const TYPE_SYMBOL = Symbol('SelectOption'); | |||
function SelectOption({ | |||
label, | |||
value, | |||
avatar, |
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.
missing type check here?
@zhusee2 The code has been refined. You may take a look at it when you're free 😃 |
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.
LGTM 🥇
Purpose
In our project in development, there is a need to add users' avatars alongside the text of
<ListRow>
,<SelectRow>
, and<SelectOption>
.With this in mind, we add the following three types (square, rounded, and circle) of
<Avatar>
s to display an image along with the text, and change related components to accommodate the avatars.Screenshots
<Avatar>
<ListRow>
<Checkbox>
<SelectRow>
Changes
<Avatar>
rowComp()
to allow the appearance of<Avatar>
alongside the text<SelectRow>
and<Checkbox>
to display<Avatar>
Risks
The change of
rowComp()
allows any components wrapped with it to integrate<Avatar>
on its left. However, since<Avatar>
is an experimental feature in a project, components except<ListRow>
and<SelectRow>
have not been tested and documented.