Skip to content

Commit 21e1822

Browse files
committed
Merge pull request mui#4148 from mbrookes/avatar-icon-size
[Avatar] Fix icon size issue for non-default Avatar size
2 parents 014476d + 45b2ea0 commit 21e1822

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

docs/src/app/components/pages/components/Avatar/ExampleSimple.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pink400,
1414
purple500,
1515
} from 'material-ui/styles/colors';
1616

17+
const style = {margin: 5};
18+
1719
const AvatarExampleSimple = () => (
1820
<List>
1921
<ListItem
@@ -24,6 +26,18 @@ const AvatarExampleSimple = () => (
2426
>
2527
Image Avatar
2628
</ListItem>
29+
<ListItem
30+
disabled={true}
31+
leftAvatar={
32+
<Avatar
33+
src="images/uxceo-128.jpg"
34+
size={30}
35+
style={style}
36+
/>
37+
}
38+
>
39+
Image Avatar with custom size
40+
</ListItem>
2741
<ListItem
2842
disabled={true}
2943
leftAvatar={
@@ -39,10 +53,12 @@ const AvatarExampleSimple = () => (
3953
icon={<FontIcon className="muidocs-icon-communication-voicemail" />}
4054
color={blue300}
4155
backgroundColor={indigo900}
56+
size={30}
57+
style={style}
4258
/>
4359
}
4460
>
45-
FontIcon Avatar with custom colors
61+
FontIcon Avatar with custom colors and size
4662
</ListItem>
4763
<ListItem
4864
disabled={true}
@@ -59,10 +75,12 @@ const AvatarExampleSimple = () => (
5975
icon={<FileFolder />}
6076
color={orange200}
6177
backgroundColor={pink400}
78+
size={30}
79+
style={style}
6280
/>
6381
}
6482
>
65-
SvgIcon Avatar with custom colors
83+
SvgIcon Avatar with custom colors and size
6684
</ListItem>
6785
<ListItem
6886
disabled={true}
@@ -76,12 +94,14 @@ const AvatarExampleSimple = () => (
7694
<Avatar
7795
color={deepOrange300}
7896
backgroundColor={purple500}
97+
size={30}
98+
style={style}
7999
>
80100
A
81101
</Avatar>
82102
}
83103
>
84-
Letter Avatar with custom colors
104+
Letter Avatar with custom colors and size
85105
</ListItem>
86106
</List>
87107
);

src/Avatar/Avatar.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ function getStyles(props, context) {
1818
display: 'inline-block',
1919
textAlign: 'center',
2020
lineHeight: `${size}px`,
21-
fontSize: size / 2 + 4,
21+
fontSize: size / 2,
2222
borderRadius: '50%',
2323
height: size,
2424
width: size,
2525
},
2626
icon: {
2727
color: color || avatar.color,
28-
margin: 8,
28+
width: size * 0.6,
29+
height: size * 0.6,
30+
fontSize: size * 0.6,
31+
margin: size * 0.2,
2932
},
3033
};
3134

0 commit comments

Comments
 (0)