Skip to content

Commit 1e82bb0

Browse files
committed
fix(conflicts): fixed conflicts of component
2 parents afe6cca + b4845c4 commit 1e82bb0

File tree

22 files changed

+446
-246
lines changed

22 files changed

+446
-246
lines changed

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
"config": {},
1313
"size-limit": [
1414
{
15+
<<<<<<< HEAD
1516
"limit": "40 KB",
17+
=======
18+
"limit": "36 KB",
19+
>>>>>>> b4845c46416a6db3ed1ea5a46f75eb1146ec4cff
1620
"webpack": false,
1721
"path": "dist/**/!(*.test).js"
1822
}
@@ -75,7 +79,7 @@
7579
},
7680
"dependencies": {
7781
"@bluebase/component-mapper": "^1.4.0",
78-
"@bluebase/components": "^5.5.1",
82+
"@bluebase/components": "^5.6.0",
7983
"@material-ui/core": "^3.9.3",
8084
"@material-ui/lab": "^3.0.0-alpha.30",
8185
"deepmerge": "^3.2.0",
@@ -156,4 +160,4 @@
156160
"publishConfig": {
157161
"access": "public"
158162
}
159-
}
163+
}

src/components/Badge/Badge.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// import { Badge as RNPBadge } from 'react-native-paper';
2+
import { BadgeDefaultProps, BadgeProps } from '@bluebase/components';
3+
import MUIBadge from '@material-ui/core/Badge';
4+
import { componentMapper } from '@bluebase/component-mapper';
5+
export const Badge = componentMapper<BadgeProps>(
6+
MUIBadge,
7+
{
8+
badgeContent: ({ children }: any) => children,
9+
color: () => {
10+
return 'error';
11+
},
12+
},
13+
{ rest: true, ignore: ['children'] }
14+
);
15+
Badge.defaultProps = BadgeDefaultProps;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {
2+
// Icon,
3+
Badge,
4+
// BadgeProps,
5+
} from '@bluebase/components';
6+
// import { getComponent } from '@bluebase/core';
7+
import storiesOf from '@bluebase/storybook-addon';
8+
import { withInfo } from '@storybook/addon-info';
9+
import { withKnobs } from '@storybook/addon-knobs';
10+
import React from 'react';
11+
12+
const stories = storiesOf('Badge', module);
13+
stories.addDecorator(withInfo);
14+
stories.addDecorator(withKnobs);
15+
// const Badge = getComponent<BadgeProps>('Badge');
16+
// const Icons: any = Icon;
17+
// stories.add('Contained Badge', () => (
18+
// <Badge>
19+
// <Icon name="star" size={20} color="red" />
20+
// </Badge>
21+
// ))
22+
stories.add('Contained Badge with number prop', () => (
23+
<Badge>
24+
4
25+
</Badge>
26+
))
27+
stories.add('With out child', () => (
28+
<Badge/>
29+
))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Badge } from '../Badge';
2+
import React from 'react';
3+
import { shallow } from 'enzyme';
4+
5+
test('Badge component with visible Prop', () => {
6+
const component = shallow(
7+
<Badge visible = {false}/>
8+
);
9+
// expect(component).toMatchSnapshot();
10+
expect(component.props().visible).toEqual(false);
11+
});
12+
13+
// test('Badge component with Children', () => {
14+
// const component = shallow(
15+
// <Badge>
16+
// <Text></Text>
17+
// </Badge>
18+
// );
19+
// console.log(component.children());
20+
// // expect(component).toMatchSnapshot();
21+
// expect(component.children()).toEqual(5);
22+
// });

src/components/Badge/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Badge';

src/components/BottomNavigation/__stories__/BottomNavigation.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ stories
2323
<BottomNavigation value={1} onChange={(_e, i) => console.log(`Clicked tab ${i}`)} >
2424
<BottomNavigationAction
2525
label="Item One"
26-
icon={{ type: 'image', size: 20, source: { uri: 'https://placeimg.com/100/100/any' } }}
26+
icon={{ type: 'icon', name: 'star' }}
2727
/>
2828
<BottomNavigationAction
2929
label="Item Two"
30-
icon={{ type: 'image', size: 20, source: { uri: 'https://placeimg.com/100/100/any' } }}
30+
icon={{ type: 'icon', name: 'favorite' }}
3131
/>
3232
<BottomNavigationAction
3333
label="Item Three"
34-
icon={{ type: 'image', size: 20, source: { uri: 'https://placeimg.com/100/100/any' } }}
34+
icon={{ type: 'icon', name: 'help' }}
3535
/>
3636
</BottomNavigation>
3737
))

