diff --git a/.eslintrc.js b/.eslintrc.js index 126cc22188..541cdc8ef9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -18,6 +18,7 @@ module.exports = { 'import/extensions': 0, 'react/jsx-props-no-spreading': 'off', 'react/prop-types': [2, { ignore: ['theme'] }], + 'react/require-default-props': 'off', 'import/no-extraneous-dependencies': 0, 'no-plusplus': 0, 'no-restricted-globals': 0, diff --git a/packages/doc/src/components/Clipboard/index.jsx b/packages/doc/src/components/Clipboard/index.jsx index 19c9221586..016190f37b 100644 --- a/packages/doc/src/components/Clipboard/index.jsx +++ b/packages/doc/src/components/Clipboard/index.jsx @@ -40,8 +40,4 @@ Clipboard.propTypes = { copyText: string, }; -Clipboard.defaultProps = { - copyText: undefined, -}; - export default Clipboard; diff --git a/packages/yoga/src/Accordion/web/Accordion.jsx b/packages/yoga/src/Accordion/web/Accordion.jsx index ac1943f0a6..b3d53bd8c6 100644 --- a/packages/yoga/src/Accordion/web/Accordion.jsx +++ b/packages/yoga/src/Accordion/web/Accordion.jsx @@ -202,10 +202,10 @@ const Accordion = ({ title, subtitle, children, - disabled, - expanded, - small, - hasHorizontalPadding, + disabled = false, + expanded = false, + small = false, + hasHorizontalPadding = true, ...props }) => { const [open, setOpen] = useState(expanded); @@ -272,13 +272,4 @@ Accordion.propTypes = { hasHorizontalPadding: bool, }; -Accordion.defaultProps = { - title: undefined, - subtitle: undefined, - disabled: false, - expanded: false, - small: false, - hasHorizontalPadding: true, -}; - export default Accordion; diff --git a/packages/yoga/src/Accordion/web/Small.jsx b/packages/yoga/src/Accordion/web/Small.jsx index ca8247923f..35bd58ac13 100644 --- a/packages/yoga/src/Accordion/web/Small.jsx +++ b/packages/yoga/src/Accordion/web/Small.jsx @@ -8,6 +8,4 @@ function AccordionSmall(props) { AccordionSmall.propTypes = Accordion.propTypes; -AccordionSmall.defaultProps = Accordion.defaultProps; - export default AccordionSmall; diff --git a/packages/yoga/src/ActionRequirement/web/ActionRequirement.jsx b/packages/yoga/src/ActionRequirement/web/ActionRequirement.jsx index 9e4836bca7..3bb7b712c9 100644 --- a/packages/yoga/src/ActionRequirement/web/ActionRequirement.jsx +++ b/packages/yoga/src/ActionRequirement/web/ActionRequirement.jsx @@ -57,7 +57,7 @@ function ActionRequirement(props) { checkable, illustration, list, - titleAsTextDisplay, + titleAsTextDisplay = false, } = props; let primaryButton; @@ -106,12 +106,4 @@ ActionRequirement.propTypes = { titleAsTextDisplay: bool, }; -ActionRequirement.defaultProps = { - children: undefined, - checkable: undefined, - illustration: undefined, - list: undefined, - titleAsTextDisplay: false, -}; - export default ActionRequirement; diff --git a/packages/yoga/src/AutoComplete/web/AutoComplete.jsx b/packages/yoga/src/AutoComplete/web/AutoComplete.jsx index cd823648a9..94f0b963be 100644 --- a/packages/yoga/src/AutoComplete/web/AutoComplete.jsx +++ b/packages/yoga/src/AutoComplete/web/AutoComplete.jsx @@ -147,22 +147,25 @@ const Match = styled.mark` `} `; +const noop = () => {}; +const emptyArr = []; + /** The autocomplete is a normal input field enhanced by a panel of suggested options. */ const AutoComplete = React.forwardRef( ( { className, style, - full, - options, - onChange, - onClean, - onSelect, + full = false, + options = emptyArr, + onChange = noop, + onClean = noop, + onSelect = noop, value, error, - openSuggestionsAriaLabel, - closeSuggestionsAriaLabel, - shouldFilterOptions, + openSuggestionsAriaLabel = 'Open suggestions', + closeSuggestionsAriaLabel = 'Close suggestions', + shouldFilterOptions = true, ...props }, ref, @@ -333,19 +336,4 @@ AutoComplete.propTypes = { shouldFilterOptions: bool, }; -AutoComplete.defaultProps = { - className: undefined, - full: false, - options: [], - style: undefined, - onSelect: () => {}, - onChange: () => {}, - onClean: () => {}, - value: undefined, - error: undefined, - openSuggestionsAriaLabel: 'Open suggestions', - closeSuggestionsAriaLabel: 'Close suggestions', - shouldFilterOptions: true, -}; - export default AutoComplete; diff --git a/packages/yoga/src/Avatar/web/Avatar.jsx b/packages/yoga/src/Avatar/web/Avatar.jsx index 5bc639a675..5e990efd78 100644 --- a/packages/yoga/src/Avatar/web/Avatar.jsx +++ b/packages/yoga/src/Avatar/web/Avatar.jsx @@ -30,7 +30,15 @@ const Content = ({ icon, alt, src, fill, content, stroke }) => { */ const Avatar = forwardRef( ( - { src, alt, fill, stroke, icon = BuildingFilled, children, ...otherProps }, + { + src, + alt, + fill = 'white', + stroke, + icon = BuildingFilled, + children, + ...otherProps + }, ref, ) => { return ( @@ -68,13 +76,6 @@ Content.propTypes = { ...Box.propTypes, }; -Content.defaultProps = { - src: undefined, - fill: 'white', - alt: undefined, - icon: undefined, -}; - Avatar.propTypes = { src: string, /** Required if src is true */ @@ -111,14 +112,6 @@ Avatar.propTypes = { ...Box.propTypes, }; -Avatar.defaultProps = { - src: undefined, - alt: undefined, - icon: undefined, - fill: 'white', - stroke: undefined, - ...Box.defaultProps, -}; Avatar.displayName = 'Avatar'; export default Avatar; diff --git a/packages/yoga/src/Avatar/web/AvatarCircle.jsx b/packages/yoga/src/Avatar/web/AvatarCircle.jsx index aa7eb2d6ec..d1074fd86d 100644 --- a/packages/yoga/src/Avatar/web/AvatarCircle.jsx +++ b/packages/yoga/src/Avatar/web/AvatarCircle.jsx @@ -16,8 +16,6 @@ const AvatarCircle = forwardRef(({ src, alt = '', ...props }, ref) => ( AvatarCircle.propTypes = Avatar.propTypes; -AvatarCircle.defaultProps = Avatar.defaultProps; - AvatarCircle.displayName = 'Avatar.Circle'; export default AvatarCircle; diff --git a/packages/yoga/src/Banner/web/Banner.jsx b/packages/yoga/src/Banner/web/Banner.jsx index 0bd20dfd7e..74495ead5b 100644 --- a/packages/yoga/src/Banner/web/Banner.jsx +++ b/packages/yoga/src/Banner/web/Banner.jsx @@ -68,8 +68,14 @@ BannerActionButton.propTypes = { /** A banner is a component that displays a prominent message. It can have related action buttons on it or not. */ const Banner = forwardRef((props, ref) => { - const { icon, variant, message, primaryButton, secondaryButton, ...rest } = - props; + const { + icon, + variant = 'informative', + message, + primaryButton, + secondaryButton, + ...rest + } = props; return ( @@ -137,11 +143,4 @@ Banner.propTypes = { }, }; -Banner.defaultProps = { - icon: undefined, - variant: 'informative', - primaryButton: undefined, - secondaryButton: undefined, -}; - export default Banner; diff --git a/packages/yoga/src/BottomSheet/web/__snapshots__/BottomSheet.test.jsx.snap b/packages/yoga/src/BottomSheet/web/__snapshots__/BottomSheet.test.jsx.snap index 238bd92b26..8978849a06 100644 --- a/packages/yoga/src/BottomSheet/web/__snapshots__/BottomSheet.test.jsx.snap +++ b/packages/yoga/src/BottomSheet/web/__snapshots__/BottomSheet.test.jsx.snap @@ -100,7 +100,7 @@ exports[` should match snapshot 1`] = ` } .c1 { - padding: 16px 16px 16px 16px; + padding: 16px 16px 16px 16px; box-shadow: 0 2px 4px -1px rgba(152,152,166,0.2),0 4px 5px 0px rgba(152,152,166,0.14),0 1px 10px 0px rgba(152,152,166,0.12); border-radius: 8px; background-color: #FFFFFF; diff --git a/packages/yoga/src/Button/web/Button.jsx b/packages/yoga/src/Button/web/Button.jsx index 14a84457cd..63b0b9b747 100644 --- a/packages/yoga/src/Button/web/Button.jsx +++ b/packages/yoga/src/Button/web/Button.jsx @@ -11,19 +11,21 @@ const SpinnerContainer = styled.div` transform: translate(-50%, -50%); `; +const noop = () => {}; + /** Buttons make common actions more obvious and help users more easily perform them. Buttons use labels and sometimes icons to communicate the action that will occur when the user touches them. */ const Button = forwardRef( ( { - children, - onClick, - full, - disabled, - inverted, - small, - secondary, + children = 'Button', + onClick = noop, + full = false, + disabled = undefined, + inverted = false, + small = false, + secondary = false, icon: Icon, - isLoading, + isLoading = false, ...props }, ref, @@ -77,20 +79,6 @@ Button.propTypes = { href: string, }; -Button.defaultProps = { - ariaLabel: undefined, - children: 'Button', - disabled: undefined, - full: false, - inverted: false, - isLoading: false, - onClick: () => {}, - small: false, - secondary: false, - icon: undefined, - href: undefined, -}; - Button.displayName = 'Button'; export default Button; diff --git a/packages/yoga/src/Button/web/Icon.jsx b/packages/yoga/src/Button/web/Icon.jsx index 4724766b78..b09db437ca 100644 --- a/packages/yoga/src/Button/web/Icon.jsx +++ b/packages/yoga/src/Button/web/Icon.jsx @@ -38,9 +38,11 @@ const ButtonIcon = forwardRef( components: { button }, }, }, - small, + small = false, disabled, - isLoading, + isLoading = false, + secondary = false, + inverted = false, ...props }, ref, @@ -48,6 +50,8 @@ const ButtonIcon = forwardRef( return ( { +const ButtonLink = forwardRef(({ secondary = false, ...rest }, ref) => { const props = Object.fromEntries( Object.entries(rest).filter(([key]) => key !== 'isLoading'), ); @@ -95,7 +95,13 @@ const ButtonLink = forwardRef(({ ...rest }, ref) => { const { disabled } = props; return ( - + ); }); @@ -107,13 +113,6 @@ ButtonLink.propTypes = { icon: oneOfType([node, func]), }; -ButtonLink.defaultProps = { - disabled: undefined, - secondary: false, - href: undefined, - icon: undefined, -}; - ButtonLink.displayName = 'Button.Link'; export default ButtonLink; diff --git a/packages/yoga/src/Button/web/Text.jsx b/packages/yoga/src/Button/web/Text.jsx index 1a9b50edeb..04f8e60c93 100644 --- a/packages/yoga/src/Button/web/Text.jsx +++ b/packages/yoga/src/Button/web/Text.jsx @@ -113,7 +113,7 @@ const ButtonText = forwardRef(({ ...rest }, ref) => { Object.entries(rest).filter(([key]) => key !== 'isLoading'), ); - const { secondary, inverted } = props; + const { secondary = false, inverted = false } = props; return ( ( - - {Object.keys(ribbon).length > 0 && ( - - {ribbon.text} - - )} - {children} - -)); +const emptyObj = {}; + +const Card = React.forwardRef( + ({ ribbon = emptyObj, children = null, hasShadow = true, ...rest }, ref) => ( + + {Object.keys(ribbon).length > 0 && ( + + {ribbon.text} + + )} + {children} + + ), +); Card.propTypes = { /** text: the content inside the Card Ribbon. @@ -113,12 +117,6 @@ Card.propTypes = { hasShadow: bool, }; -Card.defaultProps = { - ribbon: {}, - children: null, - hasShadow: true, -}; - Card.displayName = 'Card'; export default Card; diff --git a/packages/yoga/src/Card/web/Card/__snapshots__/Card.test.jsx.snap b/packages/yoga/src/Card/web/Card/__snapshots__/Card.test.jsx.snap index 14051fdbc1..e53f82a306 100644 --- a/packages/yoga/src/Card/web/Card/__snapshots__/Card.test.jsx.snap +++ b/packages/yoga/src/Card/web/Card/__snapshots__/Card.test.jsx.snap @@ -64,7 +64,7 @@ exports[` Snapshots should match snapshot with default Card 1`] = ` } .c0 { - padding: 16px 16px 16px 16px; + padding: 16px 16px 16px 16px; box-shadow: 0 2px 4px -1px rgba(152,152,166,0.2),0 4px 5px 0px rgba(152,152,166,0.14),0 1px 10px 0px rgba(152,152,166,0.12); border-radius: 8px; background-color: #FFFFFF; diff --git a/packages/yoga/src/Card/web/PlanCard/Content.jsx b/packages/yoga/src/Card/web/PlanCard/Content.jsx index d54e0a673c..4a299e84ce 100644 --- a/packages/yoga/src/Card/web/PlanCard/Content.jsx +++ b/packages/yoga/src/Card/web/PlanCard/Content.jsx @@ -77,15 +77,15 @@ const EnhancePrice = styled(Text.Medium)` const PlanCardContent = ({ title, - badgeColor, - subtitle, - description, - currency, - suffix, - price, - period, - extra, - children, + badgeColor = null, + subtitle = null, + description = null, + currency = null, + suffix = null, + price = null, + period = null, + extra = null, + children = null, ...rest }) => ( @@ -128,18 +128,6 @@ PlanCardContent.propTypes = { badgeColor: string, }; -PlanCardContent.defaultProps = { - children: null, - description: null, - subtitle: null, - currency: null, - suffix: null, - price: null, - period: null, - extra: null, - badgeColor: null, -}; - PlanCardContent.displayName = 'PlanCard.Content'; export default PlanCardContent; diff --git a/packages/yoga/src/Card/web/PlanCard/List.jsx b/packages/yoga/src/Card/web/PlanCard/List.jsx index 1c29426e10..96b6f378e1 100644 --- a/packages/yoga/src/Card/web/PlanCard/List.jsx +++ b/packages/yoga/src/Card/web/PlanCard/List.jsx @@ -89,12 +89,14 @@ const Button = styled.button` ${truncateStyle} `; +const emptyObj = {}; + const ListItem = withTheme(props => { const { text, - truncate, + truncate = true, icon: Icon, - buttonProps, + buttonProps = emptyObj, theme: yogaTheme, children, onClick, @@ -146,12 +148,4 @@ ListItem.propTypes = { truncate: bool, }; -ListItem.defaultProps = { - truncate: true, - icon: undefined, - buttonProps: {}, - onClick: undefined, - children: undefined, -}; - export { List, ListItem }; diff --git a/packages/yoga/src/Card/web/PlanCard/PlanCard.jsx b/packages/yoga/src/Card/web/PlanCard/PlanCard.jsx index dd6fe7dc5e..7737d7769d 100644 --- a/packages/yoga/src/Card/web/PlanCard/PlanCard.jsx +++ b/packages/yoga/src/Card/web/PlanCard/PlanCard.jsx @@ -111,7 +111,7 @@ const DiscountWrapper = styled(Box).attrs({ }} `; -function PlanCard({ children, discount, variant, ...rest }) { +function PlanCard({ children, discount, variant = 'deepPurple', ...rest }) { const hasDiscount = !!discount; return ( @@ -135,12 +135,6 @@ PlanCard.propTypes = { variant: string, }; -PlanCard.defaultProps = { - children: undefined, - discount: undefined, - variant: 'deepPurple', -}; - PlanCard.displayName = 'PlanCard'; export default PlanCard; diff --git a/packages/yoga/src/Checkbox/web/Checkbox.jsx b/packages/yoga/src/Checkbox/web/Checkbox.jsx index dd1331f4c7..e9ad833b5b 100644 --- a/packages/yoga/src/Checkbox/web/Checkbox.jsx +++ b/packages/yoga/src/Checkbox/web/Checkbox.jsx @@ -240,13 +240,13 @@ const Checkbox = ({ value, label, helper, - disabled, - checked, + disabled = false, + checked = false, error, style, className, - inverted, - indeterminate, + inverted = false, + indeterminate = false, ariaLabel, theme: { yoga: { @@ -340,20 +340,6 @@ Checkbox.propTypes = { ariaLabel: string, }; -Checkbox.defaultProps = { - label: undefined, - value: undefined, - helper: undefined, - checked: false, - disabled: false, - inverted: false, - indeterminate: false, - error: undefined, - style: undefined, - className: undefined, - ariaLabel: undefined, -}; - Checkbox.displayName = 'Checkbox'; export default withTheme(Checkbox); diff --git a/packages/yoga/src/Checkbox/web/Switch.jsx b/packages/yoga/src/Checkbox/web/Switch.jsx index 0d6c737b32..ed628934fd 100644 --- a/packages/yoga/src/Checkbox/web/Switch.jsx +++ b/packages/yoga/src/Checkbox/web/Switch.jsx @@ -123,21 +123,30 @@ const SwitchThumb = styled.span` `}; `; +const noop = () => {}; + /** Switches allow users to turn an individual option on or off. They are usually used to activate or deactivate a specific setting. */ -const CheckboxSwitch = ({ checked, disabled, onChange, ...rest }) => ( - - - - -); +function CheckboxSwitch({ + checked = false, + disabled = false, + onChange = noop, + ...rest +}) { + return ( + + + + + ); +} CheckboxSwitch.propTypes = { checked: bool, @@ -145,12 +154,6 @@ CheckboxSwitch.propTypes = { onChange: func, }; -CheckboxSwitch.defaultProps = { - checked: false, - disabled: false, - onChange: () => {}, -}; - CheckboxSwitch.displayName = 'Checkbox.Switch'; export default CheckboxSwitch; diff --git a/packages/yoga/src/Chips/web/Chips.jsx b/packages/yoga/src/Chips/web/Chips.jsx index de7e4ef019..7c25f8b3ea 100644 --- a/packages/yoga/src/Chips/web/Chips.jsx +++ b/packages/yoga/src/Chips/web/Chips.jsx @@ -68,9 +68,9 @@ const Wrapper = styled.button` p { color: ${colors.white}; } - + background-color: ${colors.secondary}; - + border-color: transparent; @@ -115,14 +115,16 @@ const Wrapper = styled.button` }} `; +const emptyArr = []; + const Chips = React.forwardRef( ( { children, - selected, + selected = false, counter, - icons, - disabled, + icons = emptyArr, + disabled = false, onToggle, onClick = onToggle, theme: { @@ -193,14 +195,4 @@ Chips.propTypes = { onClick: func, }; -Chips.defaultProps = { - children: undefined, - selected: false, - disabled: false, - counter: undefined, - icons: [], - onToggle: undefined, - onClick: undefined, -}; - export default withTheme(Chips); diff --git a/packages/yoga/src/Datepicker/web/Calendar.jsx b/packages/yoga/src/Datepicker/web/Calendar.jsx index a6204dcdb8..62fd604425 100644 --- a/packages/yoga/src/Datepicker/web/Calendar.jsx +++ b/packages/yoga/src/Datepicker/web/Calendar.jsx @@ -183,10 +183,10 @@ function Calendar({ type, startDate, endDate, - onSelectSingle, - onSelectRange, - disablePastDates, - disableFutureDates, + onSelectSingle = null, + onSelectRange = null, + disablePastDates = false, + disableFutureDates = false, disablePastFrom, disableFutureFrom, }) { @@ -433,15 +433,4 @@ Calendar.propTypes = { disableFutureFrom: instanceOf(Date), }; -Calendar.defaultProps = { - startDate: undefined, - endDate: undefined, - onSelectSingle: null, - onSelectRange: null, - disablePastDates: false, - disableFutureDates: false, - disablePastFrom: undefined, - disableFutureFrom: undefined, -}; - export default Calendar; diff --git a/packages/yoga/src/Datepicker/web/Datepicker.jsx b/packages/yoga/src/Datepicker/web/Datepicker.jsx index 51e7c7229f..11c1dec747 100644 --- a/packages/yoga/src/Datepicker/web/Datepicker.jsx +++ b/packages/yoga/src/Datepicker/web/Datepicker.jsx @@ -165,23 +165,24 @@ const ErrorWrapper = styled(Text.Small)` export const toUTC = date => { return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()); }; + function Datepicker({ - fullWidth, + fullWidth = false, type, placeholder, startDate, endDate, onSelectSingle, - disabled, + disabled = false, onSelectRange, customOnSelectRange, - disablePastDates, - disableFutureDates, + disablePastDates = false, + disableFutureDates = false, disablePastFrom, disableFutureFrom, error, onOpen, - displayEndDateOnly, + displayEndDateOnly = false, ...props }) { const [open, setOpen] = useState(); @@ -351,22 +352,4 @@ Datepicker.propTypes = { displayEndDateOnly: bool, }; -Datepicker.defaultProps = { - fullWidth: false, - placeholder: undefined, - startDate: undefined, - endDate: undefined, - disabled: false, - onSelectSingle: undefined, - onSelectRange: undefined, - customOnSelectRange: undefined, - disablePastDates: false, - disableFutureDates: false, - disablePastFrom: undefined, - disableFutureFrom: undefined, - error: undefined, - onOpen: undefined, - displayEndDateOnly: false, -}; - export default Datepicker; diff --git a/packages/yoga/src/Dialog/web/Dialog.jsx b/packages/yoga/src/Dialog/web/Dialog.jsx index eec0645c8f..f413e24bee 100644 --- a/packages/yoga/src/Dialog/web/Dialog.jsx +++ b/packages/yoga/src/Dialog/web/Dialog.jsx @@ -81,12 +81,12 @@ const CloseButton = styled(Button.Icon)` const Dialog = React.forwardRef( ( { - isOpen, - hideCloseButton, + isOpen = false, + hideCloseButton = false, children, dialogId, onClose, - zIndex, + zIndex = 3, closeLabel, className, ...props @@ -182,16 +182,6 @@ Dialog.propTypes = { children: node.isRequired, }; -Dialog.defaultProps = { - isOpen: false, - hideCloseButton: false, - onClose: undefined, - closeLabel: undefined, - className: undefined, - zIndex: 3, - dialogId: undefined, -}; - Dialog.displayName = 'Dialog'; export default Dialog; diff --git a/packages/yoga/src/Dialog/web/__snapshots__/Dialog.test.jsx.snap b/packages/yoga/src/Dialog/web/__snapshots__/Dialog.test.jsx.snap index 261d3fbd3a..6ab7002e91 100644 --- a/packages/yoga/src/Dialog/web/__snapshots__/Dialog.test.jsx.snap +++ b/packages/yoga/src/Dialog/web/__snapshots__/Dialog.test.jsx.snap @@ -100,7 +100,7 @@ exports[` should match snapshot 1`] = ` } .c1 { - padding: 16px 16px 16px 16px; + padding: 16px 16px 16px 16px; box-shadow: 0 2px 4px -1px rgba(152,152,166,0.2),0 4px 5px 0px rgba(152,152,166,0.14),0 1px 10px 0px rgba(152,152,166,0.12); border-radius: 8px; background-color: #FFFFFF; @@ -410,7 +410,7 @@ exports[` should match snapshot with close button 1`] = ` } .c1 { - padding: 16px 16px 16px 16px; + padding: 16px 16px 16px 16px; box-shadow: 0 2px 4px -1px rgba(152,152,166,0.2),0 4px 5px 0px rgba(152,152,166,0.14),0 1px 10px 0px rgba(152,152,166,0.12); border-radius: 8px; background-color: #FFFFFF; diff --git a/packages/yoga/src/Divider/web/Divider.jsx b/packages/yoga/src/Divider/web/Divider.jsx index 0a2b80cacd..81ed9c118b 100644 --- a/packages/yoga/src/Divider/web/Divider.jsx +++ b/packages/yoga/src/Divider/web/Divider.jsx @@ -20,11 +20,13 @@ const StyledDivider = styled.hr` }} `; -const Divider = React.forwardRef(({ vertical, style, ...props }, ref) => { - return ( - - ); -}); +const Divider = React.forwardRef( + ({ vertical = false, style, ...props }, ref) => { + return ( + + ); + }, +); Divider.propTypes = { /** If this value is defined, the divider will be in vertical if the flexDirection is row type */ @@ -32,9 +34,4 @@ Divider.propTypes = { style: shape({}), }; -Divider.defaultProps = { - vertical: false, - style: undefined, -}; - export default withTheme(Divider); diff --git a/packages/yoga/src/Drawer/web/Drawer.jsx b/packages/yoga/src/Drawer/web/Drawer.jsx index 5895e55b89..2ac629a125 100644 --- a/packages/yoga/src/Drawer/web/Drawer.jsx +++ b/packages/yoga/src/Drawer/web/Drawer.jsx @@ -30,8 +30,8 @@ const StyledDrawer = styled(Dialog)` } `; -const Drawer = React.forwardRef((props, forwardedRef) => ( - +const Drawer = React.forwardRef(({ zIndex = 3, ...rest }, forwardedRef) => ( + )); Drawer.propTypes = { @@ -39,8 +39,4 @@ Drawer.propTypes = { zIndex: number, }; -Drawer.defaultProps = { - zIndex: 3, -}; - export default Drawer; diff --git a/packages/yoga/src/Drawer/web/__snapshots__/Drawer.test.jsx.snap b/packages/yoga/src/Drawer/web/__snapshots__/Drawer.test.jsx.snap index 6d114e07ba..b9a688f4b4 100644 --- a/packages/yoga/src/Drawer/web/__snapshots__/Drawer.test.jsx.snap +++ b/packages/yoga/src/Drawer/web/__snapshots__/Drawer.test.jsx.snap @@ -89,7 +89,7 @@ exports[` should match snapshot 1`] = ` } .c1 { - padding: 16px 16px 16px 16px; + padding: 16px 16px 16px 16px; box-shadow: 0 2px 4px -1px rgba(152,152,166,0.2),0 4px 5px 0px rgba(152,152,166,0.14),0 1px 10px 0px rgba(152,152,166,0.12); border-radius: 8px; background-color: #FFFFFF; diff --git a/packages/yoga/src/Dropdown/web/Dropdown.jsx b/packages/yoga/src/Dropdown/web/Dropdown.jsx index 82ccca5879..8a6054dee4 100644 --- a/packages/yoga/src/Dropdown/web/Dropdown.jsx +++ b/packages/yoga/src/Dropdown/web/Dropdown.jsx @@ -28,7 +28,7 @@ const Wrapper = styled.div` position: relative; display: inline-block; vertical-align: top; - + width: ${full ? '100%' : `${dropdown.width}px`}; `} `; @@ -267,10 +267,21 @@ const ArrowIcon = styled(({ isOpen, selected, ...props }) => ( `} `; +const noop = () => {}; + /** Gympass Dropdown is a multiple choice type of menu. */ const Dropdown = React.forwardRef( ( - { error, label, disabled, full, options, onChange, isMaxHeight, ...rest }, + { + error, + label = '', + disabled = false, + full = false, + options, + onChange = noop, + isMaxHeight = true, + ...rest + }, ref, ) => { const inputRef = ref || React.useRef(null); @@ -382,13 +393,4 @@ Dropdown.propTypes = { isMaxHeight: bool, }; -Dropdown.defaultProps = { - label: '', - error: undefined, - full: false, - disabled: false, - onChange: () => {}, - isMaxHeight: true, -}; - export default Dropdown; diff --git a/packages/yoga/src/Feedback/web/Feedback.jsx b/packages/yoga/src/Feedback/web/Feedback.jsx index 2d6e607b09..07f476d5b8 100644 --- a/packages/yoga/src/Feedback/web/Feedback.jsx +++ b/packages/yoga/src/Feedback/web/Feedback.jsx @@ -35,7 +35,14 @@ function isChildFromComponent(child, component) { return child.type.displayName === component.displayName; } -function Feedback({ variant, title, description, children, center, ...props }) { +function Feedback({ + variant, + title, + description, + children, + center = true, + ...props +}) { const iconProps = VARIANT_ICONS[variant]; let primaryButton; let secondaryButton; @@ -99,10 +106,4 @@ Feedback.propTypes = { center: bool, }; -Feedback.defaultProps = { - title: undefined, - children: undefined, - center: true, -}; - export default Feedback; diff --git a/packages/yoga/src/Grid/web/Col.jsx b/packages/yoga/src/Grid/web/Col.jsx index 1399b76d9b..6d76d6b9de 100644 --- a/packages/yoga/src/Grid/web/Col.jsx +++ b/packages/yoga/src/Grid/web/Col.jsx @@ -60,24 +60,4 @@ Col.propTypes = { 'xxxl-start': number, }; -Col.defaultProps = { - hide: undefined, - xxs: undefined, - xs: undefined, - sm: undefined, - md: undefined, - lg: undefined, - xl: undefined, - xxl: undefined, - xxxl: undefined, - 'xxs-start': undefined, - 'xs-start': undefined, - 'sm-start': undefined, - 'md-start': undefined, - 'lg-start': undefined, - 'xl-start': undefined, - 'xxl-start': undefined, - 'xxxl-start': undefined, -}; - export default Col; diff --git a/packages/yoga/src/Grid/web/Hide.jsx b/packages/yoga/src/Grid/web/Hide.jsx index f8a5cb3d15..8cbefc6429 100644 --- a/packages/yoga/src/Grid/web/Hide.jsx +++ b/packages/yoga/src/Grid/web/Hide.jsx @@ -5,8 +5,27 @@ import { media } from '@gympass/yoga-helpers'; const { breakpoints } = tokens; +const defaultProps = { + xxs: undefined, + xs: undefined, + sm: undefined, + md: undefined, + lg: undefined, + xl: undefined, + xxl: undefined, + xxxl: undefined, + 'xxs-start': undefined, + 'xs-start': undefined, + 'sm-start': undefined, + 'md-start': undefined, + 'lg-start': undefined, + 'xl-start': undefined, + 'xxl-start': undefined, + 'xxxl-start': undefined, +}; + const Hide = styled.div` - ${props => + ${(props = defaultProps) => Object.keys(props) .filter(prop => props[prop] && Object.keys(breakpoints).includes(prop)) .map(breakpoint => media.hide[breakpoint])} diff --git a/packages/yoga/src/Header/web/Header.jsx b/packages/yoga/src/Header/web/Header.jsx index 9c40a2063d..a2babb6934 100644 --- a/packages/yoga/src/Header/web/Header.jsx +++ b/packages/yoga/src/Header/web/Header.jsx @@ -26,7 +26,7 @@ const StyledHeader = styled(Box)` `} `; -const Header = ({ link, logo, children, ...props }) => { +const Header = ({ link = null, logo = null, children = null, ...props }) => { return ( +const Logo = ({ customLogo: CustomLogo = null }) => CustomLogo ? : ; Logo.propTypes = { customLogo: elementType, }; -Logo.defaultProps = { - customLogo: null, -}; - export default Logo; diff --git a/packages/yoga/src/Heading/web/Heading.jsx b/packages/yoga/src/Heading/web/Heading.jsx index e67ad86b09..6802f7f9c8 100644 --- a/packages/yoga/src/Heading/web/Heading.jsx +++ b/packages/yoga/src/Heading/web/Heading.jsx @@ -6,7 +6,7 @@ import Title from './Title'; import BackButton from './BackButton'; import RightButton from './RightButton'; -const Heading = ({ children, noPadding, ...props }) => { +const Heading = ({ children, noPadding = false, ...props }) => { let backButton = null; let title = null; const rightButtons = []; @@ -46,10 +46,4 @@ Heading.propTypes = { bg: PropTypes.string, }; -Heading.defaultProps = { - children: undefined, - noPadding: false, - bg: undefined, -}; - export default Heading; diff --git a/packages/yoga/src/Icon/Icon.jsx b/packages/yoga/src/Icon/Icon.jsx index 9bdd610fb2..381c910a41 100644 --- a/packages/yoga/src/Icon/Icon.jsx +++ b/packages/yoga/src/Icon/Icon.jsx @@ -14,7 +14,7 @@ import Box from '../Box'; const Icon = ({ as: Component, - size, + size = 12, width = size, height = size, fill, @@ -139,15 +139,4 @@ Icon.propTypes = { size: oneOfType([oneOf(commonSizes), string, number]), }; -Icon.defaultProps = { - fill: undefined, - stroke: undefined, - title: undefined, - description: undefined, - ariaLabel: undefined, - width: undefined, - height: undefined, - size: 12, -}; - export default withTheme(Icon); diff --git a/packages/yoga/src/Input/web/Helper.jsx b/packages/yoga/src/Input/web/Helper.jsx index 4a504e9deb..5754c1b9f6 100644 --- a/packages/yoga/src/Input/web/Helper.jsx +++ b/packages/yoga/src/Input/web/Helper.jsx @@ -71,14 +71,4 @@ Helper.propTypes = { a11yId: string, }; -Helper.defaultProps = { - disabled: undefined, - error: undefined, - helper: undefined, - maxLength: undefined, - length: undefined, - hideMaxLength: undefined, - a11yId: undefined, -}; - export default Helper; diff --git a/packages/yoga/src/Input/web/Input.jsx b/packages/yoga/src/Input/web/Input.jsx index 15096169bf..5565172c6f 100644 --- a/packages/yoga/src/Input/web/Input.jsx +++ b/packages/yoga/src/Input/web/Input.jsx @@ -91,28 +91,30 @@ const LeftElementWrapper = styled.div` `} `; +const noop = () => {}; + const Input = React.forwardRef( ( { - cleanable, + cleanable = true, children, - disabled, + disabled = false, error, - full, + full = false, helper, label, ariaLabel, maxLength, - readOnly, + readOnly = false, style, - value, - onChange, - onClean, - hideMaxLength, + value = '', + onChange = noop, + onClean = noop, + hideMaxLength = false, rightIcon, a11yId, - closeAriaLabel, - includeAriaAttributes, + closeAriaLabel = 'Clear', + includeAriaAttributes = true, leftElement, ...props }, @@ -286,29 +288,4 @@ Input.propTypes = { leftElement: node, }; -Input.defaultProps = { - className: undefined, - children: undefined, - cleanable: true, - disabled: false, - error: undefined, - full: false, - helper: undefined, - label: undefined, - ariaLabel: undefined, - maxLength: undefined, - readOnly: false, - style: undefined, - value: '', - onChange: () => {}, - onClean: () => {}, - hideMaxLength: false, - placeholder: undefined, - rightIcon: undefined, - a11yId: undefined, - closeAriaLabel: 'Clear', - includeAriaAttributes: true, - leftElement: undefined, -}; - export default Input; diff --git a/packages/yoga/src/Input/web/Password.jsx b/packages/yoga/src/Input/web/Password.jsx index 1fd6facfcc..4a6aac1c1e 100644 --- a/packages/yoga/src/Input/web/Password.jsx +++ b/packages/yoga/src/Input/web/Password.jsx @@ -81,10 +81,10 @@ const IconWrapper = styled.div` `; const Password = ({ - disabled, + disabled = false, style, className, - full, + full = false, showPasswordAriaLabel, hidePasswordAriaLabel, ...props @@ -151,13 +151,4 @@ Password.propTypes = { style: shape({}), }; -Password.defaultProps = { - className: undefined, - disabled: false, - full: false, - style: undefined, - showPasswordAriaLabel: undefined, - hidePasswordAriaLabel: undefined, -}; - export default Password; diff --git a/packages/yoga/src/Input/web/Phone.jsx b/packages/yoga/src/Input/web/Phone.jsx index d14cc99d86..8db0affa5c 100644 --- a/packages/yoga/src/Input/web/Phone.jsx +++ b/packages/yoga/src/Input/web/Phone.jsx @@ -22,19 +22,22 @@ const phoneBaseSettings = { ], }; +const noop = () => {}; + const Phone = React.forwardRef( ( { - defaultCountry, - disabled, - readOnly, + defaultCountry = 'br', + disabled = false, + readOnly = false, error, - full, + full = false, helper, - label, - placeholder, - value, - onChange, + label = '', + placeholder = '+55 (11) 999999999', + value = '', + onChange = noop, + cleanable = true, ...rest }, forwardedRef, @@ -57,6 +60,7 @@ const Phone = React.forwardRef( full, helper, value, + cleanable, ...rest, }} ref={inputRef} @@ -113,19 +117,4 @@ Phone.propTypes = { placeholder: string, }; -Phone.defaultProps = { - className: undefined, - cleanable: true, - defaultCountry: 'br', - disabled: false, - error: undefined, - full: false, - helper: undefined, - label: '', - readOnly: false, - value: '', - onChange: () => {}, - placeholder: '+55 (11) 999999999', -}; - export default Phone; diff --git a/packages/yoga/src/List/web/List.jsx b/packages/yoga/src/List/web/List.jsx index 87af789d63..0857270c2f 100644 --- a/packages/yoga/src/List/web/List.jsx +++ b/packages/yoga/src/List/web/List.jsx @@ -42,20 +42,18 @@ const StyledList = styled.ul` /** Lists are a continuous group of text or images. They are composed of items containing primary and supplemental actions, which are represented by icons and text. */ -const List = React.forwardRef(({ horizontal, divided, ...rest }, ref) => ( - -)); + +const List = React.forwardRef( + ({ horizontal = false, divided = true, ...rest }, ref) => ( + + ), +); List.propTypes = { horizontal: PropTypes.bool, divided: PropTypes.bool, }; -List.defaultProps = { - horizontal: false, - divided: true, -}; - List.displayName = 'List'; export default List; diff --git a/packages/yoga/src/Menu/web/Menu.jsx b/packages/yoga/src/Menu/web/Menu.jsx index 35cffc9387..345773a0d7 100644 --- a/packages/yoga/src/Menu/web/Menu.jsx +++ b/packages/yoga/src/Menu/web/Menu.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { Root as MenuRoot } from '@radix-ui/react-dropdown-menu'; import { bool, node } from 'prop-types'; -const Menu = ({ children, onMouseHover }) => { +const Menu = ({ children, onMouseHover = true }) => { const [isOpen, setIsOpen] = React.useState(false); function handleOpenMenu() { @@ -32,10 +32,6 @@ Menu.propTypes = { onMouseHover: bool, }; -Menu.defaultProps = { - onMouseHover: true, -}; - Menu.displayName = 'Menu'; export default Menu; diff --git a/packages/yoga/src/Menu/web/MenuItem.jsx b/packages/yoga/src/Menu/web/MenuItem.jsx index c234063880..0da941274b 100644 --- a/packages/yoga/src/Menu/web/MenuItem.jsx +++ b/packages/yoga/src/Menu/web/MenuItem.jsx @@ -77,8 +77,8 @@ const MenuItem = forwardRef( { icon: Icon, href, - active, - disabled, + active = false, + disabled = false, iconColor, iconSize, children, @@ -126,15 +126,6 @@ MenuItem.propTypes = { iconSize: string, }; -MenuItem.defaultProps = { - icon: undefined, - href: undefined, - disabled: false, - active: false, - iconColor: undefined, - iconSize: undefined, -}; - MenuItem.displayName = 'Menu.Item'; export default withTheme(MenuItem); diff --git a/packages/yoga/src/Menu/web/MenuList.jsx b/packages/yoga/src/Menu/web/MenuList.jsx index 0862903037..db810ff9e0 100644 --- a/packages/yoga/src/Menu/web/MenuList.jsx +++ b/packages/yoga/src/Menu/web/MenuList.jsx @@ -32,7 +32,17 @@ const StyledMenuList = styled(MenuListRoot)` `; const MenuList = forwardRef( - ({ children, align, alignOffset, side, sideOffset, zIndex }, ref) => { + ( + { + children, + align = 'start', + alignOffset = 0, + side = 'bottom', + sideOffset = 4, + zIndex = 'auto', + }, + ref, + ) => { return ( should match snapshot Menu with a onMouseHover props false 1`]