-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathWarning.js
122 lines (106 loc) · 2.94 KB
/
Warning.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import React, { Fragment } from 'react'
import PropTypes from 'prop-types'
import styled, { css } from 'styled-components'
const createHelpers = (width, height, css) => {
// somehow sizes is ending up in markup, even if it is not a valid svg attribute
// until we have a better solution, just render it empty, instead to '[Object object]'
const sanitizeSizes = sizes =>
Object.defineProperty(sizes, 'toString', {
value: () => '',
enumerable: false
})
const getDimensions = (size, sizes) => {
if (
size &&
typeof size.width === 'number' &&
typeof size.height === 'number'
) {
return size
}
return size && sizes[size] ? sizes[size] : { width, height }
}
const getCss = (size, sizes, fillColor, fillColorRule, noStyles) => {
if (noStyles) {
return ''
}
const dimensions = getDimensions(size, sizes)
const fillRule =
fillColor && fillColorRule
? `${fillColorRule}{ fill: ${fillColor}; }`
: ''
return css`
width: ${dimensions.width}px;
height: ${dimensions.height}px;
${fillRule}
`
}
const propsToCss = ({ size, sizes, fillColor, fillColorRule, noStyles }) =>
getCss(size, sizes, fillColor, fillColorRule, noStyles)
return {
getCss,
getDimensions,
propsToCss,
sanitizeSizes
}
}
const width = '18'
const height = '18'
const viewBox = '0 0 18 18'
const { getDimensions, getCss, propsToCss, sanitizeSizes } = createHelpers(
width,
height,
css
)
const sizes = sanitizeSizes({
small: { width: 18, height: 18 },
medium: { width: 24, height: 24 },
large: { width: 36, height: 36 }
})
const Image = styled.svg`
${propsToCss}
`
const children = (
<Fragment>
<g fill='none' fillRule='evenodd' key='key-0'>
<path
fill='#FFCF29'
d='M7.236 1.095L5.68 4.193.204 15.143A2 2 0 002.011 18h14a2 2 0 002-2c0-.306-.074-.592-.197-.851l-5.47-10.956-1.558-3.098A1.993 1.993 0 009.011 0c-.777 0-1.443.448-1.775 1.095z'
/>
<path
fill='#333'
d='M9.02 12a1 1 0 01-1-1V5a1 1 0 012.001 0v6a1 1 0 01-1 1m0 4c-.261 0-.521-.11-.712-.29-.18-.19-.29-.44-.29-.71 0-.27.11-.52.29-.71.37-.37 1.042-.37 1.422 0 .18.19.29.45.29.71 0 .26-.11.52-.29.71-.19.18-.45.29-.71.29'
/>
</g>
</Fragment>
)
const defaultProps = {
children,
viewBox,
fillColor: null,
fillColorRule: '&&& path, &&& use, &&& g',
sizes,
size: null
}
Image.propTypes /* remove-proptypes */ = {
fillColor: PropTypes.string,
fillColorRule: PropTypes.string,
viewBox: PropTypes.string.isRequired,
children: PropTypes.node.isRequired,
size: PropTypes.oneOfType([
PropTypes.string,
PropTypes.shape({
height: PropTypes.number.isRequired,
width: PropTypes.number.isRequired
})
]),
sizes: PropTypes.shape({
height: PropTypes.number,
width: PropTypes.number
})
}
export default Object.assign(Image, {
getDimensions,
getCss,
defaultProps,
displayName: 'Warning'
})