UNPKG

9.99 kBJavaScriptView Raw
1import React from 'react'
2import PropTypes from 'prop-types'
3import { iconStyle, disabledIconStyle, svgStyle } from './styles'
4
5const darkSvg = (
6 <svg
7 version="1.1"
8 xmlns="http://www.w3.org/2000/svg"
9 width="46px"
10 height="46px"
11 viewBox="0 0 46 46"
12 style={svgStyle}
13 >
14 <defs>
15 <filter
16 x="-50%"
17 y="-50%"
18 width="200%"
19 height="200%"
20 filterUnits="objectBoundingBox"
21 id="filter-1"
22 >
23 <feOffset dx="0" dy="1" in="SourceAlpha" result="shadowOffsetOuter1" />
24 <feGaussianBlur
25 stdDeviation="0.5"
26 in="shadowOffsetOuter1"
27 result="shadowBlurOuter1"
28 />
29 <feColorMatrix
30 values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.168 0"
31 in="shadowBlurOuter1"
32 type="matrix"
33 result="shadowMatrixOuter1"
34 />
35 <feOffset dx="0" dy="0" in="SourceAlpha" result="shadowOffsetOuter2" />
36 <feGaussianBlur
37 stdDeviation="0.5"
38 in="shadowOffsetOuter2"
39 result="shadowBlurOuter2"
40 />
41 <feColorMatrix
42 values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.084 0"
43 in="shadowBlurOuter2"
44 type="matrix"
45 result="shadowMatrixOuter2"
46 />
47 <feMerge>
48 <feMergeNode in="shadowMatrixOuter1" />
49 <feMergeNode in="shadowMatrixOuter2" />
50 <feMergeNode in="SourceGraphic" />
51 </feMerge>
52 </filter>
53 <rect id="path-2" x="0" y="0" width="40" height="40" rx="2" />
54 <rect id="path-3" x="5" y="5" width="38" height="38" rx="1" />
55 </defs>
56 <g
57 id="Google-Button"
58 stroke="none"
59 strokeWidth="1"
60 fill="none"
61 fillRule="evenodd"
62 >
63 <g id="9-PATCH" transform="translate(-608.000000, -219.000000)" />
64 <g
65 id="btn_google_dark_normal"
66 transform="translate(-1.000000, -1.000000)"
67 >
68 <g
69 id="button"
70 transform="translate(4.000000, 4.000000)"
71 filter="url(#filter-1)"
72 >
73 <g id="button-bg">
74 <use fill="#4285F4" fillRule="evenodd" />
75 <use fill="none" />
76 <use fill="none" />
77 <use fill="none" />
78 </g>
79 </g>
80 <g id="button-bg-copy">
81 <use fill="#FFFFFF" fillRule="evenodd" />
82 <use fill="none" />
83 <use fill="none" />
84 <use fill="none" />
85 </g>
86 <g id="logo_googleg_48dp" transform="translate(15.000000, 15.000000)">
87 <path
88 d="M17.64,9.20454545 C17.64,8.56636364 17.5827273,7.95272727 17.4763636,7.36363636 L9,7.36363636 L9,10.845 L13.8436364,10.845 C13.635,11.97 13.0009091,12.9231818 12.0477273,13.5613636 L12.0477273,15.8195455 L14.9563636,15.8195455 C16.6581818,14.2527273 17.64,11.9454545 17.64,9.20454545 L17.64,9.20454545 Z"
89 id="Shape"
90 fill="#4285F4"
91 />
92 <path
93 d="M9,18 C11.43,18 13.4672727,17.1940909 14.9563636,15.8195455 L12.0477273,13.5613636 C11.2418182,14.1013636 10.2109091,14.4204545 9,14.4204545 C6.65590909,14.4204545 4.67181818,12.8372727 3.96409091,10.71 L0.957272727,10.71 L0.957272727,13.0418182 C2.43818182,15.9831818 5.48181818,18 9,18 L9,18 Z"
94 id="Shape"
95 fill="#34A853"
96 />
97 <path
98 d="M3.96409091,10.71 C3.78409091,10.17 3.68181818,9.59318182 3.68181818,9 C3.68181818,8.40681818 3.78409091,7.83 3.96409091,7.29 L3.96409091,4.95818182 L0.957272727,4.95818182 C0.347727273,6.17318182 0,7.54772727 0,9 C0,10.4522727 0.347727273,11.8268182 0.957272727,13.0418182 L3.96409091,10.71 L3.96409091,10.71 Z"
99 id="Shape"
100 fill="#FBBC05"
101 />
102 <path
103 d="M9,3.57954545 C10.3213636,3.57954545 11.5077273,4.03363636 12.4404545,4.92545455 L15.0218182,2.34409091 C13.4631818,0.891818182 11.4259091,0 9,0 C5.48181818,0 2.43818182,2.01681818 0.957272727,4.95818182 L3.96409091,7.29 C4.67181818,5.16272727 6.65590909,3.57954545 9,3.57954545 L9,3.57954545 Z"
104 id="Shape"
105 fill="#EA4335"
106 />
107 <path d="M0,0 L18,0 L18,18 L0,18 L0,0 Z" id="Shape" />
108 </g>
109 <g id="handles_square" />
110 </g>
111 </g>
112 </svg>
113)
114
115const lightSvg = (
116 <svg
117 version="1.1"
118 xmlns="http://www.w3.org/2000/svg"
119 width="46px"
120 height="46px"
121 viewBox="0 0 46 46"
122 style={svgStyle}
123 >
124 <defs>
125 <filter
126 x="-50%"
127 y="-50%"
128 width="200%"
129 height="200%"
130 filterUnits="objectBoundingBox"
131 id="filter-1"
132 >
133 <feOffset dx="0" dy="1" in="SourceAlpha" result="shadowOffsetOuter1" />
134 <feGaussianBlur
135 stdDeviation="0.5"
136 in="shadowOffsetOuter1"
137 result="shadowBlurOuter1"
138 />
139 <feColorMatrix
140 values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.168 0"
141 in="shadowBlurOuter1"
142 type="matrix"
143 result="shadowMatrixOuter1"
144 />
145 <feOffset dx="0" dy="0" in="SourceAlpha" result="shadowOffsetOuter2" />
146 <feGaussianBlur
147 stdDeviation="0.5"
148 in="shadowOffsetOuter2"
149 result="shadowBlurOuter2"
150 />
151 <feColorMatrix
152 values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.084 0"
153 in="shadowBlurOuter2"
154 type="matrix"
155 result="shadowMatrixOuter2"
156 />
157 <feMerge>
158 <feMergeNode in="shadowMatrixOuter1" />
159 <feMergeNode in="shadowMatrixOuter2" />
160 <feMergeNode in="SourceGraphic" />
161 </feMerge>
162 </filter>
163 <rect id="path-2" x="0" y="0" width="40" height="40" rx="2" />
164 </defs>
165 <g
166 id="Google-Button"
167 stroke="none"
168 strokeWidth="1"
169 fill="none"
170 fillRule="evenodd"
171 >
172 <g id="9-PATCH" transform="translate(-608.000000, -160.000000)" />
173 <g
174 id="btn_google_light_normal"
175 transform="translate(-1.000000, -1.000000)"
176 >
177 <g
178 id="button"
179 transform="translate(4.000000, 4.000000)"
180 filter="url(#filter-1)"
181 >
182 <g id="button-bg">
183 <use fill="#FFFFFF" fillRule="evenodd" />
184 <use fill="none" />
185 <use fill="none" />
186 <use fill="none" />
187 </g>
188 </g>
189 <g id="logo_googleg_48dp" transform="translate(15.000000, 15.000000)">
190 <path
191 d="M17.64,9.20454545 C17.64,8.56636364 17.5827273,7.95272727 17.4763636,7.36363636 L9,7.36363636 L9,10.845 L13.8436364,10.845 C13.635,11.97 13.0009091,12.9231818 12.0477273,13.5613636 L12.0477273,15.8195455 L14.9563636,15.8195455 C16.6581818,14.2527273 17.64,11.9454545 17.64,9.20454545 L17.64,9.20454545 Z"
192 id="Shape"
193 fill="#4285F4"
194 />
195 <path
196 d="M9,18 C11.43,18 13.4672727,17.1940909 14.9563636,15.8195455 L12.0477273,13.5613636 C11.2418182,14.1013636 10.2109091,14.4204545 9,14.4204545 C6.65590909,14.4204545 4.67181818,12.8372727 3.96409091,10.71 L0.957272727,10.71 L0.957272727,13.0418182 C2.43818182,15.9831818 5.48181818,18 9,18 L9,18 Z"
197 id="Shape"
198 fill="#34A853"
199 />
200 <path
201 d="M3.96409091,10.71 C3.78409091,10.17 3.68181818,9.59318182 3.68181818,9 C3.68181818,8.40681818 3.78409091,7.83 3.96409091,7.29 L3.96409091,4.95818182 L0.957272727,4.95818182 C0.347727273,6.17318182 0,7.54772727 0,9 C0,10.4522727 0.347727273,11.8268182 0.957272727,13.0418182 L3.96409091,10.71 L3.96409091,10.71 Z"
202 id="Shape"
203 fill="#FBBC05"
204 />
205 <path
206 d="M9,3.57954545 C10.3213636,3.57954545 11.5077273,4.03363636 12.4404545,4.92545455 L15.0218182,2.34409091 C13.4631818,0.891818182 11.4259091,0 9,0 C5.48181818,0 2.43818182,2.01681818 0.957272727,4.95818182 L3.96409091,7.29 C4.67181818,5.16272727 6.65590909,3.57954545 9,3.57954545 L9,3.57954545 Z"
207 id="Shape"
208 fill="#EA4335"
209 />
210 <path d="M0,0 L18,0 L18,18 L0,18 L0,0 Z" id="Shape" />
211 </g>
212 <g id="handles_square" />
213 </g>
214 </g>
215 </svg>
216)
217
218const disabledSvg = (
219 <svg
220 width="46px"
221 height="46px"
222 viewBox="0 0 46 46"
223 version="1.1"
224 xmlns="http://www.w3.org/2000/svg"
225 style={svgStyle}
226 >
227 <defs>
228 <rect id="path-1" x="0" y="0" width="40" height="40" rx="2" />
229 </defs>
230 <g
231 id="Google-Button"
232 stroke="none"
233 strokeWidth="1"
234 fill="none"
235 fillRule="evenodd"
236 >
237 <g id="9-PATCH" transform="translate(-788.000000, -219.000000)" />
238 <g
239 id="btn_google_dark_disabled"
240 transform="translate(-1.000000, -1.000000)"
241 >
242 <g id="button" transform="translate(4.000000, 4.000000)">
243 <g id="button-bg">
244 <use fillOpacity="0.08" fill="#000000" fillRule="evenodd" />
245 <use fill="none" />
246 <use fill="none" />
247 <use fill="none" />
248 </g>
249 </g>
250 <path
251 d="M24.001,25.71 L24.001,22.362 L32.425,22.362 C32.551,22.929 32.65,23.46 32.65,24.207 C32.65,29.346 29.203,33 24.01,33 C19.042,33 15.01,28.968 15.01,24 C15.01,19.032 19.042,15 24.01,15 C26.44,15 28.474,15.891 30.031,17.349 L27.475,19.833 C26.827,19.221 25.693,18.501 24.01,18.501 C21.031,18.501 18.601,20.976 18.601,24.009 C18.601,27.042 21.031,29.517 24.01,29.517 C27.457,29.517 28.726,27.132 28.96,25.719 L24.001,25.719 L24.001,25.71 Z"
252 id="Shape-Copy"
253 fillOpacity="0.4"
254 fill="#000000"
255 />
256 <g id="handles_square" />
257 </g>
258 </g>
259 </svg>
260)
261
262export const GoogleIcon = ({ disabled, type }) => (
263 <div style={!disabled ? iconStyle : { ...iconStyle, ...disabledIconStyle }}>
264 {!disabled ? (type === 'dark' ? darkSvg : lightSvg) : disabledSvg}
265 </div>
266)
267
268GoogleIcon.propTypes = {
269 disabled: PropTypes.bool,
270 type: PropTypes.oneOf(['light', 'dark'])
271}
272
273GoogleIcon.defaultProps = {
274 type: 'dark'
275}