DocSpace-client/packages/components/social-button/index.js

76 lines
1.8 KiB
JavaScript
Raw Normal View History

import React from "react";
import PropTypes from "prop-types";
import equal from "fast-deep-equal/react";
import Text from "../text";
import StyledSocialButton from "./styled-social-button";
import { ReactSVG } from "react-svg";
// eslint-disable-next-line no-unused-vars
class SocialButton extends React.Component {
shouldComponentUpdate(nextProps) {
return !equal(this.props, nextProps);
}
render() {
2022-09-20 23:15:26 +00:00
const {
label,
iconName,
IconComponent,
isConnect,
...otherProps
} = this.props;
return (
2022-09-20 23:15:26 +00:00
<StyledSocialButton isConnect={isConnect} {...otherProps}>
<div>
2022-08-31 22:14:24 +00:00
{IconComponent ? (
<IconComponent className="iconWrapper" />
) : (
<ReactSVG className="iconWrapper" src={iconName} />
)}
</div>
<div>
{label && (
<Text as="span" className="social_button_text">
{label}
</Text>
)}
</div>
</StyledSocialButton>
);
}
}
SocialButton.propTypes = {
/** Button text */
label: PropTypes.string,
/** Icon of button */
iconName: PropTypes.string,
/** Accepts tabindex prop*/
tabIndex: PropTypes.number,
/** Tells when the button should present a disabled state */
isDisabled: PropTypes.bool,
/** Accepts class */
className: PropTypes.string,
/** Accepts id */
id: PropTypes.string,
/** Accepts css style */
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
onClick: PropTypes.func,
$iconOptions: PropTypes.object,
2022-09-08 12:37:38 +00:00
size: PropTypes.oneOf(["base", "small"]),
isConnect: PropTypes.bool,
};
SocialButton.defaultProps = {
label: "",
iconName: "SocialButtonGoogleIcon",
tabIndex: -1,
isDisabled: false,
$iconOptions: {},
2022-09-08 12:37:38 +00:00
size: "base",
isConnect: false,
};
export default SocialButton;