-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
22 lines (17 loc) · 848 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import React from 'react';
// Object.assign Polyfill.
const _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const Blur = function({ children, radius = 0, transition = '0s' }) {
const styles = {
'transition': 'filter ' + transition,
'-webkit-filter': 'blur(' + radius + ')',
'filter': 'blur(' + radius + ')'
};
return React.Children.count(children) > 1
? React.createElement('span', { style: styles }, children)
: addStylesToElement(React.Children.only(children), styles);
};
const addStylesToElement = function(el, styles) {
return React.cloneElement(el, { style: _extends({}, el.style, styles) });
};
export default Blur;