Skip to content

Commit

Permalink
chore: Avoiding passing props from the Carousel and Modal components …
Browse files Browse the repository at this point in the history
…to the Card component
  • Loading branch information
MarcosViniciusPC committed Apr 25, 2024
1 parent ff76215 commit b83a882
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 11 deletions.
22 changes: 17 additions & 5 deletions components/Carousel/sub-components/DescriptionCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ const cardMeasures = {
},
};

const AdaptedCard = styled(Card)`
const propsNotContainedInTheCard = ['theme', 'cardMeasure'];

const AdaptedCard = styled(Card).withConfig({
shouldForwardProp: (prop) => !propsNotContainedInTheCard.includes(prop),
})`
${({
theme: {
spacing: { xxxsmall, xsmall },
Expand All @@ -27,7 +31,9 @@ const AdaptedCard = styled(Card)`
${({ cardMeasure: { height } }) => `height: ${height}px;`}
`;

const Content = styled(Card.Content)`
const Content = styled(Card.Content).withConfig({
shouldForwardProp: (prop) => !propsNotContainedInTheCard.includes(prop),
})`
height: 100%;
${({
theme: {
Expand All @@ -39,7 +45,9 @@ const Content = styled(Card.Content)`
box-sizing: border-box;
`;

const Media = styled(Card.Media)`
const Media = styled(Card.Media).withConfig({
shouldForwardProp: (prop) => !propsNotContainedInTheCard.includes(prop),
})`
width: 192px;
height: 104px;
padding-bottom: 0;
Expand All @@ -49,7 +57,9 @@ const Media = styled(Card.Media)`
`};
`;

const Title = styled(Card.Title)`
const Title = styled(Card.Title).withConfig({
shouldForwardProp: (prop) => !propsNotContainedInTheCard.includes(prop),
})`
${({
theme: {
baseFontSize: baseFont,
Expand All @@ -66,7 +76,9 @@ const Title = styled(Card.Title)`
text-overflow: ellipsis;
`;

const Description = styled(Card.Description)`
const Description = styled(Card.Description).withConfig({
shouldForwardProp: (prop) => !propsNotContainedInTheCard.includes(prop),
})`
${({
theme: {
baseFontSize: baseFont,
Expand Down
9 changes: 7 additions & 2 deletions components/Carousel/sub-components/ThumbCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { colors, spacing, baseFontSize } from '../../shared/theme';

const SQUARE_CARD_SIZE = 80;
const SQUARE_THUMB_SIZE = 64;
const propsNotContainedInTheCard = ['theme'];

const AdaptedCard = styled(Card)`
const AdaptedCard = styled(Card).withConfig({
shouldForwardProp: (prop) => !propsNotContainedInTheCard.includes(prop),
})`
${({
theme: {
spacing: { xxxsmall, xxsmall },
Expand All @@ -20,7 +23,9 @@ const AdaptedCard = styled(Card)`
width: ${SQUARE_CARD_SIZE}px;
`;

const Content = styled(Card.Content)`
const Content = styled(Card.Content).withConfig({
shouldForwardProp: (prop) => !propsNotContainedInTheCard.includes(prop),
})`
height: 100%;
${({
theme: {
Expand Down
5 changes: 4 additions & 1 deletion components/Modal/Modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { breakpoints, colors, spacing, components } from '../shared/theme';
import isSSR from '../shared/isSSR';

const closeButtonPadding = spacing.medium;
const propsNotContainedInTheCard = ['theme'];

function getBreakpoint({ theme: { breakpoints: themeBreakpoints } }) {
const sizes = {
Expand All @@ -27,7 +28,9 @@ function getBreakpoint({ theme: { breakpoints: themeBreakpoints } }) {
);
}

const ModalCard = styled(Card)`
const ModalCard = styled(Card).withConfig({
shouldForwardProp: (prop) => !propsNotContainedInTheCard.includes(prop),
})`
header {
padding-right: ${({
theme: {
Expand Down
6 changes: 5 additions & 1 deletion components/Modal/sub-components/Content.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import PropTypes from 'prop-types';
import Card from '../../Card';
import { spacing } from '../../shared/theme';

const Content = styled(Card.Content)`
const propsNotContainedInTheCard = ['theme'];

const Content = styled(Card.Content).withConfig({
shouldForwardProp: (prop) => !propsNotContainedInTheCard.includes(prop),
})`
font-size: 16px;
max-height: 70vh;
overflow-y: auto;
Expand Down
6 changes: 5 additions & 1 deletion components/Modal/sub-components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import PropTypes from 'prop-types';
import Card from '../../Card';
import { spacing } from '../../shared/theme';

const Header = styled(Card.Header)`
const propsNotContainedInTheCard = ['theme'];

const Header = styled(Card.Header).withConfig({
shouldForwardProp: (prop) => !propsNotContainedInTheCard.includes(prop),
})`
padding: ${({
theme: {
spacing: { medium },
Expand Down
6 changes: 5 additions & 1 deletion components/Modal/sub-components/Title.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import styled from 'styled-components';
import Card from '../../Card';

const Title = styled(Card.Title)`
const propsNotContainedInTheCard = ['theme'];

const Title = styled(Card.Title).withConfig({
shouldForwardProp: (prop) => !propsNotContainedInTheCard.includes(prop),
})`
font-weight: 700;
line-height: 1.25;
`;
Expand Down

0 comments on commit b83a882

Please sign in to comment.