Skip to content

Commit f9645a7

Browse files
author
Giacomo Rebonato
committed
Pass className to <Icon />
1 parent 92110f1 commit f9645a7

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

packages/buttons/src/views/icon-button/Icon.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ import ButtonStyles from '@zendeskgarden/css-buttons';
1212

1313
const COMPONENT_ID = 'buttons.icon';
1414

15-
const Icon = ({ children, rotated }) => {
15+
const Icon = ({ children, className, rotated }) => {
1616
return React.cloneElement(Children.only(children), {
1717
'data-garden-id': COMPONENT_ID,
1818
'data-garden-version': PACKAGE_VERSION,
19-
className: classNames(ButtonStyles['c-btn__icon'], {
20-
[ButtonStyles['is-rotated']]: rotated
21-
})
19+
className: classNames(
20+
ButtonStyles['c-btn__icon'],
21+
{
22+
[ButtonStyles['is-rotated']]: rotated
23+
},
24+
className
25+
)
2226
});
2327
};
2428

packages/buttons/src/views/icon-button/Icon.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,14 @@ describe('Icon', () => {
2929

3030
expect(container.firstChild).toHaveClass('is-rotated');
3131
});
32+
33+
it('passes className prop', () => {
34+
const { container } = render(
35+
<Icon className="test">
36+
<svg />
37+
</Icon>
38+
);
39+
40+
expect(container.firstChild.classList[1]).toBe('test');
41+
});
3242
});

0 commit comments

Comments
 (0)