src/components/BottomNavigationAction/BottomNavigationAction.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,25 @@ import React from 'react';
44
import { componentMapper } from '@bluebase/component-mapper';
55

66
export const BottomNavigationAction = componentMapper<BottomNavigationActionProps>(MuiBottomNavigationAction, {
7-
icon: ({ icon }) => icon ? React.createElement(DynamicIcon, icon) : undefined
7+
icon: ({ icon }) => {
8+
9+
if (!icon) {
10+
return;
11+
}
12+
13+
const size = icon.size || 24;
14+
15+
const props = {
16+
size,
17+
style: {
18+
lineHeight: size,
19+
...icon.style,
20+
},
21+
...icon,
22+
};
23+
24+
return React.createElement(DynamicIcon, props);
25+
}
826
}, {
927
rest: true
1028
});

src/components/DrawerItem/DrawerItem.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
import { DrawerItemProps, IconProps } from '@bluebase/components';
2-
import ListItemIcon from '@material-ui/core/ListItemIcon';
1+
import { DrawerItemProps, List } from '@bluebase/components';
32
import ListItemText from '@material-ui/core/ListItemText';
43
import MUIListItem from '@material-ui/core/ListItem';
54
import React from 'react';
6-
import { getComponent } from '@bluebase/core';
75

86
export const DrawerItem = (props: DrawerItemProps) => {
97

108
const { active, disabled, icon, onPress, right, title } = props;
11-
const Icon = getComponent<IconProps>('Icon', 'Noop');
129

1310
return (
1411
<MUIListItem button={!!onPress} disabled={disabled} selected={active} onClick={onPress}>
15-
{icon ? <ListItemIcon><Icon {...icon} /></ListItemIcon> : null}
12+
{icon ? <List.Icon size={24} {...icon} /> : null}
1613
{(title) ? <ListItemText inset={!!icon} primary={title} /> : null}
1714
{right}
1815
</MUIListItem>

src/components/DrawerItem/__stories__/DrawerItem.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ stories.add('Default props', () => (
1818
));
1919

2020
stories.add('With Icon', () => (
21-
<DrawerItem title="Item 1" icon={{ name: 'rocket' }} />
21+
<DrawerItem title="Item 1" icon={{ name: 'favorite' }} />
2222
));
2323

2424
stories.add('onPress listener', () => (
25-
<DrawerItem title="Click Me" onPress={action('drawer-item-click')} />
25+
<DrawerItem title="Click Me" icon={{ name: 'favorite' }} onPress={action('drawer-item-click')} />
2626
));
2727

2828
stories.add('Active', () => (

src/components/DrawerItem/__tests__/DrawerItem.test.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,29 @@ describe('DrawerItem', () => {
99
const component = shallow(
1010
<DrawerItem title="Item 1" />
1111
);
12-
expect(component.childAt(0).props().primary).toEqual('Item 1');
13-
expect(component.childAt(0).props().inset).toEqual(false);
12+
// expect(component).toMatchSnapshot();
13+
14+
expect(component.props().children[1].props.primary).toEqual('Item 1');
15+
expect(component.props().children[1].props.inset).toEqual(false);
1416
});
1517

1618
test('should forward left and right as children, set inset to true', () => {
1719
const component = shallow(
1820
<DrawerItem title="Item 1" icon={{ name: 'rocket' }} right={<Text>R</Text>} />
19-
);
20-
// expect(component).toMatchSnapshot();
21-
expect(component.childAt(0).childAt(0).props().name).toBe('rocket');
22-
expect(component.childAt(1).props().inset).toEqual(true);
23-
expect(component.childAt(2).childAt(0).text()).toEqual('R');
21+
);
22+
23+
expect(component.props().children[0].props.name).toBe('rocket');
24+
expect(component.props().children[1].props.inset).toEqual(true);
25+
expect(component.props().children[2].props.children).toEqual('R');
2426
});
2527

2628
test('should not render anything in main area if no title or description', () => {
2729
const component = shallow(
2830
<DrawerItem title={null as any} icon={{ name: 'rocket' }} right={<Text>R</Text>} />
2931
);
3032
// expect(component).toMatchSnapshot();
31-
expect(component.childAt(0).childAt(0).props().name).toBe('rocket');
32-
expect(component.childAt(1).childAt(0).text()).toEqual('R');
33+
expect(component.props().children[0].props.name).toBe('rocket');
34+
expect(component.props().children[2].props.children).toEqual('R');
3335
});
3436

3537
});

0 commit comments

Comments
 (0)