Skip to content

Commit

Permalink
feat(Icon): support polygon
Browse files Browse the repository at this point in the history
  • Loading branch information
asudoh committed Oct 16, 2018
1 parent c44df79 commit 535b572
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/Icon/Icon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ describe('Icon', () => {
expect(content.length).toBeGreaterThan(0);
expect(content).toEqual(['']);
});

it('takes care of polygons', () => {
const svgData = {
polygons: [
{
points: 'POINT',
},
],
};
expect(
svgShapes(svgData).map(item =>
item.map(({ type, key, props }) => ({ type, key, props }))
)
).toEqual([
[{ type: 'polygon', key: 'key0', props: { points: 'POINT' } }],
]);
});
});

describe('isPrefixed', () => {
Expand Down
4 changes: 4 additions & 0 deletions src/components/Icon/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export function svgShapes(svgData) {
return data.map((path, index) => (
<path d={path.d} key={`key${index}`} />
));
} else if (svgProp === 'polygons') {
return data.map((polygon, index) => (
<polygon points={polygon.points} key={`key${index}`} />
));
}

return '';
Expand Down

0 comments on commit 535b572

Please sign in to comment.