Skip to content

Commit d32d727

Browse files
authored
v0.1.8
2 parents 22d7810 + 5cbdde7 commit d32d727

File tree

14 files changed

+200
-36
lines changed

14 files changed

+200
-36
lines changed

.svgrrc

Lines changed: 0 additions & 15 deletions
This file was deleted.

.svgrrc.js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
const svgElements = [
2+
'a',,
3+
'animate',
4+
'animateMotion',
5+
'animateTransform',
6+
'audio',
7+
'canvas',
8+
'circle',
9+
'clipPath',
10+
'defs',
11+
'desc',
12+
'discard',
13+
'ellipse',
14+
'feBlend',
15+
'feColorMatrix',
16+
'feComponentTransfer',
17+
'feComposite',
18+
'feConvolveMatrix',
19+
'feDiffuseLighting',
20+
'feDisplacementMap',
21+
'feDistantLight',
22+
'feDropShadow',
23+
'feFlood',
24+
'feFuncA',
25+
'feFuncB',
26+
'feFuncG',
27+
'feFuncR',
28+
'feGaussianBlur',
29+
'feImage',
30+
'feMerge',
31+
'feMergeNode',
32+
'feMorphology',
33+
'feOffset',
34+
'fePointLight',
35+
'feSpecularLighting',
36+
'feSpotLight',
37+
'feTile',
38+
'feTurbulence',
39+
'filter',
40+
'foreignObject',
41+
'g',
42+
'iframe',
43+
'image',
44+
'line',
45+
'linearGradient',
46+
'marker',
47+
'mask',
48+
'metadata',
49+
'mpath',
50+
'path',
51+
'pattern',
52+
'polygon',
53+
'polyline',
54+
'radialGradient',
55+
'rect',
56+
'script',
57+
'set',
58+
'stop',
59+
'style',
60+
'switch',
61+
'symbol',
62+
'text',
63+
'textPath',
64+
'title',
65+
'tspan',
66+
'unknown',
67+
'use',
68+
'video',
69+
'view',
70+
]
71+
72+
module.exports = {
73+
"icon": true,
74+
"typescript": true,
75+
"singleQuote": true,
76+
"prettier": true,
77+
"prettierConfig": {
78+
"dimensions": false,
79+
"semi": false,
80+
"endOfLine": "lf",
81+
"singleQuote": true
82+
},
83+
"jsx": {
84+
babelConfig: {
85+
plugins: [
86+
[
87+
'@svgr/babel-plugin-remove-jsx-attribute',
88+
{
89+
elements: svgElements,
90+
attributes: ['fill'],
91+
},
92+
],
93+
[
94+
'@svgr/babel-plugin-add-jsx-attribute',
95+
{
96+
elements: svgElements,
97+
attributes: [
98+
{
99+
name: 'fill',
100+
value: 'currentColor',
101+
position: 'start',
102+
}
103+
],
104+
}
105+
]
106+
],
107+
},
108+
}
109+
}

package-lock.json

