Skip to content

Commit 273959a

Browse files
committed
fix(ListIcon): Icon color is now themed
1 parent c994d49 commit 273959a

File tree

2 files changed

+44
-9
lines changed

2 files changed

+44
-9
lines changed

src/components/ListIcon/ListIcon.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
import { Icon, ListIconDefaultProps, ListIconProps, } from '@bluebase/components';
1+
import { Icon, ListIconDefaultProps, ListIconProps } from '@bluebase/components';
2+
23
import ListItemIcon from '@material-ui/core/ListItemIcon';
34
import React from 'react';
5+
import { Theme } from '@bluebase/core';
6+
7+
export interface Props extends ListIconProps {
8+
styles?: Partial<{
9+
color: string;
10+
}>;
11+
}
412

5-
export const ListIcon = (props: ListIconProps) => (
13+
export const ListIcon = ({ styles = {}, ...rest }: Props) => (
614
<ListItemIcon>
7-
<Icon {...props} />
15+
<Icon color={styles.color} {...rest} />
816
</ListItemIcon>
917
);
1018

11-
ListIcon.defaultProps = ListIconDefaultProps;
19+
ListIcon.defaultProps = ListIconDefaultProps;
20+
21+
ListIcon.defaultStyles = (theme: Theme) => ({
22+
color: theme.palette.action.active,
23+
});
Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { BlueBaseApp } from '@bluebase/core';
2-
import { ListIcon } from '../ListIcon';
3-
import Plugin from '../../../';
1+
import { BlueBaseApp, getComponent } from '@bluebase/core';
2+
3+
import Plugin from '../../..';
44
import React from 'react';
55
import { mount } from 'enzyme';
66
import { waitForElement } from 'enzyme-async-helpers';
77

8-
describe('ListIcon', () => {
8+
const ListIcon = getComponent('ListIcon');
99

10+
describe('ListIcon', () => {
1011
test('should forward title prop as primary', async () => {
1112
const component = mount(
1213
<BlueBaseApp plugins={[Plugin]}>
@@ -16,7 +17,29 @@ describe('ListIcon', () => {
1617

1718
await waitForElement(component, ListIcon);
1819

19-
expect(component.find('Icon').first().prop('name')).toBe('inbox');
20+
expect(
21+
component
22+
.find('Icon')
23+
.first()
24+
.prop('name')
25+
).toBe('inbox');
2026
});
2127

28+
test('should not crash if improted directly', async () => {
29+
const Component = require('../ListIcon').ListIcon;
30+
const component = mount(
31+
<BlueBaseApp plugins={[Plugin]}>
32+
<Component name="inbox" />
33+
</BlueBaseApp>
34+
);
35+
36+
await waitForElement(component, Component);
37+
38+
expect(
39+
component
40+
.find('Icon')
41+
.first()
42+
.prop('name')
43+
).toBe('inbox');
44+
});
2245
});

0 commit comments

Comments
 (0)