Support elements in icon attribute in IconButton

This makes IconButton more flexible. It also makes icon elements work
when used with leftIcon/rightIcon attributes in AppBar.
old
Antti Ahti 2016-11-02 22:09:18 +02:00
parent ccb396f4d7
commit 62f55cae1e
3 changed files with 3 additions and 1 deletions

View File

@ -65,7 +65,7 @@ const factory = (ripple, FontIcon) => {
}; };
return React.createElement(element, props, return React.createElement(element, props,
icon ? <FontIcon className={theme.icon} value={icon}/> : null, icon ? typeof icon === 'string' ? <FontIcon className={theme.icon} value={icon} /> : icon : null,
children children
); );
} }

View File

@ -23,6 +23,7 @@ const TestButtons = () => (
<Button icon='add' floating /> <Button icon='add' floating />
<Button icon='add' floating accent mini /> <Button icon='add' floating accent mini />
<IconButton icon='favorite' accent /> <IconButton icon='favorite' accent />
<IconButton icon={<GithubIcon />} accent />
<IconButton primary><GithubIcon /></IconButton> <IconButton primary><GithubIcon /></IconButton>
<Button icon='add' label='Add this' flat primary /> <Button icon='add' label='Add this' flat primary />
<Button icon='add' label='Add this' flat disabled /> <Button icon='add' label='Add this' flat disabled />

View File

@ -15,6 +15,7 @@ const ButtonsTest = () => (
<Button icon='add' floating /> <Button icon='add' floating />
<Button icon='add' floating accent mini /> <Button icon='add' floating accent mini />
<IconButton icon='favorite' accent /> <IconButton icon='favorite' accent />
<IconButton icon={<GithubIcon />} accent />
<IconButton primary><GithubIcon /></IconButton> <IconButton primary><GithubIcon /></IconButton>
<Button icon='add' label='Add this' flat primary /> <Button icon='add' label='Add this' flat primary />
<Button icon='add' label='Add this' flat disabled /> <Button icon='add' label='Add this' flat disabled />