Skip to content

Commit

Permalink
format height and width type to pass jsx style
Browse files Browse the repository at this point in the history
  • Loading branch information
Akai0734 authored and Akai0734 committed Dec 7, 2020
1 parent a9452fe commit 81c04fb
Show file tree
Hide file tree
Showing 2 changed files with 7,158 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/react-loading.jsx
Expand Up @@ -3,6 +3,12 @@ import PropTypes from 'prop-types';

import * as svgSources from './svg';

// format if width and height to number or css value
// default value as defaultProps.(width|height)
function formatStyleProp(style) {
return Number(style) || style;
}

export default class Loading extends Component {
static propTypes = {
color: PropTypes.string,
Expand Down Expand Up @@ -59,10 +65,11 @@ export default class Loading extends Component {
const svg = svgSources[selectedType];
const style = {
fill: color,
height,
width,
height: formatStyleProp(height),
width: formatStyleProp(width),
};


return (
<div
style={style}
Expand Down

0 comments on commit 81c04fb

Please sign in to comment.