Skip to content

Commit

Permalink
WIP: merge pull request #120 from KDederichs/remove_defaultProps
Browse files Browse the repository at this point in the history
Replace defaultProps
  • Loading branch information
supersnager authored Mar 3, 2024
2 parents 774b221 + 7bc07d0 commit 1caac48
Show file tree
Hide file tree
Showing 47 changed files with 146 additions and 369 deletions.
11 changes: 1 addition & 10 deletions src/components/Avatar/Avatar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Status } from "../Status/Status";
import { SizeEnum, StatusEnum } from "../enums";

function AvatarInner(
{ name, src, size, status, className, active, children, ...rest },
{ name = "", src = "", size = "md", status, className, active = false, children, ...rest },
ref
) {
const cName = `${prefix}-avatar`;
Expand Down Expand Up @@ -72,14 +72,5 @@ Avatar.propTypes = {

AvatarInner.propTypes = Avatar.propTypes;

AvatarInner.defaultProps = {
name: "",
src: "",
size: "md",
active: false,
};

Avatar.defaultProps = AvatarInner.defaultProps;

export { Avatar };
export default Avatar;
6 changes: 1 addition & 5 deletions src/components/AvatarGroup/AvatarGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Avatar from "../Avatar";

export const AvatarGroup = ({
children,
size,
size = "md",
className,
max,
activeIndex,
Expand Down Expand Up @@ -79,8 +79,4 @@ AvatarGroup.propTypes = {
hoverToFront: PropTypes.bool,
};

AvatarGroup.defaultProps = {
size: "md",
};

export default AvatarGroup;
6 changes: 1 addition & 5 deletions src/components/Buttons/AddUserButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Button from "./Button";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faUserPlus } from "@fortawesome/free-solid-svg-icons/faUserPlus";

export const AddUserButton = ({ className, children, ...rest }) => {
export const AddUserButton = ({ className = "", children, ...rest }) => {
const cName = `${prefix}-button--adduser`;

return (
Expand All @@ -30,8 +30,4 @@ AddUserButton.propTypes = {
className: PropTypes.string,
};

AddUserButton.defaultProps = {
className: "",
};

export default AddUserButton;
7 changes: 1 addition & 6 deletions src/components/Buttons/ArrowButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { faArrowRight } from "@fortawesome/free-solid-svg-icons/faArrowRight";
import { faArrowDown } from "@fortawesome/free-solid-svg-icons/faArrowDown";
import { faArrowLeft } from "@fortawesome/free-solid-svg-icons/faArrowLeft";

export const ArrowButton = ({ className, direction, children, ...rest }) => {
export const ArrowButton = ({ className = "", direction = "right", children, ...rest }) => {
const cName = `${prefix}-button--arrow`;

const icon = (() => {
Expand Down Expand Up @@ -47,9 +47,4 @@ ArrowButton.propTypes = {
direction: PropTypes.oneOf(["up", "right", "down", "left"]),
};

ArrowButton.defaultProps = {
className: "",
direction: "right",
};

export default ArrowButton;
6 changes: 1 addition & 5 deletions src/components/Buttons/AttachmentButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Button from "./Button";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faPaperclip } from "@fortawesome/free-solid-svg-icons/faPaperclip";

export const AttachmentButton = ({ className, children, ...rest }) => {
export const AttachmentButton = ({ className = "", children, ...rest }) => {
const cName = `${prefix}-button--attachment`;

return (
Expand All @@ -28,8 +28,4 @@ AttachmentButton.propTypes = {
className: PropTypes.string,
};

AttachmentButton.defaultProps = {
className: "",
};

export default AttachmentButton;
18 changes: 5 additions & 13 deletions src/components/Buttons/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import classNames from "classnames";
import { prefix } from "../settings";

export const Button = ({
children,
className,
icon,
border,
labelPosition,
children = undefined,
className = "",
icon = undefined,
border = false,
labelPosition = undefined,
...rest
}) => {
const cName = `${prefix}-button`;
Expand Down Expand Up @@ -44,12 +44,4 @@ Button.propTypes = {
border: PropTypes.bool,
};

Button.defaultProps = {
children: undefined,
className: "",
icon: undefined,
labelPosition: undefined,
border: false,
};

export default Button;
9 changes: 2 additions & 7 deletions src/components/Buttons/EllipsisButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { faEllipsisV } from "@fortawesome/free-solid-svg-icons/faEllipsisV";
import { faEllipsisH } from "@fortawesome/free-solid-svg-icons/faEllipsisH";

export const EllipsisButton = ({
className,
orientation,
className = "",
orientation = "horizontal",
children,
...rest
}) => {
Expand Down Expand Up @@ -38,9 +38,4 @@ EllipsisButton.propTypes = {
orientation: PropTypes.oneOf(["horizontal", "vertical"]),
};

EllipsisButton.defaultProps = {
className: "",
orientation: "horizontal",
};

export default EllipsisButton;
6 changes: 1 addition & 5 deletions src/components/Buttons/InfoButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Button from "./Button";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faInfoCircle } from "@fortawesome/free-solid-svg-icons/faInfoCircle";

export const InfoButton = ({ className, children, ...rest }) => {
export const InfoButton = ({ className = "", children, ...rest }) => {
const cName = `${prefix}-button--info`;

return (
Expand All @@ -28,8 +28,4 @@ InfoButton.propTypes = {
className: PropTypes.string,
};

InfoButton.defaultProps = {
className: "",
};

export default InfoButton;
6 changes: 1 addition & 5 deletions src/components/Buttons/SendButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Button from "./Button";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faPaperPlane } from "@fortawesome/free-solid-svg-icons/faPaperPlane";

export const SendButton = ({ className, children, ...rest }) => {
export const SendButton = ({ className = "", children, ...rest }) => {
const cName = `${prefix}-button--send`;

return (
Expand All @@ -28,8 +28,4 @@ SendButton.propTypes = {
className: PropTypes.string,
};

SendButton.defaultProps = {
className: "",
};

export default SendButton;
6 changes: 1 addition & 5 deletions src/components/Buttons/StarButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Button from "./Button";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faStar } from "@fortawesome/free-solid-svg-icons/faStar";

export const StarButton = ({ className, children, ...rest }) => {
export const StarButton = ({ className = "", children, ...rest }) => {
const cName = `${prefix}-button--star`;

return (
Expand All @@ -28,8 +28,4 @@ StarButton.propTypes = {
className: PropTypes.string,
};

StarButton.defaultProps = {
className: "",
};

export default StarButton;
5 changes: 1 addition & 4 deletions src/components/Buttons/VideoCallButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Button from "./Button";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faVideo } from "@fortawesome/free-solid-svg-icons/faVideo";

export const VideoCallButton = ({ className, children, ...rest }) => {
export const VideoCallButton = ({ className = "", children, ...rest }) => {
const cName = `${prefix}-button--videocall`;

return (
Expand All @@ -28,8 +28,5 @@ VideoCallButton.propTypes = {
className: PropTypes.string,
};

VideoCallButton.defaultProps = {
className: "",
};

export default VideoCallButton;
6 changes: 1 addition & 5 deletions src/components/Buttons/VoiceCallButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Button from "./Button";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faPhoneAlt } from "@fortawesome/free-solid-svg-icons/faPhoneAlt";

export const VoiceCallButton = ({ className, children, ...rest }) => {
export const VoiceCallButton = ({ className = "", children, ...rest }) => {
const cName = `${prefix}-button--voicecall`;

return (
Expand All @@ -28,8 +28,4 @@ VoiceCallButton.propTypes = {
className: PropTypes.string,
};

VoiceCallButton.defaultProps = {
className: "",
};

export default VoiceCallButton;
6 changes: 1 addition & 5 deletions src/components/ChatContainer/ChatContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import classNames from "classnames";
import { prefix } from "../settings";
import PropTypes from "prop-types";

export const ChatContainer = ({ children, className, ...rest }) => {
export const ChatContainer = ({ children = undefined, className, ...rest }) => {
const cName = `${prefix}-chat-container`;

const [
Expand Down Expand Up @@ -54,8 +54,4 @@ ChatContainer.propTypes = {
className: PropTypes.string,
};

ChatContainer.defaultProps = {
children: undefined,
};

export default ChatContainer;
14 changes: 2 additions & 12 deletions src/components/ContentEditable/ContentEditable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const replaceCaret = (el, activateAfterChange) => {
};

export class ContentEditable extends Component {
constructor(props) {
super(props);
constructor({value = undefined, placeholder = "", disabled = false, activateAfterChange = false, autoFocus = false, onChange = () => {}, onKeyPress = () => {}, ...rest}) {
super({value, placeholder,disabled, activateAfterChange, autoFocus, onChange, onKeyPress, ...rest});
this.msgRef = React.createRef();
}

Expand Down Expand Up @@ -167,14 +167,4 @@ ContentEditable.propTypes = {
className: PropTypes.string,
};

ContentEditable.defaultProps = {
value: undefined,
placeholder: "",
disabled: false,
activateAfterChange: false,
autoFocus: false,
onChange: () => {},
onKeyPress: () => {},
};

export default ContentEditable;
24 changes: 7 additions & 17 deletions src/components/Conversation/Conversation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ const LastActivityTime = ({ time }) => (
const UnreadDot = () => <div className={`${cName}__unread-dot`}></div>;

export const Conversation = ({
name,
unreadCnt,
lastSenderName,
info,
lastActivityTime,
unreadDot,
name = undefined,
unreadCnt = undefined,
lastSenderName = undefined,
info = undefined,
lastActivityTime = undefined,
unreadDot = false,
children,
className,
active,
active = false,
...rest
}) => {
const [avatar, avatarGroup, operations, content] = getChildren(children, [
Expand Down Expand Up @@ -118,16 +118,6 @@ Conversation.propTypes = {
className: PropTypes.string,
};

Conversation.defaultProps = {
name: undefined,
unreadCnt: undefined,
unreadDot: false,
lastSenderName: undefined,
info: undefined,
lastActivityTime: undefined,
active: false,
};

Conversation.Operations = ConversationOperations;
Conversation.Content = ConversationContent;

Expand Down
1 change: 0 additions & 1 deletion src/components/Conversation/ConversationContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,5 @@ ConversationContent.propTypes = {
info: PropTypes.node,
};

ConversationContent.defaultProps = {};

export default ConversationContent;
2 changes: 0 additions & 2 deletions src/components/Conversation/ConversationOperations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,4 @@ ConversationOperations.propTypes = {
visible: PropTypes.bool,
};

ConversationOperations.defaultProps = {};

export default ConversationOperations;
6 changes: 1 addition & 5 deletions src/components/ConversationHeader/ConversationHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ConversationHeaderActions from "./ConversationHeaderActions";
import ConversationHeaderContent from "./ConversationHeaderContent";
import PropTypes from "prop-types";

export const ConversationHeader = ({ children, className, ...rest }) => {
export const ConversationHeader = ({ children = undefined, className, ...rest }) => {
const cName = `${prefix}-conversation-header`;

const [back, avatar, avatarGroup, content, actions] = getChildren(children, [
Expand Down Expand Up @@ -58,10 +58,6 @@ ConversationHeader.propTypes = {
className: PropTypes.string,
};

ConversationHeader.defaultProps = {
children: undefined,
};

ConversationHeader.Back = ConversationHeaderBack;
ConversationHeader.Actions = ConversationHeaderActions;
ConversationHeader.Content = ConversationHeaderContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from "prop-types";
import { prefix } from "../settings";
import classNames from "classnames";

export const ConversationHeaderActions = ({ children, className, ...rest }) => {
export const ConversationHeaderActions = ({ children = undefined, className, ...rest }) => {
const cName = `${prefix}-conversation-header__actions`;

return (
Expand All @@ -23,8 +23,4 @@ ConversationHeaderActions.propTypes = {
className: PropTypes.string,
};

ConversationHeaderActions.defaultProps = {
children: undefined,
};

export default ConversationHeaderActions;
9 changes: 2 additions & 7 deletions src/components/ConversationHeader/ConversationHeaderBack.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import classNames from "classnames";
import { ArrowButton } from "../Buttons";

export const ConversationHeaderBack = ({
onClick,
children,
onClick = () => {},
children = undefined,
className,
...rest
}) => {
Expand Down Expand Up @@ -36,9 +36,4 @@ ConversationHeaderBack.propTypes = {
className: PropTypes.string,
};

ConversationHeaderBack.defaultProps = {
children: undefined,
onClick: () => {},
};

export default ConversationHeaderBack;
Loading

0 comments on commit 1caac48

Please sign in to comment.