Lines changed: 21 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@channel.io/design-system",
3-
"version": "0.1.7",
3+
"version": "0.1.8",
44
"description": "Design System by Channel",
55
"repository": {
66
"type": "git",
@@ -64,6 +64,8 @@
6464
"@storybook/addon-knobs": "^5.3.19",
6565
"@storybook/react": "^5.3.18",
6666
"@storybook/storybook-deployer": "^2.8.6",
67+
"@svgr/babel-plugin-add-jsx-attribute": "^5.4.0",
68+
"@svgr/babel-plugin-remove-jsx-attribute": "^5.4.0",
6769
"@svgr/cli": "^5.4.0",
6870
"@testing-library/jest-dom": "^5.5.0",
6971
"@testing-library/react": "^10.0.4",

src/components/Icon/Icon.test.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* External dependencies */
2+
import React from 'react'
3+
import { render } from '@testing-library/react'
4+
5+
/* Internal dependencies */
6+
import Icon, { ICON_TEST_ID } from './Icon'
7+
import IconProps from './Icon.types'
8+
9+
describe('Icon test >', () => {
10+
let props: IconProps
11+
12+
beforeEach(() => {
13+
props = {
14+
name: 'all',
15+
}
16+
})
17+
18+
const renderIcon = (optionProps?: IconProps) => render(<Icon {...props} {...optionProps}/>)
19+
20+
it('Icon inherits fill color', () => {
21+
const { getByTestId } = renderIcon()
22+
23+
const renderedIcon = getByTestId(ICON_TEST_ID)
24+
25+
expect(renderedIcon).toHaveStyle('color: inherit;')
26+
})
27+
28+
it('Icon receives custom color', () => {
29+
const { getByTestId } = renderIcon({ name: 'all', color: 'rgb(20, 30, 50)' })
30+
31+
const renderedIcon = getByTestId(ICON_TEST_ID)
32+
33+
expect(renderedIcon).toHaveStyle('color: rgb(20, 30, 50);')
34+
})
35+
})

src/components/Icon/Icon.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
/* External dependencies */
22
import React, { memo } from 'react'
3+
import _ from 'lodash'
34

45
/* Internal dependencies */
56
import IconProps, { IconSize } from './Icon.types'
67
import icons from './generated'
78
import Styled from './Icon.styled'
89

10+
export const ICON_TEST_ID = 'ch-design-system-icon'
11+
912
function Icon({
1013
className,
1114
style,
1215
name,
1316
color,
17+
testId = ICON_TEST_ID,
1418
size = IconSize.Normal,
1519
marginTop = 0,
1620
marginRight = 0,
1721
marginBottom = 0,
1822
marginLeft = 0,
1923
}: IconProps) {
24+
if (_.isNil(icons[name])) { return null }
25+
2026
return (
2127
<Styled
28+
data-testid={testId}
2229
className={className}
2330
color={color}
2431
as={icons[name]}

src/components/Icon/generated/CloseWin.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function SvgCloseWin(props: React.SVGProps<SVGSVGElement>) {
44
return (
55
<svg width="1em" height="1em" viewBox="0 0 24 24" {...props}>
66
<path
7-
fill="#A7A7AA"
7+
fill="currentColor"
88
fillRule="evenodd"
99
d="M16.5 6.793l.707.707-4.5 4.5 4.5 4.5-.707.707-4.5-4.5-4.5 4.5-.707-.707 4.5-4.5-4.5-4.5.707-.707 4.5 4.5 4.5-4.5z"
1010
/>

src/components/Icon/generated/EnlargeWin.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function SvgEnlargeWin(props: React.SVGProps<SVGSVGElement>) {
44
return (
55
<svg width="1em" height="1em" viewBox="0 0 24 24" {...props}>
66
<path
7-
fill="#A7A7AA"
7+
fill="currentColor"
88
fillRule="evenodd"
99
d="M17 7v10H7V7h10zm-1 1H8v8h8V8z"
1010
/>

src/components/Icon/generated/Hexahedron.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ function SvgHexahedron(props: React.SVGProps<SVGSVGElement>) {
44
return (
55
<svg width="1em" height="1em" viewBox="0 0 24 24" {...props}>
66
<g fill="currentColor" fillRule="evenodd">
7-
<path d="M13 2.577l7 4.042c.619.357 1 1.017 1 1.732v8.083a2 2 0 01-1 1.732l-7 4.041a1.996 1.996 0 01-2 0l-7-4.041a2 2 0 01-1-1.732V8.35c0-.715.381-1.375 1-1.732l7-4.042a2.001 2.001 0 012 0zm-1 1.605L4.89 8.287v8.21L12 20.604l7.11-4.105v-8.21L12 4.181z" />
8-
<path d="M19.502 7.133l.996 1.734L13 13.177v8.22h-2v-8.219L3.502 8.867l.996-1.734L12 11.445l7.502-4.312z" />
7+
<path
8+
fill="currentColor"
9+
d="M13 2.577l7 4.042c.619.357 1 1.017 1 1.732v8.083a2 2 0 01-1 1.732l-7 4.041a1.996 1.996 0 01-2 0l-7-4.041a2 2 0 01-1-1.732V8.35c0-.715.381-1.375 1-1.732l7-4.042a2.001 2.001 0 012 0zm-1 1.605L4.89 8.287v8.21L12 20.604l7.11-4.105v-8.21L12 4.181z"
10+
/>
11+
<path
12+
fill="currentColor"
13+
d="M19.502 7.133l.996 1.734L13 13.177v8.22h-2v-8.219L3.502 8.867l.996-1.734L12 11.445l7.502-4.312z"
14+
/>
915
</g>
1016
</svg>
1117
)

src/components/Icon/generated/Ios.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ function SvgIos(props: React.SVGProps<SVGSVGElement>) {
44
return (
55
<svg width="1em" height="1em" viewBox="0 0 24 24" {...props}>
66
<g fill="currentColor" fillRule="evenodd">
7-
<path d="M18.542 10.194c2.185 0 3.045 1.554 3.045 1.554s-1.681.86-1.681 2.946c0 2.353 2.094 3.162 2.094 3.162s-1.464 4.121-3.441 4.121c-.908 0-1.614-.611-2.571-.611-.976 0-1.943.634-2.574.634-1.805 0-4.087-3.91-4.087-7.05 0-3.091 1.932-4.713 3.743-4.713 1.177 0 2.09.678 2.703.678.525 0 1.5-.721 2.769-.721zm.22-3.739s.21 1.266-.805 2.486c-1.083 1.301-2.314 1.088-2.314 1.088s-.232-1.024.676-2.221c.944-1.243 2.226-1.344 2.418-1.352z" />
8-
<path d="M13 2a2 2 0 012 2v16a2 2 0 01-2 2H5a2 2 0 01-2-2V4a2 2 0 012-2h8zm0 3H5v14h8V5z" />
7+
<path
8+
fill="currentColor"
9+
d="M18.542 10.194c2.185 0 3.045 1.554 3.045 1.554s-1.681.86-1.681 2.946c0 2.353 2.094 3.162 2.094 3.162s-1.464 4.121-3.441 4.121c-.908 0-1.614-.611-2.571-.611-.976 0-1.943.634-2.574.634-1.805 0-4.087-3.91-4.087-7.05 0-3.091 1.932-4.713 3.743-4.713 1.177 0 2.09.678 2.703.678.525 0 1.5-.721 2.769-.721zm.22-3.739s.21 1.266-.805 2.486c-1.083 1.301-2.314 1.088-2.314 1.088s-.232-1.024.676-2.221c.944-1.243 2.226-1.344 2.418-1.352z"
10+
/>
11+
<path
12+
fill="currentColor"
13+
d="M13 2a2 2 0 012 2v16a2 2 0 01-2 2H5a2 2 0 01-2-2V4a2 2 0 012-2h8zm0 3H5v14h8V5z"
14+
/>
915
</g>
1016
</svg>
1117
)

0 commit comments

Comments
 (0)