From 5b80b54ad7187c24c41e5a0a40c2ae7b1d80cf66 Mon Sep 17 00:00:00 2001 From: Marcos Conceicao Date: Tue, 30 Jul 2024 15:34:46 -0300 Subject: [PATCH 1/9] chore(Popover.jsx, SnackBar.jsx): Removed passing of non-native props from the Button component --- components/Popover/sub-components/Content.jsx | 12 +++++++++--- components/SnackBar/SnackBar.jsx | 16 ++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/components/Popover/sub-components/Content.jsx b/components/Popover/sub-components/Content.jsx index e03cbd6d3..9d352cc21 100644 --- a/components/Popover/sub-components/Content.jsx +++ b/components/Popover/sub-components/Content.jsx @@ -89,9 +89,15 @@ const PopoverContent = styled.div` ${_getColors} `; -const CloseButton = styled(Button.Icon).attrs({ - icon: 'close', -})` +const propsNotContainedInButton = ['inverted']; + +const CloseButton = styled(Button.Icon) + .attrs({ + icon: 'close', + }) + .withConfig({ + shouldForwardProp: (prop) => !propsNotContainedInButton.includes(prop), + })` ${_getTextColor} display: inherit; height: auto; diff --git a/components/SnackBar/SnackBar.jsx b/components/SnackBar/SnackBar.jsx index dbcfc67cf..4f5b2b1e2 100644 --- a/components/SnackBar/SnackBar.jsx +++ b/components/SnackBar/SnackBar.jsx @@ -125,9 +125,15 @@ const SkinIcon = styled(Icon)` `} `; -const CloseButton = styled(Button.Icon).attrs({ - icon: 'close', -})` +const propsNotContainedInButton = ['inverted']; + +const CloseButton = styled(Button.Icon) + .attrs({ + icon: 'close', + }) + .withConfig({ + shouldForwardProp: (prop) => !propsNotContainedInButton.includes(prop), + })` ${({ skin, theme, inverted }) => { const { text } = getBackgroundAndTextColorBySkin({ skin, theme, inverted }); @@ -150,7 +156,9 @@ const CloseButton = styled(Button.Icon).attrs({ }} `; -const ActionButton = styled(Button)` +const ActionButton = styled(Button).withConfig({ + shouldForwardProp: (prop) => !propsNotContainedInButton.includes(prop), +})` ${({ theme, skin, inverted }) => { const { text: color } = getBackgroundAndTextColorBySkin({ skin, From d99ea37344a76d108a22cbde28969fea8428edbd Mon Sep 17 00:00:00 2001 From: Marcos Conceicao Date: Wed, 31 Jul 2024 15:28:29 -0300 Subject: [PATCH 2/9] feat: Migrated SegmentedControl component and use of shared styles with the button --- components/Button/Button.jsx | 39 ++++---- components/Button/index.css | 1 - .../SegmentedControl/SegmentedButton.jsx | 47 +++++----- .../SegmentedButton.module.css | 23 +++++ .../SegmentedControl/SegmentedControl.jsx | 91 ++++++------------- .../SegmentedControl.module.css | 4 + components/SegmentedControl/index.css | 2 + components/index.css | 2 +- .../styles/ButtonBase.module.css} | 0 9 files changed, 104 insertions(+), 105 deletions(-) delete mode 100644 components/Button/index.css create mode 100644 components/SegmentedControl/SegmentedButton.module.css create mode 100644 components/SegmentedControl/SegmentedControl.module.css create mode 100644 components/SegmentedControl/index.css rename components/{Button/Button.module.css => shared/styles/ButtonBase.module.css} (100%) diff --git a/components/Button/Button.jsx b/components/Button/Button.jsx index 436dd6299..c17a01498 100644 --- a/components/Button/Button.jsx +++ b/components/Button/Button.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import classNames from 'classnames'; import Icon from '../Icon/Icon'; -import styles from './Button.module.css'; +import buttonBaseStyles from '../shared/styles/ButtonBase.module.css'; const Button = ({ children, @@ -22,26 +22,26 @@ const Button = ({ const isStrokedType = stroked && !disabled; const defaultButtonStyle = classNames( - styles.button, - styles[`button-${size}`], - { [styles['button-disable']]: disabled }, - { [styles['button-center']]: center }, - { [styles['button-default']]: isDefaultType }, - { [styles[`button-default-${skin}`]]: isDefaultType }, - { [styles['button-disable-stroked']]: disabled && stroked }, - { [styles[`button-stroked-${skin}`]]: isStrokedType }, - { [styles['button-full']]: full }, - styles['shadow-2-neutral-500'], - { [styles[`shadow-4-${skin}-900`]]: !disabled }, - { [styles[`shadow-4-${skin}-700`]]: !disabled }, - { [styles[`shadow-8-${skin}-900`]]: !disabled }, + buttonBaseStyles.button, + buttonBaseStyles[`button-${size}`], + { [buttonBaseStyles['button-disable']]: disabled }, + { [buttonBaseStyles['button-center']]: center }, + { [buttonBaseStyles['button-default']]: isDefaultType }, + { [buttonBaseStyles[`button-default-${skin}`]]: isDefaultType }, + { [buttonBaseStyles['button-disable-stroked']]: disabled && stroked }, + { [buttonBaseStyles[`button-stroked-${skin}`]]: isStrokedType }, + { [buttonBaseStyles['button-full']]: full }, + buttonBaseStyles['shadow-2-neutral-500'], + { [buttonBaseStyles[`shadow-4-${skin}-900`]]: !disabled }, + { [buttonBaseStyles[`shadow-4-${skin}-700`]]: !disabled }, + { [buttonBaseStyles[`shadow-8-${skin}-900`]]: !disabled }, className, ); const iconStyle = classNames( - styles['button-icon'], - { [styles['button-icon-with-children']]: children }, - styles[`button-icon-${size}`], + buttonBaseStyles['button-icon'], + { [buttonBaseStyles['button-icon-with-children']]: children }, + buttonBaseStyles[`button-icon-${size}`], ); return ( @@ -97,7 +97,10 @@ Button.propTypes = { }; const IconButton = ({ className = '', skin, ...props }) => { - const classIconButton = classNames(styles['icon-button'], className); + const classIconButton = classNames( + buttonBaseStyles['icon-button'], + className, + ); return - - + @@ -232,7 +208,7 @@ exports[` should match the snapshots 2`] = ` word-break: break-word; } -.Button-module__button___AbcpN { +.ButtonBase-module__button___-CVUK { align-items: center; border-radius: 4px; box-sizing: border-box; @@ -243,39 +219,59 @@ exports[` should match the snapshots 2`] = ` transition: all .2s ease-in-out; } -.Button-module__button-default___miWV3 { +.ButtonBase-module__button-default___K4Nmm { color: var(--qtm-colors-neutral-0); } -.Button-module__button-default-primary___bURr2 { +.ButtonBase-module__button-default-primary___X9GaT { background-color: var(--qtm-colors-primary-700); border: 2px solid var(--qtm-colors-primary-700); } -.Button-module__button-stroked-primary___YY4WC { +.ButtonBase-module__button-stroked-primary___uybCe { background-color: var(--qtm-colors-neutral-0); border: 2px solid var(--qtm-colors-primary-700); color: var(--qtm-colors-primary-700); } -.Button-module__button-medium___qo6Ym, -.Button-module__button-small___HWutw { +.ButtonBase-module__button-medium___BtByl, +.ButtonBase-module__button-small___ffdO7 { padding: var(--qtm-spacing-xxsmall) var(--qtm-spacing-medium); } -.Button-module__button-medium___qo6Ym { +.ButtonBase-module__button-medium___BtByl { font-size: var(--qtm-base-font-size); line-height: calc(var(--qtm-base-font-size)*1.5); min-height: var(--qtm-spacing-xxlarge); } -.Button-module__shadow-2-neutral-500___hxqSk { +.ButtonBase-module__shadow-2-neutral-500___mSG-z { --qtm-shadow-umbra-neutral-500-color: rgba(153,153,153,var(--qtm-shadow-umbra-opacity)); --qtm-shadow-penumbra-neutral-500-color: rgba(153,153,153,var(--qtm-shadow-penumbra-opacity)); --qtm-shadow-ambient-neutral-500-color: rgba(153,153,153,var(--qtm-shadow-ambient-opacity)); box-shadow: 0 3px 1px -2px var(--qtm-shadow-umbra-neutral-500-color),0 2px 2px 0 var(--qtm-shadow-penumbra-neutral-500-color),0 1px 5px 0 var(--qtm-shadow-ambient-neutral-500-color); } +.SegmentedButton-module__label___sRquy { + border: 1px solid; + border-radius: 0; + border-right: 0; + border-color: var(--qtm-colors-primary-700); + font-weight: 400; + letter-spacing: .2px; + padding: var(--qtm-spacing-xxsmall) var(--qtm-spacing-xsmall); + width: 100%; +} + +.SegmentedButton-module__label-checked___xgs6w { + font-weight: 700; +} + +.SegmentedControl-module__wrapper___pHm7V { + display: flex; + justify-content: space-around; +} + @media (min-width:0px) { .Row-module__row___xiasO { margin-bottom: var(--qtm-gutter-xsmall); @@ -324,7 +320,7 @@ exports[` should match the snapshots 2`] = ` } } -.c2 { +.c0 { border: 0; height: 0; margin: 0; @@ -335,47 +331,6 @@ exports[` should match the snapshots 2`] = ` width: 0; } -.c1 { - width: 100%; - border-radius: 0px; - font-weight: 400; - -webkit-letter-spacing: 0.2px; - -moz-letter-spacing: 0.2px; - -ms-letter-spacing: 0.2px; - letter-spacing: 0.2px; -} - -.c1.input-checked { - font-weight: 700; -} - -.c0 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-pack: space-around; - -webkit-justify-content: space-around; - -ms-flex-pack: space-around; - justify-content: space-around; -} - -.c0 button { - border: 1px solid; - border-right: 0px; - border-color: #1250C4; - padding: 4px 8px; -} - -.c0 button:first-child { - border-radius: 4px 0px 0px 4px; -} - -.c0 button:last-child { - border-radius: 0px 4px 4px 0px; - border: 1px solid #1250C4; -} -
@@ -384,17 +339,16 @@ exports[` should match the snapshots 2`] = ` style="--qtm-col-small-size: 6; --qtm-col-medium-size: 5;" >
- - - - - +
@@ -549,7 +499,7 @@ exports[` should match the snapshots 3`] = ` word-break: break-word; } -.Button-module__button___AbcpN { +.ButtonBase-module__button___-CVUK { align-items: center; border-radius: 4px; box-sizing: border-box; @@ -560,39 +510,59 @@ exports[` should match the snapshots 3`] = ` transition: all .2s ease-in-out; } -.Button-module__button-default___miWV3 { +.ButtonBase-module__button-default___K4Nmm { color: var(--qtm-colors-neutral-0); } -.Button-module__button-default-primary___bURr2 { +.ButtonBase-module__button-default-primary___X9GaT { background-color: var(--qtm-colors-primary-700); border: 2px solid var(--qtm-colors-primary-700); } -.Button-module__button-stroked-primary___YY4WC { +.ButtonBase-module__button-stroked-primary___uybCe { background-color: var(--qtm-colors-neutral-0); border: 2px solid var(--qtm-colors-primary-700); color: var(--qtm-colors-primary-700); } -.Button-module__button-medium___qo6Ym, -.Button-module__button-small___HWutw { +.ButtonBase-module__button-medium___BtByl, +.ButtonBase-module__button-small___ffdO7 { padding: var(--qtm-spacing-xxsmall) var(--qtm-spacing-medium); } -.Button-module__button-medium___qo6Ym { +.ButtonBase-module__button-medium___BtByl { font-size: var(--qtm-base-font-size); line-height: calc(var(--qtm-base-font-size)*1.5); min-height: var(--qtm-spacing-xxlarge); } -.Button-module__shadow-2-neutral-500___hxqSk { +.ButtonBase-module__shadow-2-neutral-500___mSG-z { --qtm-shadow-umbra-neutral-500-color: rgba(153,153,153,var(--qtm-shadow-umbra-opacity)); --qtm-shadow-penumbra-neutral-500-color: rgba(153,153,153,var(--qtm-shadow-penumbra-opacity)); --qtm-shadow-ambient-neutral-500-color: rgba(153,153,153,var(--qtm-shadow-ambient-opacity)); box-shadow: 0 3px 1px -2px var(--qtm-shadow-umbra-neutral-500-color),0 2px 2px 0 var(--qtm-shadow-penumbra-neutral-500-color),0 1px 5px 0 var(--qtm-shadow-ambient-neutral-500-color); } +.SegmentedButton-module__label___sRquy { + border: 1px solid; + border-radius: 0; + border-right: 0; + border-color: var(--qtm-colors-primary-700); + font-weight: 400; + letter-spacing: .2px; + padding: var(--qtm-spacing-xxsmall) var(--qtm-spacing-xsmall); + width: 100%; +} + +.SegmentedButton-module__label-checked___xgs6w { + font-weight: 700; +} + +.SegmentedControl-module__wrapper___pHm7V { + display: flex; + justify-content: space-around; +} + @media (min-width:0px) { .Row-module__row___xiasO { margin-bottom: var(--qtm-gutter-xsmall); @@ -641,7 +611,7 @@ exports[` should match the snapshots 3`] = ` } } -.c2 { +.c0 { border: 0; height: 0; margin: 0; @@ -652,47 +622,6 @@ exports[` should match the snapshots 3`] = ` width: 0; } -.c1 { - width: 100%; - border-radius: 0px; - font-weight: 400; - -webkit-letter-spacing: 0.2px; - -moz-letter-spacing: 0.2px; - -ms-letter-spacing: 0.2px; - letter-spacing: 0.2px; -} - -.c1.input-checked { - font-weight: 700; -} - -.c0 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-pack: space-around; - -webkit-justify-content: space-around; - -ms-flex-pack: space-around; - justify-content: space-around; -} - -.c0 button { - border: 1px solid; - border-right: 0px; - border-color: #1250C4; - padding: 4px 8px; -} - -.c0 button:first-child { - border-radius: 4px 0px 0px 4px; -} - -.c0 button:last-child { - border-radius: 0px 4px 4px 0px; - border: 1px solid #1250C4; -} -
@@ -701,17 +630,16 @@ exports[` should match the snapshots 3`] = ` style="--qtm-col-small-size: 6; --qtm-col-medium-size: 5;" >
- - - +
@@ -808,7 +734,7 @@ exports[` should match the snapshots 4`] = ` word-break: break-word; } -.Button-module__button___AbcpN { +.ButtonBase-module__button___-CVUK { align-items: center; border-radius: 4px; box-sizing: border-box; @@ -819,39 +745,59 @@ exports[` should match the snapshots 4`] = ` transition: all .2s ease-in-out; } -.Button-module__button-default___miWV3 { +.ButtonBase-module__button-default___K4Nmm { color: var(--qtm-colors-neutral-0); } -.Button-module__button-default-primary___bURr2 { +.ButtonBase-module__button-default-primary___X9GaT { background-color: var(--qtm-colors-primary-700); border: 2px solid var(--qtm-colors-primary-700); } -.Button-module__button-stroked-primary___YY4WC { +.ButtonBase-module__button-stroked-primary___uybCe { background-color: var(--qtm-colors-neutral-0); border: 2px solid var(--qtm-colors-primary-700); color: var(--qtm-colors-primary-700); } -.Button-module__button-medium___qo6Ym, -.Button-module__button-small___HWutw { +.ButtonBase-module__button-medium___BtByl, +.ButtonBase-module__button-small___ffdO7 { padding: var(--qtm-spacing-xxsmall) var(--qtm-spacing-medium); } -.Button-module__button-medium___qo6Ym { +.ButtonBase-module__button-medium___BtByl { font-size: var(--qtm-base-font-size); line-height: calc(var(--qtm-base-font-size)*1.5); min-height: var(--qtm-spacing-xxlarge); } -.Button-module__shadow-2-neutral-500___hxqSk { +.ButtonBase-module__shadow-2-neutral-500___mSG-z { --qtm-shadow-umbra-neutral-500-color: rgba(153,153,153,var(--qtm-shadow-umbra-opacity)); --qtm-shadow-penumbra-neutral-500-color: rgba(153,153,153,var(--qtm-shadow-penumbra-opacity)); --qtm-shadow-ambient-neutral-500-color: rgba(153,153,153,var(--qtm-shadow-ambient-opacity)); box-shadow: 0 3px 1px -2px var(--qtm-shadow-umbra-neutral-500-color),0 2px 2px 0 var(--qtm-shadow-penumbra-neutral-500-color),0 1px 5px 0 var(--qtm-shadow-ambient-neutral-500-color); } +.SegmentedButton-module__label___sRquy { + border: 1px solid; + border-radius: 0; + border-right: 0; + border-color: var(--qtm-colors-primary-700); + font-weight: 400; + letter-spacing: .2px; + padding: var(--qtm-spacing-xxsmall) var(--qtm-spacing-xsmall); + width: 100%; +} + +.SegmentedButton-module__label-checked___xgs6w { + font-weight: 700; +} + +.SegmentedControl-module__wrapper___pHm7V { + display: flex; + justify-content: space-around; +} + @media (min-width:0px) { .Row-module__row___xiasO { margin-bottom: var(--qtm-gutter-xsmall); @@ -900,7 +846,7 @@ exports[` should match the snapshots 4`] = ` } } -.c2 { +.c0 { border: 0; height: 0; margin: 0; @@ -911,47 +857,6 @@ exports[` should match the snapshots 4`] = ` width: 0; } -.c1 { - width: 100%; - border-radius: 0px; - font-weight: 400; - -webkit-letter-spacing: 0.2px; - -moz-letter-spacing: 0.2px; - -ms-letter-spacing: 0.2px; - letter-spacing: 0.2px; -} - -.c1.input-checked { - font-weight: 700; -} - -.c0 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-pack: space-around; - -webkit-justify-content: space-around; - -ms-flex-pack: space-around; - justify-content: space-around; -} - -.c0 button { - border: 1px solid; - border-right: 0px; - border-color: #1250C4; - padding: 4px 8px; -} - -.c0 button:first-child { - border-radius: 4px 0px 0px 4px; -} - -.c0 button:last-child { - border-radius: 0px 4px 4px 0px; - border: 1px solid #1250C4; -} -
@@ -960,17 +865,16 @@ exports[` should match the snapshots 4`] = ` style="--qtm-col-small-size: 6; --qtm-col-medium-size: 5;" >
- - - +
diff --git a/components/SocialButton/__snapshots__/SocialButton.unit.test.jsx.snap b/components/SocialButton/__snapshots__/SocialButton.unit.test.jsx.snap index 0ad078aec..15942768f 100644 --- a/components/SocialButton/__snapshots__/SocialButton.unit.test.jsx.snap +++ b/components/SocialButton/__snapshots__/SocialButton.unit.test.jsx.snap @@ -2,7 +2,7 @@ exports[`SocialButton component Should match the snapshot 1`] = ` - .Button-module__button___AbcpN { + .ButtonBase-module__button___-CVUK { align-items: center; border-radius: 4px; box-sizing: border-box; @@ -13,24 +13,24 @@ exports[`SocialButton component Should match the snapshot 1`] = ` transition: all .2s ease-in-out; } -.Button-module__button-stroked-neutral___U5syT { +.ButtonBase-module__button-stroked-neutral___S8irH { background-color: var(--qtm-colors-neutral-0); border: 2px solid var(--qtm-colors-neutral-700); color: var(--qtm-colors-neutral-700); } -.Button-module__button-medium___qo6Ym, -.Button-module__button-small___HWutw { +.ButtonBase-module__button-medium___BtByl, +.ButtonBase-module__button-small___ffdO7 { padding: var(--qtm-spacing-xxsmall) var(--qtm-spacing-medium); } -.Button-module__button-medium___qo6Ym { +.ButtonBase-module__button-medium___BtByl { font-size: var(--qtm-base-font-size); line-height: calc(var(--qtm-base-font-size)*1.5); min-height: var(--qtm-spacing-xxlarge); } -.Button-module__shadow-2-neutral-500___hxqSk { +.ButtonBase-module__shadow-2-neutral-500___mSG-z { --qtm-shadow-umbra-neutral-500-color: rgba(153,153,153,var(--qtm-shadow-umbra-opacity)); --qtm-shadow-penumbra-neutral-500-color: rgba(153,153,153,var(--qtm-shadow-penumbra-opacity)); --qtm-shadow-ambient-neutral-500-color: rgba(153,153,153,var(--qtm-shadow-ambient-opacity)); @@ -55,7 +55,7 @@ exports[`SocialButton component Should match the snapshot 1`] = ` }